(function($){$.fn.pajinate=function(options){var current_page="current_page";var items_per_page="items_per_page";var meta;var defaults={item_container_id:".content",items_per_page:10,nav_panel_id:".page_navigation",num_page_links_to_display:20,start_page:0,nav_label_first:"First",nav_label_prev:"Prev",nav_label_next:"Next",nav_label_last:"Last"};var options=$.extend(defaults,options);var $item_container;var $page_container;var $items;var $nav_panels;return this.each(function(){$page_container=$(this);$item_container=$(this).find(options.item_container_id);$items=$page_container.find(options.item_container_id).children();meta=$page_container;meta.data(current_page,0);meta.data(items_per_page,options.items_per_page);var total_items=$item_container.children().size();var number_of_pages=Math.ceil(total_items/options.items_per_page);var more='<span class="ellipse more">...</span>';var less='<span class="ellipse less">...</span>';var navigation_html='<a class="first_link" href="">'+options.nav_label_first+"</a>";navigation_html+='<a class="previous_link" href="">'+options.nav_label_prev+"</a>"+less;var current_link=0;while(number_of_pages>current_link){navigation_html+='<a class="page_link" href="" longdesc="'+current_link+'">'+(current_link+1)+"</a>";current_link++}navigation_html+=more+'<a class="next_link" href="">'+options.nav_label_next+"</a>";navigation_html+='<a class="last_link" href="">'+options.nav_label_last+"</a>";$nav_panels=$page_container.find(options.nav_panel_id);$nav_panels.html(navigation_html).each(function(){$(this).find(".page_link:first").addClass("first");$(this).find(".page_link:last").addClass("last")});$nav_panels.children(".ellipse").hide();$nav_panels.find(".previous_link").next().next().addClass("active_page");$items.hide();$items.slice(0,meta.data(items_per_page)).show();var total_page_no_links=$page_container.children(options.nav_panel_id+":first").children(".page_link").size();options.num_page_links_to_display=Math.min(options.num_page_links_to_display,total_page_no_links);$nav_panels.children(".page_link").hide();$nav_panels.each(function(){$(this).children(".page_link").slice(0,options.num_page_links_to_display).show()});$page_container.find(".first_link").click(function(e){e.preventDefault();movePageNumbersRight($(this),0);gotoPage(0)});$page_container.find(".last_link").click(function(e){e.preventDefault();var lastPage=total_page_no_links-1;movePageNumbersLeft($(this),lastPage);gotoPage(lastPage)});$page_container.find(".previous_link").click(function(e){e.preventDefault();showPrevPage($(this))});$page_container.find(".next_link").click(function(e){e.preventDefault();showNextPage($(this))});$page_container.find(".page_link").click(function(e){e.preventDefault();gotoPage($(this).attr("longdesc"))});gotoPage(parseInt(options.start_page));toggleMoreLess()});function showPrevPage(e){new_page=parseInt(meta.data(current_page))-1;if($(e).siblings(".active_page").prev(".page_link").length==true){movePageNumbersRight(e,new_page);gotoPage(new_page)}}function showNextPage(e){new_page=parseInt(meta.data(current_page))+1;if($(e).siblings(".active_page").next(".page_link").length==true){movePageNumbersLeft(e,new_page);gotoPage(new_page)}}function gotoPage(page_num){var ipp=meta.data(items_per_page);var isLastPage=false;start_from=page_num*ipp;end_on=start_from+ipp;$items.hide().slice(start_from,end_on).show();$page_container.find(options.nav_panel_id).children(".page_link[longdesc="+page_num+"]").addClass("active_page").siblings(".active_page").removeClass("active_page");meta.data(current_page,page_num);toggleMoreLess()}function movePageNumbersLeft(e,new_p){var new_page=new_p;var $current_active_link=$(e).siblings(".active_page");if($current_active_link.siblings(".page_link[longdesc="+new_page+"]").css("display")=="none"){$nav_panels.each(function(){$(this).children(".page_link").hide().slice(parseInt(new_page-options.num_page_links_to_display+1),new_page+1).show()})}}function movePageNumbersRight(e,new_p){var new_page=new_p;var $current_active_link=$(e).siblings(".active_page");if($current_active_link.siblings(".page_link[longdesc="+new_page+"]").css("display")=="none"){$nav_panels.each(function(){$(this).children(".page_link").hide().slice(new_page,new_page+parseInt(options.num_page_links_to_display)).show()})}}function toggleMoreLess(){if(!$nav_panels.children(".page_link:visible").hasClass("last")){$nav_panels.children(".more").show()}else{$nav_panels.children(".more").hide()}if(!$nav_panels.children(".page_link:visible").hasClass("first")){$nav_panels.children(".less").show()}else{$nav_panels.children(".less").hide()}}}})(jQuery);
/* Brazilian initialisation for the jQuery UI date picker plugin. */
/* Written by Leonildo Costa Silva (leocsilva@gmail.com). */
jQuery(function($){
$.datepicker.regional['pt'] = {
closeText: 'Fechar',
prevText: '&#x3c;Anterior',
nextText: 'Pr&oacute;ximo&#x3e;',
currentText: 'Hoje',
monthNames: ['Janeiro','Fevereiro','Mar&ccedil;o','Abril','Maio','Junho',
'Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun',
'Jul','Ago','Set','Out','Nov','Dez'],
dayNames: ['Domingo','Segunda-feira','Ter&ccedil;a-feira','Quarta-feira','Quinta-feira','Sexta-feira','Sabado'],
dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sab'],
dayNamesMin: ['Dom','Seg','Ter','Qua','Qui','Sex','Sab'],
weekHeader: 'Sm',
dateFormat: 'dd/mm/yy',
firstDay: 0,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''};
$.datepicker.setDefaults($.datepicker.regional['pt-BR']);
});
/* German initialisation for the jQuery UI date picker plugin. */
/* Written by Milian Wolff (mail@milianw.de). */
jQuery(function($){
$.datepicker.regional['de'] = {
closeText: 'schlieÃŸen',
prevText: '&#x3c;zurÃ¼ck',
nextText: 'Vor&#x3e;',
currentText: 'heute',
monthNames: ['Januar','Februar','MÃ¤rz','April','Mai','Juni',
'Juli','August','September','Oktober','November','Dezember'],
monthNamesShort: ['Jan','Feb','MÃ¤r','Apr','Mai','Jun',
'Jul','Aug','Sep','Okt','Nov','Dez'],
dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
weekHeader: 'Wo',
dateFormat: 'dd.mm.yy',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''};
});
/* English/UK initialisation for the jQuery UI date picker plugin. */
/* Written by Stuart. */
jQuery(function($){
$.datepicker.regional['en'] = {
closeText: 'Done',
prevText: 'Prev',
nextText: 'Next',
currentText: 'Today',
monthNames: ['January','February','March','April','May','June',
'July','August','September','October','November','December'],
monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'],
weekHeader: 'Wk',
dateFormat: 'dd/mm/yy',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''};
});
/* Inicializaciè´¸n en espaå¸½ol para la extensiè´¸n 'UI date picker' para jQuery. */
/* Traducido por Vester (xvester@gmail.com). */
jQuery(function($){
$.datepicker.regional['es'] = {
closeText: 'Cerrar',
prevText: '&#x3c;Ant',
nextText: 'Sig&#x3e;',
currentText: 'Hoy',
monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio',
'Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun',
'Jul','Ago','Sep','Oct','Nov','Dic'],
dayNames: ['Domingo','Lunes','Martes','Mi&eacute;rcoles','Jueves','Viernes','S&aacute;bado'],
dayNamesShort: ['Dom','Lun','Mar','Mi&eacute;','Juv','Vie','S&aacute;b'],
dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','S&aacute;'],
weekHeader: 'Sm',
dateFormat: 'dd/mm/yy',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''};
});
/* French initialisation for the jQuery UI date picker plugin. */
/* Written by Keith Wood (kbwood{at}iinet.com.au) and StÃ©phane Nahmani (sholby@sholby.net). */
jQuery(function($){
$.datepicker.regional['fr'] = {
closeText: 'Fermer',
prevText: '&#x3c;PrÃ©c',
nextText: 'Suiv&#x3e;',
currentText: 'Courant',
monthNames: ['Janvier','FÃ©vrier','Mars','Avril','Mai','Juin',
'Juillet','AoÃ»t','Septembre','Octobre','Novembre','DÃ©cembre'],
monthNamesShort: ['Jan','FÃ©v','Mar','Avr','Mai','Jun',
'Jul','AoÃ»','Sep','Oct','Nov','DÃ©c'],
dayNames: ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'],
dayNamesShort: ['Dim','Lun','Mar','Mer','Jeu','Ven','Sam'],
dayNamesMin: ['Di','Lu','Ma','Me','Je','Ve','Sa'],
weekHeader: 'Sm',
dateFormat: 'dd/mm/yy',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''};
});
/* Italian initialisation for the jQuery UI date picker plugin. */
/* Written by Antonello Pasella (antonello.pasella@gmail.com). */
jQuery(function($){
$.datepicker.regional['it'] = {
closeText: 'Chiudi',
prevText: '&#x3c;Prec',
nextText: 'Succ&#x3e;',
currentText: 'Oggi',
monthNames: ['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno',
'Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'],
monthNamesShort: ['Gen','Feb','Mar','Apr','Mag','Giu',
'Lug','Ago','Set','Ott','Nov','Dic'],
dayNames: ['Domenica','Luned&#236','Marted&#236','Mercoled&#236','Gioved&#236','Venerd&#236','Sabato'],
dayNamesShort: ['Dom','Lun','Mar','Mer','Gio','Ven','Sab'],
dayNamesMin: ['Do','Lu','Ma','Me','Gi','Ve','Sa'],
weekHeader: 'Sm',
dateFormat: 'dd/mm/yy',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''};
});
// modo de compatibilidad de JQUERY
var $j = jQuery.noConflict();
$j.datepicker.setDefaults($j.datepicker.regional['es']);
var $ = function (id){
return $j('#'+id).get(0);
}
var included_js_files = new Array();
var included_css_files = new Array();
var is_ie = $j.browser.msie;
    function $F(id) { return $(id).value; }
//deteccion de objetos
    function isObject(a) { return (typeof a == 'object' && !!a); }
    var in_array = function(needle, haystack) { for (var i = 0; i < haystack.length; i++) { if (haystack[i] == needle) return true; } return false; };
    Array.prototype.inArray = function (needle) { return in_array(needle,this); }
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;
}
}
};
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 ) );
}
    // 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;
        }
        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.header = {};
/**
* DEPRECATED
*/
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 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;
//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
{
$j.ajax({
method: 'GET',
url:  'http://www.atrapalo.com/common/error/'+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.');
}
});
} catch(err){}
}else{
eval(val(this.messages));
}
this.clean();
};
this.layer=function()
{
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.');
this.clean();
};
this.showLayer=function()
{
this.showAlert();
};
this.showAlert=function()
{
if(this.arrErrores.length==0) return -1;
var codigos=this.toString();
this.processActions();
if(codigos!='')
{
try
{
$j.ajax({
method: 'GET',
url: 'http://www.atrapalo.com/common/error/'+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.');
}
});
}catch(err){}
}else return this.alert();
};
this.show=function()
{
if($j('#splash_error')) $j('#splash_error').css('display', 'none');
try{this.showAlert();}catch(e){}
this.clean();
};
this.hide=function() {$j('#lista_de_errores').html('');};
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
{
$j.ajax({
method: 'GET',
url: 'http://www.atrapalo.com/common/error/'+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.');
}
});
}catch(err){}
}else{
eval(val(this.messages));
}
this.clean();
};
}
var setErrorBackColor = function(obj)
{
if (!obj.style) return;
obj.style.backgroundColor='#FFFF75';
obj.onchange=setGoodBackColor;
};
var setGoodBackColor = function() {this.style.backgroundColor='#FFF';};
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;
}
//COMPATIBILIDAD
YAHOO = {};
YAHOO.util = {};
YAHOO.example = {};
YAHOO.util.Event = {};
YAHOO.util.Event.addListener =  function(a,b,c){
$j("#"+a).bind(b,c);
}
YAHOO.util.Event.onDOMReady =   function(a){
$j(document).bind("ready",a);
}
YAHOO.util.Event.purgeElement =  function(a){
$j("#"+a).unbind();
}
YAHOO.util.Event.removeListener =  function(a){
$j("#"+a).unbind();
}
//Declaracion de vars
Atrapalo.hoteles={};
Atrapalo.hoteles.MONEDA ='&euro;';
Atrapalo.hoteles.MONEDADELANTE ='';
Atrapalo.hoteles.MONEDARATIO ='1';
Atrapalo.hoteles.aplicacion="HOT";
Atrapalo.hoteles.id_package_hot="12";
Atrapalo.hoteles.dir='/hoteles/';
var str_cualquiera='Cualquiera';
var str_cargando='Cargando...';
var str_selecciona='Selecciona';
var pestanaya_activa='';
var skicos = false;
var oPanel;
var mapa_cargado = false;
var d = new Date();
var opiniones=[];
var img_header_HOT=[];
var dir_hoteles='/hoteles/';
var dispo_desplegado = false;
var titulos=[];
var bus_vmh='';
var bus_hot='';
var max_zoom = 12;
var so_box=3;
var cod_idioma = 'es';
var dominio = 'atrapalo.com';
function setUpCalendar()
{
var opt = {
dateFormat: 'dd/mm/yy',
minDate: '0',
maxDate: '+1Y',
numberOfMonths: 2,
showAnim: '',
showButtonPanel: true,
closeText: 'cerrar',
onSelect: calSelectDate
};
$j('#fecha_entrada').datepicker(opt);
$j('#fecha_salida').datepicker(opt);
$j('#salida-trigger').bind('click',function(){
$j('#fecha_salida').datepicker('show');
$j('#fecha_entrada').datepicker('hide');
});
$j('#entrada-trigger').bind('click',function(){
$j('#fecha_entrada').datepicker('show');
$j('#fecha_salida').datepicker('hide');
});
}
function calSelectDate(d,obj)
{
var dates = d.split('/');
var year = parseInt(dates[2], 10), month = parseInt(dates[1], 10), day = parseInt(dates[0], 10);
var nn = 1;
var next_day=new Date(year, (month-1), (day+nn));
var prev_day=new Date(year, (month-1), (day-nn));
var fechaEntrada = ($('fecha_entrada').value) ? $('fecha_entrada').value.split('/'):null;
var fechaSalida  = ($('fecha_salida').value) ? $('fecha_salida').value.split('/'):null;
var nn_old = parseInt($('num_noches').value, 10);
if(obj.id=="fecha_entrada")
{
if(fechaSalida!=null) nn=nn_old;
next_day=new Date(year, (month-1), (day+nn));
$j('#fecha_salida').datepicker( 'setDate' , next_day);
}else if(obj.id=="fecha_salida")
{
if(fechaEntrada!=null)
{
var fecha_ini=new Date(parseInt(fechaEntrada[2], 10),parseInt(fechaEntrada[1], 10)-1,parseInt(fechaEntrada[0], 10));
var fecha_fin=new Date(parseInt(fechaSalida[2], 10),parseInt(fechaSalida[1], 10)-1,parseInt(fechaSalida[0], 10));
nn=Math.round((fecha_fin.getTime()-fecha_ini.getTime())/(1000*3600*24));
if(fecha_ini.getTime()>=fecha_fin.getTime())
{
errores.push(new error_o('12','999','002'));
errores.show();
return;
}
}
prev_day=new Date(year, (month-1), (day-nn));
$j('#fecha_entrada').datepicker( 'setDate' , prev_day);
}
$('num_noches').value = nn;
$j('#'+obj.id).datepicker( 'hide' );
}
function showCal(obj)
{
if(obj.id=='fecha_entrada'){
$j('#fecha_entrada').datepicker('show');
$j('#fecha_salida').datepicker('hide');
} else {
$j('#fecha_salida').datepicker('show');
$j('#fecha_entrada').datepicker('hide');
}
}
// Metodo que inicializa el buscador a los datos por defecto, par aque no haya problema de cahes
function initBuscador()
{
try{
$('nombre_destino1').value = '';
$('nombre_destino2').value = '';
$('id_costa2').value = '';
$('id_costaa').value = '';
$('id_costab').value = '';
}catch(err){}
$('fecha_entrada').value = '';
$('fecha_salida').value = '';
$('num_habitaciones').selectedIndex = '0';
if($('nombre_destino1'))
{
$j("#nombre_destino1").autocomplete({
minLength: 2,
delay: 0,
select: updateAutocompletId,
focus: null,
source: function(request, response) {
$j.getJSON('/wp-content/plugins/atrapalo/p.php?f='+dir_hoteles+"do_ajax/destinos_json/"+request.term,null,function(data){
response($j.map(data.ResultSet.Result, function(item) {
return {
label: item.text,
value: item.name,
id: item.id
}
}))
});
}
});
$('id_destino').value = '';
$('nombre_destino').value = '';
}
for(k=1;k<=num_max_hab;k++)
{
$('num_adultos_'+k).selectedIndex = '1';
if($('id_regimen_menu')) $('num_ninos_'+k).selectedIndex = '0';
if($('id_regimen_menu')) for(y=1;y<=3;y++) $('edad_'+k+'_'+y).selectedIndex = '0';
}
recuperarDatos();
}
function updateAutocompletId (a,ui)
{
var id=ui.item.id.split("_");
if(id[0]=='cid'){
$('id_costa').value=id[1];
$('id_destino').value='';
}else{
$('id_destino').value=id[1];
$('id_costa').value='';
}
if($('nombre_destino') ) $('nombre_destino').value=ui.item.value;
if($('nombre_destino2')) $('nombre_destino2').value=ui.item.value;
if ( pestanaya_activa=='3' || pestanaya_activa=='5' || pestanaya_activa=='4' || pestanaya_activa=='7' ) reloadHoteles('id_hotel2');
}
// Funcion que asigna el id_destino a los campos correspondientes
function setid_destino(id)
{
$('id_destino').value=id;
$('nombre_destino1').value='';
}
// Funcion que asigna el id_destino de una metadestino a los campos correspondientes
function setid_costa2(id)
{
$('id_destino').value=$('id_costa').value=id;
$('nombre_destino1').value='';
}
//BUSCADOR
//Funcion que actualiza el el destino y los nombres segun la seleccion en el desplegable dinamico
function updateId(elem)
{
var id=elem.getAttribute('id').split('_');
var name=elem.getAttribute('name');
if(id[0]=='cid') $('id_costa').value=id[1];
else $('id_destino').value=id[1];
$('nombre_destino').value=$('nombre_destino1').value=$('nombre_destino2').value=name;
if ( pestanaya_activa=='3' || pestanaya_activa=='5' || pestanaya_activa=='4' || pestanaya_activa=='7' ) reloadHoteles('id_hotel2');
}
function countNinyos()
{
var nNinos = 0;
for(i=1;i<5;i++)
{
var slc = $('num_ninos_' + i);
nNinos = nNinos + slc[slc.selectedIndex].value;
}
return nNinos;
}
function actualizaNinos(fila)
{
var lim = 0;
var i=0;
var a = $('num_adultos_'+fila);
var n = $('num_ninos_'+fila);
var nAd = parseInt(a[a.selectedIndex].value);
var nNi = parseInt(n[n.selectedIndex].value);
n.options.length = 0;
lim = (nAd > 0) ? nAd + 1 : nAd;
if(nAd<4) lim++;
while ((i<lim) && ((nAd+i) <= 6))
{
n.options[i] = new Option(i,i);
if (i == (nNi-0)) n.options[i].selected = true;
i++;
}
}
function actualizaAdultos(fila)
{
var a = $('num_adultos_'+fila);
var n = $('num_ninos_'+fila);
var nNi = parseInt(n[n.selectedIndex].value);
var nAd = parseInt(a[a.selectedIndex].value);
if (nNi > 3)
{
errores.push(new error_o('12','999','001'));
errores.show();
n.selectedIndex = 0;
}else{
a.options.length=0;
if (nNi == 0) i = 1;
else i = nNi - 1;
j=0;
while ((i+nNi) <= 6)
{
a.options[j] = new Option(i,i);
if (i == nAd) a.options[j].selected = true;
j++;
i++;
}
}
}
function mostrarFilasHabitaciones(cantidad)
{
if(cantidad=='+')
{
document.location.href=dir_hoteles+"grupos/";
return;
}
if(cantidad>1 && $('hab1')) $('hab1').style.display='block';
else if($('hab1')) $('hab1').style.display='none';
for(i=2;i<(num_max_hab+1);i++)
{
if (i<=cantidad)
{
if($('fila_hab_'+i+'_a')) $('fila_hab_'+i+'_a').style.display = (is_ie ? 'block' : 'table-row');
if($('fila_hab_'+i+'_b')) $('fila_hab_'+i+'_b').style.display = (is_ie ? 'block' : 'table-row');
if($('fila_hab_'+i+'_c')) $('fila_hab_'+i+'_c').style.display = (is_ie ? 'block' : 'table-row');
if(!$('num_ninos_'+i).options[0].selected) $('label_edad_'+i).style.display = (is_ie ? 'block' : 'table-row');
}else{
if($('fila_hab_'+i+'_a')) $('fila_hab_'+i+'_a').style.display = 'none';
if($('fila_hab_'+i+'_b')) $('fila_hab_'+i+'_b').style.display = 'none';
if($('fila_hab_'+i+'_c')) $('fila_hab_'+i+'_c').style.display = 'none';
$('label_edad_'+i).style.display    = 'none';
}
}
}
function mostrarInputsEdades(cantidad,enFila)
{
for(i=1;i<=3;i++)
{
$('edad_'+enFila+'_'+i).style.display = (cantidad>=i ? '' : 'none');
}
if($('div_edades_'+enFila)) $('div_edades_'+enFila).style.display = (cantidad>0)?(!is_ie)? 'table-row' : 'block' : 'none';
if($('label_edad_'+enFila)) $('label_edad_'+enFila).style.display = (cantidad>0)?(!is_ie)? 'table-row' : 'block' : 'none';
}
function setCheckedValue(radioObj, newValue)
{
if(!radioObj) return;
var radioLength = radioObj.length;
if(radioLength == undefined) {
radioObj.checked = (radioObj.value == newValue.toString());
return;
}
for(var i = 0; i < radioLength; i++) {
radioObj[i].checked = false;
if(radioObj[i].value == newValue.toString()) {
radioObj[i].checked = true;
}
}
}
// Funcion que comprubea los datos del formulario y si todo esta correcto lo envia
function comprobar(no_splash)
{
var error='';
if (no_splash != 1) no_splash = 0;
if (($('id_destino').value == '' && $('nombre_destino').value == ''  && (pestanaya_activa!='1' && pestanaya_activa!='2')) || ($('id_costa').value == '' && (pestanaya_activa=='1' || pestanaya_activa=='2') ) )
{
errores.push(new error_o('12','999','003','',"setErrorBackColor($('nombre_destino1'))"));
}else if ($('fecha_entrada').value=='' && $('fecha_salida').value=='')
{
document.busqueda.submit();
}else if ($('fecha_entrada').value=='' || $('fecha_salida').value=='' || $('fecha_salida').value==$('fecha_entrada').value)
{
errores.push(new error_o('12','999','004',"","setErrorBackColor($('fecha_entrada'));"));
}else{
var today = new Date();
var thisYear = today.getFullYear();
var thisMonth = today.getMonth();
var thisDay = today.getDate();
var fechaEntrada = $('fecha_entrada').value.split('/');
var fechaSalida = $('fecha_salida').value.split('/');
fecha_ini=new Date(parseInt(fechaEntrada[2], 10),parseInt(fechaEntrada[1], 10)-1,parseInt(fechaEntrada[0], 10));
fecha_fin=new Date(parseInt(fechaSalida[2], 10),parseInt(fechaSalida[1], 10)-1,parseInt(fechaSalida[0], 10));
fecha_control=new Date(thisYear,thisMonth-1,thisDay);
if (fecha_ini.valueOf()<fecha_control.valueOf()) errores.push(new error_o('12','999','005',"","setErrorBackColor($('fecha_entrada'));"));
else if (today.getUTCHours()>=20 && fecha_ini.valueOf()==fecha_control.valueOf()) errores.push(new error_o('12','999','006',""));
if($('id_hotel2')) $('id_hotel').value=$('id_hotel2').value;
$('num_noches').value=Math.round((fecha_fin.getTime()-fecha_ini.getTime())/(1000*3600*24));
if($('num_noches').value>30) {
errores.push(new error_o('12','999','007',"","setErrorBackColor($('fecha_salida'));"));
}
var i = 1;
while (error.length==0 && i<=$('num_habitaciones')[$('num_habitaciones').selectedIndex].value)
{
var j = 1;
var f = i;
var n = $('num_ninos_'+f);
if(n[n.selectedIndex])
{
while (error.length==0 && j<=n[n.selectedIndex].value)
{
if ($('edad_'+f+'_'+j).selectedIndex==0)  errores.push(new error_o('12','999','000',"Debe especificar la edad del niño "+j+" de la habitacion "+f,"setErrorBackColor($('edad_"+f+"_"+j+"'));"));
j++;
}
}
i++;
}
if (errores.cuantos()>0)
{
errores.show();
return;
}else{
if (no_splash) document.busqueda.submit();
else
{
setTimeout("document.busqueda.submit()",500);
}
return;
}
}
errores.show();
return;
}

function recuperarDatos()
{
if($('id_regimen_menu'))
{
mostrarFilasHabitaciones($F('num_habitaciones'))
for(k=1;k<=$F('num_habitaciones');k++)
{
actualizaNinos(k);
mostrarInputsEdades($('num_ninos_'+k)[$('num_ninos_'+k).selectedIndex].value,k);
}
}
}
function recalcularPaxHab() {
num_hab=$('num_habitaciones').value;
num_max_hab=5;
for(i=1;i<=num_hab;i++) {
$('num_adultos_'+i).value=$('num_adultos_1').value;
}
for(y=i;y<=num_max_hab;y++) {
$('num_adultos_'+y).value=0;
}
}
num_max_hab=5;
//Inicializaciones
$j(document).bind("ready",setUpCalendar);
var errores = new Errores();

$j(document).ready(function(){
				$j('#paging_atrapalo_result').pajinate({
					items_per_page : 10,
					item_container_id : '.alt_content',
					nav_panel_id : '.alt_page_navigation',
                                        nav_label_first : '<<',
					nav_label_last : '>>',
					nav_label_prev : '<',
					nav_label_next : '>'

				});
			});
