function validateEmail(email)
{
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(email))
        return true
    else
        return false;
}


function show_alert_message(text){

	scrollY = getScrollH();
	show_hide_select("hidden");
	show_hide_video("hidden");
	document.getElementById("blackBg").style.display = 'block';
	document.getElementById("blackBg").style.height = document.body.clientHeight + 100 + "px";
	var popupBlock = document.getElementById("form_alert_message");
	popupBlock.style.top = scrollY + 100 + "px";
	popupBlock.style.display = "block";
	document.getElementById("alert_getstarted").innerHTML = text;
}

function hide_alert_message(){
	show_hide_select("visible");
	show_hide_video("visible");
	document.getElementById("blackBg").style.display = 'none';
	var popupBlock = document.getElementById("form_alert_message");
	popupBlock.style.display = "none";
}

function show_hide_select(types)
{

	for(i=0;i<document.getElementsByTagName("select").length;i++){
		document.getElementsByTagName("select")[i].style.visibility = types;
	}

}
function show_hide_video(type){
	if(document.getElementById("contents")){
		document.getElementById("contents").style.visibility = type;
	}
}

function getScrollH()
{

	var scrollY = 0;
	if ( document.documentElement && document.documentElement.scrollTop ){
		scrollY = document.documentElement.scrollTop;
	}else if ( document.body && document.body.scrollTop ){
		scrollY = document.body.scrollTop;
	}else if ( window.pageYOffset ){
		scrollY = window.pageYOffset;
	}else if ( window.scrollY ){
		scrollY = window.scrollY;
	}
	return scrollY;
}

function checkSearch(){
	var seatxt = document.getElementById("filter");
	if(seatxt){
		if(seatxt.value.length>2){
			document.location.href = "../search/?filter="+seatxt.value;
		}
		else{
			alert("Для поиска вбейте не менее 2х символов");
		}
	}
}

var idTimeoutMenu;
function show_submenu(id)
{
	clearTimeout(idTimeoutMenu);
	var block;
	for(i=0; i< 15; i++){
		block = document.getElementById("submenu_" + i);
		if(block){
			if(id == i){
				block.style.display = "block";
			}
			else{
				block.style.display = "none";
			}
		}
	}

}

function hide_submenu(id)
{
	block = document.getElementById("submenu_" + id);
			
	idTimeoutMenu = setTimeout(function(){
		if(block){
			block.style.display = "none";
			if(act_id >= 0){
				if(document.getElementById("submenu_" + act_id)){
					document.getElementById("submenu_" + act_id).style.display = "block";
				}
			}
		}
	}, 500);
	
	
}


