// JavaScript Document

function check_ulid(i){
	if( $('#id_'+i ).is(':hidden') || $('#id_'+i ).is(':empty') ){
		$("#id_"+i).show('slow');
	}else{
		$("#id_"+i).hide('slow');
		}
	}

function cambiaestado(id,estado,p,t){
	document.location='contenido.php?est='+estado+'&id='+id+'&p='+p+'&t='+t;
	}

function enviar_contacto(){
	$('#form_contacto').submit();

	}

function ir( nom ){
	$('#content').hide();
	$("#content").html( $.ajax({ url: nom, cache:false, async: false}).responseText );
	$('#content').show();
	}
	
		
function menu( it,lang ){
//	$('#content').hide();
	if( $('#'+it ).is(':hidden') || $('#'+it ).is(':empty') ){
		$("#"+it).html( $.ajax({ url: it+'.php?lang='+lang, cache:false, async: false}).responseText );
		$("#"+it).show('slow');
	}else{
		$("#"+it).hide();
		}
	}
	
function amplia(u,t){
	$.fancybox({'titleShow'     : false,
				'transitionIn'  : 'elastic',
				'transitionOut' : 'elastic',
				'href' 			: 'amplia.php?url='+u+'&t='+t
			});
}	

function team(id){
	$.fancybox({'titleShow'     : false,
				'height'		: '3',
				'transitionIn'  : 'elastic',
				'transitionOut' : 'elastic',
				'href' 			: 'team.php?i='+id
			});
}

function load_work( wh ){
	if( $('#'+wh ).is(':hidden') || $('#'+wh ).is(':empty') ){
		$('#'+wh ).html( $.ajax({ url: 'works/'+wh+'.php', cache:false, async: false}).responseText);
		$('#'+wh ).show('slow');
	} else {
		$('#'+wh ).hide();
	}
}


function validEmail($email)
{
   $isValid = true;
   $atIndex = strrpos($email, "@");
   if (is_bool($atIndex) && !$atIndex)
   {
      $isValid = false;
   }
   else
   {
      $domain = substr($email, $atIndex+1);
      $local = substr($email, 0, $atIndex);
      $localLen = strlen($local);
      $domainLen = strlen($domain);
      if ($localLen < 1 || $localLen > 64)
      {
         $isValid = false;
      }
      else if ($domainLen < 1 || $domainLen > 255)
      {
         $isValid = false;
      }
      else if ($local[0] == '.' || $local[$localLen-1] == '.')
      {
         $isValid = false;
      }
      else if (preg_match('/\\.\\./', $local))
      {
         $isValid = false;
      }
      else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain))
      {
         $isValid = false;
      }
      else if (preg_match('/\\.\\./', $domain))
      {
         $isValid = false;
      }
      else if(!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/',
                 str_replace("\\\\","",$local)))
      {
         if (!preg_match('/^"(\\\\"|[^"])+"$/',
             str_replace("\\\\","",$local)))
         {
            $isValid = false;
         }
      }
   }
   return $isValid;
}
