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.pt/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.pt/";
			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');");
	}
	
	function popUp2(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=550,height=450');");
	
	}
	
	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=530,height=470');");
	
	}
	
	// Formulario Home
	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("Indique por favor o seu nome");
				document.frmSolicitud.Nombre.focus();
			} else if ( strApellido1 == "" ) {
				alert("Indique por favor o seu apelido");
				document.frmSolicitud.Apellido1.focus();
			} else if ( strTlf1 == "" ) {
				alert("Indique por favor um numero de contacto");
				document.frmSolicitud.Telefono1.focus();
			} else if (!checkNumPhone(strTlf1)) {
				alert("Insira por favor um numero de contacto válido");
				document.frmSolicitud.Telefono1.focus();
			} else {
				document.frmSolicitud.action = "http://www.afiliateasecuritasdirect.com/comercial/envio";
				document.frmSolicitud.btSubmit.disabled = true;
				document.frmSolicitud.btCambiar.disabled = true;
				MM_showHideLayers('capabar','','show','bar','','show');
				document.frmSolicitud.submit();
			}
		}
		
		function checkNumPhone(objValue){
			var myobjDato = new String(objValue)
			
			if (myobjDato == "")			// Comprueba que no está vacio
				return false;
			if (myobjDato.length != 9)		// Comprueba que tenga longitud de nueve
				return false;
			if (!isNumeric(myobjDato))		// Comprueba si es numérico
				return false;
			if ((myobjDato.substring(0,1) != '2') && (myobjDato.substring(0,1) != '9'))	// Comprueba si empieza por 9 ó 6
				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;
		}
		
		function checkEmail(objValue){
			if (objValue == "")
				return false;
			if (objValue.charAt(0) == '@')
				return false;
			if (objValue.length < 6)
				return false;
			if (objValue.indexOf("@") == -1)
				return false;
			if (objValue.indexOf(".") == -1)
				return false;
			if (objValue.slice(objValue.indexOf("@")).indexOf(".") == -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 Formulario Home
	
	//set this variable to 1 if you wish the URLs of the highlighted menu to be displayed in the status bar
	var display_url=1
	function showmenu(){
	var rightedge=document.body.clientWidth-event.clientX
	var bottomedge=document.body.clientHeight-event.clientY
	
	if (rightedge<menu.offsetWidth)
	menu.style.left=document.body.scrollLeft+event.clientX-menu.offsetWidth
	else
	menu.style.left=document.body.scrollLeft+event.clientX
	
	if (bottomedge<menu.offsetHeight)
	menu.style.top=document.body.scrollTop+event.clientY-menu.offsetHeight
	else
	menu.style.top=document.body.scrollTop+event.clientY
	
	menu.style.visibility="visible"
	return false
	}
	
	function hidemenu(){
	menu.style.visibility="hidden"
	}
	
	function over(){
	if (event.srcElement.className=="menuitems"){
	event.srcElement.style.backgroundColor="red"
	event.srcElement.style.color="#ffffff"
	if (display_url==1)
	window.status=event.srcElement.url
	}
	}
	
	function out(){
	if (event.srcElement.className=="menuitems"){
	event.srcElement.style.backgroundColor=""
	event.srcElement.style.color="#6d8196"
	window.status=''
	}
	}
	
	function linkTo(){
	if (event.srcElement.className=="menuitems")
	window.location=event.srcElement.url
	}