
function isValidEmail(strEmail){

  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) 
   {
      alert('A valid e-mail address is required.\nPlease amend and retry');
      return false;
    } 
    return true; 
}

function showElementAndFadeIn(elementID)
{
	Element.show(elementID);
	fadeIn(elementID,0.3,1.1,0.8);
}

function fadeIn(el,f,t,d)
{
	if(!f)
		f = 0.3;
	if(!t)
		t = 1;
	if(!d)
		d = 1.0;
	new Effect.Opacity(el,
	    { duration: d, 
	      transition: Effect.Transitions.linear, 
	      from: f, to: t
		  });
}
function fadeOut(el)
{

	new Effect.Opacity(el,
	    { duration: 1.0, 
	      transition: Effect.Transitions.linear, 
	      from: 1, to: 0.3,
	      afterFinish: Element.hide(el)});
}


function menuSelect(idSelected,itens)
			    {   i = 1; 
			        for(i=1;i<=itens;i++)
			           document.getElementById("m"+i).className = "menu_off";
			        document.getElementById(idSelected).className = "menu_on";
			    }
 //Change DIV
 function CD(id,conteudo)
   {  
     document.getElementById(id).innerHTML = conteudo;
   }
  function CI(id,conteudo)
   {  
     document.getElementById(id).innerHTML = "<img src=../img/"+conteudo+" border=0>";
   }


/*função que carrega dados via AJAX.
parametros: 
	url -> url que vai ser chamada;
	div_id -> id do objeto que vai receber o conteudo da chamada da url
	loadObj -> objeto que vai servir de loading enquanto o ajax carrega
	func -> função javascript que vai ser executada após a carga da página.
*/

function PL(url, div_id,loadObj,func)
{

showResponse = function(originalRequest)
        {
          div = $(div_id);  
          fechaLoading(loadObj);
          div.innerHTML = unescape(originalRequest.responseText);
        } 	

pars = ""
abreLoading = function (loadObj){
	if(loadObj)
	{	Element.show(loadObj);}
}
fechaLoading = function (loadObj){
	if(loadObj)
	{	Element.hide(loadObj);
		if(func) func.call();
	}
}

var myAjax = new Ajax.Request(
          url, 
          {
            method: 'get', 
            parameters: pars,
			onLoading: abreLoading(loadObj),
            onSuccess: showResponse
          });
}

function copyDivPosition(source,dest,leftInc,topInc)
{
   var result = [0, 0];
   el = $(source);
   while (el) {
    result[0] += el.offsetLeft;
    result[1] += el.offsetTop;
    el = el.offsetParent;
  }
    x = result[0];
    y = result[1];
   
   
   $(dest).style.left = x+leftInc+"px";
   $(dest).style.top = y+topInc+"px";
}

function sendToFriendValidation()
{

	if (!document.formSend.nome.value)
	{
		alert("The field Name is required.");
		document.formSend.nome.focus();
		return false;
	}	
		
	if (!document.formSend.email.value)
	{
		alert("The field E-mail is required.");
		
		document.formSend.email.focus();
		return false;
	}
	if(!isValidEmail(document.formSend.email.value))
	{	document.formSend.email.focus();
		return false;
	}
	
	if (!document.formSend.iemail.value)
	{
		alert("The field Friend e-mail is required.");
		
		document.formSend.email.focus();
		return false;
	}
	
		if(!isValidEmail(document.formSend.iemail.value))
	{	document.formSend.iemail.focus();
		return false;
	}
	
	function showResponse(originalRequest)
        {
          
		  div = $('respFriend');  
          div.innerHTML = unescape(originalRequest.responseText);
          $('send_nome').value='';
		  $('send_email').value='';
		  $('send_iemail').value='';
          Element.show('respFriend');
        } 
	function abreLoading()
	{
		$('respFriend').text = 'Sending the message...'; 
	}
    pars = 'nome=' +escape($F('send_nome'))+ '&email='+escape($F('send_email'))+'&iemail='+escape($F('send_iemail'))+'&url='+escape(window.location);
	url = document.formSend.action;	
	//alert(pars);
	var myAjax = new Ajax.Request(
          url, 
          {
            method: 'get', 
            parameters: pars,
            onLoading: abreLoading,
            onSuccess: showResponse
          });
          
	
	return false;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}



	var tam = 12;
	function mudaFonte(tipo){
	
		if (tipo=="mais") {
			if(tam<16) tam+=2;
			//createCookie('fonte',tam,365);
		} else {
			if(tam>10) tam-=2;
			//createCookie('fonte',tam,365);
		}
		document.getElementById('interna_meio').style.fontSize = tam+'px';
	}
	
	//Abre e fecha os layers
	function trocaTam(elemento,alt,tamIni,botaoMore){
 	
	if (document.getElementById(elemento).style.height == tamIni+"px" || document.getElementById(elemento).style.height == tamIni )		
	{	
		document.getElementById(elemento).style.height = alt;
		document.getElementById(botaoMore).innerHTML = "<img src='"+imgurl+"bt_less.gif' vspace=2 border=0>";
		
	}
	else	
		{
			document.getElementById(elemento).style.height = tamIni+'px';
			document.getElementById(botaoMore).innerHTML = "<img src='"+imgurl+"bt_more.gif' vspace=2 border=0>";
		}
 	
	 }
 	
 	
 	
 	function trocaTexto(elemento)
 	{
 		document.getElementById("moreLess").innerHTML = "<< Less";
 	}
 	
	//Somente abre o layer
	function abreLayer(elemento,alt){
		if(alt != '100%')
			document.getElementById(elemento).style.height = alt+"px";
		else
			document.getElementById(elemento).style.height = alt;

 	}
 	
 	function carregaPagina(value)
 	{
	 	if(value)
	 	window.location = value;
	 }
	 
	 		 
					
	var refer=true;
	function combo() {
	if (refer) {
	  
	  document.getElementById("contents").style.visibility = "visible";
	  
	  refer=false;
	}

	}
	
	
	function combo_on(){
	
	document.getElementById("contents").style.visibility = "visible";
	
	}

	function combo_off()
	{
	document.getElementById("contents").style.visibility = "hidden";
	}
				

