function reload( name )
{
	var color	= '';
	var url		= '';

	switch( name )
	{
		case 'mision':
			color	+= 'color2';
			url		+= 'frames/mision';
			break;

		case 'contacto':
			color	+= 'color5';
			url		+= 'frames/contacto';
			break;

		case 'empleo':
			color	+= 'color4';
			url		+= 'frames/empleo';
			break;

		case 'construccion':
			color	+= 'color3';
			url		+= 'frames/construccion';
			break;

		case 'comunicacion':
			color	+= 'color3';
			url		+= 'frames/comunicacion';
			break;

		case 'formacion':
			color	+= 'color3';
			url		+= 'frames/formacion';
			break;

		case 'arte':
			color	+= 'color3';
			url		+= 'frames/arte';
			break;

		case 'grupo':
			color	+= 'color2';
			url		+= 'frames/grupo';
			break;

		case 'economia':
			color	+= 'color1';
			url		+= 'frames/economia';
			break;

		case 'triformacion':
			color	+= 'color1';
			url		+= 'frames/triformacion';
			break;
	}

	url += '.php?included=1';

	loadFlashMenu( name );
	loadContent( url, name, color );
}

// Cargadores de Flash

function loadFlashMenu( section )
{
	if( section == undefined )
		section = null;

	jQuery('div[@id=flashcontent]').media({ 
		width		: '100%', 
		height		: '100%', 
		autoplay	: true,
		params		: { scale: 'noscale' },
		flashvars	: { donde: section },
		src			: 'web-triform.swf', 
		caption		: false
	}); 
}

function loadFlash( name )
{
	var swf = 'anis/';

	switch( name )
	{
		case 'arte'				: swf += 'arte-ani.swf'; break;
		case 'comunicacion'		: swf += 'comunicacion-ani.swf'; break;
		case 'construccion'		: swf += 'construccion-ani.swf'; break;
		case 'formacion'		: swf += 'formacion-ani.swf'; break;
		case 'grupo'			: swf += 'grupo-ani.swf'; break;
		case 'empleo'			: swf += 'salud-ani.swf'; break;
	}

	jQuery('div[@class=flash_intro_sec]').media({ 
		width		: 400, 
		height		: 200, 
		autoplay	: true, 
		src			: swf, 
		caption		: false
	}); 
}

function loadFoot( color )
{
	var className='';
	
	switch( color )
	{
		case 'color1' : className = 'pie1'; break;
		case 'color2' : className = 'pie2'; break;
		case 'color3' : className = 'pie3'; break;
		case 'color4' : className = 'pie4'; break;
		case 'color5' : className = 'pie5'; break;
		case 'color6' : className = 'pie6'; break;
	}
	
	jQuery('div[@id=pie]').removeClass().addClass( className );
}

function loadContent( url, name, color )
{
	jQuery('div[@id=maincontent]').load( url, {}, function(){
		if( name != null )
			loadFlash( name );

		initCheckboxes();
		loadFoot( color );
	});
}

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}


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];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function loadNotice()
{
	if (window.innerHeight){
		h = window.innerHeight
	}else{
		h = document.body.clientHeight
	}
	h = h - 50;
	document.write('<div class="modulo_link_noticias" style="height: '+h+'px; ">');
}


function amplia_datos(id_boton,id_div)
  {
     if(document.getElementById(id_div).style.display=='none')
   {
     document.getElementById(id_div).style.display='block';  
  document.getElementById(id_boton).src='../images/mas-3b.gif';  
   }
    else
      {
    document.getElementById(id_boton).src='../images/mas-3a.gif';
    document.getElementById(id_div).style.display='none';   
   }
  }

/*
function despliega_ayudanos(id_boton,id_div)
  {
     if(document.getElementById(id_div).style.display=='none')
   {
     document.getElementById(id_div).style.display='block';  
  document.getElementById(id_boton).src='../images/titulo_contacto-3b.gif';  
   }
    else
      {
    document.getElementById(id_boton).src='../images/titulo_contacto-3a.gif';
    document.getElementById(id_div).style.display='none';   
   }
  }
*/

//	CONTACTO
function initCheckboxes()
{
	jQuery('input[@type=checkbox]').bind('click', function(){
		var id = jQuery(this).attr('id');
		var checked = jQuery(this).attr('checked');
		
		if( checked )
		{
			jQuery('label[@for='+ id +']').attr('id', 'color5');
			jQuery('label[@for='+ id +']').find('img').each(function(){
				var src_off = jQuery(this).attr('src');
				var src_on = src_off.replace('_off.gif', '_on.gif');
				jQuery(this).attr('src', src_on);
			});
		}
		else
		{
			jQuery('label[@for='+ id +']').attr('id','');
			jQuery('label[@for='+ id +']').find('img').each(function(){
				var src_on = jQuery(this).attr('src');
				var src_off = src_on.replace('_on.gif', '_off.gif');
				jQuery(this).attr('src', src_off);
			});
		}
	});
}

function emailCheck (emailStr) {
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
		alert("La direccion de email parece ser incorrecta.")
		return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]
	if (user.match(userPat)==null) {
	    alert("El usuario no parece ser correcto.")
	    return false
	}
	
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
	    // this is an IP address
		  for (var i=1;i<=4;i++) {
		    if (IPArray[i]>255) {
		        alert("La direccion IP del destino no parece correcta.")
			return false
		    }
	    }
	    return true
	}
	
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		alert("El nombre de dominio no parece correcto.")
	    return false
	}
	
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || 
	    domArr[domArr.length-1].length>3) {
	   // the address must end in a two letter or three letter word.
	   alert("La cuenta de correo debe contener al menos tres caracteres o dos de dominio.")
	   return false
	}
	
	if (len<2) {
	   var errStr="Esta cuenta de correo no cuenta con el nombre de servidor!"
	   alert(errStr)
	   return false
	}
	
	return true;
}


function comprobar_campos_ayudanos()
{
	ret=false;	
	if (document.formu.txtNombre.value=="")
  	{
		alert("Por favor, rellene el campo nombre");
		ret=false;
		document.formu.txtNombre.focus();
  	}
  	else if (document.formu.txtApellidos.value=="")
	{
		alert("Por favor, rellene el campo apellidos ");
		ret=false;
		document.formu.txtApellidos.focus();
	}
/*
	else if (document.formu.txtTelefono.value=="")
	{
		alert("Por favor, rellene el campo telefono");
		ret=false;
		document.formu.txtTelefono.focus();
	}
	else if (document.formu.txtMovil.value=="")
	{
		alert("Por favor, rellene el campo movil");
		ret=false;
		document.formu.txtMovil.focus();
	}
*/
	else if (document.formu.txtMail.value=="")
	{
		alert("Por favor, rellene el campo e-mail");
		ret=false;
		document.formu.txtMail.focus();
	}
	else if (!emailCheck(document.formu.txtMail.value)) {
		ret=false;
		document.formu.txtMail.focus();
	}
	else if (document.formu.txtAsunto.value=="")
	{
		alert("Por favor, rellene el campo asunto");
		ret=false;
		document.formu.txtAsunto.focus();
	}
	else if (document.formu.txtMensaje.value=="")
	{
		alert("Por favor, escriba algun texto de mensaje");
		ret=false;
		document.formu.txtMensaje.focus();
	}
	else { ret=true;};
	return ret;
}

function comprobar_campos_empleo()
{
	ret=false;	
	if (document.formu.nombre.value=="")
  	{
		alert("Por favor, rellene el campo nombre");
		ret=false;
		document.formu.nombre.focus();
  	}
	
	else { ret=true;};
	return ret;
}