var showing;

function on(obj){
	document.getElementById(obj).style.backgroundColor = "#000000";
}

function off(obj){
	document.getElementById(obj).style.backgroundColor = "#474747";
}

function _on(obj){
	obj.style.backgroundColor = "#E4C088";
}

function _off(obj){
	if (!showing) obj.style.backgroundColor = "#F2D9B1";
}

function show_popup (id) {
	if (showing != id){
		if (showing){
			 document.getElementById('p'+showing).style.visibility = "hidden";
			 document.getElementById('s'+showing).style.backgroundColor = "#F2D9B1";
			  showing = null;
		}
		if (o = document.getElementById('p'+id)){
			o.style.visibility = "visible";
			showing = id;
		}
	}
}

function check_send(obj){
	o = obj.elements;
	text = '';
	if (o["info[name]"].value.length < 1) text=text+"Ââåä³òü ³ì\'ÿ!\n"
	if (!IsEmailValid(o["info[email]"].value) || !o["info[email]"].value) text=text+"Ââåä³òü â³ðíèé E-Mail!\n"
	if (o["info[header]"].value.length < 1) text=text+"Ââåä³òü çàãîëîâîê ïîâ³äîìëåííÿ!\n"
	if (o["info[message]"].value.length < 1) text=text+"Ââåä³òü òåêñò ïîâ³äîìëåííÿ!\n"
	if (text) alert(text);
	else obj.submit();
}

function check_s_email(){
	o=document.getElementById("s_email");
	if (!IsEmailValid(o.value))
		alert("Ââåä³òü â³ðíèé E-mail");
	else window.open("sub_insert.php?e="+o.value+"&action=sub","si","width=400,height=200,srollbar=no,toolbar=no");
} 

function IsEmailValid(checkThisEmail) {
    var myEMailIsValid = true;
    var myAtSymbolAt = checkThisEmail.indexOf('@');
    var myLastDotAt = checkThisEmail.lastIndexOf('.');
    var mySpaceAt = checkThisEmail.indexOf(' ');
    var myLength = checkThisEmail.length;

if (myAtSymbolAt < 1 )
 {myEMailIsValid = false}

if (myLastDotAt < myAtSymbolAt)
 {myEMailIsValid = false}

if (myLength - myLastDotAt <= 2)
 {myEMailIsValid = false}

if (mySpaceAt != -1)
 {myEMailIsValid = false}

return (myLength?myEMailIsValid:false)
}
