//more funtions

function moduleSearch()
	{location = "/search/"+$('#mod_search_searchword').attr('value')+"/";}

function checkname()
	{var str=document.getElementById('first_name').value;
	 var filter=/^[А-ЯA-Z]{2,}( +)?([А-ЯA-Z]{2,})?( +)?$/i;
	 if (filter.test(str)) {document.getElementById('name_div').style.visibility="hidden"; document.getElementById('name_pic').style.visibility="visible";} else {document.getElementById('name_pic').style.visibility="hidden"; document.getElementById('name_div').style.visibility="visible";}
	}
function checksurname()
	{var str=document.getElementById('last_name').value;
	 var filter=/^[А-ЯA-Z]{2,}( +)?([А-ЯA-Z]{2,})?( +)?$/i;
	 if (filter.test(str)) {document.getElementById('surname_div').style.visibility="hidden"; document.getElementById('surname_pic').style.visibility="visible";} else {document.getElementById('surname_pic').style.visibility="hidden"; document.getElementById('surname_div').style.visibility="visible";}}
function checkmail()
	{var str=document.getElementById('email').value;
	 var filter=/^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,4}$/i;
	 if (filter.test(str)) {document.getElementById('mail_div').style.visibility="hidden"; document.getElementById('mail_pic').style.visibility="visible";} else {document.getElementById('mail_pic').style.visibility="hidden"; document.getElementById('mail_div').style.visibility="visible";}
	}
function checkphone()
	{var str=document.getElementById('phone').value;
	 var filter=/^(?:8|\+7)? ?\(\d{1,5}\)? ?\d{1,5}\-\d{2}\-\d{2}$/;
	 if (str != "") {document.getElementById('phone_div').style.visibility="hidden"; document.getElementById('phone_pic').style.visibility="visible";} else {document.getElementById('phone_pic').style.visibility="hidden"; document.getElementById('phone_div').style.visibility="visible";}
	}
 
function open_window(link,w,h) //opens new window
	{
	var win = "width="+w+",height="+h+",menubar=no,location=no,resizable=yes,scrollbars=yes";
	newWin = window.open(link,'newWin',win);
	newWin.focus();
	}


function confirmDelete() //unsubscription confirmation
	{
	temp = window.confirm(QUESTION_UNSUBSCRIBE);
	if (temp) //delete
		{
		window.location="index.php?killuser=yes";
		}
	}

function validate_custinfo() //validate customer information
	{	
	
	var strFName=document.getElementById('first_name').value;
	var filterFName=/^[А-ЯA-Z]{2,}( +)?([А-ЯA-Z]{2,})?( +)?$/i;

	if (!filterFName.test(strFName)) 
		{
		alert(ERROR_INPUT_NAME);
		return false;
		}

	var strSName=document.getElementById('last_name').value;
	var filterSName=/^[А-ЯA-Z]{2,}( +)?([А-ЯA-Z]{2,})?( +)?$/i;

	if (!filterSName.test(strSName)) 
		{
		alert(ERROR_INPUT_NAME);
		return false;
		}

	var strEmail=document.getElementById('email').value;
	var filterEmail=/^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,4}$/i;

	if (!filterEmail.test(strEmail)) 
		{
		alert(ERROR_INPUT_EMAIL);
		return false;
		}

	var strPhone=document.getElementById('phone').value;
	var filterPhone=/^(?:8|\+7)? ?\(\d{1,5}\)? ?\d{1,5}\-\d{2}\-\d{2}$/;
	if (str ="" )
		{
		alert(ERROR_INPUT_PHONE);
		return false;
		}
	return true;
	}

function googleTranslateElementInit()
	{
	new google.translate.TranslateElement(
		{pageLanguage: PAGE_LANG,includedLanguages: 'en, ru'}, 'google_translate_element');
	}


//$(document).ready(function(){   

//	if (REVIEW_SAVED != 1) {$.tabs('.tabs a');} else {$.tabs('.tabs a', '#tab_review');}


//ajax cart function
//    $('.ajaxcart').click(function () {                //Биндим клик по классу ajxcart
//        var curid = this.id.split('_')[1];            //Смотрим id (вида tocard_123) и берем из него код продукта
//        poststr="shopping_cart=yes&add2cart="+curid;        //Формируем POST
//        $.ajax(                            //Отправляем
//        {
//            type: "GET",
//            url: "/ajax_cart.php",
//            data: poststr,
//            success:
//                function (html)                               //Обрабатываем ответ
//                    {
//                        $('#sci').text(html.split(":")[1]);    //Пишем количество товаров в элемент с id="sci"
//                        $('#scs').text(html.split(":")[2]);    //Пишем сумму товаров в элемент с id="scs"
            //Тут же функции анимации и прочих красивостей

//				var image = $('#dp'+curid).offset();
//				var cart  = $('#module_cart').offset();
//	
//				$('#dp'+curid).before('<img src="' + $('#dp'+curid).attr('src') + '" id="temp" style="position: absolute; top: ' + image.top + 'px; left: ' + image.left + 'px;" />');
//	
//				params = {
//					top : cart.top + 'px',
//					left : cart.left + 'px',
//					opacity : 0.0,
//					width : $('#module_cart').width(),  
//					heigth : $('#module_cart').height()
//				};		
//	
//				$('#temp').animate(params, 'slow', false, function () {
//					$('#temp').remove();
//				});
//                    }
//        });
//	return false;
//    });

//hits carusel

//    $(".carouselDiv .jCarouselLite").jCarouselLite({
//	auto: 3000,
//        speed: 1000,
//	vertical: true,
//	visible: 3,
//        easing: "easeinout"
//    });
//
//
//// search
//    $('#mod_search_searchword').keydown(function(e) {if (e.keyCode == 13) {moduleSearch();}});
//});


