function nuevoAjax(){

  var objetoAjax=false;
  try {
   /*Para navegadores distintos a internet explorer*/
   objetoAjax = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
   try {
     /*Para explorer*/
     objetoAjax = new ActiveXObject("Microsoft.XMLHTTP");
     } 
     catch (E) {
     objetoAjax = false;
   }
  }

  if (!objetoAjax && typeof XMLHttpRequest!='undefined') {
   objetoAjax = new XMLHttpRequest();
  }
  return objetoAjax;


   
    
    
    } 



function substr( f_string, f_start, f_length ) {
    // http://kevin.vanzonneveld.net
    // +     original by: Martijn Wieringa
    // +     bugfixed by: T.Wild
    // +      tweaked by: Onno Marsman
    // *       example 1: substr('abcdef', 0, -1);
    // *       returns 1: 'abcde'
    // *       example 2: substr(2, 0, -6);
    // *       returns 2: ''
 
    f_string += '';
 
    if(f_start < 0) {
        f_start += f_string.length;
    }
 
    if(f_length == undefined) {
        f_length = f_string.length;
    } else if(f_length < 0){
        f_length += f_string.length;
    } else {
        f_length += f_start;
    }
 
    if(f_length < f_start) {
        f_length = f_start;
    }
 
    return f_string.substring(f_start, f_length);
}




function aURL(cadena){
	
buscados=new Array(" ",32,225,233,237,243,250,241,231);

sustitut=new Array("-","-","a","e","i","o","u","n","c");

cadena = cadena.toLowerCase();

for(i=0;i<buscados.length;i++)
cadena = cadena.replace(eval("/"+String.fromCharCode(buscados[i])+"/gi"),sustitut[i]);

cadena = cadena.replace(/[^a-z0-9-]+/gi,"");

return cadena;

}



function change(clase, id){
	
document.getElementById(id).className= clase;

}


function ChequearTodos(id){

if(document.getElementById(id).checked)
check = true;
else
check = false;



for (var i=0;i < document.forms.form.elements.length;i++){
var elemento = document.forms.form.elements[i];
if (elemento.type == "checkbox")
elemento.checked = check;

}
} 



function cargar(obj) {

	
var getstr = "";
var formObj =document.getElementById(obj);
for (var i=0;i<formObj.length;i++){

var valor = formObj.elements[i].value;


if(formObj.elements[i].type == "checkbox"){

if(formObj.elements[i].checked != true)
valor = "";

}


getstr += formObj.elements[i].name + "=" + encodeURIComponent(valor) + "&";
}

return substr(getstr,0,-1);

}    
    
(function($)
		{
		var settings=
			{
			adWidth:300,adHeight:250,showAd:true,forcePreroll:false,usePercentsInPreroll:true,loadingBar:true,fileType:'swf',contentId:'#flashobj',preloadId:'#flashobj_mc',beforeCallback:null,afterCallback:null,gameInsertCallback:null,skipLinkCallback:null,loadingText:"Loading game...",afterLoadingText:"Game loaded. Click here to start the game\u2026",progressbarText:'The game will start in %d seconds',closeText:'Close the advertisement and go on to the game.',advertisementText:'Advertisement',tickInterval:200,progressTime:15000,showSkipTime:0,barWidth:300,adType:'iframe',adCode:''
		};
		var percent=0;
		var timeElapsed=0;
		var linkShowTimeElapsed=0;
		var that=this;
		var flashLoadTries=0;
		var skipTextInserted=false;
		var skipLinkInserted=false;
		var neoedgeAd=false;
		var afterWarning=true;
		var intervalHandle,target,check98PercentHandle,preTimer,preloaderWidth,preloaderHeight,preroll,neoedgeHandler,startPreloaderHandler;
		var showGame=function()
			{
			if(settings.afterCallback!=null)
				{
				settings.afterCallback.call(that,settings)
			}
			if(settings.fileType!='swf'||settings.forcePreroll||!settings.showAd)
				{
				settings.gameInsertCallback.call(that)
			}
			else
				{
				$(settings.contentId).css(
					{
					width:preloaderWidth,height:preloaderHeight
				}
				)
			}
		};
		var cleanupAndShowGame=function()
			{
			if(intervalHandle!=null)
				{
				clearInterval(intervalHandle);
				intervalHandle=null
			}
			if(neoedgeHandler!=null)
				{
				clearTimeout(neoedgeHandler);
				neoedgeHandler=null
			}
			if(check98PercentHandle!=null)
				{
				clearTimeout(check98PercentHandle);
				check98PercentHandle=null
			}
			if(startPreloaderHandler!=null)
				{
				clearTimeout(startPreloaderHandler);
				neoedgeHandler=null
			}
			if(target!=null)
				{
				target.remove();
				target=null
			}
			if(afterWarning)
				{
				showGame()
			}
		};
		var insertSkipLink=function(innerText)
			{
			var a=$('<a href="javascript:void(0);">'+innerText+'</a>');
			if(settings.skipLinkCallback!=null)
				{
				a.click(settings.skipLinkCallback)
			}
			a.click(cleanupAndShowGame);
			$('#ap_skiptext').empty().append(a);
			skipLinkInserted=true
		};
		var skipTextAddOrDecrement=function(afterLoading)
			{
			skipTextInserted=afterLoading?false:skipTextInserted;
			if(linkShowTimeElapsed<=0&&!skipTextInserted)
				{
				if(preroll)
					{
					if(!skipLinkInserted)
						{
						insertSkipLink(settings.closeText)
					}
				}
				else if(afterLoading)
					{
					if(!skipLinkInserted)
						{
						insertSkipLink(settings.afterLoadingText)
					}
				}
				else
					{
					$('#ap_skiptext').empty().append(settings.loadingText)
				}
				skipTextInserted=true;
				return
			}
			else if(linkShowTimeElapsed>0&&!preroll&&!afterLoading&&!skipTextInserted)
				{
				$('#ap_skiptext').empty().append(settings.loadingText);
				skipTextInserted=true
			}
			linkShowTimeElapsed-=settings.tickInterval
		};
		var insertAd=function()
			{
			target.css(
				{
				width:(settings.adWidth+'px')
			}
			);
			target.prepend('<div id="ap_adtext">'+settings.advertisementText+'</div>');
			if(settings.adType=='iframe')
				{
				target.append('<div id="ap_adframe"></div>');
				$('#ap_adframe').css(
					{
					width:(settings.adWidth+'px'),height:(settings.adHeight+'px')
				}
				);
				$('#ap_adframe').append(settings.adCode)
			}
			else
				{
				$('#ap_adframe').css(
					{
					width:(settings.adWidth+'px'),height:(settings.adHeight+'px')
				}
				)
			}
			if(settings.loadingBar&&!neoedgeAd)
				{
				target.append('<div id="ap_progressbar"></div>');
				$('#ap_progressbar').css('width',settings.barWidth+'px');
				if(preroll&&!settings.usePercentsInPreroll)
					{
					$("#ap_progressbar").reportprogress(0,100,SPI.sprintf(settings.progressbarText,Math.ceil(settings.progressTime/1000)))
				}
				else
					{
					$("#ap_progressbar").reportprogress(0,100,'0 %')
				}
			}
			if(!neoedgeAd)
				{
				target.append('<div id="ap_skiptext"></div>')
			}
			skipTextAddOrDecrement()
		};
		var progressUpdatePreroll=function()
			{
			timeElapsed+=settings.tickInterval;
			percent=Math.round(100*timeElapsed/settings.progressTime);
			if(settings.usePercentsInPreroll)
				{
				$("#ap_progressbar").reportprogress(percent,100,percent+' %')
			}
			else
				{
				$("#ap_progressbar").reportprogress(percent,100,SPI.sprintf(settings.progressbarText,Math.ceil((settings.progressTime-timeElapsed)/1000)))
			}
			skipTextAddOrDecrement();
			if(percent>=100)
				{
				if(!neoedgeAd)
					{
					cleanupAndShowGame()
				}
			}
		};
		var check98Percent=function(oldvalue)
			{
			var loaded=$(settings.preloadId)[0].PercentLoaded();
			if(oldvalue==loaded)
				{
				if(!neoedgeAd)
					{
					cleanupAndShowGame()
				}
				if(check98PercentHandle!=null)
					{
					clearTimeout(sometime);
					check98PercentHandle=null
				}
			}
		};
		var progressUpdatePreloader=function()
			{
			var fromTimer=parseInt((settings.progressTime-preTimer)*100/settings.progressTime);
			var loaded=$(settings.preloadId)[0].PercentLoaded();
			if(loaded<0)
				{
				loaded=100
			}
			percent=fromTimer<loaded?fromTimer:loaded;
			$("#ap_progressbar").reportprogress(percent,100,percent+' %');
			preTimer-=settings.tickInterval;
			if(fromTimer>=100)
				{
				check98PercentHandle=setTimeout(function()
					{
					check98Percent(loaded)
				}
				,2500)
			}
			if(percent<100)
				{
				if(loaded>=100)
					{
					skipTextAddOrDecrement(true)
				}
				else
					{
					skipTextAddOrDecrement()
				}
			}
			else if(!neoedgeAd)
				{
				cleanupAndShowGame()
			}
		};
		var startPreloader;
		startPreloader=function()
			{
			flashLoadTries++;
			try
				{
				var loaded_temp=$(settings.preloadId)[0].PercentLoaded();
				intervalHandle=setInterval(progressUpdatePreloader,settings.tickInterval);
				insertAd()
			}
			catch(e)
				{
				if(flashLoadTries<=3)
					{
					startPreloaderHandler=setTimeout(startPreloader,1000)
				}
				else
					{
					if(!neoedgeAd)
						{
						cleanupAndShowGame()
					}
				}
			}
		};
		var showAd=function()
			{
			if(settings.beforeCallback!=null)
				{
				settings.beforeCallback.call(that,settings)
			}
			linkShowTimeElapsed=settings.showSkipTime;
			if(settings.fileType!='swf'||settings.forcePreroll)
				{
				preroll=true;
				intervalHandle=setInterval(progressUpdatePreroll,settings.tickInterval);
				insertAd()
			}
			else
				{
				settings.gameInsertCallback.call(that);
				preloaderHeight=$(settings.contentId).css('height');
				preloaderWidth=$(settings.contentId).css('width');
				$(settings.contentId).css(
					{
					width:'0px',height:'0px'
				}
				);
				preroll=false;
				preTimer=settings.progressTime;
				startPreloader()
			}
		};
		$.spiPreloaderNeoEdge=function(timeout)
			{
			return function(_cmd)
				{
				if(_cmd=="AD_STARTED")
					{
					if(parent)neoedgeAd=true;
					neoedgeHandler=setTimeout(cleanupAndShowGame,timeout||30000)
				}
				if(_cmd=="AD_COMPLETED")
					{
					cleanupAndShowGame()
				}
			}
		};
		$.fn.spiPreloader=function(options)
			{
			target=$(this);
			$.extend(settings,options);
			if(settings.showAd)
				{
				if(settings.adultWarning)
					{
					setupAdultWarning()
				}
				showAd()
			}
			else
				{
				if(settings.adultWarning)
					{
					setupAdultWarning();
					target.remove();
					target=null
				}
				if(settings.beforeCallback!=null)
					{
					settings.beforeCallback.call(that,settings)
				}
				settings.gameInsertCallback.call(that,settings);
				if(settings.afterCallback!=null)
					{
					settings.afterCallback.call(that,settings)
				}
			}
		}
	}
	)(jQuery);

(function($)
	{
	$.flashPlayerVersion=function()
		{
		var flashVersion,activeX=null,fp6Crash=false,shockwaveFlash='ShockwaveFlash.ShockwaveFlash';
		if(!(flashVersion=navigator.plugins['Shockwave Flash']))
			{
			try
				{
				activeX=new ActiveXObject(shockwaveFlash+'.7')
			}
			catch(errorA)
				{
				try
					{
					activeX=new ActiveXObject(shockwaveFlash+'.6');
					flashVersion=[6,0,21];
					activeX.AllowScriptAccess='always'
				}
				catch(errorB)
					{
					if(flashVersion&&flashVersion[0]===6)
						{
						fp6Crash=true
					}
				}
				if(!fp6Crash)
					{
					try
						{
						activeX=new ActiveXObject(shockwaveFlash)
					}
					catch(errorC)
						{
						flashVersion='X 0,0,0'
					}
				}
			}
			if(!fp6Crash&&activeX)
				{
				try
					{
					flashVersion=activeX.GetVariable('$version')
				}
				catch(errorD)
					{
				}
			}
		}
		else
			{
			flashVersion=flashVersion.description
		}
		flashVersion=flashVersion.match(/^[A-Za-z\s]*?(\d+)(\.|,)(\d+)(\s+r|\s+d|,)(\d+)/);
		return[flashVersion[1]*1,flashVersion[3]*1,flashVersion[5]*1]
	}
	();
	$.flashExpressInstaller='expressInstall.swf';
	$.hasFlashPlayer=($.flashPlayerVersion[0]!==0);
	$.hasFlashPlayerVersion=function(options)
		{
		var flashVersion=$.flashPlayerVersion;
		options=(/string|integer/.test(typeof options))?options.toString().split('.'):options;
		return(options)?(flashVersion[0]>=(options.major||options[0]||flashVersion[0])&&flashVersion[1]>=(options.minor||options[1]||flashVersion[1])&&flashVersion[2]>=(options.release||options[2]||flashVersion[2])):(flashVersion[0]!==0)
	};
	$.flash=function(options)
		{
		if(!$.hasFlashPlayer)
			{
			return false
		}
		var movieFilename=options.url||'',contentType=options.type||'swf',paramAttributes=options.params||
			{
		}
		,buildDOM=document.createElement('body'),aArr,bArr,cArr,dArr,a,b,c,d;
		options.height=options.height||180;
		options.width=options.width||320;
		if(options.hasVersion&&!$.hasFlashPlayerVersion(options.hasVersion))
			{
			$.extend(options,
				{
				id:'SWFObjectExprInst',height:Math.max(options.height,137),width:Math.max(options.width,214)
			}
			);
			movieFilename=options.expressInstaller||$.flashExpressInstaller;
			paramAttributes=
				{
				flashvars:
					{
					MMredirectURL:window.location.href,MMplayerType:($.browser.msie&&$.browser.win)?'ActiveX':'PlugIn',MMdoctitle:document.title.slice(0,47)+' - Flash Player Installation'
				}
			}
		}
		if(options.flashvars&&typeof paramAttributes==='object')
			{
			$.extend(paramAttributes,
				{
				flashvars:options.flashvars
			}
			)
		}
		for(a in(b=['url','type','expressInstall','hasVersion','params','flashvars']))
			{
			delete options[b[a]]
		}
		aArr=[];
		for(a in options)
			{
			if(typeof options[a]==='object')
				{
				bArr=[];
				for(b in options[a])
					{
					bArr.push(b.replace(/([A-Z])/,'-$1').toLowerCase()+':'+options[a][b]+';')
				}
				options[a]=bArr.join('')
			}
			aArr.push(a+'="'+options[a]+'"')
		}
		options=aArr.join(' ');
		if(typeof paramAttributes==='object')
			{
			aArr=[];
			for(a in paramAttributes)
				{
				if(typeof paramAttributes[a]==='object')
					{
					bArr=[];
					for(b in paramAttributes[a])
						{
						if(typeof paramAttributes[a][b]==='object')
							{
							cArr=[];
							for(c in paramAttributes[a][b])
								{
								if(typeof paramAttributes[a][b][c]==='object')
									{
									dArr=[];
									for(d in paramAttributes[a][b][c])
										{
										dArr.push(d.replace(/([A-Z])/,'-$1').toLowerCase()+':'+paramAttributes[a][b][c][d]+';')
									}
									paramAttributes[a][b][c]=dArr.join('')
								}
								cArr.push(c+'{'+paramAttributes[a][b][c]+'}')
							}
							paramAttributes[a][b]=cArr.join('')
						}
						bArr.push(window.escape(b)+'='+window.escape(paramAttributes[a][b]))
					}
					paramAttributes[a]=bArr.join('&amp;')
				}
				aArr.push('<PARAM NAME="'+a+'" VALUE="'+paramAttributes[a]+'">')
			}
			paramAttributes=aArr.join('')
		}
		if(contentType=='swf')
			{
			if(!(/style=/.test(options)))
				{
				options+=' style="vertical-align:text-top;"'
			}
			if(!(/style=(.*?)vertical-align/.test(options)))
				{
				options=options.replace(/style="/,'style="vertical-align:text-top;')
			}
		}
		if($.browser.msie)
			{
			if(contentType=='swf')
				{
				options+=' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
				paramAttributes='<PARAM NAME="movie" VALUE="'+movieFilename+'">'+paramAttributes
			}
			else
				{
				options+=' classid="clsid:233C1507-6A77-46A4-9443-F871F945D258"';
				paramAttributes='<PARAM NAME="src" VALUE="'+movieFilename+'">'+paramAttributes
			}
		}
		else
			{
			if(contentType=='swf')
				{
				options+=' type="application/x-shockwave-flash" data="'+movieFilename+'"'
			}
			else
				{
				options+=' type="application/x-director" data="'+movieFilename+'"'
			}
		}
		return'<OBJECT '+options+'>'+paramAttributes+'</OBJECT>'
	};
	$.fn.flash=function(options)
		{
		if(!$.hasFlashPlayer)
			{
			return this
		}
		var a=0,each;
		while((each=this.eq(a++))[0])
			{
			each.html($.flash($.extend(
				{
			}
			,options)));
			if(each[0].firstChild.getAttribute('id')==='SWFObjectExprInst')
				{
				a=this.length
			}
		}
		return this
	}
}
(jQuery));
(function($)
		{
		$.fn.reportprogress=function(val,maxVal,text)
			{
			var max=100;
			if(maxVal)max=maxVal;
			return this.each(function()
				{
				var div=$(this);
				var innerdiv=div.find(".progress");
				if(innerdiv.length!=1)
					{
					innerdiv=$("<div class='progress'></div>");
					div.append("<div class='text'>&nbsp;</div>");
					$("<span class='text'>&nbsp;</span>").css("width",div.css("width")).appendTo(innerdiv);
					div.append(innerdiv)
				}
				var width=Math.round(val/max*100);
				innerdiv.css("width",width+"%");
				if(text)
					{
					div.find(".text").html(text)
				}
			}
			)
		}
	}
	)(jQuery);


_ge=function(id)
{
if(document.getElementById)
	{
	var elem=document.getElementById(id)
}
else if(document.all)
	{
	var elem=document.all[id]
}
return elem
};

var actualWidth=0;
var actualHeight=0;
var startWidth=0;
var startHeight=0;
var ratio=1.1;
zoom=function(inout)
	{
	var obj=_ge('flashobj');
	if(actualWidth==0||actualHeight==0)
		{
		actualWidth=obj.style.width.replace(/px/i,'');
		actualHeight=obj.style.height.replace(/px/i,'');
		startWidth=actualWidth;
		startHeight=actualHeight
	}
	switch(inout)
		{
		case 1:var temp=actualWidth;
		actualWidth=Math.ceil(ratio*actualWidth);
		actualHeight=Math.ceil((actualHeight*actualWidth)/temp);
		break;
		case-1:var temp=actualWidth;
		actualWidth=Math.ceil(actualWidth/ratio);
		actualHeight=Math.ceil((actualHeight*actualWidth)/temp);
		break
	}
	obj.style.width=actualWidth+'px';
	obj.style.height=actualHeight+'px'
};
resetZoom=function()
	{
	if(startWidth>0&&startHeight>0)
		{
		var obj=_ge('flashobj');
		actualWidth=0;
		actualHeight=0;
		obj.style.width=startWidth+'px';
		obj.style.height=startHeight+'px'
	}
};





var rssImage = {
		name: 'img/rss1.png',
		width: 73,
		height: 14	    };
var images_dir = 'img';

function showRating(note,style,get)
	{
	if(note<0)
		{
		return''
	}
	note=Math.ceil(note);
	if(note<0)
		{
		note=0
	}
	if(note>10)
		{
		note=10
	}
	var note=note*rssImage.height;
	var image=new Image();
	image.src=images_dir+'/spacer.gif';
	image.cssstyle="overflow: hidden;width: "+rssImage.width+"px;height: "+rssImage.height+"px;background-image: url("+rssImage.name+");background-repeat: no-repeat;background-position: 0 -"+(note)+"px;cursor: pointer;border:0;padding:0";
	var toReturn='<img src="'+image.src+'" style="'+image.cssstyle+'" />';
	if(get==""||get==null||get=="undefined")
		{
		document.write(toReturn)
	}
	else
		{
		return toReturn
	}
}
    
function traeCodigo(url, idForm, valor_botonPas, valor_botonAct, idBoton)
{




valor = cargar(idForm);

idBoton = (idBoton == undefined) ? 'boton' : idBoton;

if(valor_botonPas != undefined)
var boton = document.getElementById(idBoton);

/*
var cargando = document.getElementById('cargando');
*/
	ajax=nuevoAjax();
	ajax.open("POST", base+url, true);


	ajax.onreadystatechange=function() 
	{
		if(ajax.readyState==4)
		{

     if(valor_botonPas != undefined){		
		 boton.disabled=false;
     boton.value = valor_botonPas;
     }
            
			// Obtengo el XML y separo sus nodos
			var resp=ajax.responseXML;
			var javascript=resp.getElementsByTagName("javascript")[0].childNodes[0].data;

			// Creo el nuevo JS

			var etiquetaScript=document.createElement("script");
			document.getElementsByTagName('head')[0].appendChild(etiquetaScript);
			etiquetaScript.text=javascript;


	
		}else{
		
		   if(valor_botonPas != undefined){		
		   boton.disabled=true;
       boton.value = valor_botonAct;
       }
		
		} 	
	}
	
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send(valor);
		
}






function cambiar_imagen(){

var imagen = document.getElementById('imagen');

var date = new Date();
var timestamp = date.getTime();

imagen.src = base+"captcha.php?time="+timestamp;

}


function traeCodigoGET(url,valores)
{

var date = new Date();
var timestamp = date.getTime();


	var ajax=nuevoAjax();
	ajax.open("GET", url+"?time="+timestamp+valores, true);
  ajax.onreadystatechange=function() 
	{
		if(ajax.readyState==4)
		{
		
			// Obtengo el XML y separo sus nodos
			var resp=ajax.responseXML;
			var javascript=resp.getElementsByTagName("javascript")[0].childNodes[0].data;

			// Creo el nuevo JS

			var etiquetaScript=document.createElement("script");
			document.getElementsByTagName('head')[0].appendChild(etiquetaScript);
			etiquetaScript.text=javascript;

		}
			
	}
	ajax.send(null);
			
}




function mostrar(id){

var div = document.getElementById(id);

div.style.display = (div.style.display == 'none') ? 'block' : 'none';

}

  
