// Fecha:     20050703
// 20040401 : Aniadida justificacion en funcion EscribeGraficoFlash
//	      y modificada la salida en caso de no disponer de flash

//Notifica la inclusion o no del codigo
var JSIncludePubli = true;

var JSflashVersion = 0;
var JSflashVersion_DONTKNOW = -1;


//AdSense Google - Bloque de Anuncios
function AdsAnuncios() {
	
	/*google_ad_client = "pub-3235169008647558";
	google_ad_width = 728;
	google_ad_height = 90;
	google_ad_format = "728x90_as";
	google_ad_type = "text_image";
	google_ad_channel = "2043262060";
	google_color_border = "FFFFFF";
	google_color_bg = "FFFFFF";
	google_color_link = "779404";
	google_color_text = "000000";
	google_color_url = "3C6600";
	*/
	
	google_ad_client = "pub-3235169008647558";
	/* pista3Anuncios */
	google_ad_slot = "0181477146";
	google_ad_width = 728;
	google_ad_height = 90;
}

//AdSense Google - Bloque de Anuncios principal
function AdsAnunciosPpal() {
	/*google_ad_client = "pub-3235169008647558";
	google_ad_width = 728;
	google_ad_height = 90;
	google_ad_format = "728x90_as";
	google_ad_type = "text_image";
	google_ad_channel = "2043262060";
	google_color_border = "FFFFFF";
	google_color_bg = "FFFFFF";
	google_color_link = "779404";
	google_color_text = "000000";
	google_color_url = "3C6600";	*/
	
	
	google_ad_client = "pub-3235169008647558";
	// pista3AnunciosPpal 
	google_ad_slot = "7620516068";
	google_ad_width = 728;
	google_ad_height = 90;
	
	/*
	google_ad_client = "pub-3235169008647558";
	//  pista3PpalAnuncios468x60 
	google_ad_slot = "3229612998";
	google_ad_width = 468;
	google_ad_height = 60;
	*/
}

//AdSense Google - Bloque de Vínculos
function AdsVinculos() {
	
	/*google_ad_client = "pub-3235169008647558";
	google_ad_width = 728;
	google_ad_height = 15;
	google_ad_format = "728x15_0ads_al";
	google_ad_channel = "4805644226";
	google_color_border = "FFFFFF";
	google_color_bg = "FFFFFF";
	google_color_link = "779404";
	google_color_text = "000000";
	google_color_url = "3C6600";*/
	
	google_ad_client = "pub-3235169008647558";
	/* pista3Vinculos */
	google_ad_slot = "7944746003";
	google_ad_width = 728;
	google_ad_height = 15;
}



//LnkSociable
function LnkSociable() {
	var t = document.title; 
	var u = document.URL; 
	var scriptUrlAux = 'http://blogplay.com/servers/sociable_web.php'; 
	var scriptUrl = scriptUrlAux + '?jq=1&id=3904&amp;u=' + u + '&amp;t=' + t; 
	var sociableSrc=String.fromCharCode(60) + 'scr' +'ipt type="text/javascript" language="javascript" src="' + scriptUrl + '"' + String.fromCharCode(62,60) + '/scr' + 'ipt>'; 
	document.write(sociableSrc);
}


function tieneDatos(Valor) { 
 for (var i=0; i<Valor.length; i++) { 
   if ((" \t\n\r").indexOf(Valor.charAt(i))==-1) return true; 
   } 
 return false; 
}
 
function esNumerico(Valor) { 
 return (isNaN(Valor)); 
}

//Comprueba si es fecha
function esFecha(Valor) { 
 if (!tieneDatos(Valor)) return true; 
 var DatosFecha = Valor.split('-'); 
 var Fecha = new Date(); 
 Fecha.setFullYear(DatosFecha[2],DatosFecha[1]-1,DatosFecha[0]); 
 return (Fecha.getMonth()==DatosFecha[1]-1); 
}

//Comprueba si es un usuario
function esUsername (uname) {

	/* The following string represents the pattern for matching all special
	characters.  We don't want to allow special characters in the address. 
	These characters include ( ) < > & @ , ; : \ " . [ ] */
	var specialChars="\\(\\)><&@,;:\\\\\\\"\\.\\[\\]";
	
	/* The following string represents the range of characters allowed in a 
	username or domainname.  It really states which chars aren't allowed.*/
	var validChars="\[^\\s" + specialChars + "\]";
	
	/* The following pattern applies if the "user" is a quoted string (in
	which case, there are no rules about which characters are allowed
	and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
	is a legal e-mail address. */
 	var quotedUser="(\"[^\"]*\")";
	/* The following string represents an atom (basically a series of non-special characters.) */
	var atom=validChars + '+';
	
	/* The following string represents one word in the typical username.
	For example, in john.doe@somewhere.com, john and doe are words.
	Basically, a word is either an atom or quoted string. */
	var word="(" + atom + "|" + quotedUser + ")";
	
	// The following pattern describes the structure of the user
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	
	// Start by checking that only basic ASCII characters are in the strings (0-127).
	for (i=0; i<uname.length; i++) {
	 if (uname.charCodeAt(i)>127) {
	    alert("This username contains invalid characters.");
	     return false;
	 }
	}

	// See if "user" is valid 
	if (uname.match(userPat)==null) {
		// user is not valid
		//alert("The username doesn't seem to be valid.");
		return false;
	}
	
     return true;
} 

//Comprueba si es un Nombre
function esNombre (uname) {

	/* The following string represents the pattern for matching all special
	characters.  We don't want to allow special characters in the address. 
	These characters include ( ) < > & @ , ; : \ " . [ ] */
	var specialChars="\\(\\)><&@,;:\\\\\\\"\\.\\[\\]";
	
	/* The following string represents the range of characters allowed in a 
	username or domainname.  It really states which chars aren't allowed.*/
	var validChars="\[^\\s" + specialChars + "\]";
	
	/* The following pattern applies if the "user" is a quoted string (in
	which case, there are no rules about which characters are allowed
	and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
	is a legal e-mail address. */
 	var quotedUser="(\"[^\"]*\")";
	/* The following string represents an atom (basically a series of non-special characters.) */
	var atom=validChars + '+';
	
	/* The following string represents one word in the typical username.
	For example, in john.doe@somewhere.com, john and doe are words.
	Basically, a word is either an atom or quoted string. */
	var word="(" + atom + "|" + quotedUser + ")";
	
	// The following pattern describes the structure of the user
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	
	// Start by checking that only basic ASCII characters are in the strings (0-127).
	for (i=0; i<uname.length; i++) {
	 if (uname.charCodeAt(i)>127) {
	    //alert("This username contains invalid characters.");
	     return false;
	 }
	}

	// See if "user" is valid 
	if (uname.match(userPat)==null) {
		// user is not valid
		//alert("The username doesn't seem to be valid.");
		return false;
	}
	
     return true;
} 

//Comprueba si es un Email
function emailCheck (emailStr) {

	/* The following variable tells the rest of the function whether or not
	to verify that the address ends in a two-letter country or well-known
	TLD.  1 means check it, 0 means don't. */
	
	var checkTLD=1;
	
	/* The following is the list of known TLDs that an e-mail address must end with. */
	
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	
	/* The following pattern is used to check if the entered e-mail address
	fits the user@domain format.  It also is used to separate the username
	from the domain. */
	
	var emailPat=/^(.+)@(.+)$/;
	
	/* The following string represents the pattern for matching all special
	characters.  We don't want to allow special characters in the address. 
	These characters include ( ) < > @ , ; : \ " . [ ] */
	
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	
	/* The following string represents the range of characters allowed in a 
	username or domainname.  It really states which chars aren't allowed.*/
	
	var validChars="\[^\\s" + specialChars + "\]";
	
	/* The following pattern applies if the "user" is a quoted string (in
	which case, there are no rules about which characters are allowed
	and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
	is a legal e-mail address. */
	
	var quotedUser="(\"[^\"]*\")";
	
	/* The following pattern applies for domains that are IP addresses,
	rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
	e-mail address. NOTE: The square brackets are required. */
	
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	
	/* The following string represents an atom (basically a series of non-special characters.) */
	
	var atom=validChars + '+';
	
	/* The following string represents one word in the typical username.
	For example, in john.doe@somewhere.com, john and doe are words.
	Basically, a word is either an atom or quoted string. */
	
	var word="(" + atom + "|" + quotedUser + ")";
	
	// The following pattern describes the structure of the user
	
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	
	/* The following pattern describes the structure of a normal symbolic
	domain, as opposed to ipDomainPat, shown above. */
	
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	
	/* Finally, let's start trying to figure out if the supplied address is valid. */
	
	/* Begin with the coarse pattern to simply break up user@domain into
	different pieces that are easy to analyze. */
	var matchArray=emailStr.match(emailPat);
	
	if (matchArray==null) {
	
	/* Too many/few @'s or something; basically, this address doesn't
	even fit the general mould of a valid e-mail address. */
	
	//alert("Email address seems incorrect (check @ and .'s)");
	return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];
	
	// Start by checking that only basic ASCII characters are in the strings (0-127).
	for (i=0; i<user.length; i++) {
	if (user.charCodeAt(i)>127) {
	//alert("This username contains invalid characters.");
	return false;
	   }
	}
	for (i=0; i<domain.length; i++) {
	if (domain.charCodeAt(i)>127) {
	//alert("This domain name contains invalid characters.");
	return false;
	   }
	}
	
	// See if "user" is valid 
	if (user.match(userPat)==null) {
	
	// user is not valid
	
	//alert("The username doesn't seem to be valid.");
	return false;
	}
	
	/* if the e-mail address is at an IP address (as opposed to a symbolic
	host name) make sure the IP address is valid. */
	
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {
	
	// this is an IP address
	
	for (var i=1;i<=4;i++) {
	if (IPArray[i]>255) {
	//alert("Destination IP address is invalid!");
	return false;
	   }
	}
	return true;
	}
	
	// Domain is symbolic name.  Check if it's valid.
	 
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
	if (domArr[i].search(atomPat)==-1) {
	//alert("The domain name does not seem to be valid.");
	return false;
	   }
	}
	
	/* domain name seems valid, but now make sure that it ends in a
	known top-level domain (like com, edu, gov) or a two-letter word,
	representing country (uk, nl), and that there's a hostname preceding 
	the domain or country. */
	
	if (checkTLD && domArr[domArr.length-1].length!=2 && 
	domArr[domArr.length-1].search(knownDomsPat)==-1) {
	//alert("The address must end in a well-known domain or two letter " + "country.");
	return false;
	}
	
	// Make sure there's a host name preceding the domain.
	
	if (len<2) {
	//alert("This address is missing a hostname!");
	return false;
	}
	
	// If we've gotten this far, everything's valid!
	return true;
}


//Comprueba si es un Numerico
function isNumeric (num, bEmptyOK) {
	reNumeric = /^\d+$/;
	if (trim(num)!="" && !reNumeric.test(num)) {
		if (bEmptyOK)
		   return true;
		else
		    return false;
	}
return true;
} 

//Comprueba si es un Email: ###########NOFUNCIONA
function compruebaEmail (email, bEmptyOK) {
var reEmail;

	reEmail = /^[A-Z, a-z, 0-9,_]+\.{0,1}[A-Z, a-z, 0-9,_]+\@[A-Z, a-z, 0-9,_]+\.[A-Z, a-z, 0-9,_]+/;

	if (trim(email)!="" && !reEmail.test(email)) 
	{ 
		if (bEmptyOK)
		    return true;
		else
		   return false;
	}
	return true;
		
} 



//Comprueba si el formato de la fecha es dd-mm-yyyy ###########NOFUNCIONA
function compruebaFecha(strfecha)
{
var patron=new RegExp("^[0-9]{2}-[0-9]{2}-[0-9]{4}$");
//var fecha=strfecha;
/*	if(patron.test(strfecha))
	{
	  //alert("fecha correcta");
	    return true;
	}
	else
	{
	    return false;
	}
*/
	/* la forma de verificar el formato es la que ya comentamos */
	//re=/^[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9][0-9][0-9]$/
	re=/^[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]$/
	if(f.length==0 || !re.exec(f))
	{
		alert("La fecha no tiene formato correcto.")
		return false;
	}
	 
	/* comprobamos que la fecha es válida */
	var d = new Date()
	/* la función tiene como entrada: año, mes, día */
	d.setFullYear(f.substring(6,10), 
		      f.substring(3,5)-1,
		      f.substring(0,2))
	 
	/* ¿el mes del objeto Date es el mes introducido por el usuario?
	   OJO: getMonth() devuelve el número de mes del 0 al 11
	 
	   ¿el día del objeto Date es el día introducido por el usuario?
	   OJO: getDate() devuelve el día del mes */
	if(d.getMonth() != f.substring(3,5)-1 
		|| d.getDate() != f.substring(0,2))
	{
		alert("Fecha no válida.")
		return false;
	}
	
}

//Objeto Ajax
function nuevoAjax(){
	var xmlhttp=false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            xmlhttp = new XMLHttpRequest();
            if (xmlhttp.overrideMimeType) {
                xmlhttp.overrideMimeType('text/xml');
                // Ver nota sobre esta linea al final
            }
        } 
        else if (window.ActiveXObject) { // IE
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }
	 }
        }
        	
	/*if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	  xmlhttp = new XMLHttpRequest();
	}
	*/
	
       if (!xmlhttp) {
            alert('Error :( No es posible crear una instancia XMLHTTP');
            return false;
        }	
	
	return xmlhttp;
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function getFlashVersion() {
	var agent = navigator.userAgent.toLowerCase(); 

   //Excluimos los khtml
	if (navigator.userAgent.toLowerCase().indexOf("khtml") != -1)
	{
		return 0;
	}	
	
   // NS3 needs JSflashVersion to be a local variable
   if (agent.indexOf("mozilla/3") != -1 && agent.indexOf("msie") == -1) {
      JSflashVersion = 0;
   }
   
	// NS3+, Opera3+, IE5+ Mac (support plugin array):  check for Flash plugin in plugin array
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		var flashPlugin = navigator.plugins['Shockwave Flash'];
		if (typeof flashPlugin == 'object') { 
			if (flashPlugin.description.indexOf('7.') != -1) JSflashVersion = 7;
			else if (flashPlugin.description.indexOf('6.') != -1) JSflashVersion = 6;
			else if (flashPlugin.description.indexOf('5.') != -1) JSflashVersion = 5;
			else if (flashPlugin.description.indexOf('4.') != -1) JSflashVersion = 4;
			else if (flashPlugin.description.indexOf('3.') != -1) JSflashVersion = 3;
		}
	}

	// IE4+ Win32:  attempt to create an ActiveX object using VBScript
	else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
	   document.write('<scr' + 'ipt language="VBScript"\> \n');
		document.write('on error resume next \n');
		document.write('dim obFlash \n');
		document.write('set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.7") \n');
		document.write('if IsObject(obFlash) then \n');
		document.write('JSflashVersion = 7 \n');
		document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.6") end if \n');
		document.write('if JSflashVersion < 7 and IsObject(obFlash) then \n');
		document.write('JSflashVersion = 6 \n');
		document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.5") end if \n');
		document.write('if JSflashVersion < 6 and IsObject(obFlash) then \n');
		document.write('JSflashVersion = 5 \n');
		document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.4") end if \n');
		document.write('if JSflashVersion < 5 and IsObject(obFlash) then \n');
		document.write('JSflashVersion = 4 \n');
		document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.3") end if \n');
		document.write('if JSflashVersion < 4 and IsObject(obFlash) then \n');
		document.write('JSflashVersion = 3 \n');
		document.write('end if');
		document.write('</scr' + 'ipt\> \n');
  }
		
	// WebTV 2.5 supports flash 3
	else if (agent.indexOf("webtv/2.5") != -1) JSflashVersion = 3;

	// older WebTV supports flash 2
	else if (agent.indexOf("webtv") != -1) JSflashVersion = 2;

	// Can't detect in all other cases
	else {
		JSflashVersion = JSflashVersion_DONTKNOW;
	}

	return JSflashVersion;
}


//Escritura bloque flash para publicidad
//archivoswf: url al archivo swf
//cadenaclicktag: parametros  que se le pasa al swf (cadena completa desde ? incluido)
//ancho: dimension x
//alto: dimension y
//wmode:    window, opaque, transparent  Uno de ellos
//No se puede utilizar para navegadores khtml (da problemas escribiendo el object)
function EscribeBloquePublicidadFlash(archivoswf, cadenaclicktag, ancho, alto, wmode)
{
	var cadena = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" ' + 'width="' + ancho + '" height="' + alto + '" id="PeliculaFlash">\n';
	cadena = cadena + '<param name="movie" value="' + archivoswf + cadenaclicktag + '" />\n'; 
	cadena = cadena + '<param name="wmode" value="' + wmode +'" />\n';
	cadena = cadena + '<param name="quality" value="high" />\n';
	cadena = cadena + '<embed wmode="' + wmode + '" src="' + archivoswf + cadenaclicktag + '" quality="high"  width="' + ancho + '" height="' + alto + '" name="PeliculaFlash" type="application/x-shockwave-flash" ' + ' pluginspage="http://www.macromedia.com/go/getflashplayer">\n';
	cadena = cadena + '</embed>\n';
	cadena = cadena + '</object>\n';
	document.write(cadena);
}



//Escritura bloque flash para graficos
//archivoswf: url al archivo swf
//cadenaclicktag: parametros  que se le pasa al swf (cadena completa desde ? incluido)
//ancho: dimension x
//alto: dimension y
//wmode:    window (opaco) transparent (transparente)
//version: version para la que ha sido creado el swf
function EscribeGraficoFlash(archivoswf, cadenaclicktag, ancho, alto, wmode,version,justificacion)
{

	var LocalVersion = getFlashVersion();
	//Vemos si tiene flash	y no es un khtml (da problemas escribiendo el objecto de flash
	if (LocalVersion > 0)
	{
		//Si no se dispone de la version adecuada mostramos un flash version 1, respetando las dimensiones 
		if (LocalVersion < version)
		{
			archivoswf = "http://cache.elmundo.es/banners/publicidad/noflashc.swf";
			cadenaclicktag = "?clickTag=http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
			//ancho = 300;
			//alto = 300;
		}
		//Escribimos el bloque
		var cadena= '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' + 
			'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" ' +
			'width="' + ancho +
			'" height="' + alto +
			'" align="' + justificacion +
			'" id="PeliculaFlash">\n';
		cadena = cadena + '<param name="movie" value="' + archivoswf + cadenaclicktag + '" />\n'; 
		cadena = cadena + '<param name="wmode" value="' + wmode + '" />\n';
		cadena = cadena + '<param name="quality" value="high" />\n';
		cadena = cadena + '<embed wmode="' + wmode + '" src="' + archivoswf + cadenaclicktag + '" quality="high"  width="' + ancho + '" height="' + alto + '" align="' + justificacion + '" name="PeliculaFlash" type="application/x-shockwave-flash" ' + ' pluginspage="http://www.macromedia.com/go/getflashplayer">\n';
		cadena = cadena + '</embed>\n';
		cadena = cadena + '</object>\n';
		document.write(cadena);
	}
	else
	{
		var cadena = '<table cellspacing="0" cellpadding="10" bgcolor="eeeeee" border="0" width="'+ Ancho +'" height="'+ Alto +'" align="'+ justificacion +'"><tr><td align="center"><a href="http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank">Creatividad en flash<br> y<br> plugin no disponible</a></td></tr></table>\n'
		document.write(cadena);
	}
}


