submenus = new Array(6);

function gid(id)
{
	return document.getElementById(id);
}

function show(i)
{
	clearTimeout(submenus[i-1]);
	id = "submenu_"+i;
	action = "gid('"+id+"').style.display = 'block'";
	setTimeout(action,10);
}

function hide(i)
{
	clearTimeout(submenus[i-1]);
	id = "submenu_"+i;
	action = "gid('"+id+"').style.display = 'none'";
	submenus[i-1] = setTimeout(action,10);
}

function relocateSubmenus()
{
	var my_width = 0;
	if (!(my_width = document.width))
	{
		my_width = document.body.scrollWidth;
	}
	if (my_width>780)
	{
		my_width = Math.ceil((my_width - 782) / 2);
	}
	else
	{
		if (navigator.appName=="Netscape"&&navigator.userAgent.indexOf("Opera")==-1)
			my_width = 0;
		else
			my_width = 8;
	}
	gid("submenus").style.left = (189 + my_width)+"px";
}

function gid(id)
{
	return document.getElementById(id);
}


function formSend()
{
	var send = true;
	send *= k = gid("nm").value.length;
	if (k)
	gid("nm_txt").style.color = "#656565";
	else
	gid("nm_txt").style.color = "#FF0000";
	
	send *= k = gid("ad").value.length;
	if (k)
	gid("ad_txt").style.color = "#656565";
	else
	gid("ad_txt").style.color = "#FF0000";
	
	send *= k = gid("ct").value.length;
	if (k)
	gid("ct_txt").style.color = "#656565";
	else
	gid("ct_txt").style.color = "#FF0000";
	
	send *= k = gid("st").value.length;
	if (k)
	gid("st_txt").style.color = "#656565";
	else
	gid("st_txt").style.color = "#FF0000";
	
	r = /^\d{5}$/;
	send *= k = gid("zp").value.search(r)+1;
	if (k)
	gid("zp_txt").style.color = "#656565";
	else
	gid("zp_txt").style.color = "#FF0000";
	
	send *= k = gid("ph").value.length;
	if (k)
	gid("ph_txt").style.color = "#656565";
	else
	gid("ph_txt").style.color = "#FF0000";
	
	r = /^[a-z]+\.?[-_.a-z0-9]*@[a-z][-_.a-z0-9]+\.[a-z]{2,3}$/i;
	send *= k = gid("ml").value.search(r)+1;
	if (k)
	gid("ml_txt").style.color = "#656565";
	else
	gid("ml_txt").style.color = "#FF0000";
	
	r = /^.{1,1000}$/;
	send *= k = gid("in").value.search(r)+1;
	if (k)
	gid("in_txt").style.color = "#656565";
	else
	gid("in_txt").style.color = "#FF0000";
	
	$.get("php/check_antibot.php?sec_code=" + $('#sec_code').val(), function(data){
        if ('f' == data){
            send = false;
            gid("captcha_txt").style.color = "#FF0000";
        } else {
            gid("captcha_txt").style.color = "#656565";
        }
        if (send)
		return true;
	else
	{
		alert("Please fill in correctly required fields.");
		return false;
	}
        });
        return false;
}

function formSubmit()
{
	send = true;
	send *= k = document.getElementById("name").value.length;
	if (k)
		document.getElementById("name_txt").style.color = "#333333";
	else
		document.getElementById("name_txt").style.color = "#FF0000";
		
	send *= k = document.getElementById("address").value.length;
	if (k)
		document.getElementById("address_txt").style.color = "#333333";
	else
		document.getElementById("address_txt").style.color = "#FF0000";

	send *= k = document.getElementById("city").value.length;
	if (k)
		document.getElementById("city_txt").style.color = "#333333";
	else
		document.getElementById("city_txt").style.color = "#FF0000";

	send *= k = document.getElementById("state").value.length;
	if (k)
		document.getElementById("state_txt").style.color = "#333333";
	else
		document.getElementById("state_txt").style.color = "#FF0000";

	r = /^\d{5}$/;
	send *= k = document.getElementById("zip").value.search(r)+1;
	if (k)
		document.getElementById("zip_txt").style.color = "#333333";
	else
		document.getElementById("zip_txt").style.color = "#FF0000";

	send *= k = document.getElementById("nature").value.length;
	if (k)
		document.getElementById("nature_txt").style.color = "#333333";
	else
		document.getElementById("nature_txt").style.color = "#FF0000";
		
	send *= k = document.getElementById("time").value.length;
	if (k)
		document.getElementById("time_txt").style.color = "#333333";
	else
		document.getElementById("time_txt").style.color = "#FF0000";
		
	$.get("php/check_antibot.php?sec_code=" + $('#sec_code').val(), function(data){
        if ('f' == data){
            send = false;
            gid("captcha_txt").style.color = "#FF0000";
        } else {
            gid("captcha_txt").style.color = "#333333";
        }
        if (send)
		return true;
	else
	{
		alert("Please fill in correctly required fields.");
		return false;
	}
        });
        return false;
}