var legal = document.cookie;
var today = new Date();
var expiry = new Date(today.getTime() + 28 * 24 * 60 * 60 * 1000);

	function getCookie(name) {
		var index = legal.indexOf(name + "=");
		if (index == -1) return null;
		index = legal.indexOf("=", index) + 1;
		var endstr = legal.indexOf(";", index);
		if (endstr == -1) endstr = legal.length;
		
		return unescape(legal.substring(index, endstr));
	}	
	
	function submit_login(l_objfrmlogin, strIdioma) {

		if ( strIdioma == null ) strIdioma = "es";

		//document.cookie = "LANG=" + strIdioma + ";";

		l_objfrmlogin.action="https://www.securitasdirect.es/sdpc/security/frmProcess_login.jsp";
		/*
			alert ("\n Se está realizando un mantenimiento del sistema." + 
					 "\n\n Hora de inicio: 0:30 h." + 
					 "\n Hora final estimada: 2:30 h." + 
					 "\n\n Disculpen las molestias" 
					 ); 
		*/ 
		/*		
            alert ("\n Se va a realizar un mantenimiento del sistema." +
                             "\n\n Hora de inicio: 14:15 h." +
                             "\n Hora final estimada: 15:00 h." +
                             "\n\n Disculpen las molestias"
                             );
        */  
		/* CONDICIONES LEGALES */
		var auxLegales = getCookie("Legal");
		var auxLegalesUser = getCookie("LegalUser");
		l_objfrmlogin.legales.value=auxLegales;
		l_objfrmlogin.legalesuser.value=auxLegalesUser;
		/* CONDICIONES LEGALES */

		l_objfrmlogin.submit();
	}	
	
	function button_onKeyPress(l_objfrmlogin){
	
		var objKey = window.event.keyCode;
	
		if (objKey == 13) submit_login(l_objfrmlogin);
	
		if ((objKey < 65 || objKey > 90) && (objKey < 97 || objKey > 122) && (objKey < 48 || objKey > 57)) {
			window.event.keyCode = 0;
		}
	}	

	function cancelar(){
		document.frmLogin.txtUser.value = "";
		document.frmLogin.txtPassword.value = "";
	}
	
	function agregar(){
		   if ((navigator.appName=="Microsoft Internet Explorer") && 
		         (parseInt(navigator.appVersion)>=4)) {
		      var url="http://www.securitasdirect.es/index.html"; 
		      var titulo="Securitas Direct";
		      window.external.AddFavorite(url,titulo);
		   } else { 
		      if(navigator.appName == "Netscape") 
		         alert("Presione Crtl+D para agregar este sitio en sus Bookmarks"); 
		   }
		} 
	
	function agregar2(){
		   if ((navigator.appName=="Microsoft Internet Explorer") && 
		         (parseInt(navigator.appVersion)>=4)) {
		      var url="http://www.securitasdirect.es/index.html?Id=mk_n01"; 
		      var titulo="Securitas Direct";
		      window.external.AddFavorite(url,titulo);
		   } else { 
		      if(navigator.appName == "Netscape") 
		         alert("Presione Crtl+D para agregar este sitio en sus Bookmarks"); 
		   }
		} 
	
	
	
	
	
		
	function Lvl_openWin(u,n,w,h,l,t,c,f) { //v1.0 4LevelWebs
	  var ww=((screen.width-w)/2);if(c==1){l=ww;t=(screen.height-h)/2;}if(c==2){l=ww}
		f+=',top='+t+',left='+l;window.open(u,n,f);
	}		
	
	function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=520,height=570,left = 515,top = 337');");
	}
	
	function popUp2(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=550,height=395');");
	}
	
	function popUp3(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=495,height=245');");
	}
	
	function popUp4(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=610,height=350');");
	}
	
	function demo(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=547,height=447');");
	}
	
	function video(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=420,height=520');");
	}
	
	function veri(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=530,height=470');");
	}
	
	function freepass(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=549,height=382');");
	}
	
	function interactivo(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=765,height=520');");
	}
	
	
	//Inicio Enviar Formulario
	
	function enviarFormulario() {
			var strNombre = document.frmSolicitud.Nombre.value;
			var strApellido1 = document.frmSolicitud.Apellido1.value;
			var strTlf1 = document.frmSolicitud.Telefono1.value;
			var strEmail1 = document.frmSolicitud.sdemail1.value;
			
			
			
			if ( strNombre == "" ) {
				alert("svp écrivez votre nom");
				document.frmSolicitud.Nombre.focus();
			} else if ( strApellido1 == "" ) {
				alert("svp écrivez votre prénom");
				document.frmSolicitud.Apellido1.focus();
			} else if ( strTlf1 == "" ) {
				alert("svp introduisez votre numéro de téléphone");
				document.frmSolicitud.Telefono1.focus();
			} else if (!checkNumPhone(strTlf1)) {
				alert("svp introduisez votre numéro de téléphone");
				document.frmSolicitud.Telefono1.focus();
				
			
				
			} else {
				if ( getCookie("telefono") == strTlf1 ) {
					document.location.href = document.frmSolicitud.sdurlfalta.value;
					return false;
				}
				
				setCookie("nombre", strNombre);
				setCookie("telefono", strTlf1);
				document.frmSolicitud.action = "http://www.securitasdirect.fr/base_co/envio/envio_mail.php";
				document.frmSolicitud.btSubmit.disabled = true;
				
				MM_showHideLayers('capabar','','show','_xpbar0','','show');
				document.frmSolicitud.submit();
			}
		}
		
		function checkNumPhone(objValue){
			var myobjDato = new String(objValue)
			
			if (myobjDato == "")			// Comprueba que no está vacio
				return false;
			if (myobjDato.length != 10)		// Comprueba que tenga longitud de nueve
				return false;
			if (!isNumeric(myobjDato))		// Comprueba si es numérico
				return false;
			if ((myobjDato.substring(0,1) != '0') && (myobjDato.substring(0,1) != '0'))	// Comprueba si empieza por 0 ó 0
				return false;
			return true;
		}

		function isNumeric(string, ignoreWhiteSpace){
			if (string.search){
				if ((ignoreWhiteSpace && string.search(/[^\d\s]/) != -1) || (!ignoreWhiteSpace && string.search(/\D/) != -1)) return false;
			}
			return true;
		}
		
		

		//función para usar las capas
		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;
		}
		
		//función para usar las capas
		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; }
		}

		//Fin Enviar Formulario