var splashpage={

	// Variable que indica si está activada la splash screen(1 = activado, 0 = desactivado)
	splashenabled: 1,

	// URL mostrada en la splash screen
	splashpageurl: "/factoria/web/requisitos.html",

	// Control de frecuencia (1 si, 0 no)
	enablefrequency: 1,

	// Frecuencia de mostrado: sessiononly o x days (valor string).
	displayfrequency: "sessiononly",

	// HTML del header del splash screen
	defineheader: '<div style="padding: 5px; color: white; font: bold 16px Arial; background: url(/factoria/web/img/blockdefault.gif) center center repeat-x;"><a style="position:absolute; text-decoration: none; top: 5px; right: 5px" href="javascript:splashpage.closeit()" title="Ir al contenido"><div style="color: white; font: bold 16px Arial;">Ir al contenido</div></a>Vivero Virtual de Empresas</div>',

	// Propiedades de la cookie: ["cookie_name", "cookie_path"]
	cookiename: ["FACTORIAPHP", "path=/"],

	// Duración del splash screen: x segundos (valor entero o 0 = no)
	autohidetimer: 30,

	//// Funciones necesarias no modificables ////

	launch:false,
	browserdetectstr: (window.opera&&window.getSelection) || (!window.opera && window.XMLHttpRequest) || (!window.opera && (typeof window.ActiveXObject != 'undefined')),

	output:function(){
		document.write('<div id="splashpage" style="position: absolute; z-index: 100; color: #155c81; background-color: white">')
		document.write(this.defineheader)
		document.write('<iframe name="splashpage-iframe" src="about:blank" style="margin:0; padding:0; width:100%; height: 100%"></iframe>')
		document.write('<br />&nbsp;</div>')
		this.splashpageref=document.getElementById("splashpage")
		this.splashiframeref=window.frames["splashpage-iframe"]
		this.splashiframeref.location.replace(this.splashpageurl)
		this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
		if (!/safari/i.test(navigator.userAgent))
		this.standardbody.style.overflow="hidden"
		this.splashpageref.style.left=0
		this.splashpageref.style.top=0
		this.splashpageref.style.width="100%"
		this.splashpageref.style.height="100%"
		this.moveuptimer=setInterval("window.scrollTo(0,0)", 50)
	},

	closeit:function(){
		clearInterval(this.moveuptimer)
		this.splashpageref.style.display="none"
		this.splashiframeref.location.replace("about:blank")
		this.standardbody.style.overflow="auto"
	},

	init:function(){
		if (this.enablefrequency==1){
			if (/sessiononly/i.test(this.displayfrequency)){
				if (this.getCookie(this.cookiename[0]+"_s")==null){
					this.setCookie(this.cookiename[0]+"_s", "loaded")
					this.launch=true
				}
			}
			else if (/day/i.test(this.displayfrequency)){
				if (this.getCookie(this.cookiename[0])==null || parseInt(this.getCookie(this.cookiename[0]))!=parseInt(this.displayfrequency)){
					this.setCookie(this.cookiename[0], parseInt(this.displayfrequency), parseInt(this.displayfrequency))
					this.launch=true
				} 
			}
		}
		else
			this.launch=true
		if (this.launch){
			this.output()
			if (parseInt(this.autohidetimer)>0)
				setTimeout("splashpage.closeit()", parseInt(this.autohidetimer)*1000)
		}
	},

	getCookie:function(Name){
		var re=new RegExp(Name+"=[^;]+", "i");
		if (document.cookie.match(re))
			return document.cookie.match(re)[0].split("=")[1]
		return null
	},

	setCookie:function(name, value, days){
		var expireDate = new Date()
		if (typeof days!="undefined"){
			var expstring=expireDate.setDate(expireDate.getDate()+parseInt(days))
			document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; "+splashpage.cookiename[1]
		}
		else document.cookie = name+"="+value+"; "+splashpage.cookiename[1]
	}

}

//Muestro la splash screen si todo es correcto
if (splashpage.browserdetectstr && splashpage.splashenabled==1)	splashpage.init()
