function select_all(text_val){	text_val.focus();	text_val.select();}function Get_Cookie( name ) {	var start = document.cookie.indexOf( name + "=" );var len = start + name.length + 1;if ( ( !start ) &&( name != document.cookie.substring( 0, name.length ) ) ){return null;}if ( start == -1 ) return null;var end = document.cookie.indexOf( ";", len );if ( end == -1 ) end = document.cookie.length;return unescape( document.cookie.substring( len, end ) );}			// this deletes the cookie when called		function Delete_Cookie( name, path, domain ) {			if ( Get_Cookie( name ) ) document.cookie = name + "=" +			( ( path ) ? ";path=" + path : "") +			( ( domain ) ? ";domain=" + domain : "" ) +			";expires=Thu, 01-Jan-1970 00:00:01 GMT";			}function validar_alta(formulario){	if(formulario.usuario.value.length<4){		alert("El usuario debe tener por lo menos 4 caracteres");		return false;		}	if(formulario.password.value.length<4){		alert("La contrasena debe tener por lo menos 4 caracteres");		return false;		}	if(formulario.nombre.value.length<1){		alert("El nombre debe tener por lo menos 1 caracter");		return false;		}	if(formulario.pers_ctcto.value.length<1){		alert("La persona de contacto debe tener por lo menos 1 caracter");		return false;		}	if(!emailCheck(formulario.mail.value)){		return false;		}	if(formulario.desc_empresa.value.length<100){		alert("La descripción de la empresa tiene que tener por lo menos 100 caracteres");		return false;		}	return true;	}function validar_usuario(formulario){	if(formulario.usuario.value.length<4){		alert("El usuario debe tener por lo menos 4 caracteres");		return false;		}	if(formulario.password.value.length<4){		alert("La contrasena debe tener por lo menos 4 caracteres");		return false;		}	if(formulario.nombre.value.length<1){		alert("El nombre debe tener por lo menos 1 caracter");		return false;		}	if(!emailCheck(formulario.mail.value)){		return false;		}	return true;}	function validar_producto(formulario){	if(formulario.nombre.value.length<3){		alert("El nombre del producto debe tener por lo menos 3 caracteres");		formulario.nombre.focus();		return false;		}	if(formulario.precio.value.length==0){		alert("Para que el usuario pueda elegir mejor debes poner el precio, si de todas maneras no lo quieres poner con -1 aparecerá a consultar");		formulario.precio.focus();		return false;		}	if(!isNumeric(formulario.precio.value) && formulario.precio.value!=-1){		alert("El precio debe ser un número");		formulario.precio.focus();		return false;		}	if (formulario.categoria.selectedIndex==0){       alert("Debe seleccionar una categoria para el producto.");       formulario.categoria.focus();       return false;    } 	if(document.getElementById('tipologia').selectedIndex==-1){			alert("Debe seleccionar por lo menos una tipología para el producto.");       document.getElementById('tipologia').focus();       return false;		}		if(formulario.longitud.value<200){		alert("La descripción debe ser de 200 caracteres para que el usuario pueda elegir su regalo conociendo lo que está seleccionando");		return false;		}		return true;		}function controlPrograma(){	var oEditor = FCKeditorAPI.GetInstance('desc_regalo') ;	var length = GetLength();							if(length >20000 && length != globalLength){		alert("<cfoutput>#application.V.MENUCENTER.MODIFCOURSE.ALERT_PROGRAMCHARS#</cfoutput>");						}	globalLength = length;	document.getElementById("longitud").value=length;}function FCKeditor_OnComplete( editorInstance ){	var oEditor = FCKeditorAPI.GetInstance('desc_regalo') ;	if(!document.all){		oEditor.Events.AttachEvent( 'OnSelectionChange', controlPrograma ) ;	}	oEditor.EditorDocument.body.onkeypress = controlPrograma;	oEditor.EditorDocument.body.onkeyup = controlPrograma;	oEditor.EditorDocument.body.onfocus = controlPrograma;	document.getElementById("longitud").value=GetLength();	}function GetLength() {      // This functions shows that you can interact directly with the editor area      // DOM. In this way you have the freedom to do anything you want with it.        // Get the editor instance that we want to interact with.      var oEditor = FCKeditorAPI.GetInstance('desc_regalo') ;        // Get the Editor Area DOM (Document object).      var oDOM = oEditor.EditorDocument ;        var iLength ;        // The are two diffent ways to get the text (without HTML markups).      // It is browser specific.       if ( document.all )     // If Internet Explorer.      {             content = oDOM.body.innerText ; 	    conte=content.replace(/\s/g, '');	    conte=conte.replace(new RegExp('<br>','gi'), ' ');	    conte=conte.replace(new RegExp('&nbsp;','gi'), ' ');	    conte=conte.replace(new RegExp('&lt;','gi'), ' ');	    conte=conte.replace(new RegExp('&gt;','gi'), ' ');	    conte=conte.replace(new RegExp('<[^>]*>','gi'), '');	    iLength = conte.length;     }      else                    // If Gecko.      {          var r = oDOM.createRange() ;          r.selectNodeContents( oDOM.body ) ;          content = r.toString() ; 	 conte=content.replace(/\s/g, '');	 conte=conte.replace(new RegExp('<br>','gi'), ' ');	 conte=conte.replace(new RegExp('&nbsp;','gi'), ' ');	 conte=conte.replace(new RegExp('&lt;','gi'), ' ');	 conte=conte.replace(new RegExp('&gt;','gi'), ' ');	 conte=conte.replace(new RegExp('<[^>]*>','gi'), '');	 iLength = conte.length;     }           return iLength; } function isNumeric(sText){   var ValidChars = "0123456789.,-";   var IsNumber=true;   var Char;	var i;    for (i = 0; i < sText.length && IsNumber == true; i++)       {       Char = sText.charAt(i);       if (ValidChars.indexOf(Char) == -1)          {         IsNumber = false;         }      }   return IsNumber;      } function emailCheck (emailStr) {/* Verificar si el email tiene el formato user@dominio. */var emailPat=/^(.+)@(.+)$/;/* Verificar la existencia de caracteres. ( ) < > @ , ; : \ " . [ ] */var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";/* Verifica los caracteres que son válidos en una dirección de email */var validChars="\[^\\s" + specialChars + "\]";var quotedUser="(\"[^\"]*\")";/* Verifica si la dirección de email está representada con una dirección IP Válida */var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;/* Verificar caracteres inválidos */var atom=validChars + '+';var word="(" + atom + "|" + quotedUser + ")";var userPat=new RegExp("^" + word + "(\\." + word + ")*$");/*domain, as opposed to ipDomainPat, shown above. */var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");var matchArray=emailStr.match(emailPat);if (matchArray==null) {alert("La dirección de mail parece no ser correcta (comprueba que tiene @ y .)");return false;}var user=matchArray[1];var domain=matchArray[2];// Si el user "user" es valido if (user.match(userPat)==null) {// Si noalert("El nombre de usuario no es válido.");return false;}/* Si la dirección IP es válida */var IPArray=domain.match(ipDomainPat);if (IPArray!=null) {for (var i=1;i<=4;i++) {if (IPArray[i]>255) {alert("IP de destino inválida");return false}}return true}var domainArray=domain.match(domainPat);if (domainArray==null) {alert("El dominio parece no ser válido.");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) {alert("La dicrección debe tener 3 letras si es .com o 2 si en de algún pais.");return false}if (len<2) {var errStr="La dirección es erronea";alert(errStr);return false}// La dirección de email ingresada es Válidareturn true;}// End -->// this function gets the cookie, if it existsfunction creaXML(){	var xmlhttp=false;	/*@cc_on @*/	/*@if (@_jscript_version >= 5)	  try {	  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");	 } catch (e) {	  try {	    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");	  } catch (E) {	   xmlhttp=false;	  }	 }	@else	 xmlhttp=false	 @end @*/		if (!xmlhttp && typeof XMLHttpRequest!='undefined') {		try {			xmlhttp = new XMLHttpRequest();		} catch (e) {			xmlhttp=false;		}	}	if (!xmlhttp && window.createRequest) {		try {			xmlhttp = window.createRequest();		} catch (e) {			xmlhttp=false;		}	}	return xmlhttp;}function combo_provincia(pais,id_provincia){	var xmlhttp=creaXML();	var urlcaja="/menu_centros/carga_provincias.php?id_pais="+pais+"&id_provincia="+id_provincia;	xmlhttp.open("GET",urlcaja,false);	xmlhttp.setRequestHeader('Accept','message/x-jl-formresult');	xmlhttp.send(null);		if (xmlhttp.readyState==4) {				document.getElementById("capa_provincias").innerHTML=xmlhttp.responseText;		}	}function addRegalo(id_regalo){	var xmlhttp=creaXML();	var urlcaja="/menu_usuario/addRegaloLista.php?id_regalo="+id_regalo;	xmlhttp.open("GET",urlcaja,false);	xmlhttp.setRequestHeader('Accept','message/x-jl-formresult');	xmlhttp.send(null);		if (xmlhttp.readyState==4) {				if(xmlhttp.responseText=="1"){				alert("Regalo guardado en tu lista de regalos");				document.getElementById('addtoList').innerHTML="<a rel=\"nofollow\" href=\"/menu_usuario/milista.php\" style=\"color:#0000FF; font-size:16px; font-weight:bold \" ><img align=\"absbottom\" border=\"0\" src=\"img/lista.gif\">&nbsp; ver mi lista</a>";			}else{				alert("No se ha podido guardar el regalo en tu lista de regalos");		}		}	}	function combo_ciudades(provincia,id_ciudad){	var xmlhttp=creaXML();	var urlcaja="/menu_centros/carga_ciudades.php?id_provincia="+provincia+"&id_ciudad="+id_ciudad;	xmlhttp.open("GET",urlcaja,false);	xmlhttp.setRequestHeader('Accept','message/x-jl-formresult');	xmlhttp.send(null);	if (xmlhttp.readyState==4) {			   		document.getElementById("capa_ciudades").innerHTML=xmlhttp.responseText;		}	}function combo_categorias(categoria,id_categ_sel,orden){	if(orden<3){	var xmlhttp=creaXML();	var urlcaja="/menu_centros/carga_categorias.php?id_categ="+categoria+"&id_categ_sel="+id_categ_sel+"&orden="+orden;	xmlhttp.open("GET",urlcaja,false);	xmlhttp.setRequestHeader('Accept','message/x-jl-formresult');	xmlhttp.send(null);	if (xmlhttp.readyState==4) {											   		document.getElementById("capa_categorias"+orden).innerHTML=xmlhttp.responseText;		}	}}function comprueba_datos(){	if(document.getElementById('usuari').value==""){			alert("Debes poner un nombre de usuario");			return false;		}	if(document.getElementById('asunto').value==""){			alert("Debes poner un titulo al comentario");			return false;		}	if(document.getElementById('texto').value==""){			alert("Debes escribir un comentario");			return false;		}	if(document.getElementById('tmptxt').value==""){		alert("Debes copiar el texto de validación");		return false;	}		return true;	}function loadComentari(){	var id_empresa=document.getElementById('empresa').value;	var xmlhttp=creaXML();	var urlcaja="carga_comentario.php?id_empresa="+id_empresa;	xmlhttp.open("GET",urlcaja,false);	xmlhttp.setRequestHeader('Accept','message/x-jl-formresult');	xmlhttp.send(null);		if (xmlhttp.readyState==4) {				document.getElementById("comentari").innerHTML=xmlhttp.responseText;		}	}function cargar(){	var categ=-1;	if(document.getElementById("categoria").value==-1){		alert("Tienes que seleccionar una categoria");		return false;	}else{		categ=document.getElementById("categoria").value;	}	if(document.getElementById("categoria1").value=="" || document.getElementById("categoria1").value==-1){		cargar_categ(categ);		return false;	}else{		categ=document.getElementById("categoria1").value;		}	if(document.getElementById("categoria2").value=="" || document.getElementById("categoria2").value==-1){		cargar_categ(categ);		return false;	}else{		categ=document.getElementById("categoria2").value;		}	cargar_categ(categ);} function cargar_categ(id_categ){	 	var xmlhttp=creaXML();	var urlcaja="carga_categorias_admin.php?id_categ="+id_categ;	xmlhttp.open("GET",urlcaja,false);	xmlhttp.setRequestHeader('Accept','message/x-jl-formresult');	xmlhttp.send(null);		if (xmlhttp.readyState==4) {				document.getElementById("datos_categ").innerHTML=xmlhttp.responseText;		}}function desconectar(){			Delete_Cookie("kregalar_iduser","/","kregalar.net");			Delete_Cookie("kregalar_user","/","kregalar.net");			window.location="http://www.kregalar.net";		}// Mostramos ventana de información (Compra - Packs, etc...)function InfoWindow1(page) {		var objBody = document.getElementsByTagName("body").item(0);	var objOverlay = document.createElement("div");	objOverlay.setAttribute('id','overlay');		objOverlay.style.display = 'none';	objBody.appendChild(objOverlay);	var objLightbox = document.createElement("div");	objLightbox.setAttribute('id','lightbox');	objLightbox.style.display = 'none';	objBody.appendChild(objLightbox);				hideSelectBoxes();	hideFlash();				// stretch overlay to fill page and fade in	var arrayPageSize = getPageSize();	Element.setHeight('overlay', arrayPageSize[1]);			new Effect.Appear('overlay', { duration: overlayDuration, from: 0.0, to: overlayOpacity });	// calculate top offset for the lightbox and display 	ajaxpagesin(page,'lightbox');				var arrayPageScroll = getPageScroll();	var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);	Element.setTop('lightbox', lightboxTop);	Element.show('lightbox');	}function CloseInfoWindow1() {	Element.hide('overlay');	Element.removeChild('lightbox');	if(typeof(FCKeditorAPI)!="undefined") {FCKeditorAPI=null;}	showSelectBoxes();	showFlash();	}function validar_info(id_regalo){	valor=emailCheck(document.getElementById('mail_info').value);	if(valor){		window.open('/frame_compra.php?producto='+id_regalo);	}	return valor;}function validar_info_compra(form){	if(!emailCheck(document.getElementById('mail').value)){		return false;		}	if(document.getElementById('nombre').value==""){			alert("Debes poner un nombre para que realicemos en envio correctamente");			return false;		}	if(document.getElementById('apellidos').value==""){			alert("Debes poner un apellido para que realicemos en envio correctamente");			return false;		}	if(document.getElementById('direccion').value==""){			alert("Debes poner una dirección para que realicemos en envio correctamente");			return false;		}	if(document.getElementById('cp').value==""){			alert("Debes poner un código postal para que realicemos en envio correctamente");			return false;		}	if(document.getElementById('ciudad').value==""){			alert("Debes poner una ciudad para que realicemos en envio correctamente");			return false;		}	if(document.getElementById('provincia').value==""){			alert("Debes poner un provincia para que realicemos en envio correctamente");			return false;		}	if(document.getElementById('telefono').value==""){			alert("Debes poner un teléfono para que nos pongamos en contacto contigo");			return false;		}	return valor;}