/**
 * utilidades varias
 * @package atrapalo
 * @version $Id: atrapalo.js,v 1.51.2.8 2009-06-23 14:59:55 wwwagent Exp $;
 */
var Atrapalo={};
Atrapalo.included_js_files = [];
Atrapalo.included_css_files = [];
//Funcion para cargar javascripts on demand
Atrapalo.util = {};
Atrapalo.util.prototype = {cookie:{},error:{},dates:{}};
Atrapalo.util.include_js = function (script_filename,force)
{
    var html_doc = document.getElementsByTagName('head').item(0);
    var filename_parts = script_filename.split('.');
    if(filename_parts[1].match(/js/)) {
        if (!in_array(script_filename, Atrapalo.included_js_files) || force === true) {
            var js = document.createElement('script');
            js.setAttribute('language', 'javascript');
            js.setAttribute('type', 'text/javascript');
            js.setAttribute('src', script_filename);
            html_doc.appendChild(js);
            Atrapalo.included_js_files[included_js_files.length] = script_filename;
        }
    }
    if(filename_parts[1].match(/css/)) {
        if (!in_array(script_filename, Atrapalo.included_css_files) || force === true) {
            var css = document.createElement('link');
            css.setAttribute('type', 'text/css');
            css.setAttribute('media','screen');
            css.setAttribute('rel',  'stylesheet');
            css.setAttribute('href', script_filename);
            html_doc.appendChild(css);
            Atrapalo.included_css_files[included_css_files.length] = script_filename;
        }
    }
};
//COOKIES
/*
name - name of the cookie
value - value of the cookie
[expires] - expiration date of the cookie (defaults to end of current session)
[path] - path for which the cookie is valid (defaults to path of calling document)
[domain] - domain for which the cookie is valid (defaults to domain of calling document)
[secure] - Boolean value indicating if the cookie transmission requires a secure transmission
*/
Atrapalo.util.cookie = {};
Atrapalo.util.cookie.setCookie = function(name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
    document.cookie = curCookie;
};
Atrapalo.util.cookie.getCookie = function (name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else begin += 2;
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) end = dc.length;
    return unescape(dc.substring(begin + prefix.length, end));
};
Atrapalo.util.cookie.deleteCookie = function(name, path, domain) {
    if (Atrapalo.util.cookie.getCookie(name)) {
        document.cookie = name + "=" +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
};
Atrapalo.util.rand = function (n) {
      return ( Math.floor ( Math.random ( ) * n + 1 ) );
}
Atrapalo.util.writeAd = function (zone) {
    if(isNaN(zone)) return;
    if (!document.phpAds_used) document.phpAds_used = ',';
    phpAds_random = new String (Math.random());
    phpAds_random = phpAds_random.substring(2,11);
    document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
    document.write ("http://adserver.atrapalo.com/adjs.php?n=" + phpAds_random);
    document.write ("&amp;what=zone:"+zone);
    document.write ("&amp;exclude=" + document.phpAds_used);
    if(document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
    document.write ("'><" + "/script>");
}
// date - any instance of the Date object
Atrapalo.util.dates = {};
Atrapalo.util.dates.fixDate = function(date) { var base = new Date(0); var skew = base.getTime(); if (skew > 0) date.setTime(date.getTime() - skew); };
//Shorcuts
Atrapalo.util.shortcut = function (shortcut,callback,opt) {
//Provide a set of default options
var default_options = { 'type':'keydown', 'propagate':false, 'target':document };
if(!opt) opt = default_options;
else{for(var dfo in default_options){if(typeof opt[dfo] == 'undefined') opt[dfo] = default_options[dfo];}}
var ele = opt.target;
if(typeof opt.target == 'string') ele = document.getElementById(opt.target);
var ths = this;
//The function to be called at keypress
var func = function(e) {
    e = e || window.event;
    //Find Which key is pressed
    if (e.keyCode) code = e.keyCode;
    else if (e.which) code = e.which;
    var character = String.fromCharCode(code).toLowerCase();
    var keys = shortcut.toLowerCase().split("+");
    //Key Pressed - counts the number of valid keypresses - if it is same as the number of keys, the shortcut function is invoked
    var kp = 0;
    //Work around for stupid Shift key bug created by using lowercase - as a result the shift+num combination was broken
    var shift_nums = {"`":"~", "1":"!", "2":"@", "3":"#", "4":"$","5":"%", "6":"^", "7":"&", "8":"*", "9":"(","0":")", "-":"_", "=":"+", ";":":", "'":"\"",",":"<", ".":">", "/":"?", "\\":"|"};
    //Special Keys - and their codes
    var special_keys = { 'esc':27, 'escape':27, 'tab':9, 'space':32, 'return':13, 'enter':13, 'backspace':8, 'scrolllock':145, 'scroll_lock':145, 'scroll':145,
	'capslock':20, 'caps_lock':20, 'caps':20, 'numlock':144, 'num_lock':144, 'num':144, 'pause':19, 'break':19, 'insert':45, 'home':36, 'delete':46, 'end':35, 'pageup':33, 'page_up':33,
	'pu':33, 'pagedown':34, 'page_down':34, 'pd':34, 'left':37, 'up':38, 'right':39, 'down':40, 'f1':112, 'f2':113, 'f3':114, 'f4':115, 'f5':116, 'f6':117, 'f7':118, 'f8':119, 'f9':120, 'f10':121,
	'f11':122, 'f12':123 };
    for(var i=0; k=keys[i],i<keys.length; i++) {
        //Modifiers
        if(k == 'ctrl' || k == 'control') {
            if(e.ctrlKey) kp++;
        }else if(k ==  'shift') {
           if(e.shiftKey) kp++;
        }else if(k == 'alt') {
            if(e.altKey) kp++;
            }else if(k.length > 1) { //If it is a special key
               if(special_keys[k] == code) kp++;
            }else { //The special keys did not match
                if(character == k) kp++;
                else {
                    if(shift_nums[character] && e.shiftKey) { //Stupid Shift key bug created by using lowercase
                        character = shift_nums[character];
                        if(character == k) kp++;
                    }
                }
            }
	}
	if(kp == keys.length) {
		callback(e);
		if(!opt['propagate']) { //Stop the event
			e.cancelBubble = true; e.returnValue = false;
            if (e.stopPropagation) { e.stopPropagation(); e.preventDefault();}
			return false;
		}
	}
};
//Attach the function with the event
if(ele.addEventListener) ele.addEventListener(opt['type'], func, false);
else if(ele.attachEvent) ele.attachEvent('on'+opt['type'], func);
else ele['on'+opt['type']] = func;
}
/*required
req     The field should not be empty
maxlen=???
maxlength=???   checks the length entered data to the maximum. For example, if the maximum size permitted is 25, give the validation descriptor as "maxlen=25"
minlen=???
minlength=???   checks the length of the entered string to the required minimum. example "minlen=5"
alphanumeric /
alnum   Check the data if it contains any other characters other than alphabetic or numeric characters
num
numeric     Check numeric data
alpha
alphabetic  Check alphabetic data.
email   The field is an email field and verify the validity of the data.
lt=???
lessthan=???    Verify the data to be less than the value passed. Valid only for numeric fields.
example: if the value should be less than 1000 give validation description as "lt=1000"
gt=???
greaterthan=???     Verify the data to be greater than the value passed. Valid only for numeric fields.
example: if the value should be greater than 10 give validation description as "gt=10"
regexp=???  Check with a regular expression the value should match the regular expression.
example: "regexp=^[A-Za-z]{1,20}$" allow up to 20 alphabetic characters.
dontselect=??   This validation descriptor is valid only for select input items (lists) Normally, the select list boxes will have one item saying 'Select One' or some thing like that. The user should select an option other than this option. If the index of this option is 0, the validation description should be "dontselect=0"
*/
Atrapalo.util.validar = function(){};
Atrapalo.util.validar.isEmail = function(email)
{
    var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    return(filter.test(email));
};
Atrapalo.util.validar.validateEmailv2 = function(email) { return ((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))); };
Atrapalo.util.validar.V2validateData = function(strValidateStr,objValue)
{
    var epos = strValidateStr.search("=");
    var command  = "";
    var cmdvalue = "";
    var re_alphabetic = "[^A-Za-zá-úà-ùÁ-ÚÀ-Ùä-üÄ-Üâ-ûÂ-ÛçÇñÑ ]";
    var re_numeric = "[^0-9]";
    var re_alphanumeric = "[^A-Za-zá-úà-ùÁ-ÚÀ-Ùä-üÄ-Üâ-ûÂ-ÛçÇñÑ0-9 ]";
    var re_alnumhyphen = "[^A-Za-zá-úà-ùÁ-ÚÀ-Ùä-üÄ-Üâ-ûÂ-ÛçÇñÑ0-9\-_]";
    if(epos >= 0){
        command  = strValidateStr.substring(0,epos);
        cmdvalue = strValidateStr.substr(epos+1);
    }else{
        command = strValidateStr;
    }
    switch(command) {
        case "req":
        case "required": if(eval(objValue.value.length) == 0) return false; break;
        case "length":
        case "len": if(eval(objValue.value.length) !=  eval(cmdvalue)) return false; break;
        case "maxlength":
        case "maxlen": if(eval(objValue.value.length) >  eval(cmdvalue)) return false; break;
        case "minlength":
        case "minlen": if(eval(objValue.value.length) <  eval(cmdvalue)) return false; break;
        case "alnum":
        case "alphanumeric":
            var charpos = objValue.value.search(re_alphanum);
            if(objValue.value.length > 0 &&  charpos >= 0) return false;
            break;
        case "num":
        case "numeric":
            var charpos = objValue.value.search(re_numeric);
            if(objValue.value.length > 0 &&  charpos >= 0) return false;
            break;
        case "alphabetic":
        case "alpha":
            var charpos = objValue.value.search(re_alphabetic);
            if(objValue.value.length > 0 &&  charpos >= 0) return false;
            break;
        case "alnumhyphen":
            var charpos = objValue.value.search(re_alnumhyphen);
            if(objValue.value.length > 0 &&  charpos >= 0) return false;
            break;
        case "email": if(!this.validateEmailv2(objValue.value)) return false; break;
        case "lt":
        case "lessthan":
            if(isNaN(objValue.value)) return false;
            if(eval(objValue.value) >=  eval(cmdvalue)) return false;
            break;
        case "gt":
        case "greaterthan":
            if(isNaN(objValue.value)) return false;
            if(eval(objValue.value) <=  eval(cmdvalue)) return false;
            break;
        case "regexp":
            if(objValue.value.length > 0 && !objValue.value.match(cmdvalue)) return false;
            break;
        case "dontselect":
            if(objValue.selectedIndex == null) return false;
            if(objValue.selectedIndex == eval(cmdvalue)) return false;
            break;
    }
    return true;
};
Atrapalo.header = {};
//Funcion que carga el numero de pedidos en el carrito
Atrapalo.header.setNumCartItems = function()
{
    try{
    var c_items=parseInt(getCookie('cart_items'),10);
    if($('divCesta'))
    {
    	if(c_items>1) c_prod = txt_productos;
    	else c_prod = txt_producto;
        if(c_items>0){
            $('divCesta').hidden=false;
            $('n_cart_items').innerHTML=c_items;
            $('c_cart_items').innerHTML=c_prod;
            YAHOO.util.Dom.replaceClass('header_js_ck', 'cesta_header sin_cesta', 'cesta_header con_cesta');
            YAHOO.util.Dom.removeClass('divCesta', 'oculto');
        }else{
            $('divCesta').hidden=true;
            YAHOO.util.Dom.addClass('divCesta', 'oculto');
            YAHOO.util.Dom.addClass('link', 'oculto');
            YAHOO.util.Dom.replaceClass('header_js_ck', 'cesta_header con_cesta', 'cesta_header sin_cesta');
        }
    }
    }catch(e) {}
};
//Get URL parameter
Atrapalo.util.gup = function (name){
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null ) return false;
  else return results[1];
}
//Calcula la fecha de expire de una cookie
Atrapalo.util.getFechaExpire = function (dias){
    milisegundos=parseInt(dias*24*60*60*1000);
    fecha=new Date();
    tiempo=fecha.getTime();
    total=fecha.setTime(parseInt(tiempo+milisegundos));
    dia=fecha.getDate();
    mes=fecha.getMonth();
    anio=fecha.getFullYear();
    fecha_new = new Date(anio, mes, dia);
    return fecha_new;
}
/*
* DEPRECATED
*/
var V2validateData = Atrapalo.util.validar.V2validateData;
var isEmail = Atrapalo.util.validar.isEmail;
var validateEmailv2 = Atrapalo.util.validar.validateEmailv2;
var setCookie = Atrapalo.util.cookie.setCookie;
var getCookie = Atrapalo.util.cookie.getCookie;
var deleteCookie = Atrapalo.util.cookie.deleteCookie;
var fixDate = Atrapalo.util.dates.fixDate;
var shortcut = Atrapalo.util.shortcut;
var setNumCartItems = Atrapalo.header.setNumCartItems;
var included_js_files = Atrapalo.util.include_js;
var included_css_files = Atrapalo.util.include_js;
var include_dom = Atrapalo.util.include_js;
var rand = Atrapalo.util.rand;
//ADX
function phpads_deliverActiveX(content) { document.write(content); }
//Math
function randomString()
{
    var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';
    var string_length = 8;
    var randomstring = '';
    for (var i=0; i<string_length; i++){
        var rnum = Math.floor(Math.random() * chars.length);
        randomstring += chars.substring(rnum,rnum+1);
    }
    return randomstring;
}
/**
* Objeto error
* Vars es un array cuyos valores se substituyen por %s en el mensaje del error.
*/
var error_o = function(id_package,id_class,id_exception,msg,action,vars)
{
    this.id_package=(!isNaN(id_package))?id_package:0;
    this.id_class=(!isNaN(id_class))?id_class:0;
    this.id_exception=(!isNaN(id_exception))?id_exception:0;
    this.action=(action!=undefined)?action:'';
    this.msg=(msg!=undefined && msg!='')?msg+"\n":'';
    this.vars = (vars!=undefined && vars!='')? vars : '';
    if(this.msg=='' && (isNaN(id_package) || !isNaN(id_class) || isNaN(id_exception)))
    {
        if(isNaN(id_package)) this.msg=id_package;
        else if(isNaN(id_class)) this.msg=id_class;
        else if(isNaN(id_exception)) this.msg=id_exception;
        if(this.msg == undefined) this.msg='';
    }
    this.getCodigoError=function()
    {
        for(i=this.id_class.length;i<3;i++) this.id_class='0'+this.id_class;
        for(i=this.id_exception.length;i<3;i++) this.id_exception='0'+this.id_exception;
        return ''+this.id_package+''+this.id_class+''+this.id_exception+'';
    }
    this.setCodigoError=function(val)
    {
        if(val.length<8) return -1;
        this.id_package=val.substr(0,2);
        this.id_class=val.substr(2,3);
        this.id_exception=val.substr(5,3);
    };
    this.setAction=function(val) { this.action=val; };
    this.setMsg=function(val) { this.msg=val; };
    this.getMsg=function() { return this.msg; };
    // Por ahora el vars solo acepta 1 valor.
    this.getVars=function()
    {
        var tmp = '';
        if (this.vars.length > 0) tmp = this.vars;
        return tmp;
    }
}
var Error = error_o;
// Classe que contiene y muestra los errores
var Errores =  function()
{
    this.arrErrores=new Array();
    this.messages=[];
    this.text='';
    this.push=function(val) { this.arrErrores[this.arrErrores.length]=val; };
    this.toString=function()
    {
        var str=[];
        var len = this.arrErrores.length;
        for (y=0;y<len;y++)
        {
            if(this.arrErrores[y].msg=='' || this.arrErrores[y].msg.indexOf('undefined')>=0)
            {
                if (this.arrErrores[y].getVars() != '') str.push(this.arrErrores[y].getCodigoError()+'_'+this.arrErrores[y].getVars());
                else str.push(this.arrErrores[y].getCodigoError());
            }else this.messages.push(this.arrErrores[y].msg);
        }
        return str.join('|');
    };
    this.cargarErroresCookie=function()
    {
        try
        {
            var vars=[];
            var arr_errores = Atrapalo.util.cookie.getCookie('id_errores');
            if (arr_errores != null) { arr_errores = arr_errores.split('|');}
            else { return;}
            var len = arr_errores.length;
            for (var i=0;i<len;i++)
            {
                var e=new error_o();
                vars[i]=[];
                if(arr_errores[i].indexOf("_")>0)
                {
                    var tmp=arr_errores[i].split("_");
                    arr_errores[i]=tmp[0];
                    for(var y=1;y<tmp.length;y++) vars[i][vars.length]=tmp[y];
                }
                if ((arr_errores[i] != undefined) && (arr_errores[i] != ''))
                {
                    if(isNaN(arr_errores[i])) e.setMsg(unescape(arr_errores[i]));
                    else e.setCodigoError(unescape(arr_errores[i]));
                    if(vars[i].length>0) e.vars=vars[i].join("_");
                    this.push(e);
                }
            }
            var domain=location.hostname.split(".");
            var tld=domain.pop();
            var dname=domain.pop()
            domain=dname+"."+tld;
            Atrapalo.util.cookie.deleteCookie('id_errores','/');
			Atrapalo.util.cookie.deleteCookie('id_errores','/',domain);
			Atrapalo.util.cookie.deleteCookie('id_errores','/',domain,true);
            //borramos cookie en funcion del dominio
            if(this.cargarErroresCookie.arguments.length > 0) {
                var domain_to_delete = this.cargarErroresCookie.arguments[0];
                Atrapalo.util.cookie.deleteCookie('id_errores','/','.'+domain_to_delete);
            }
        }catch(e) {}
    };
    this.eval=function(val)
    {
        if(this.arrErrores.length==0) return -1;
        var codigos=this.toString();
        if(codigos!='')
        {
            try
            {
                YAHOO.util.Connect.asyncRequest('GET', '/common/index.php?pg=error&mode=simple&squid=yes&id_errores='+codigos,
                {
                    success: function(response)
                             {
                                if(response.responseText!='') errores.messages.push(response.responseText);
                                else errores.messages.push('Error nums: '+codigos);
                                eval(val(errores.messages.join("\n").replace(/<br\/>/g,'\n')));
                             },
                    failure: function (response)
                             {
                                alert('Error Interno 697. Sentimos las molestias, por favor intentelo mas tarde.' + '\n Error 697. Sorry, please try again. Thanks' + '\n Errore interno 697: problemi di comunicazione con il server, per favore riprova piú tardi');
                             }
                });

            }catch(err){}
        }else{
            eval(val(this.messages));
        }
        this.clean();
    };
    this.layer=function()
    {
        if($('AlertOverlay'))
        {
            $('AlertOverlay').style.height='auto';
            $('lista_de_errores').innerHTML=this.messages.join("<br/>").replace(/\n/,'<br'+'/'+'>');
            $('AlertOverlay').style.display='block';
            this.processActions();
            this.clean();
            document.location.href=document.location.href.replace(/#(.)*/,"")+"#";
        }else{
            this.alert();
        }
    };
    this.alert=function()
    {
        var tmp = this.messages;
        tmp = tmp.join("\n");
        tmp = tmp.replace(/&lt;/ig,'<');
        tmp = tmp.replace(/&gt;/ig,'>');
        tmp = tmp.replace(/<br\/>/g,'\n');
        tmp = tmp.replace(/<br \/>/g,'\n');
        tmp = tmp.replace(/&aacute;/ig,'á');
        tmp = tmp.replace(/&eacute;/ig,'é');
        tmp = tmp.replace(/&oacute;/ig,'ó');
        tmp = tmp.replace(/&iacute;/ig,'í');
        tmp = tmp.replace(/&uacute;/ig,'ú');
        this.messages = tmp;
		if (this.messages != '') alert(this.messages);
		else alert('Error Interno 696. Sentimos las molestias, por favor intentelo mas tarde.' + '\n Error 696. Sorry, please try again. Thanks' + '\n Errore interno 696: problemi di comunicazione con il server, per favore riprova piú tardi');
        this.clean();
    };
    this.showLayer=function()
    {
        if(this.arrErrores.length==0) return -1;
        var codigos=this.toString();
        if(codigos!='')
        {
            try
            {
                YAHOO.util.Connect.asyncRequest('GET', '/common/index.php?pg=error&squid=yes&mode=simple&id_errores='+codigos,
                {
                    success: function(response)
                             {
                                if(response.responseText!='') errores.messages.push(response.responseText);
                                else errores.messages.push('Error nums: '+codigos);
                                return errores.layer();
                             },
                    failure: function (response)
                             {
                                alert('Error Interno 698. Sentimos las molestias, por favor intentelo mas tarde.' + '\n Error 698. Sorry, please try again. Thanks' + '\n Errore interno 698: problemi di comunicazione con il server, per favore riprova piÃ¹ tardi');
                             }
                },'id_errores='+codigos);
            }catch(err){}
        }else return this.layer();
    };
    this.showAlert=function()
    {
        if(this.arrErrores.length==0) return -1;
        var codigos=this.toString();
        this.processActions();
        if(codigos!='')
        {
            try
            {
                YAHOO.util.Connect.asyncRequest('GET', '/common/index.php?pg=error&mode=simple&squid=yes&id_errores='+codigos,
                {
                    success: function(response)
                             {
                                if(response.responseText!='') errores.messages.push(response.responseText);
                                else errores.messages.push('Error nums: '+codigos);
                                return errores.alert();
                             },
                    failure: function (response)
                             {
                                alert('Error Interno 699. Sentimos las molestias, por favor intentelo mas tarde.' + '\n Error 699. Sorry, please try again. Thanks' + '\n Errore interno 699: problemi di comunicazione con il server, per favore riprova piú tardi');
                             }
                },'id_errores='+codigos);
            }catch(err){}
        }else return this.alert();
    };
    this.show=function()
    {
        if($('splash_error')) $('splash_error').style.display='none';
        try{ this.showAlert(); }catch(e){}
        this.clean();
    };
    this.hide=function() { $('lista_de_errores').innerHTML=''; };
    this.clean=function() { this.arrErrores=[]; this.messages=[]; };
    this.cuantos=function() { return this.arrErrores.length; };
    this.close=function() { this.processActions(); this.clean(); };
    this.processActions=function()
    {
        var actions='';
        var len=this.arrErrores.length;
        for (var y=0;y<len;y++)
            if(this.arrErrores[y].action!='') actions+=this.arrErrores[y].action;
        try { eval(actions); }catch(e) {}
    };
    this.eval=function(val)
    {
        if(this.arrErrores.length==0) return -1;
        var codigos=this.toString();
        if(codigos!='')
        {
            try
            {
                YAHOO.util.Connect.asyncRequest('GET', '/common/index.php?pg=error&squid=yes&mode=simple&id_errores='+codigos,
                {
                    success: function(response)
                             {
                                if(response.responseText!='') errores.messages.push(response.responseText);
                                else errores.messages.push('Error nums: '+codigos);
                                eval(val(errores.messages.join("\n").replace(/<br\/>/g, '\n')));
                             },
                    failure: function (response)
                             {
                                alert('Error Interno 700. Sentimos las molestias, por favor intentelo mas tarde.' + '\n Error 700. Sorry, please try again. Thanks' + '\n Errore interno 700: problemi di comunicazione con il server, per favore riprova piú tardi');
                             }
                },'id_errores='+codigos);
            }catch(err){}
        }else{
            eval(val(this.messages));
        }
        this.clean();
    };
}
//Metodos para cambiar el color de campos con errores
//Pone el color a amarillo y le da el focus
var setErrorBackColor = function(obj)
{
    if (!obj.style) return;
    obj.style.backgroundColor='#FFFF75';
    obj.onchange=setGoodBackColor;
};
//Pone el color a blanco
var setGoodBackColor = function() { this.style.backgroundColor='#FFF'; };
var loadPest = function() {Nifty("ul#navheader a","transparent top");} // OBSOLETO CON CABECERO V3
var cargaPestanas = function(pestana,productos){ YAHOO.util.Dom.addClass(pestana, 'activelink'); Atrapalo.header.setNumCartItems(); };  // OBSOLETO CON CABECERO V3
var overli = function(li){ YAHOO.util.Dom.addClass(li, 'pestSelected'); }  // OBSOLETO CON CABECERO V3
var outli = function(li){ YAHOO.util.Dom.removeClass(li, 'pestSelected'); }  // OBSOLETO CON CABECERO V3
var urlHeader = function(dominio) {
    if(dominio == 'afferralo.com' || dominio == 'atrapalo.it') {
        var productos = new Array('hom','hot','vue','vmh');
        if      (location.pathname.indexOf('/hotel') > -1)  cargaPestanas('hot',productos);
        else if (location.pathname.indexOf('/voli+hotel') > -1)  cargaPestanas('vmh',productos);
        else if (location.pathname.indexOf('/voli') > -1)  cargaPestanas('vue',productos);
        else if (location.pathname.indexOf('/home') > -1)  cargaPestanas('hom',productos);
        else  cargaPestanas('gen',productos);
    }else{
        var productos = new Array('hom','res','esp','hot','via','vue','coc','act','vmh');
        if (location.pathname.indexOf('/espectaculos') > -1) cargaPestanas('esp',productos);
            else if(location.pathname.indexOf('/home') > -1) cargaPestanas('hom',productos);
            else if(location.pathname.indexOf('/restaurantes') > -1) cargaPestanas('res',productos);
            else if(location.pathname.indexOf('/hoteles') > -1) cargaPestanas('hot',productos);
            else if(location.pathname.indexOf('/actividades') > -1) cargaPestanas('act',productos);
            else if(location.pathname.indexOf('/vuelos') > -1) cargaPestanas('vue',productos);
            else if(location.pathname.indexOf('/vuelo+hotel') > -1) cargaPestanas('vmh',productos);
            else if(location.pathname.indexOf('/viajes') > -1) cargaPestanas('via',productos);
            else if(location.pathname.indexOf('/coches') > -1) cargaPestanas('coc',productos);
            else if(location.pathname.indexOf('/Ofertas/Vuelos') > -1) cargaPestanas('vue',productos);
            else if(location.pathname.indexOf('/Ofertas/Coches') > -1) cargaPestanas('coc',productos);
            else if(location.pathname.indexOf('/OpAct') > -1) cargaPestanas('act',productos);
            else if(location.pathname.indexOf('/opiniones/ver/ESP') > -1) cargaPestanas('esp',productos);
            else if(location.pathname.indexOf('/opiniones/ver/RES') > -1) cargaPestanas('res',productos);
            else if(location.pathname.indexOf('/opiniones/ver/HOT') > -1) cargaPestanas('hot',productos);
        else {
            if($('es_home')) cargaPestanas('hom',productos);
            else cargaPestanas('gen',productos);
        }
    }
};
function checkDate(day,month,year)
{
    var monthLength = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
    if (isNaN(day) || isNaN(month) || isNaN(year)) return false;
    if (year/4 == parseInt(year/4)) monthLength[1] = 29;
    if (day > monthLength[month]) return false;
    return true;
}
// Mantiene compatibilidad con el infinitamente abusado urchinTracker
function urchinTracker(false_page)
{
    if (typeof gaTracker != 'undefined' && gaTracker != 'null' && typeof pageTracker != 'undefined')
    {
        pageTracker._trackPageview(false_page);
        gaTracker._trackPageview(false_page);
    }
}
//--- nuevo menu cabecero v3 (nov-08)
// en esta version ya no se utiliza el urlHeader() sino que hay una version mas simplificada
// ya no se utiliza el niftycorners para los tabs. todo por css
// menu cabecero 3
var Menu3 = function() {
	this.estiloHover = 	'hover';
	this.idIframe =		'mnu_iframe';
	this.marcado = 		'';
	this.overlayOn =	false;

	this.marcar = function(pes) {
		var YUD = YAHOO.util.Dom;
		var pest = "mnu_" + pes;
		if(!YUD.hasClass(pest,this.estiloHover))
		{
			YUD.addClass(pest,this.estiloHover);
			this.marcado = pest;
		}
	},
	// cuando se navega en el menu desplegable, mantener la pestana negra
	this.ov = function(mnu, accion) {
		var YUD = YAHOO.util.Dom;
		var estiloHover = this.estiloHover;
		if(mnu != this.marcado)
		{
			if(accion == 'ov') {
				if(!YUD.hasClass(mnu,estiloHover)) YUD.addClass(mnu,estiloHover);
				if(this.overlayOn) this.overlayFix(mnu);
			}
			if(accion == '') {
				if(YUD.hasClass(mnu,estiloHover)) YUD.removeClass(mnu,estiloHover);
				if(this.overlayOn) this.overlayFixOut();
			}
		}
	},
	this.overlayFix = function(mnu) {
		$(this.idIframe).style.display = 'block';

		var YUD = YAHOO.util.Dom;
		var smnu = "s" + mnu;
		var x  = YUD.getX(mnu) + 1;
		var y  = YUD.getY(mnu) + 25;
		var width = $(smnu).clientWidth - 12;
		var height = $(smnu).clientHeight - 10;

		if(YUD.getX(this.idIframe) != x)
		{
			YUD.setX(this.idIframe,x);
			YUD.setY(this.idIframe,y);
			$(this.idIframe).width = width;
			$(this.idIframe).height = height;
			this.overlayFixCasoEspecial(mnu);
		}
	},
	this.overlayFixCasoEspecial = function(mnu) {
		var x = '';
		var YUD = YAHOO.util.Dom;
		switch(mnu)
		{
			case 'mnu_coc': x = YUD.getX(mnu) - 110; break;
			case 'mnu_extra': x = YUD.getX(mnu) - 87; break;
		}
		if(x != "")
		{
			YUD.setX(this.idIframe,x);
		}
	},
	this.overlayFixInit = function(pestanas) {
		var YUE = YAHOO.util.Event;
		var vPest = new Array();

		vPest = pestanas.split(",");
		var othis = this;
		this.overlayOn = true;
		for(i=0 ; i<vPest.length ; i++)
		{
			oElement = document.getElementById(vPest[i]);
			YUE.addListener(oElement, "mouseover", function(e,pest) {
				othis.overlayFix(pest);
			},vPest[i]);
			YUE.addListener(oElement, "mouseout", function(){
				othis.overlayFixOut();
			});
		}
	},
	this.overlayFixOut = function() {
		$(this.idIframe).style.display = 'none';
	},
	// marcar la pestana activa segun producto
	this.pestanaActiva = function(dominio) {
		if(dominio == 'afferralo.com' || dominio == 'atrapalo.it') {
	        if 		(location.href.indexOf('/hotel/index.php?pg=frame&pg_action=2') > -1)  this.marcar('cva');
	        else if (location.pathname.indexOf('/hotel') > -1)  this.marcar('hot');
	        else if (location.href.indexOf('http://agriturismo.atrapalo.it/') > -1)  this.marcar('hot');
	        else if (location.pathname.indexOf('/voli+hotel') > -1)  this.marcar('vmh');
	        else if (location.pathname.indexOf('/voli') > -1)  this.marcar('vue');
	        else if (location.pathname.indexOf('/attivita') > -1)  this.marcar('act');
	        else if (location.pathname.indexOf('/spettacoli') > -1)  this.marcar('esp');
	        else if (location.href.indexOf('http://autonoleggio.atrapalo.it/') > -1)  this.marcar('aut');
	        else  this.marcar('hom');
	    }else{
	        if (location.pathname.indexOf('/espectaculos') > -1) this.marcar('esp');
	        else if(location.pathname.indexOf('/entradas') > -1) this.marcar('esp');
            else if(location.pathname.indexOf('/home') > -1) this.marcar('hom');
            else if(location.pathname.indexOf('/restaurantes') > -1) this.marcar('res');
            else if(location.pathname.indexOf('/hoteles/playa/') > -1) this.marcar('extra');
            else if(location.pathname.indexOf('/hoteles') > -1) this.marcar('hot');
            else if(location.pathname.indexOf('/actividades/escapadas') > -1) this.marcar('esc');
            else if(location.pathname.indexOf('/actividades') > -1) this.marcar('act');            
            else if(location.pathname.indexOf('/vuelos') > -1) this.marcar('vue');
            else if(location.pathname.indexOf('/vuelo+hotel') > -1) this.marcar('vmh');
            else if(location.pathname.indexOf('/viajes') > -1) this.marcar('via');
            else if(location.pathname.indexOf('/coches') > -1) this.marcar('coc');
            else if(location.hostname.indexOf('hostales') > -1) this.marcar('hos');
            else if(location.pathname.indexOf('/Ofertas/Vuelos') > -1) this.marcar('vue');
            else if(location.pathname.indexOf('/Ofertas/Coches') > -1) this.marcar('coc');
            else if(location.pathname.indexOf('/OpAct') > -1) this.marcar('act');
            else if(location.pathname.indexOf('/opiniones/ver/ESP') > -1) this.marcar('esp');
            else if(location.pathname.indexOf('/opiniones/ver/RES') > -1) this.marcar('res');
            else if(location.pathname.indexOf('/opiniones/ver/HOT') > -1) this.marcar('hot');
	        else {
	            if($('es_home')) this.marcar('hom');
	            else this.marcar('gen');
	        }
	    }
	    Atrapalo.header.setNumCartItems();
	}
}
try
{
	if (self != top && framed!=1)
	{
		if (document.images)
			top.location.replace(window.location.href);
		else
			top.location.href = window.location.href;
	}
}
catch(err)
{
	if(self!=top)
	{
		if (document.images)
			top.location.replace(window.location.href);
		else
			top.location.href = window.location.href;
	}
}
