/*
	Added transparent bg to the floating thing for yotubesexo
	forced to use the charset uft-8 internet explorer 8 complains about the charset unicode
*/



var openxAttributes={}
var openxDebugMode=0;


function openxAddVar(name,value)
{
	openxAttributes[name]=value
}

function openxClearVars()
{
	openxAttributes={}
}

function openxWriteZone(id,preventContext)
{
	if(openxDebugMode){
		document.write("[[zone "+id+"]]");
	}
	var m3_u = (location.protocol=='https:'?'https://adsdelivery.envialo.es/ajs.php':'http://adsdelivery.envialo.es/ajs.php');
	var m3_r = Math.floor(Math.random()*99999999999);
	if (!document.MAX_used) document.MAX_used = ',';
	document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
	document.write ("?zoneid="+id+"&amp;target=_blank");
	document.write ('&amp;cb=' + m3_r);
	if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
//	document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
	document.write (document.charset ? '&amp;charset='+'utf-8' : (document.characterSet ? '&amp;charset='+'utf-8' : ''));
	document.write ("&amp;loc=" + escape(window.location));

	// Content channels
	for(k in openxAttributes){
		document.write ("&amp;"+escape(k)+"=" + escape( openxAttributes[k] ));
	}

	if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
	// Disabled by ismael 11-may-2010, it fucks the zones in somes sites like xxxrasuradas.com
	if(!preventContext)
		if (document.context) document.write ("&amp;context=" + escape(document.context));
	if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
	document.write ("'><\/scr"+"ipt>");
}


function openxWriteFloatingZone(id,align,valign,preventContext,closetime)
{
	if(!align){
		align='left';
	}


	if(!closetime){
		closetime=15;
	}

	if(!valign){
		valign='middle';
	}
   	var ox_u = 'http://adsdelivery.envialo.es/al.php?zoneid='+id+'&cb=INSERT_RANDOM_NUMBER_HERE&layerstyle=simple&align='+align+'&valign='+valign+'&padding=2&closetime='+closetime+'&padding=2&shifth=0&shiftv=0&closebutton=t&closetext=Cerrar&noborder=t&nobg=t';
	// Custom ESPANACASH vars

	// Content channels
	for(k in openxAttributes){
		ox_u +="&"+escape(k)+"=" + escape(openxAttributes[k]);
	}
	if(!preventContext)
	      if (document.context) ox_u += '&context=' + escape(document.context);
	// Custom yosolo vars
         document.write("<scr"+"ipt type='text/javascript' src='" + ox_u + "'></scr"+"ipt>");
}


function openxSecuence( zone_list, step)
{
	this.zones = zone_list
	this.step=step
	this.current=1

	this.getZone=function (){
		var ret=0;
		if( (this.current % step) ==0 && this.zones.length ){
			ret= this.zones.shift()
		}

		this.current++
		return ret;
	}

	return this
}


function openxGetVars()
{
	return openxAttributes;
}

function openxGetVarsAsQuery()
{
	var query="";
	for(var t in openxAttributes){
		query += t +"="+encodeURIComponent(openxAttributes[t])+"&";				
	}
	return query;
}


