//
//
document.write('<script type="text/javascript" src="/vistas/js/prototype.js"></script>');
//document.write('<script type="text/javascript" src="/admin/flvplayer/flvplayer.js"></script>');
//document.write('<script src="/admin/audioplayer/audio-player.js" type="text/javascript"> </script>');
//document.write('<script type="text/javascript" src="/vistas/js/ext.classes.js"></script>');
document.write('<script type="text/javascript" src="/vistas/js/appobj.js"></script>');
//document.write('<script src="/vistas/js/scriptaculous/scriptaculous.js?load=builder,effects" type="text/javascript"></script>');
//document.write('<script src="/vistas/js/scriptaculous/scriptaculous.js?load=effects" type="text/javascript"></script>');

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/g,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/g,"");
}

//funcion que permite en una caja de texto determinada, el ingreso de numeros unicamente
/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;
function defaultOnEmpty(object,value) {

	if (object == '' || object == null) {
		return value;
	}
	return object;

}
function changeFinzalizedRoundsCat (intCat) {
	var aleatorio = Math.round(Math.random()*10000);
	AppObj.Ajax.updaterAjax('/upload/htmls/tandasfinalizadas_'+intCat+'.htm?ale='+aleatorio ,'div_finalized');
}
function openPPCEV(arrRace,strMod) {
	strMod = typeof arrRace == 'undefined' ? '' : strMod;
	window.open ( '/modules/ppcev/?arrrace=' + Object.toJSON(arrRace) + '&show=' + strMod );
}

function changeHomeNewsCat(intCat) {
	AppObj.Ajax.updaterAjax('/modules/news/ajax_home_news.php?cat=' + intCat ,'div_newsflash');
}
function $V (object) {
	var obj = $(object);
	if (obj) {
		return obj.value; 
	} 
	return obj;
}
function changeTop48NewsCat (intIdCat) {
	AppObj.Ajax.updaterAjax('/modules/news/ajax_more_news.php?cat=' + intIdCat + '&home=yes' ,'div_more_news_48');
}
function changeTrastiendaNewsCat (intIdCat) {
	AppObj.Ajax.updaterAjax('/modules/news/ajax_trastienda_news.php?cat=' + intIdCat + '&home=yes' ,'div_trastienda');
}
function showMicrositeList(strRank) {
	AppObj.Ajax.updaterAjax('/modules/microsites/ajax_microsite_full_list.php?rank=' + strRank,'div_microsite_full_list');
}

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("El formato de la fecha formato deber&iacute;a ser: dd/mm/aaaa")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Por favor ingrese un mes v&aacute;lido")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Por favor ingrese un d&iacute;a v&aacute;lido")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Por favor ingrese un año de 4 d&iacute;gitos entre "+minYear+" y "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Por favor ingrese una fecha v&aacute;lida")
		return false
	}
return true
}

var nav4 = window.Event ? true : false;

function solonumeros ( evt ) { 
	
	// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57 
	var key = nav4 ? evt.which : evt.keyCode;
	
	return (key <= 13 || (key >= 48 && key <= 57));

}


function solonumerosdecimales ( evt ) { 
	
	// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57 
	var key = nav4 ? evt.which : evt.keyCode;
	
	return (key <= 13 || (key >= 48 && key <= 57) || key == 46 );

}

//Abre un popup
function MM_openBrWindow ( theURL , winName , features ) { //v2.0
	if(features==""){
		features="location=0,status=1,scrollbars=1,width=800,height=600";	
	}

  window.open ( theURL , winName , features ) ;

 }



//Imprime todo el contenido de una pagina
function Imprimir() {
	
	window.print();

}

//Cierra el Popup abierto o ventana abierta
function Cerrar() {
	
	window.close();

}

//Vuelve a la pagina anterior
function Volver() {
	window.history.go(-1);
}


//Realiza la validacion del control que se le pasa como parametro en pObj, valida si esta vacio o no y ademas controla que el dato ingresado sea del tipo pTipo, sino devuelve "false" y ademas genera un mensaje de error.
function VerificarForm ( pObj , pControl , pTipo ) {
	
	pObj = document.getElementById ( pObj ) ;
	if(pObj==null) return true
	if ( pObj.value == '' && pTipo != 'validmail' && pTipo != 'validdate') {
		
		alert(pControl + " es requerido...");
		
		pObj.focus();
		
		return false;
		
	} else {
		
		//Ahora debo corroborar que el dato sea del tipo que se especifica en el parametro pTipo
		switch ( pTipo ) {
			
			case "mail":
				
				//Corroborar que el dato sea una direccion de email valida
				
				if ( pObj.value.indexOf ('@', 0) == -1 || pObj.value.indexOf ('.' , 0) == -1 ) {
					
					alert(pControl + " no es una dirección de e-mail válida...");
					
					pObj.focus();
					
					return false ;
		
				} else {
					
					return true ;
				
				}
				
				break;

			case "validmail":
				
				if (pObj.value == '') return true;

				if ( pObj.value.indexOf ('@', 0) == -1 || pObj.value.indexOf ('.' , 0) == -1 ) {
					
					alert(pControl + " no es una dirección de e-mail válida...");
					
					pObj.focus();
					
					return false ;
		
				} else {
					
					return true ;
				
				}
				
				break;			

			case 'date':
					
			case 'validdate':
				if (pObj.value == '') return true;
			case 'date':
				if (!isDate(pObj.value)) {
					pObj.focus();
					return false;
				}
				return true;
				break;
			case "int":
				
				//Corroborar que el dato sea un valor entero
				
				break;
			case "url":
				if(!isValidURL(pObj.value)){
					alert(pControl + " no es una url válida...");
					pObj.focus();
					return false;
				}
				return true;
				break;
		}
		
		return true;
		
	}
	
}

//Funcion que inicializa el objeto ajax
function initAjax(){


	
	var ajax=false;

	/*@cc_on @*/
	
	/*@if (@_jscript_version >= 5)
	
	try {
	
	ajax = new ActiveXObject("Msxml2.XMLHTTP");
	
	} catch (e) {
	
		try {
	
	ajax = new ActiveXObject("Microsoft.XMLHTTP");
	
	} catch (E) {
	
	ajax = false;
	
	}
	
	}
	
	@end @*/
	
	if (!ajax && typeof XMLHttpRequest!='undefined') {
	
		ajax = new XMLHttpRequest();
	
	}
	
	return ajax;
}

//Funcion que coloca en el divId el resultado del archivo url
function TGAjax ( url , divId , sync, method) {

	var ajax = initAjax() ;    
	
	if (typeof sync == 'undefined') sync = false;

	if (typeof method == 'undefined') method = 'GET';

	/* //Reemplazado por el nuevo objeto para AJAX
	var obj = document.getElementById( divId ) ;

	if (sync == false) {		
		ajax.open ( method , url ) ;
	
		ajax.onreadystatechange = function() {

			if (ajax.readyState == 4 && ajax.status == 200) {

				if (obj!=null) obj.innerHTML = ajax.responseText ;
			
			}	
		}
	
		ajax.send(null);

	} else {

		ajax.open ( "GET" , url ,false) ;
	
		ajax.send(null);

		if (ajax.readyState == 4 && ajax.status == 200) {

				if (obj!=null) 	

					obj.innerHTML = ajax.responseText ;
			
		}	

	}

	*/
	options =  { asynchronous: !sync } ;

	AppObj.Ajax.updaterAjax(url,divId,options);

}

//Funcion que permite comparar que los valores de 2 controles sean identicos para poder enviar el formulario. Esta funcion es muy util a la hora de corroborar confirmaciones de campos
function CompararCampos ( pCampo1 , pLeyendaCampo1 , pCampo2 ) {
	
	pObj1 = document.getElementById ( pCampo1 ) ;
	
	pObj2 = document.getElementById ( pCampo2 ) ;
	
	if ( pObj1.value != pObj2.value ) {
		
		alert ( pLeyendaCampo1 + " no coincide con su confirmación" ) ;
		
		pObj2.focus();
		
		return false ;
		
	} else {
		
		//Si los campos son iguales, se devuelve 'true'
		return true ;
		
	}
	
	
}

function isValidURL(url){
    var RegExp = /^(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
    if(RegExp.test(url)){
        return true;
    }else{
        return false;
    }
}

//Abre un popup reproductor
function openRepWindow ( theURL , winName, strWindowTitle  ) { 
  features="width=390 , height=310 , scrollbar=yes";
  window.open ( theURL , winName, features) ;

}
function imgShow(url,title) {
	if (typeof title == 'undefined') title = '';
	var div = new Element('div', { 'style': 'display:none' });
	var a = new Element('a', { 'rel': 'lightbox[roadtrip]', href: url, 'title':title });
	div.insert(a);
	$('box').insert(div);
	myLightbox.start(a);
	Element.remove(div);
}

function showWaitAjax(intHeight){
	var strHtml = '<div class="waitingimage"  align="center" style="width:100%;min-height:' + intHeight + 'px"><img border="0" src="/vistas/images/wait.gif"><div class="waitingimagetext">Cargando...</div></div>';
	return strHtml
}
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return ""
}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date()
	exdate.setDate(exdate.getDate()+expiredays)
	document.cookie=c_name+ "=" +escape(value)+
		((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}
	function openpop(file,nombre){
		var features="location=0,status=1,scrollbars=1,width=960,height=760";
		win=window.open(file,nombre,features);
		
		 if(win)
		    var popUpsBlocked = false
		 else
		    var popUpsBlocked = true	
		    
		if(popUpsBlocked)
			alert('La configuraci&oacute;n de tu browser no permiten que se vea el popup.');		    	
	} 
	function openpopvideo(file,nombre){
		var features="location=0,status=1,scrollbars=0,width=372,height=322";
		win=window.open(file,nombre,features);
		
		 if(win)
		    var popUpsBlocked = false
		 else
		    var popUpsBlocked = true	
		    
		if(popUpsBlocked)
			alert('La configuraci&oacute;n de tu browser no permiten que se vea el popup.');		    	
	} 

function showVideo(strUrl) {

	strUrlPlayer = '/admin/flvplayer/flvplayer.php?width=352&height=306&url=' + strUrl;

	AppObj.Ajax.updaterAjax(strUrlPlayer,'reproductor');

	image = strUrl.substr(0,strUrl.indexOf('.',0)) + '.jpg';
	var FO = {	movie:"/admin/flvplayer/flvplayer.swf",
				width:"352",
				height:"306",
				majorversion:"7",
				build:"0",
				bgcolor:"#000000",
				allowfullscreen:"true",
				flashvars:"file=" + strUrl + '&image=' + image
			};

	UFO.create(	FO, "player1");


}


	function do_armagaleria(tipomedio,intColumnas,intFilas,idGaleria,page,section){

		section=(typeof section=='undefined'?'':section);

		if(parseInt(tipomedio)){
			strUrl = '/multimedia/listadorecursos.php?intTipoMedio=' + tipomedio + "&intColumnas=" + intColumnas + "&intFilas=" + intFilas + "&idGaleria=" + idGaleria + "&page=" + page + '&section=' + section;
		
			//ajax option
			var objOption;
			switch(parseInt(tipomedio)){			
				case 1:
					objOption = {		
								method: 'get',
								
								onComplete  : function() {
								   	myLightbox.updateImageList();		
								  }
						};				
//					objAjax1 = new Ajax.Updater("div_imagen", strUrl, objOption);

					AppObj.Ajax.updaterAjax(strUrl,'div_imagen',objOption);
				break;
				case 2:
					objOption = {		
								method: 'get'
							};				
					
					AppObj.Ajax.updaterAjax(strUrl,'div_audio',objOption);
				break;			
				case 3:
//					objOption = {		
//								method: 'get',onComplete  : function() {
//									if ($('firstVideo')!=null) {
//
//									showVideo($('firstVideo').value);
//			
//										}		
//								  }
//							};
//					
					objOption = {		
								method: 'get',
								asynchronous: false
							};	
					

					AppObj.Ajax.updaterAjax(strUrl,'div_videos',objOption);
					if ($('firstVideo')!=null) {
	
						showVideo($('firstVideo').value);
	
					}
					
					
				break;
			}					
			
			if ($('galeriatop')!=null) {

				$('galeriatop').scrollTo();

			}
		}	
		
	}

function showppcev() {

	var link = $('linkppcev').value;

	if (link.indexOf('javascript:')<0) { // es un link normal

		window.location.href = link;

	} else { // Es un link de javascript

		link = link.replace('javascript:','');

		eval(link);

	}

}

	/****************************************************************************************
	 * This function verifies if a URI is valid.											*
	 * @todo Validar el string de finalizacion de la url									*
	 * @since 07/11/2007																	*
	 * @version 1.0																			*
	 * @author Gonzalo F. Fernandez															*
	 * @param obj Object that contains the URI to validate.									*
	 * @return boolean 																		*
	 ****************************************************************************************/
	function validaURI(obj) {
		//var re=/^(ftp|gopher|http(s)?|mailto|news|telnet|tftp):\/\/S+.(com|net|org|info|biz|ws|us|tv|cc)/;
		var re0=/^(ftp|gopher|http(s)?|mailto|news|telnet|tftp):\/\//;
		//var re=/.(com|net|org|info|biz|ws|us|tv|cc|uy)/;		
		var invalida=false;
		var url=obj.value;
		if(url!=""){
				if(re0.test(url)){
					invalida=true;
				}else{
					return true;

//					while (url.indexOf("\\") != -1){
//						url = url.slice(url.indexOf("\\") + 1);
//						
//					}
//					var ultimaparteurl = url.slice(url.indexOf(".")).toLowerCase();		
//					
//					if (re.test(ultimaparteurl)) {
//						return true;
//					}else{
//						invalida=true;
//					}
					
				}
				if(invalida){
					alert(getMessage('MSG_URLINVALID'));
					obj.value="";
					obj.focus();
					
					return false;				
				}			
		}else{
			return false;
		}


	}


function loadImages() {

	for (var i = 0 ; i < images_preload.length ; i++) {
	
		MM_preloadImages(images_preload[i]);

	}

}

/**
*
* URL encode / decode
* http://www.webtoolkit.info/
*
**/

var Url = {

    // public method for url encoding
    encode : function (string) {
        return escape(this._utf8_encode(string));
    },

    // public method for url decoding
    decode : function (string) {
        return this._utf8_decode(unescape(string));
    },

    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // private method for UTF-8 decoding
    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }

}

	
	function showLimit(object,limit,elementToUpdate) {
	
		object.value = object.value.substr(0,limit);
		
		$(elementToUpdate).innerHTML = '&nbsp; Le quedan ' + (limit - object.value.length) + ' caracteres';
		
	}

/****************************************************************************************
 * @todo Funcion que verifica la extension del archivo cuando se desea hacer un upload. *
 * @since 07/11/2007																	*
 * @version 1.0																			*
 * @author Gonzalo F. Fernandez															*
 * @param obj Objeto que contiene el archivo a validar									*
 * @param pListaFiles string con los tipos de archivos válidos							*
 * @return verdadero o falso según corresponda											*
 ****************************************************************************************/

function FormatoUploadFront ( obj , pListaFiles ) {
	
	var file = obj.value ;
	
	file = file.toLowerCase();
	
	var b = pListaFiles ;
	
	b = b.toLowerCase();
	
	var temp = new Array() ;
	
	temp = b.split ( ',' ) ;
	
	var acummal = 0 ;
		
	var acumbien = 0 ;
	
	while (file.indexOf("\\") != -1){
		file = file.slice(file.indexOf("\\") + 1);
		
	}
	ext = file.slice(file.indexOf(".")+1).toLowerCase();	
	
	for ( $a = 0 ; $a < temp.length ; $a++ ) {

		if ( ext !=  temp [ $a ] ) {
			
			acummal++ ;
			
		} else {
			
			acumbien++ ;
		
		}
	
	}

	if ( acumbien == 0 ) {
			
		alert ("El archivo tiene una extensión no permitida. Los archivos permitidos tiene que ser: " + pListaFiles  ) ;
		
		//Debo crear un elemento debido a que en IE a un control no le puedo cambiar el value		
			var elemento=document.createElement("input");
			var padre=obj.parentNode;
			elemento.name=obj.name;
			elemento.id=obj.id; 
			elemento.size=obj.size; 
			elemento.maxlength=obj.maxlength;
			elemento.type="file";
			elemento.className="caja";
			
			elemento.onchange=obj.onchange;
			
			try{
                padre.insertBefore(elemento, obj);
                Element.remove(obj);
                //padre.appendChild(elemento);
            }catch(e){
            
            }

		////////////////////////////////////////////////////////////////////////////////////////
		
		return false ;
			
	} else {
		
		return true ;
		
	}

}

function goToPilot(obj){
	//idAuto:${idAuto},idDriver:${idDriver},idCategoria:${idCategoria},idCalendario:${idCalendario}
	
			var body=document.getElementsByTagName("body");
			var frm=document.createElement('form');
			frm.id="frm_send";
			frm.name="frm_send";		
			frm.action='/modules/pilots/index.php' ;
			frm.method="post";
//			frm.target="_blank";
			
			var op=document.createElement('input');
			op.type="hidden";
			op.id="op";
			op.name="op";
			op.value="driver";
			frm.appendChild(op);		
			
			var idAuto=document.createElement('input');
			idAuto.type="hidden";
			idAuto.id="idAuto";
			idAuto.name="idAuto";
			idAuto.value=obj.idAuto;
			frm.appendChild(idAuto);
			
			var idDriver=document.createElement('input');
			idDriver.type="hidden";
			idDriver.id="idDriver";
			idDriver.name="idDriver";
			idDriver.value=obj.idDriver;
			frm.appendChild(idDriver);		
			
			var idCategoria=document.createElement('input');
			idCategoria.type="hidden";
			idCategoria.id="idCategoria";
			idCategoria.name="idCategoria";
			idCategoria.value=obj.idCategoria;
			frm.appendChild(idCategoria);					
			
			var idCalendario=document.createElement('input');
			idCalendario.type="hidden";
			idCalendario.id="idCalendario";
			idCalendario.name="idCalendario";
			idCalendario.value=obj.idCalendario;
			frm.appendChild(idCalendario);		
			
			body[0].appendChild(frm);
			
			frm.submit();
			Element.remove(frm);	
	
	
//	alert(obj.idDriver);
}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
            		function ratePhoto(idPhoto,element, info, type){
	                  var value = info.rated;
					  var module = 'gallery';
	                  if(typeof type != 'undefined'){
	                  	module = type;
	                  }
					  AppObj.Ajax.updaterAjax('/modules/'+module+'/ajax_rate_photo.php?rate=' + value + '&idphoto=' + idPhoto,'');
		            }
					function onLightBoxClose() {
						if (typeof idPhoto == 'undefined') return;
						if ($('div_tools_' + idPhoto) != null && ! $('div_tools_' + idPhoto).visible()) {
							//Effect.BlindDown('div_tools_' + idPhoto);
						}
					}
					function goToPhotoPage(intPage) {
							AppObj.Ajax.updaterAjax('/modules/gallery/ajax_photo.php?idgallery=' + $V('hdn_expanded_gallery') + '&page=' + intPage,'div_gallery_photos',{onComplete  : function() {	myLightbox.updateImageList(); }});
							Effect.ScrollTo('div_expanded_gallery');
					}
					function addAsFavoritePhoto(intPhotoId, type) {
						var modulo = 'gallery';
						if(typeof type != 'undefined'){
							modulo = type;
						}
						var options = {
							loading:false,
							onComplete: function(){
								clsMicrosite.changeTabBookmarks('images');
								var divs = $$('div.tabs_bookmarks');
								divs.each(function(div) {div.hide();div.next().show();});
								$('div_tabs_bookmarks_selected_3').show();
								$('div_tabs_bookmarks_notselected_3').hide();
								$('tabs_bookmarks').value = '3';
							}
						};
						AppObj.Ajax.updaterAjax('/modules/'+modulo+'/ajax_favorite_photo.php?idphoto=' + intPhotoId,'div_add_as_favorite_' + intPhotoId,
										options);

					}

// ** TAMAñO DE FUENTE  ***
	var tgs = new Array( 'text');
	//Specify spectrum of different font sizes:
	var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
	var startSz = 2;
	function ts( trgt,inc ) {
		
		var d = document,cEl = null,sz = startSz,i,j,cTags;
		sz += inc;
		if ( sz < 0 ) sz = 0;
		if ( sz > 4 ) sz = 4;
		startSz = sz;
		if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];
		tgs = $$('div.news_text');
		for ( i = 0 ; i < tgs.length ; i++ ) {
			tgs[i].style.fontSize = szs[ sz ]
		}
	}
	function addAsFavorite(object) {
		if (object) {
			object = $(object);
			object.onclick = '';
			object.firstDescendant().title = 'Ya es favorita';
			object.firstDescendant().alt = 'Ya es favorita';
			object.firstDescendant().src = '/vistas/iconos/bookmark_tc_ok.gif';
		}
		var options = {
			loading:false,
			onComplete: function(){
				var divs = $$('div.tabs_bookmarks');
				divs.each(function(div) {div.hide();div.next().show();});
				$('div_tabs_bookmarks_selected_1').show();
				$('div_tabs_bookmarks_notselected_1').hide();
				$('tabs_bookmarks').value = '1';
			}
		};
		AppObj.Ajax.updaterAjax('/modules/news/show/ajax_favorite_news.php?idnews=' + $('id_news').value,'div_favorite_news', options);		
	}

function setTitle(){
	if (document.title!='') return;
	var arrLinks = $$('#sidebar a[title]');
	var title = 'Turismocarretera.com - Home';
	if (readCookie('navigation') != null) {
		arrLinks.each (function (e) { if(readCookie('navigation') == (e.title) ) {
				var tag =  e.innerHTML ;
				e.up().className = 'press';
		//		e.up().update(tag);
				title = 'Turismocarretera.com - ' + tag;
					}});
	} else {
		arrLinks.each (function (e) { if(document.location.href.indexOf(e.href)>=0 ) {
				var tag =  e.innerHTML ;
				e.up().className = 'press';
		//		e.up().update(tag);
				title = 'Turismocarretera.com - ' + tag;
					}});
	}
		
	document.title=title;
	eraseCookie('navigation');
}
function goToGallerResultPage(intPage) {
	AppObj.Ajax.updaterAjax('/modules/gallery/ajax_search.php?page=' + intPage + '&objoptions=' + $V('hdn_options'),'div_gallery_search_results');
}
function goGalleries (intSection) {
	var strOptions = Object.toJSON({intSection: intSection,strSearch: ''});		
	AppObj.Ajax.updaterAjax('/modules/gallery/ajax_search.php?objoptions=' + strOptions ,'div_gallery_search_results');
}

function searchGallery() {
	$('hdn_options').value = Object.toJSON({intSection: $V('select_section'),strSearch: $V('text_search_for')});
	AppObj.Ajax.updaterAjax('/modules/gallery/ajax_search.php?objoptions=' + $V('hdn_options'),'div_gallery_search_results');

}
function goToMicrosite(strUserName) {
	window.location.href="/modules/microsites/show/?user=" + strUserName;
}
function searchNews() {
	createCookie('navigation','Novedades') ;
	$('form_search').submit();
}
function isEnterKey(e) {
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	return (keycode == 13);
}
function expandGallery (intIdGallery) {
	if ($('div_expanded_gallery')!=null) {
		AppObj.Ajax.updaterAjax('/modules/gallery/expand_gallery.php?idgallery=' + intIdGallery,'div_expanded_gallery',{onComplete  : function() {	myLightbox.updateImageList(); }});
		if (document.viewport.getScrollOffsets().top>0) { Effect.ScrollTo('div_expanded_gallery'); }
	} else {
		document.location.href = '/modules/gallery/?idgallerie=' + intIdGallery;

	}

}
function showGaleries(strObject) {
	var arr = eval(strObject);
	if (arr.length>0) {
		expandGallery (arr[0]); 
	}
	if (arr.length>1) {
		AppObj.Ajax.updaterAjax('/modules/gallery/ajax_more_galleries.php?searchfor=' + Object.toJSON(arr),'div_gallery_search_results');
	}
	//var_dump(arr);
}
		

// Class: Dump
// Author: Shuns (www.netgrow.com.au/files)
// Last Updated: 10/10/06
// Version: 1.1
var_dump=function(object, showTypes){
	var dump='';
	var st=typeof showTypes=='undefined' ? true : showTypes;
	var now = new Date(  );  
	var winName='dumpWin' + now.toString();
	var browser=_dumpIdentifyBrowser();
	var w=760;
	var h=500;
	var leftPos=screen.width ?(screen.width-w)/ 2 : 0;var topPos=screen.height ?(screen.height-h)/ 2 : 0;
	var settings='height='+h+',width='+w+',top='+topPos+',left='+leftPos+',scrollbars=yes,menubar=yes,status=yes,resizable=yes';
	var title='.:: Dump | ' + now.toString() + ' | Fuck You! ::.';
	var script='function tRow(s){t=s.parentNode.lastChild;tTarget(t, tSource(s));}function tTable(s){var switchToState=tSource(s);var table=s.parentNode.parentNode;for(var i=1;i < table.childNodes.length;i++){t=table.childNodes[i];if(t.style){tTarget(t, switchToState);}}}function tSource(s){if(s.style.fontStyle=="italic"||s.style.fontStyle==null){s.style.fontStyle="normal";s.title="click to collapse";return "open";}else{s.style.fontStyle="italic";s.title="click to expand";return "closed";}}function tTarget(t, switchToState){if(switchToState=="open"){t.style.display="";}else{t.style.display="none";}}';
	dump+=(/string|number|undefined|boolean/.test(typeof(object))||object==null)? object : recurse(object, typeof object);
	winName=window.open('', winName, settings);
	if(browser.indexOf('ie')!=-1||browser=='opera'||browser=='ie5mac'||browser=='safari'){winName.document.write('<html><head><title> '+title+' </title><script type="text/javascript">'+script+'</script><head>');winName.document.write('<body>'+dump+'</body></html>');}else{winName.document.body.innerHTML=dump;winName.document.title=title;var ffs=winName.document.createElement('script');ffs.setAttribute('type', 'text/javascript');ffs.appendChild(document.createTextNode(script));winName.document.getElementsByTagName('head')[0].appendChild(ffs);}winName.focus();function recurse(o, type){var i;var j=0;var r='';type=_dumpType(o);switch(type){case 'regexp':var t=type;r+='<table'+_dumpStyles(t,'table')+'><tr><th colspan="2"'+_dumpStyles(t,'th')+'>'+t+'</th></tr>';r+='<tr><td colspan="2"'+_dumpStyles(t,'td-value')+'><table'+_dumpStyles('arguments','table')+'><tr><td'+_dumpStyles('arguments','td-key')+'><i>RegExp: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o+'</td></tr></table>';j++;break;case 'date':var t=type;r+='<table'+_dumpStyles(t,'table')+'><tr><th colspan="2"'+_dumpStyles(t,'th')+'>'+t+'</th></tr>';r+='<tr><td colspan="2"'+_dumpStyles(t,'td-value')+'><table'+_dumpStyles('arguments','table')+'><tr><td'+_dumpStyles('arguments','td-key')+'><i>Date: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o+'</td></tr></table>';j++;break;case 'function':var t=type;var a=o.toString().match(/^.*function.*?\((.*?)\)/im);var args=(a==null||typeof a[1]=='undefined'||a[1]=='')? 'none' : a[1];r+='<table'+_dumpStyles(t,'table')+'><tr><th colspan="2"'+_dumpStyles(t,'th')+'>'+t+'</th></tr>';r+='<tr><td colspan="2"'+_dumpStyles(t,'td-value')+'><table'+_dumpStyles('arguments','table')+'><tr><td'+_dumpStyles('arguments','td-key')+'><i>Arguments: </i></td><td'+_dumpStyles(type,'td-value')+'>'+args+'</td></tr><tr><td'+_dumpStyles('arguments','td-key')+'><i>Function: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o+'</td></tr></table>';j++;break;case 'domelement':var t=type;r+='<table'+_dumpStyles(t,'table')+'><tr><th colspan="2"'+_dumpStyles(t,'th')+'>'+t+'</th></tr>';r+='<tr><td'+_dumpStyles(t,'td-key')+'><i>Node Name: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o.nodeName.toLowerCase()+'</td></tr>';r+='<tr><td'+_dumpStyles(t,'td-key')+'><i>Node Type: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o.nodeType+'</td></tr>';r+='<tr><td'+_dumpStyles(t,'td-key')+'><i>Node Value: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o.nodeValue+'</td></tr>';r+='<tr><td'+_dumpStyles(t,'td-key')+'><i>innerHTML: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o.innerHTML+'</td></tr>';j++;break;}if(/object|array/.test(type)){for(i in o){var t=_dumpType(o[i]);if(j < 1){r+='<table'+_dumpStyles(type,'table')+'><tr><th colspan="2"'+_dumpStyles(type,'th')+'>'+type+'</th></tr>';j++;}if(typeof o[i]=='object' && o[i]!=null){r+='<tr><td'+_dumpStyles(type,'td-key')+'>'+i+(st ? ' ['+t+']' : '')+'</td><td'+_dumpStyles(type,'td-value')+'>'+recurse(o[i], t)+'</td></tr>';}else if(typeof o[i]=='function'){r+='<tr><td'+_dumpStyles(type ,'td-key')+'>'+i+(st ? ' ['+t+']' : '')+'</td><td'+_dumpStyles(type,'td-value')+'>'+recurse(o[i], t)+'</td></tr>';}else{r+='<tr><td'+_dumpStyles(type,'td-key')+'>'+i+(st ? ' ['+t+']' : '')+'</td><td'+_dumpStyles(type,'td-value')+'>'+o[i]+'</td></tr>';}}}if(j==0){r+='<table'+_dumpStyles(type,'table')+'><tr><th colspan="2"'+_dumpStyles(type,'th')+'>'+type+' [empty]</th></tr>';}r+='</table>';return r;};};_dumpStyles=function(type, use){var r='';var table='font-size:xx-small;font-family:verdana,arial,helvetica,sans-serif;cell-spacing:2px;';var th='font-size:xx-small;font-family:verdana,arial,helvetica,sans-serif;text-align:left;color: white;padding: 5px;vertical-align :top;cursor:hand;cursor:pointer;';var td='font-size:xx-small;font-family:verdana,arial,helvetica,sans-serif;vertical-align:top;padding:3px;';var thScript='onClick="tTable(this);" title="click to collapse"';var tdScript='onClick="tRow(this);" title="click to collapse"';switch(type){case 'string':case 'number':case 'boolean':case 'undefined':case 'object':switch(use){case 'table':r=' style="'+table+'background-color:#0000cc;"';break;case 'th':r=' style="'+th+'background-color:#4444cc;"'+thScript;break;case 'td-key':r=' style="'+td+'background-color:#ccddff;cursor:hand;cursor:pointer;"'+tdScript;break;case 'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case 'array':switch(use){case 'table':r=' style="'+table+'background-color:#006600;"';break;case 'th':r=' style="'+th+'background-color:#009900;"'+thScript;break;case 'td-key':r=' style="'+td+'background-color:#ccffcc;cursor:hand;cursor:pointer;"'+tdScript;break;case 'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case 'function':switch(use){case 'table':r=' style="'+table+'background-color:#aa4400;"';break;case 'th':r=' style="'+th+'background-color:#cc6600;"'+thScript;break;case 'td-key':r=' style="'+td+'background-color:#fff;cursor:hand;cursor:pointer;"'+tdScript;break;case 'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case 'arguments':switch(use){case 'table':r=' style="'+table+'background-color:#dddddd;cell-spacing:3;"';break;case 'td-key':r=' style="'+th+'background-color:#eeeeee;color:#000000;cursor:hand;cursor:pointer;"'+tdScript;break;}break;case 'regexp':switch(use){case 'table':r=' style="'+table+'background-color:#CC0000;cell-spacing:3;"';break;case 'th':r=' style="'+th+'background-color:#FF0000;"'+thScript;break;case 'td-key':r=' style="'+th+'background-color:#FF5757;color:#000000;cursor:hand;cursor:pointer;"'+tdScript;break;case 'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case 'date':switch(use){case 'table':r=' style="'+table+'background-color:#663399;cell-spacing:3;"';break;case 'th':r=' style="'+th+'background-color:#9966CC;"'+thScript;break;case 'td-key':r=' style="'+th+'background-color:#B266FF;color:#000000;cursor:hand;cursor:pointer;"'+tdScript;break;case 'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case 'domelement':switch(use){case 'table':r=' style="'+table+'background-color:#FFCC33;cell-spacing:3;"';break;case 'th':r=' style="'+th+'background-color:#FFD966;"'+thScript;break;case 'td-key':r=' style="'+th+'background-color:#FFF2CC;color:#000000;cursor:hand;cursor:pointer;"'+tdScript;break;case 'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;}return r;};_dumpIdentifyBrowser=function(){var agent=navigator.userAgent.toLowerCase();if (typeof window.opera != 'undefined'){return 'opera';} else if (typeof document.all != 'undefined'){if (typeof document.getElementById != 'undefined'){var browser = agent.replace(/.*ms(ie[\/ ][^ $]+).*/, '$1').replace(/ /, '');if(typeof document.uniqueID != 'undefined') {if (browser.indexOf('5.5') != -1){return browser.replace(/(.*5\.5).*/, '$1');}else{return browser.replace(/(.*)\..*/, '$1');}}else{return 'ie5mac';}}}else if(typeof document.getElementById != 'undefined'){if (navigator.vendor.indexOf('Apple Computer, Inc.')!=-1) {return 'safari';}else if(agent.indexOf('gecko')!=-1) {return 'mozilla';}}return false;};_dumpType=function(obj){var t=typeof(obj);if(t=='function'){var f=obj.toString();if((/^\/.*\/[gi]??[gi]??$/).test(f)){return 'regexp';}else if((/^\[object.*\]$/i).test(f)){t='object'}}if(t !='object'){return t;}switch(obj){case null:return 'null';case window:return 'window';case document:return document;case window.event:return 'event';}if(window.event &&(event.type==obj.type)){return 'event';}var c=obj.constructor;if(c !=null){switch(c){case Array:t='array';break;case Date:return 'date';case RegExp:return 'regexp';case Object:t='object';break;case ReferenceError:return 'error';default:var sc=c.toString();var m=sc.match(/\s*function(.*)\(/);if(m !=null){return 'object';}}}var nt=obj.nodeType;if(nt !=null){switch(nt){case 1:if(obj.item==null){return 'domelement';}break;case 3:return 'string';}}if(obj.toString !=null){var ex=obj.toString();var am=ex.match(/^\[object(.*)\]$/i);if(am !=null){var am=am[1];switch(am.toLowerCase()){case 'event':return 'event';case 'nodelist':case 'htmlcollection':case 'elementarray':return 'array';case 'htmldocument':return 'htmldocument';}}}return t;};

function validatefloat(obj, options){
	if(typeof options == 'undefined') return false;
	
	if(typeof options.integerpart == 'undefined') return false;
	
	var strValue = obj.value;
	if(strValue.length <= 0) return false;
	
	var arrParts = strValue.split('.');
	var blnError = false;
	if(typeof arrParts[0] != 'undefined' && arrParts[0].length > options.integerpart){
		blnError = true;
	}
	
	if(typeof arrParts[1] != 'undefined' && arrParts[1].length > options.decimalpart){
		blnError = true;
	}
	
	if(blnError){
		alert('El valor ingresado esta fuera del rango. El valor puede tener como máximo ' + options.integerpart.toString() + ' números en su parte entera y ' + options.decimalpart.toString() + ' en su parte decimal.');
		new PeriodicalExecuter(function(pe) {
		 	obj.focus();
		 	obj.select();
		    pe.stop();
		}, 1);
		return false;
	}
}

function NavTopTen(strUrl) {
	var intAle = Math.round(Math.random()*10000);
	AppObj.Ajax.updaterAjax(strUrl+'?ale='+intAle,'div_TopTenMain');
}

function showFullChampionship(intCat) {
	var aleatorio = Math.round(Math.random()*10000);
	if ($('hdn_ppcev_data')!=null) { // In ppcev
		AppObj.Ajax.updaterAjax('/upload/htmls/campeonato_2008_'+intCat+'.htm?ale='+aleatorio,'div_ppcev_content');
	} else {
		window.location.href='/modules/championship/index.php?cat='+intCat;
	}
}