
onresize=windowResized;

function BubbleOver(xdiv)
{
	var obj=document.getElementById(xdiv);
	obj.style.visibility="visible";
	
}
function BubbleOut(xdiv)
{
	var obj=document.getElementById(xdiv);
	obj.style.visibility="hidden";
}

//=========================================================================
//  FORMS API by Wanich Kantasima (C)2010 SWG.
//=========================================================================

function sendMessage12(n)
{
	var valid=true;
	if(document.forms[0].ff1.value=="")
	{
		valid=false;
	}
	if(document.forms[0].ff2.value=="")
	{
		valid=false;
	}
	if(document.forms[0].ff3.value=="")
	{
		valid=false;
	}

	if(valid)
	{
		document.forms[0].submit();
		footerpopup(0);
		popmsg1("saving infomation.....")
	}
	else
	{
		alert ( msg14 );
	}
}

function sendMessage13(n)
{
	var valid=true;
	if(document.forms[1].ff1.value=="")
	{
		valid=false;
	}
	if(document.forms[1].ff2.value=="")
	{
		valid=false;
	}

	var	useremail=document.forms[1].ff2.value;
	if(!validateEmail(useremail))
	{
		alert ( msg15e );
		document.forms[1].ff2.focus();		
		document.forms[1].ff2.select();
		return 0;
	}

	if(valid)
	{
		document.forms[1].submit();
		footerpopup(0);
		popmsg1("saving infomation.....")
	}
	else
	{
		alert ( msg14e );
	}
}

msg12="   Thank you! <BR><BR>We have received your contact information and will be in touch with you shortly.";
msg13="   Thank you for joining our mailing list! <BR><BR>Please, check your email to confirm sign up.";
msg13error=" [!] There has been some errors, Please try again. ";
msg0error="";
msg14e="Looks like you've left out some information!  Please fill out all fields before submitting this contact form.  Thanks!";
msg15e="Email address is invalid";
function callback(code)
{
	var msg="";
	
	footerpopup(0);

	switch(code)
	{
		case "12" : { popmsg1(msg12); break;}
		case "13" : { popmsg1(msg13); break;}
		case "-13" : { popmsg1(msg13error); break;}
		default: popmsg1(msg0error);
	}

	setTimeout("popmsg1(0)",2500)
	window.focus();
}


function popmsg1(text1)
{
	var obj=document.getElementById("popmsgLOG");

	if(text1==0)
	{
			hidePopup("footerpopup3");
	}	
	else
	{
		obj.innerHTML=text1;
		setPopupPos("footerpopup3",185);
		showPopup("footerpopup3");
	}
}

function clearInput(obj,text)
{
		if(obj.value == text)
		{
			obj.value="";
		}
}
function clearInput2(obj,text)
{
		if(obj.value == "")
		{
			obj.value=text;
		}
}

function form0reset()
{
	document.forms[0].reset();
	document.forms[1].reset();
}
//-----------------------------------------------------------

var DivpopName="";
var DivpopHeight=0;

function footerpopup(n)
{
		hidePopup("footerpopup1");
		hidePopup("footerpopup2");
		hidePopup("footerpopup3");
	if(n==0) 
	{
		 DivpopName="";
		 return;
	}
	if(n==1)
	{
		setPopupPos("footerpopup1",160+60);
		showPopup("footerpopup1")
	}
	else
	{
		setPopupPos("footerpopup2",132);
		showPopup("footerpopup2");
	}
	form0reset();
}

function hidePopup(divname1)
{
		var obj =document.getElementById(divname1);
		obj.style.display="none";		
}
function showPopup(divname1)
{
		var obj =document.getElementById(divname1);
		obj.style.display="block";		
}

function setPopupPos(divname,hx)
{

  if( typeof( window.innerWidth ) == 'number' ) 
	{
    //Non-IE
  	
	} 
	else
	{
		hx += 8;
	}

		if(divname.length>1)
		{
				var obj =document.getElementById(divname);
				obj.style.top=getDocHeight() - hx;
				obj.style.left=getDocWidth() - 545;

				DivpopName=divname;
				DivpopHeight=hx;
		}
}

function windowResized()
{
		setPopupPos(DivpopName,DivpopHeight);
}




//---------------------------------------------------------------------
// Standard Libs
//---------------------------------------------------------------------




function getDocHeight() 
{
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

function getDocWidth() 
{
    var D = document;
    return Math.max(
        Math.max(D.body.scrollWidth, D.documentElement.scrollWidth),
        Math.max(D.body.offsetWidth, D.documentElement.offsetWidth),
        Math.max(D.body.clientWidth, D.documentElement.clientWidth)
    );
}


function validateEmail(elementValue)
{   
   var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;   
   return emailPattern.test(elementValue);   
} 

