// JavaScript Document

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}

function OSValidateForm()
{
error = '';
var mail = document.contact_form.email.value;
if (document.contact_form.fname.value == '')
	{
	error = 'Please enter your first name.\r\n';	
	}
if (document.contact_form.lname.value == '')
	{
	error += 'Please enter your last name.\r\n';	
	}
if (mail == '')
	{
	error += 'Please enter a valid email address.\r\n';		
	}
else
{
if (echeck(mail)==false)
	{
	error += 'Please enter a valid email address.\r\n';	
	}
}
if (document.contact_form.message.value == '')
	{
	error += 'Please enter your message.\r\n';	
	}
if (document.contact_form.validator.value == '')
	{
	error += 'Please enter the validation code.\r\n';	
	}	
if (error != '')
	{
	alert(error);
	return false;
	}
else
	{
	return true;	
	}
}

function OSfindPos(objeto)
	{
		var curlefte = curtope = 0;
		if (objeto.offsetParent) {
			curlefte = objeto.offsetLeft;
			curtope = objeto.offsetTop;
			while (objeto = objeto.offsetParent) {
				curlefte += objeto.offsetLeft;
				curtope += objeto.offsetTop;
				}
		}
			return [curlefte,curtope];
	}

function OSsetLyr(obje,lyre)
	{
		objeto = document.getElementById(obje);
		var coorse = OSfindPos(objeto);
		var xe = document.getElementById(lyre);
		var val_xe = parseInt(coorse[0]) - 115;
		var val_ye = parseInt(coorse[1]) + 95;
		xe.style.top = val_ye + 'px';
		xe.style.left = val_xe + 'px';
		xe.style.visibility = 'visible';
	}
	
	
var timerID = 0;

var d1_op_init = 1;
var d1_alpha_init = 100;
var d2_op_init = 0;
var d2_alpha_init = 0;
var way = 'f';

function UpdateTimer() {
	if (way == 'f')
	{
	   d1_op_init = d1_op_init - 0.08;
	   d1_alpha_init = d1_alpha_init - 8;
	   d2_op_init = d2_op_init + 0.08;
	   d2_alpha_init = d2_alpha_init + 8;
	 }
	if (way == 'b')
	{
	   d1_op_init = d1_op_init + 0.08;
	   d1_alpha_init = d1_alpha_init + 8;
	   d2_op_init = d2_op_init - 0.08;
	   d2_alpha_init = d2_alpha_init - 8;
	}
   div1.style.opacity = d1_op_init;
   div1.style.filter = "alpha(opacity=" + d1_alpha_init + ")";
   div2.style.opacity = d2_op_init;
   div2.style.filter = "alpha(opacity=" + d2_alpha_init + ")";
   
   if ( ((d1_op_init > 0) && (way == 'f')) || ((d2_op_init > 0) && (way == 'b')) )
   {
   timerID = setTimeout("UpdateTimer()", 70);
   }
   else
   {
	if (way == 'f')
		{
		way = 'b';
		div1.style.zIndex = '100';
		div2.style.zIndex = '400';
		}
	else
		{
		way = 'f';
		div1.style.zIndex = '400';
		div2.style.zIndex = '100';
		}
    timerID = setTimeout("UpdateTimer()", 4000);
	}
}

function ResetFade()
	{
	clearTimeout(timerID);
	document.getElementById('msg_box_fade').style.opacity = '1.0';
   	document.getElementById('msg_box_fade').style.filter = "alpha(opacity=100)";
	op_init = 1.0;
    alpha_init = 100;
	}

function ResumeFade()
	{
		timerID = setTimeout("UpdateTimer()", 70);
	}