//------------------- funciones Javascript para Todoenbodas -------------------------\\
iex = (document.all)? 1:0

agt=navigator.userAgent.toLowerCase();

function reposicionar(capa,refN,refE,netX,netY,expX,expY,N6X,N6Y) {		
	if (document.layers){
		if(!(eval("document."+capa))){
		}else{		
			eval("document."+capa).left=eval("document."+refN).x+netX;
			eval("document."+capa).top=eval("document."+refN).y+netY;
		}		
	}
	if(document.getElementById && !document.all){		
		eval("document.getElementById ('"+ capa +"')").style.left=eval("document."+refN).x+N6X;
		eval("document.getElementById ('"+ capa +"')").style.top=eval("document."+refN).y+N6Y;		
	}
	if (((document.all)&&(!document.getElementById))||((document.all)&&(document.getElementById))) {			
		eval("document.all."+capa).style.left=eval("document.all."+refE).offsetLeft+expX+"px";
		eval("document.all."+capa).style.top=eval("document.all."+refE).offsetTop+expY+"px";	
	}
}

function ocultar(){
 		MM_showHideLayers('profesionales','','hide','organizador','','hide','consejos','','hide','consultas','','hide','comunidad','','hide','despues','','hide','profesionales_belleza','','hide','profesionales_hogar','','hide','profesionales_vestir','','hide','direcciones','','hide') 
 }

function colocar(){  
	reposicionar('profesionales','ImgSer','principal',0,0,-10,120,0,0);	
	reposicionar('organizador','ImgSer','principal',0,0,98,111,0,0);
	reposicionar('consejos','ImgSer','principal',0,0,213,120,0,0);
	reposicionar('consultas','ImgSer','principal',0,0,380,120,0,0);
	reposicionar('comunidad','ImgSer','principal',0,0,458,120,0,0);
	reposicionar('despues','ImgSer','principal',0,0,547,120,0,0);
	reposicionar('profesionales_belleza','ImgSer','principal',0,0,191,148,0,0);
	reposicionar('profesionales_hogar','ImgSer','principal',0,0,191,224,0,0);
	reposicionar('profesionales_vestir','ImgSer','principal',0,0,191,433,0,0);
	reposicionar('direcciones','ImgSer','principal',0,0,259,205,0,0);
}

function textarea (nombre,columnas,filas,wrap,estilo,texto,html) {
	//si es explorer
	if (iex)
	{
		//si es mac
		if (agt.indexOf('mac')!=-1)
		{
			document.write("<textarea name='"+ nombre +"'  cols='"+ ( columnas * 0.86 )+"' rows='"+ ( filas * 1.02 ) +"' wrap='"+ wrap +"' class='"+ estilo +"' "+ html +">"+ texto +"</textarea>");
		}
		//si no lo es
		else
		{
			document.write("<textarea name='"+ nombre +"'  cols='"+ columnas +"'          rows='"+ filas +"'           wrap='"+ wrap +"' class='"+ estilo +"' "+ html +">"+ texto +"</textarea>");
		}
	}
	//si es netscape
	else    { document.write("<textarea name='"+ nombre +"'  cols='"+ ( columnas * 0.65 )+"' rows='"+ ( filas * 0.8 ) +"' wrap='"+ wrap +"' class='"+ estilo +"' "+ html +">"+ texto +"</textarea>"); }
}

function text_input (nombre,tipo,longitud,valor,maximo,estilo,html) {
	if (iex)
	{
		//si es mac
		if (agt.indexOf('mac')!=-1)
		{
			document.write("<input name='"+ nombre +"' type='"+ tipo +"' size='"+ ( longitud * 0.70 ) +"' value='"+ valor +"' maxlength='"+ maximo +"' class='"+ estilo +"' "+ html +">");
		}
		
		//si no lo es
		else
		{
			document.write("<input name='"+ nombre +"' type='"+ tipo +"' size='"+ longitud +"' value='"+ valor +"' maxlength='"+ maximo +"' class='"+ estilo +"' "+ html +">");
		}
	}
	//si es netscape
	else    { document.write("<input name='"+ nombre +"' type='"+ tipo +"' size='"+ ( longitud * 1 ) +"' value='"+ valor +"' maxlength='"+ maximo +"' class='"+ estilo +"' "+ html +">"); }
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe contener un direccion de email.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es obligatorio.\n'; }
  } if (errors) alert('Han ocurrido los siguientes errores:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function tarifa(){
	window.open("tarifa.htm", "", "toolbar=no,location=no,menubar=no,scrollbars=no,resizable=yes,width=525,height=400,top=0,left=0");
}

function dominio () 
   {
   txt=document.Login.userid.value;
   if ((txt == "") || (txt.indexOf('@') != -1) || (txt.indexOf('.') != -1)) 
   { 
   	alert("Debe escribir solo el nombre de usuario");
   	document.Login.userid.focus(); 
   	document.Login.userid.select();
   	return false;
   }
   accion="http://mail.todoenbodas.com:8383/login.cgi"
   document.Login.action=accion
   }

function checkFields() 
   {
   missinginfo = "";
   if (document.correo.nombre.value == "") {
      missinginfo += "\n     -  Nombre";
      }
   if(document.correo.apellido1.value == "") {
      missinginfo += "\n     -  Primer Apellido";
      }
   if(document.correo.apellido2.value == "") {
      missinginfo += "\n     -  Segundo Apellido";
      }
   if(document.correo.nombre_conyuge.value == "") {
      missinginfo += "\n     -  Nombre Pareja";
      }
   if(document.correo.apellido1_conyuge.value == "") {
      missinginfo += "\n     -  Primer Apellido Pareja";
      }
   if(document.correo.apellido2_conyuge.value == "") {
      missinginfo += "\n     -  Segundo Apellido Pareja";
      }
   if(document.correo.direccion.value == "") {
      missinginfo += "\n     -  Direccion";
      }
   if(document.correo.cp.value == "") {
      missinginfo += "\n     -  Codigo Postal";
      }
   if(document.correo.localidad.value == "") {
      missinginfo += "\n     -  Localidad";
      }
   if(document.correo.provincia.value == "") {
      missinginfo += "\n     -  Provincia:";
      }
   if(document.correo.telefono.value == "") {
      missinginfo += "\n     -  Telefono";
      }
   if(document.correo.fecha_boda.value == "") {
      missinginfo += "\n     -  Fecha de la Boda";
      }    
   
   if (missinginfo != "") {
      missinginfo ="_____________________________\n" +
      "Los datos no han sido introducidos o son erroneos en:\n" +
      missinginfo + "\n_____________________________" +
      "\nPor favor, vuelva a completarlos y envielos de nuevo!";
      alert(missinginfo);
      return false;
      }
   else return true;
   }
   
function contras() {
   var valor=1;
   if (document.correo.password.value == "") {
      alert ("La contraseña NO puede estar en blanco.\n\nPor favor escriba una.");
      document.correo.password.focus();
      document.correo.password.select();
      valor=0;
      } 
   if (document.correo.password.value != document.correo.password2.value) {
      alert ("Los valores introducidos NO coinciden\n\nPor favor vuelva a escribirlos.");
      document.correo.password.focus();
      document.correo.password.select();				
      valor=0;
      } 
   if (valor==0) {return false} else {return true} 
   }	   
   
function resetBuscador() {
	if (document.buscador.clave.value == "empresa o clave a buscar ...")
		document.buscador.clave.value = "";
}

function resetLocalidad() {		
	if (document.buscador.localidad.value == "localidad")
		document.buscador.localidad.value = "";
	}
function checkLocalidad() {
	if (document.buscador.localidad.value == "")
		document.buscador.localidad.value = "localidad";
	}   
	
function valida (field) {
	var valid = "0123456789abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZáéíóúÁÉÍÓÚ "
	var validcp = "0123456789CP."
	var ok = "yes";
	var temp;
	if (field.clave.value=="" || field.clave.value=="buscar por ...") {
		alert ("¡Error!\nLa búsqueda en blanco no esta permitida.");
		field.clave.focus();
		field.clave.select();
		return false;
   	}
   	if (field.localidad.value=="") {
		alert ("¡Error!\nLa localidad no puede estar en blanco.");
		field.localidad.focus();
		field.localidad.select();
		return false;
   	}
	for (var i=0; i<field.clave.value.length; i++) {
		temp = "" + field.clave.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
		}
	if (ok == "no") {
		alert("¡Error!\nSólo puede usar letras y números en la sentencia de búsqueda");
		field.clave.focus();
		field.clave.select();
		return false;
   	} 
	for (var i=0; i<field.localidad.value.length; i++) {
		temp = "" + field.localidad.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
		}
	if (ok == "no") {
		alert("¡Error!\nSólo puede usar letras y números en el nombre de la localidad");
		field.localidad.focus();
		field.localidad.select();
		return false;
   	}   	
}	

var message="No es necesario usar el boton derecho.";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")

