/*
	main css style development
	============================
	website 	: 	Mayra
	date 		: 	26-12-2009		
	author 		: 	mayra metaxa / developer
	company		: 	mayra
	url			:	

*/

function clear_class(nm)
{
	for (i=1; i<=nm; i++)
	{
		if (document.getElementById('thumb_'+i))
			document.getElementById('thumb_'+i).className = "thumb";
	}
}
/*

var num_show_gal = 6;

function prev_next_gal(action) 
{										
	var nm = document.getElementById('nm').value;

	if (action==1)
		from_gal = from_gal+num_show_gal;
	else
		from_gal = from_gal-num_show_gal;
	
	if (from_gal>nm)
		from_gal = 0;
			
	if (from_gal<0)
		from_gal = 0;

	var to  = from_gal+num_show_gal;
	if (to>nm)
		to = nm;
		
	for (i=0; i<nm; i++)			
		document.getElementById('thumb_'+i).style.display= "none";
	
	for (j=from_gal; j<to; j++)
		document.getElementById('thumb_'+j).style.display= "inline";

}



/* ========= FORM functions ========= */

function show_error(id)
{
	document.getElementById(id).style.background="#b6bcb4";
}

function clear_errors(which)
{
	for (i=0;i<document.forms[which].elements.length;i++)
	{
		if ( (document.forms[which].elements[i].type != "button") && (document.forms[which].elements[i].type != "reset") && (document.forms[which].elements[i].id!="fieldset") )
			document.forms[which].elements[i].style.background="#fff";
	}
}


function checkEmail(elem)
{
   var field = document.getElementById(elem);
   var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
   if (field.value.length ==0)
		return false;

   if(field.value.match(emailExp))
		   return true;
   else 
		   return false;
   
}


function check_form(formid, whichform, mandatory_fields, numericfields, emailid)
{
	clear_errors(whichform);
	
	//check mandatory fields
	var man = mandatory_fields.split(",");
	for (i=0;i<man.length;i++)
	{
		if (document.getElementById(man[i]).value == "")
		{
			show_error(man[i]);
			alert ("You must fill all the mandatory fields (*)");
			return false;
		}
	}		

	if (emailid!="")
	{
		if (!checkEmail(emailid))
		{
			show_error(emailid);
			alert ("Your email address is not valid.");
			return false;
		}
	}
		
	
	//check numeric fields
	if (numericfields != "")
	{
		var numeric = numericfields.split(",");
		for (i=0;i<numeric.length;i++)
		{
			document.getElementById(numeric[i]).value = document.getElementById(numeric[i]).value.replace(/,/,".");
			
			if (isNaN (document.getElementById(numeric[i]).value))
			{
				show_error(numeric[i]);
				alert (numeric[i]+": should be a number. Plase check and try again!");
				return false;
			}
		}
	}
	
	document.getElementById(formid).submit();
}

/* ============================================================= */

var speed = 100;	//10-100
var timer = 0;

var speed2 = 1;

var cloud_left = 0;

function change_left(id, left)
{
	document.getElementById(id).style.left = left+"px";

}

function bg_animate()
{
	var wdth = window_width()+100;
	
	for(i = cloud_left; i <= wdth; i+=1)
	{
		setTimeout("change_left('cloud_3', "+(i-800)+")",(timer * speed));
		setTimeout("change_left('cloud_1', "+i+")",(timer * speed));		
		setTimeout("change_left('cloud_2', "+(i+500)+")",(timer * speed));
		
		timer++;
		
	}
	/**/
	cloud_left = -100;
	setTimeout("bg_animate()",(timer * speed));
	
		
}


function window_width() 
{
	  var myWidth = 0;
	  if( typeof( window.innerWidth ) == 'number' ) 
	  {
		//Non-IE
		myWidth = window.innerWidth;
	  } 
	  else if ( (document.documentElement) && (document.documentElement.clientWidth) ) 
	  {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
	  } 
	  else if( (document.body) && (document.body.clientWidth) ) 
	  {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
	  }	  	  

	  return(myWidth);
}


