/*
	funciones.js
*/
function abrirVentana(url, ancho, alto) {
	top = (screen.height/2)-alto;
	left = (screen.width/2)-ancho;
	window.open('pass.asp', 'Password', 'top=' + top + ', left=' + left + ', width=' + ancho + ' , height=' + alto + ', scrollbars=no, menubar=no, location=no, resizable=no');
}

function validarEmail(valor) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
		return (true)
	} else {
		return (false);
	}
}

function validar_form_registro()
{
	miss="";
	try {
		if(document.getElementById('nombre').value < 1)
		{
			miss+="\n- El campo nombre es obligatorio.";
			document.getElementById('nombre').style.backgroundColor ="#fdc5c5";
		}
		else
			document.getElementById('nombre').style.backgroundColor ="#fff";
		if(document.getElementById('apellido1').value < 1)
		{
			miss+="\n- El campo primer apellido es obligatorio.";
			document.getElementById('apellido1').style.backgroundColor ="#fdc5c5";
		}
		else
			document.getElementById('apellido1').style.backgroundColor ="#fff";
		if(document.getElementById('apellido2').value < 1)
		{
			miss+="\n- El campo segundo apellido es obligatorio.";
			document.getElementById('apellido2').style.backgroundColor ="#fdc5c5";
		}
		else
			document.getElementById('apellido2').style.backgroundColor ="#fff";
		
		if(document.getElementById('nif').value < 1)
		{
			miss+="\n- El campo nif es obligatorio.";
			document.getElementById('nif').style.backgroundColor ="#fdc5c5";
		}
		else
			document.getElementById('nif').style.backgroundColor ="#fff";
		
		if(document.getElementById('email').value < 1)
		{
			miss+="\n- El campo Email es obligatorio.";
			document.getElementById('email').style.backgroundColor ="#fdc5c5";
		}
		else
		{
			if(!validarEmail(document.getElementById('email').value))
			{
				miss+="\n- Direccion email incorrecta.";
				document.getElementById('email').style.backgroundColor ="#fdc5c5";
			}
			else
				document.getElementById('email').style.backgroundColor ="#fff";
		}
		if(document.getElementById('telefono').value < 1)
		{
			miss+="\n- El Telefono es obligatorio.";
			document.getElementById('telefono').style.backgroundColor ="#fdc5c5";
		}
		else
			document.getElementById('telefono').style.backgroundColor ="#fff";
		
		if(document.getElementById('fecha_boda').value < 1)
		{
			miss+="\n- El campo fecha de boda es obligatorio.";
			document.getElementById('fecha_boda').style.backgroundColor ="#fdc5c5";
		}
		else
			document.getElementById('fecha_boda').style.backgroundColor ="#fff";
		
		if(document.getElementById('cmbPais').value == "000")
		{
			miss+="\n- Debe seleccionar un pais.";
			document.getElementById('cmbPais').style.backgroundColor ="#fdc5c5";
		}
		else
			document.getElementById('cmbPais').style.backgroundColor ="#fff";
		
		if(document.getElementById('cmbProvincia').value == "0")
		{
			miss+="\n- Debe seleccionar una provincia.";
			document.getElementById('cmbProvincia').style.backgroundColor ="#fdc5c5";
		}
		else
			document.getElementById('cmbProvincia').style.backgroundColor ="#fff";
		
		if(document.getElementById('poblacion').value < 1)
		{
			miss+="\n- El campo Poblacion es obligatorio.";
			document.getElementById('poblacion').style.backgroundColor ="#fdc5c5";
		}
		else
			document.getElementById('poblacion').style.backgroundColor ="#fff";
		
		if(document.getElementById('cp').value < 1)
		{
			miss+="\n- El campo Codigo postal es obligatorio.";
			document.getElementById('cp').style.backgroundColor ="#fdc5c5";
		}
		else
			document.getElementById('cp').style.backgroundColor ="#fff";
		
		if(document.getElementById('dp').value < 1)
		{
			miss+="\n- El campo direccion postal es obligatorio.";
			document.getElementById('dp').style.backgroundColor ="#fdc5c5";
		}
		else
			document.getElementById('dp').style.backgroundColor ="#fff";
		
		if(document.getElementById('usuario').value < 1)
		{	
			
			miss+="\n- El campo Ususario(debe ser un email) es obligatorio.";
			document.getElementById('usuario').style.backgroundColor ="#fdc5c5";
		}
		else {
			if(!validarEmail(document.getElementById('usuario').value))
			{
				miss+="\n- El campo Usuario debe ser un email";
				document.getElementById('usuario').style.backgroundColor ="#fdc5c5";
			}
			else
				document.getElementById('usuario').style.backgroundColor ="#fff";
		}
		if(document.getElementById('cusuario').value < 1)
		{
			miss+="\n- El campo Confirmar usuario(debe ser un email) es obligatorio.";
			document.getElementById('cusuario').style.backgroundColor ="#fdc5c5";
		}
		else {
			if(document.getElementById('usuario').value!=document.getElementById('cusuario').value)
			{
				miss+="\n- El campo Confirmar usuario y usuario son diferentes.";
				document.getElementById('usuario').style.backgroundColor ="#fdc5c5";
				document.getElementById('cusuario').style.backgroundColor ="#fdc5c5";
			}
			else
			{
				
				document.getElementById('usuario').style.backgroundColor ="#fff";
				document.getElementById('cusuario').style.backgroundColor ="#fff";
			}
		}
		
		if(document.getElementById('pass').value < 1)
		{
			miss+="\n- El campo Password es obligatorio.";
			document.getElementById('pass').style.backgroundColor ="#fdc5c5";
		}
		else
			document.getElementById('pass').style.backgroundColor ="#fff";
		
		if(document.getElementById('cpass').value < 1)
		{
			miss+="\n- El campo Confrmar Password es obligatorio.";
			document.getElementById('cpass').style.backgroundColor ="#fdc5c5";
		}
		else{
			if(document.getElementById('pass').value!=document.getElementById('cpass').value)
			{
				miss+="\n- El campo Confrmar Password y password son diferentes.";
				document.getElementById('pass').style.backgroundColor ="#fdc5c5";
				document.getElementById('cpass').style.backgroundColor ="#fdc5c5";
			}
			else
			{
				document.getElementById('pass').style.backgroundColor ="#fff";
				document.getElementById('cpass').style.backgroundColor ="#fff";
			}
		}
		//Otras validaciones
		if(!document.getElementById('acepto').checked)
		{
			miss+="\n- Debe aceptar las condiciones.";
			document.getElementById('acepto').style.backgroundColor ="#fdc5c5";
		}
		else
			document.getElementById('acepto').style.backgroundColor ="#fff";
	
		if(document.getElementById("valid").value==0)
		{
			miss+="\n- El nombre de usuario/email ya esta en nuestra base de datos.";
		}
		
		if(miss!="")
		{
			alert("Faltan los siguientes datos:\n"+miss);
			return false;
		}
		return true;
	}
	catch(e)
	{
		alert(e);
	  	return false;	
	}
}

function validar_form_contacto_etn()
{
	miss="";
	try {
	if(document.getElementById('nombre').value < 1)
	{
		miss+="\n- El campo nombre es obligatorio.";
		document.getElementById('nombre').style.backgroundColor ="#fdc5c5";
	}
	else
	document.getElementById('nombre').style.backgroundColor ="#fff";
	
	if(document.getElementById('comentarios').value < 1)
	{
		miss+="\n- El campo comentarios es obligatorio.";
		document.getElementById('comentarios').style.backgroundColor ="#fdc5c5";
	}
	else
	document.getElementById('comentarios').style.backgroundColor ="#fff";
	
	if(document.getElementById('email').value < 1)
	{
		miss+="\n- El campo Email es obligatorio.";
		document.getElementById('email').style.backgroundColor ="#fdc5c5";
	}
	else
	{
		if(!validarEmail(document.getElementById('email').value))
		{
			miss+="\n- Direccion email incorrecta.";
			document.getElementById('email').style.backgroundColor ="#fdc5c5";
		}
		else
			document.getElementById('email').style.backgroundColor ="#fff";
	}
	
	//Otras validaciones
	if(!document.getElementById('acepto').checked)
	{
		miss+="\n- Debe aceptar las condiciones.";
		document.getElementById('acepto').style.backgroundColor ="#fdc5c5";
	}
	else
	document.getElementById('acepto').style.backgroundColor ="#fff";
	
	if(miss!="")
	{
		alert("Faltan los siguientes datos:\n"+miss);
		return false;
	}
	return true;
	}
	catch(e)
	{
		alert(e);
	  return false;	
	}
}

function validar_form_consulta()
{
	miss="";
	try {
	
	if(document.getElementById('consulta').value < 1)
	{
		miss+="\n- El campo de la consulta es obligatorio.";
		document.getElementById('consulta').style.backgroundColor ="#fdc5c5";
	}
	else
	document.getElementById('consulta').style.backgroundColor ="#fff";
	
	if(!document.getElementById('acepto').checked)
	{
		miss+="\n- Debe aceptar las condiciones.";
		document.getElementById('acepto').style.backgroundColor ="#fdc5c5";
	}
	else
	document.getElementById('acepto').style.backgroundColor ="#fff";

	
	if(miss!="")
	{
		alert("Faltan los siguientes datos:\n"+miss);
		return false;
	}
	return true;
	}
	catch(e)
	{
		alert(e);
	  return false;	
	}
}

function validar_form_franquicias()
{
	miss="";
	try {
	if(document.getElementById('nombre').value < 1)
	{
		miss+="\n- El campo nombre es obligatorio.";
		document.getElementById('nombre').style.backgroundColor ="#fdc5c5";
	}
	else
	document.getElementById('nombre').style.backgroundColor ="#fff";
	
	if(document.getElementById('comentarios').value < 1)
	{
		miss+="\n- El campo comentarios es obligatorio.";
		document.getElementById('comentarios').style.backgroundColor ="#fdc5c5";
	}
	else
	document.getElementById('comentarios').style.backgroundColor ="#fff";
	
	if(document.getElementById('email').value < 1)
	{
		miss+="\n- El campo Email es obligatorio.";
		document.getElementById('email').style.backgroundColor ="#fdc5c5";
	}
	else
	{
		if(!validarEmail(document.getElementById('email').value))
		{
			miss+="\n- Direccion email incorrecta.";
			document.getElementById('email').style.backgroundColor ="#fdc5c5";
		}
		else
			document.getElementById('email').style.backgroundColor ="#fff";
	}
	
	//Otras validaciones
	if(!document.getElementById('acepto').checked)
	{
		miss+="\n- Debe aceptar las condiciones.";
		document.getElementById('acepto').style.backgroundColor ="#fdc5c5";
	}
	else
	document.getElementById('acepto').style.backgroundColor ="#fff";

	
	if(miss!="")
	{
		alert("Faltan los siguientes datos:\n"+miss);
		return false;
	}
	return true;
	}
	catch(e)
	{
		alert(e);
	  return false;	
	}
}

function validar_form_trabaja()
{
	miss="";
	try {
	if(document.getElementById('nombre').value < 1)
	{
		miss+="\n- El campo nombre es obligatorio.";
		document.getElementById('nombre').style.backgroundColor ="#fdc5c5";
	}
	else
	document.getElementById('nombre').style.backgroundColor ="#fff";
	
	if(document.getElementById('comentarios').value < 1)
	{
		miss+="\n- El campo con el curriculum es obligatorio.";
		document.getElementById('comentarios').style.backgroundColor ="#fdc5c5";
	}
	else
	document.getElementById('comentarios').style.backgroundColor ="#fff";
	
	if(document.getElementById('email').value < 1)
	{
		miss+="\n- El campo Email es obligatorio.";
		document.getElementById('email').style.backgroundColor ="#fdc5c5";
	}
	else
	{
		if(!validarEmail(document.getElementById('email').value))
		{
			miss+="\n- Direccion email incorrecta.";
			document.getElementById('email').style.backgroundColor ="#fdc5c5";
		}
		else
			document.getElementById('email').style.backgroundColor ="#fff";
	}
	
	//Otras validaciones
	if(!document.getElementById('acepto').checked)
	{
		miss+="\n- Debe aceptar las condiciones.";
		document.getElementById('acepto').style.backgroundColor ="#fdc5c5";
	}
	else
	document.getElementById('acepto').style.backgroundColor ="#fff";

	
	if(miss!="")
	{
		alert("Faltan los siguientes datos:\n"+miss);
		return false;
	}
	return true;
	}
	catch(e)
	{
		alert(e);
	  return false;	
	}
}

function passCorrecte()
{
	if(document.getElementById('passnew').value <1)
	{
		document.getElementById('passnew').style.backgroundColor ="#fdc5c5";
		document.getElementById('passnew2').style.backgroundColor ="#fdc5c5";
		alert('El password no puede estar vacio.');
		return false;
	}
	if(document.getElementById('passnew').value != document.getElementById('passnew2').value)
	{
		document.getElementById('passnew').style.backgroundColor ="#fdc5c5";
		document.getElementById('passnew2').style.backgroundColor ="#fdc5c5";
		alert('Los passwords son diferentes.');
		return false;
	}
	else
	{
		return true;
	}
}

/*
	FUNCIONES DEL FORMULARIO DE REGISTRO
	------------------------------------
*/

<!--
// Kaosweaver Calendar Settings - do not remove
// by Paul Davis - http://www.kaosweaver.com
// KW_lang[Spanish]
// KW_order[1,0,2]
// KW_del1[/]
// KW_del2[/]
// KW_dd[true]

var sDate = new Array();
var mName = new Array("enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre")
var wName = new Array("lu","ma","mi","ju","vi","sa","do")
var cFontName = "Arial, Helvetica, sans-serif;"
var KW_color = new Array("#ffffff","#ffcccc","#999999","#ffffff","#ccffcc","#cccccc","#000000","#000000")
var KW_cl=0;
var KW_od=-1;
var KW_tmo=0;
function m_class(m,d,y) { 
	this.month=m;this.day=d;this.year=y;this.output=this.day+"/"+this.month+"/"+this.year;
	var kd=new Date();this.special=checkDates(this.month,this.day,this.year)
	this.today=((kd.getMonth()+1)==this.month && kd.getDate()==this.day && kd.getFullYear()==this.year)
	var td=new Date(this.year, (this.month-1), this.day+KW_od);this.past=(KW_od==-1)?0:(kd>td)
}

// Kaosweaver End of Calendar Settings - do not remove

function checkDates(m1,d1,y1) {
	var rStr=false;for(var i=0;i<sDate.length;i++) {var tDate=sDate[i].split(",");
		if (tDate[2]=="*" || tDate[2]==y1) {if (tDate[1]==d1 && tDate[0]==m1)	rStr=true;
		}}return rStr;
}

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 KW_doCalendar(obj,E,m,y) {
  var d=new Date();f=0;d.setDate(1);if (!m && m!=0) {m=d.getMonth();f=KW_cl}
  if (f==1 && MM_findObj('KW_selectedMonth').value!=-1) 
  m=MM_findObj('KW_selectedMonth').value-1;d.setMonth(m);	
  if (!y) y=d.getFullYear();if (f==1 && MM_findObj('KW_selectedYear').value!=-1) 
  y=MM_findObj('KW_selectedYear').value;d.setFullYear(y);dy=d.getDay();if (!E) E=0;
  if(E==1)dy=(dy==0)?6:dy-1;dP=new Date();dP.setMonth(m);dP.setDate(0);
  pStart=dP.getDate()-dy+1;dStr=new Array();for (i=pStart;i<dP.getDate()+1;i++) { tmo=(KW_tmo)?"":i;
  tMonth=(m==0)?"12":m;tYear=(m==0)?y-1:y;dStr[dStr.length]=new m_class(tMonth,tmo,tYear);
  }EOM=false;for (i=1;!EOM;i++){d.setDate(i);if (m!=d.getMonth()) EOM=true; else { 
  dStr[dStr.length]=new m_class((Number(m)+1),i,y);}}cnt=1;si=0;
  if(E==1)si=(d.getDay()==0)?6:d.getDay()-1;else si=d.getDay();	for (i=si;i<7;i++) {
  tMonth=(m==11)?"1":Number(m)+2;tYear=(m==11)?Number(y)+1:y; tmo=(KW_tmo)?"":cnt;
  dStr[dStr.length]=new m_class(tMonth,tmo,tYear); cnt++;}pM=(m==0)?11:m-1;
  pY=(m==0)?y-1:y;nM=(m==11)?0:Number(m)+1;nY=(m==11)?Number(y)+1:y;
  wStr="<html><head><style type=\"text/css\"><!--td {  font-family: "+cFontName+" font-size: 12px; }\n.tblHdr { font-weight: bold; color: "+KW_color[0]+"; background-color: "+KW_color[6]+" }\n.subTbl{ color: "+KW_color[0]+"; background-color: #666666;  text-align: center}-->\n</style>\n<title>"+mName[m]+", "+y+"</title>\n</head>\n<body  topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" leftmargin=\"0\" onLoad=\"window.focus()\">\n<table width=\"100%\" border=\"0\" cellspacing=\"0\">\n<tr>\n<td bgcolor=\""+KW_color[6]+"\">\n<table width=\"100%\" border=0>\n"
  wStr+="<tr>\n<td align=center bgcolor=\""+KW_color[6]+"\" class=\"tblHdr\" colspan=\"4\"><a href=\"javascript:window.opener.KW_doCalendar('"+obj+"',"+E+",'"+pM+"','"+pY+"');\" class=\"tblHdr\">&laquo</a>&nbsp;&nbsp;"+mName[m]+"&nbsp;&nbsp;<a href=\"javascript:window.opener.KW_doCalendar('"+obj+"',"+E+",'"+nM+"','"+nY+"');\"  class=\"tblHdr\">&raquo</a></td>\n<td colspan=3 align=center class=\"tblHdr\"><a href=\"javascript:window.opener.KW_doCalendar('"+obj+"',"+E+",'"+m+"','"+(y-1)+"');\" class=\"tblHdr\">&laquo</a>&nbsp;&nbsp;"+y+"&nbsp;&nbsp;<a href=\"javascript:window.opener.KW_doCalendar('"+obj+"',"+E+",'"+m+"','"+(Number(y)+1)+"');\"  class=\"tblHdr\">&raquo</a></td>\n</tr>\n"
  wStr+="<tr>\n<td class=\"subTbl\">"+wName[0]+"</td><td class=\"subTbl\">"+wName[1]+"</td><td class=\"subTbl\">"+wName[2]+"</td><td class=\"subTbl\">"+wName[3]+"</td><td class=\"subTbl\">"+wName[4]+"</td><td class=\"subTbl\">"+wName[5]+"</td><td class=\"subTbl\">"+wName[6]+"</td>\n</tr>\n"
  for (x=0;x<parseInt(dStr.length/7);x++) {	wStr+="<tr>\n";	for (y=0;y<7;y++) {
  yT=(E==1)?5:0;bC=(y==yT||y==6)?KW_color[2]:KW_color[3];
  if ((Number(m)+1)!=dStr[x*7+y].month) bC=KW_color[5]; if (dStr[x*7+y].special) 
  bC=KW_color[4];if (dStr[x*7+y].today) bC=KW_color[1];
  a0=(KW_cl!=1)?"":"window.opener.MM_findObj('KW_selectedMonth',window.opener.document).value='"+dStr[x*7+y].month+"';window.opener.MM_findObj('KW_selectedYear',window.opener.document).value='"+dStr[x*7+y].year+"'; "  
  a1=(dStr[x*7+y].past)?"":"<a href=\"javascript:window.opener.MM_findObj('"+obj+"',window.opener.document).value='"+dStr[x*7+y].output+"';"+a0+" window.close();\" >";
  a2=(dStr[x*7+y].past)?"":"</a>";
  wStr+="<td align=\"center\" bgcolor="+bC+">"+a1+dStr[x*7+y].day+a2+"</td>\n";
	}	wStr+="</tr>\n";}	wStr+="<tr><td colspan=7></td></tr></table></td></tr></table></body></html>";
	var w = parseInt(screen.width/2-75); var h=parseInt(screen.height/2-75);
	var look='width=170,height=155,left='+w+',top='+h;	popwin=window.open('','calendar',look);
	popwin.document.open();	popwin.document.write(wStr);	popwin.document.close();
}
//-->
