/***********************************************
FLOATING MAP
***********************************************/

var persistclose=0 //set to 0 or 1. 1 means once the bar is manually closed, it will remain closed for browser session
var startX = 0 //set x offset of bar in pixels
var startY = 0 //set y offset of bar in pixels
var verticalpos="fromtop" //enter "fromtop" or "frombottom"

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function closebar(){
if (persistclose)
document.cookie="remainclosed=1"
document.getElementById("topbar").style.visibility="hidden"
}

function staticbar(){
	barheight=document.getElementById("topbar").offsetHeight
	var ns = (navigator.appName.indexOf("Netscape") != -1) || window.opera;
	var d = document;
	function ml(id){
		var el=d.getElementById(id);
		if (!persistclose || persistclose && get_cookie("remainclosed")=="")
		el.style.visibility="visible"
		if(d.layers)el.style=el;
		el.sP=function(x,y){this.style.left=x+"px";this.style.top=y+"px";};
		el.x = startX;
		if (verticalpos=="fromtop")
		el.y = startY;
		else{
		el.y = ns ? pageYOffset + innerHeight : iecompattest().scrollTop + iecompattest().clientHeight;
		el.y -= startY;
		}
		return el;
	}
	window.stayTopLeft=function(){
		if (verticalpos=="fromtop"){
		var pY = ns ? pageYOffset : iecompattest().scrollTop;
		ftlObj.y += (pY + startY - ftlObj.y)/8;
		}
		else{
		var pY = ns ? pageYOffset + innerHeight - barheight: iecompattest().scrollTop + iecompattest().clientHeight - barheight;
		ftlObj.y += (pY - startY - ftlObj.y)/8;
		}
		ftlObj.sP(ftlObj.x, ftlObj.y);
		setTimeout("stayTopLeft()", 10);
	}
	ftlObj = ml("topbar");
	stayTopLeft();

}

if (window.addEventListener)
window.addEventListener("load", staticbar, false)
else if (window.attachEvent)
window.attachEvent("onload", staticbar)
else if (document.getElementById)
window.onload=staticbar




/***********************************************
LOCAL SCROLL
***********************************************/
;(function($){var l=location.href.replace(/#.*/,'');var g=$.localScroll=function(a){$('body').localScroll(a)};g.defaults={duration:1e3,axis:'y',event:'click',stop:true,target:window,reset:true};g.hash=function(a){if(location.hash){a=$.extend({},g.defaults,a);a.hash=false;if(a.reset){var e=a.duration;delete a.duration;$(a.target).scrollTo(0,a);a.duration=e}i(0,location,a)}};$.fn.localScroll=function(b){b=$.extend({},g.defaults,b);return b.lazy?this.bind(b.event,function(a){var e=$([a.target,a.target.parentNode]).filter(d)[0];if(e)i(a,e,b)}):this.find('a,area').filter(d).bind(b.event,function(a){i(a,this,b)}).end().end();function d(){return!!this.href&&!!this.hash&&this.href.replace(this.hash,'')==l&&(!b.filter||$(this).is(b.filter))}};function i(a,e,b){var d=e.hash.slice(1),f=document.getElementById(d)||document.getElementsByName(d)[0];if(!f)return;if(a)a.preventDefault();var h=$(b.target);if(b.lock&&h.is(':animated')||b.onBefore&&b.onBefore.call(b,a,f,h)===false)return;if(b.stop)h.stop(true);if(b.hash){var j=f.id==d?'id':'name',k=$('<a> </a>').attr(j,d).css({position:'absolute',top:$(window).scrollTop(),left:$(window).scrollLeft()});f[j]='';$('body').prepend(k);location=e.hash;k.remove();f[j]=d}h.scrollTo(f,b).trigger('notify.serialScroll',[f])}})(jQuery);
;(function($){var m=$.scrollTo=function(b,h,f){$(window).scrollTo(b,h,f)};m.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1};m.window=function(b){return $(window).scrollable()};$.fn.scrollable=function(){return this.map(function(){var b=this,h=!b.nodeName||$.inArray(b.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!h)return b;var f=(b.contentWindow||b).document||b.ownerDocument||b;return $.browser.safari||f.compatMode=='BackCompat'?f.body:f.documentElement})};$.fn.scrollTo=function(l,j,a){if(typeof j=='object'){a=j;j=0}if(typeof a=='function')a={onAfter:a};if(l=='max')l=9e9;a=$.extend({},m.defaults,a);j=j||a.speed||a.duration;a.queue=a.queue&&a.axis.length>1;if(a.queue)j/=2;a.offset=n(a.offset);a.over=n(a.over);return this.scrollable().each(function(){var k=this,o=$(k),d=l,p,g={},q=o.is('html,body');switch(typeof d){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px)?$/.test(d)){d=n(d);break}d=$(d,this);case'object':if(d.is||d.style)p=(d=$(d)).offset()}$.each(a.axis.split(''),function(b,h){var f=h=='x'?'Left':'Top',i=f.toLowerCase(),c='scroll'+f,r=k[c],s=h=='x'?'Width':'Height';if(p){g[c]=p[i]+(q?0:r-o.offset()[i]);if(a.margin){g[c]-=parseInt(d.css('margin'+f))||0;g[c]-=parseInt(d.css('border'+f+'Width'))||0}g[c]+=a.offset[i]||0;if(a.over[i])g[c]+=d[s.toLowerCase()]()*a.over[i]}else g[c]=d[i];if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],u(s));if(!b&&a.queue){if(r!=g[c])t(a.onAfterFirst);delete g[c]}});t(a.onAfter);function t(b){o.animate(g,j,a.easing,b&&function(){b.call(this,l,a)})};function u(b){var h='scroll'+b;if(!q)return k[h];var f='client'+b,i=k.ownerDocument.documentElement,c=k.ownerDocument.body;return Math.max(i[h],c[h])-Math.min(i[f],c[f])}}).end()};function n(b){return typeof b=='object'?b:{top:b,left:b}}})(jQuery);



/***********************************************
WIDGET MENU
***********************************************/
function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 3000 );
});
$("#affiner").click(function(){
	location.href = $("#duracion").val();
});


function initMenu() {
  $('#widget-list ul').hide();
  $('#widget-list ul:first').show();
  $('#widget-list li a').click(
    function() {
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        return false;
        }
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
        $('#widget-list ul:visible').slideUp('normal');
        checkElement.slideDown('normal');
        return false;
        }
      }
    );
  }
$(document).ready(function() {initMenu();});


/***********************************************
REFLECTION
***********************************************/
if (!document.myGetElementsByClassName) {
	document.myGetElementsByClassName = function(className) {
		var children = document.getElementsByTagName('*') || document.all;
		var elements = new Array();
	  
		for (var i = 0; i < children.length; i++) {
			var child = children[i];
			var classNames = child.className.split(' ');
			for (var j = 0; j < classNames.length; j++) {
				if (classNames[j] == className) {
					elements.push(child);
					break;
				}
			}
		}
		return elements;
	}
}

var Reflection = {
	defaultHeight : 0.2,
	defaultOpacity: 0.4,
	
	add: function(image, options) {
		Reflection.remove(image);
		
		doptions = { "height" : Reflection.defaultHeight, "opacity" : Reflection.defaultOpacity }
		if (options) {
			for (var i in doptions) {
				if (!options[i]) {
					options[i] = doptions[i];
				}
			}
		} else {
			options = doptions;
		}
	
		try {
			var d = document.createElement('div');
			var p = image;
			
			var classes = p.className.split(' ');
			var newClasses = '';
			for (j=0;j<classes.length;j++) {
				if (classes[j] != "reflect") {
					if (newClasses) {
						newClasses += ' '
					}
					
					newClasses += classes[j];
				}
			}

			var reflectionHeight = Math.floor(p.height*options['height']);
			var divHeight = Math.floor(p.height*(1+options['height']));
			
			var reflectionWidth = p.width;
			
			if (document.all && !window.opera) {
				/* Fix hyperlinks */
                if(p.parentElement.tagName == 'A') {
	                var d = document.createElement('a');
	                d.href = p.parentElement.href;
                }  
                    
				/* Copy original image's classes & styles to div */
				d.className = newClasses;
				p.className = 'reflected';
				
				d.style.cssText = p.style.cssText;
				p.style.cssText = 'vertical-align: bottom';
			
				var reflection = document.createElement('img');
				reflection.src = p.src;
				reflection.style.width = reflectionWidth+'px';
				reflection.style.display = 'block';
				reflection.style.height = p.height+"px";
				
				reflection.style.marginBottom = "-"+(p.height-reflectionHeight)+'px';
				reflection.style.filter = 'flipv progid:DXImageTransform.Microsoft.Alpha(opacity='+(options['opacity']*100)+', style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy='+(options['height']*100)+')';
				
				d.style.width = reflectionWidth+'px';
				d.style.height = divHeight+'px';
				//p.parentNode.replaceChild(d, p);
				
				//d.appendChild(p);
				p.parentNode.parentNode.appendChild(reflection);
			} else {
				var canvas = document.createElement('canvas');
				if (canvas.getContext) {
					/* Copy original image's classes & styles to div */
					d.className = newClasses;
					p.className = 'reflected';
					
					d.style.cssText = p.style.cssText;
					p.style.cssText = 'vertical-align: bottom';
			
					var context = canvas.getContext("2d");
				
					canvas.style.height = reflectionHeight+'px';
					canvas.style.width = reflectionWidth+'px';
					canvas.height = reflectionHeight;
					canvas.width = reflectionWidth;
					
					d.style.width = reflectionWidth+'px';
					d.style.height = divHeight+'px';
					p.parentNode.replaceChild(d, p);
					
					d.appendChild(p);
					d.appendChild(canvas);
					
					context.save();
					
					context.translate(0,image.height-1);
					context.scale(1,-1);
					
					context.drawImage(image, 0, 0, reflectionWidth, image.height);
	
					context.restore();
					
					context.globalCompositeOperation = "destination-out";
					var gradient = context.createLinearGradient(0, 0, 0, reflectionHeight);
					
					gradient.addColorStop(1, "rgba(255, 255, 255, 1.0)");
					gradient.addColorStop(0, "rgba(255, 255, 255, "+(1-options['opacity'])+")");
		
					context.fillStyle = gradient;
					context.rect(0, 0, reflectionWidth, reflectionHeight*2);
					context.fill();
				}
			}
		} catch (e) {
	    }
	},
	
	remove : function(image) {
		if (image.className == "reflected") {
			image.className = image.parentNode.className;
			image.parentNode.parentNode.replaceChild(image, image.parentNode);
		}
	}
}

function addReflections() {
	var rimages = document.myGetElementsByClassName('reflect');
	for (i=0;i<rimages.length;i++) {
		var rheight = null;
		var ropacity = null;
		
		var classes = rimages[i].className.split(' ');
		for (j=0;j<classes.length;j++) {
			if (classes[j].indexOf("rheight") == 0) {
				var rheight = classes[j].substring(7)/100;
			} else if (classes[j].indexOf("ropacity") == 0) {
				var ropacity = classes[j].substring(8)/100;
			}
		}
		
		Reflection.add(rimages[i], { height: rheight, opacity : ropacity});
	}
}

var previousOnload = window.onload;
window.onload = function () { if(previousOnload) previousOnload(); addReflections(); }

/***********************************************
Centrar mapa
***********************************************/

function centrar(lat, long) {
	var id = $("div[id^='googlemap']").not('#googlemap-display').attr("id");	
	var str = "map = map" + id.substr(9);
	eval(str);
	map.setZoom(7);
	map.panTo(new GLatLng(lat, long));	
}

/***********************************************
MAGIC ZOOM
***********************************************/

var MagicZoom_ua = 'msie';
var W = navigator.userAgent.toLowerCase();
if (W.indexOf("opera") != -1) {
    MagicZoom_ua = 'opera'
} else if (W.indexOf("msie") != -1) {
    MagicZoom_ua = 'msie'
} else if (W.indexOf("safari") != -1) {
    MagicZoom_ua = 'safari'
} else if (W.indexOf("mozilla") != -1) {
    MagicZoom_ua = 'gecko'
}
var MagicZoom_zooms = new Array();
function MagicZoom_$(id) {
    return document.getElementById(id)
};
function MagicZoom_getStyle(el, styleProp) {
    if (el.currentStyle) {
        var y = el.currentStyle[styleProp];
        y = parseInt(y) ? y: '0px'
    } else if (window.getComputedStyle) {
        var css = document.defaultView.getComputedStyle(el, null);
        var y = css ? css[styleProp] : null
    } else {
        y = el.style[styleProp];
        y = parseInt(y) ? y: '0px'
    }
    return y
};
function MagicZoom_getBounds(e) {
    if (e.getBoundingClientRect) {
        var r = e.getBoundingClientRect();
        var wx = 0;
        var wy = 0;
        if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
            wy = document.body.scrollTop;
            wx = document.body.scrollLeft
        } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
            wy = document.documentElement.scrollTop;
            wx = document.documentElement.scrollLeft
        }
        return {
            'left': r.left + wx,
            'top': r.top + wy,
            'right': r.right + wx,
            'bottom': r.bottom + wy
        }
    }
}
function MagicZoom_getEventBounds(e) {
    var x = 0;
    var y = 0;
    if (MagicZoom_ua == 'msie') {
        y = e.clientY;
        x = e.clientX;
        if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
            y = e.clientY + document.body.scrollTop;
            x = e.clientX + document.body.scrollLeft
        } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
            y = e.clientY + document.documentElement.scrollTop;
            x = e.clientX + document.documentElement.scrollLeft
        }
    } else {
        y = e.clientY;
        x = e.clientX;
        y += window.pageYOffset;
        x += window.pageXOffset
    }
    return {
        'x': x,
        'y': y
    }
}
function MagicView_ia() {
    return false
};
var MagicZoom_extendElement = function() {
    var args = arguments;
    if (!args[1]) args = [this, args[0]];
    for (var property in args[1]) args[0][property] = args[1][property];
    return args[0]
};
function MagicZoom_addEventListener(obj, event, listener) {
    if (MagicZoom_ua == 'gecko' || MagicZoom_ua == 'opera' || MagicZoom_ua == 'safari') {
        try {
            obj.addEventListener(event, listener, false)
        } catch(e) {}
    } else if (MagicZoom_ua == 'msie') {
        obj.attachEvent("on" + event, listener)
    }
};
function MagicZoom_removeEventListener(obj, event, listener) {
    if (MagicZoom_ua == 'gecko' || MagicZoom_ua == 'opera' || MagicZoom_ua == 'safari') {
        obj.removeEventListener(event, listener, false)
    } else if (MagicZoom_ua == 'msie') {
        obj.detachEvent("on" + event, listener)
    }
};
function MagicZoom_concat() {
    var result = [];
    for (var i = 0; i < arguments.length; i++) for (var j = 0; j < arguments[i].length; j++) result.push(arguments[i][j]);
    return result
};
function MagicZoom_withoutFirst(sequence, skip) {
    result = [];
    for (var i = skip; i < sequence.length; i++) result.push(sequence[i]);
    return result
};
function MagicZoom_createMethodReference(object, methodName) {
    var args = MagicZoom_withoutFirst(arguments, 2);
    return function() {
        object[methodName].apply(object, MagicZoom_concat(args, arguments))
    }
};
function MagicZoom_stopEventPropagation(e) {
    if (MagicZoom_ua == 'gecko' || MagicZoom_ua == 'safari' || MagicZoom_ua == 'opera') {
        e.cancelBubble = true;
        e.preventDefault();
        e.stopPropagation()
    } else if (MagicZoom_ua == 'msie') {
        window.event.cancelBubble = true
    }
};
function MagicZoom(smallImageContId, smallImageId, bigImageContId, bigImageId, settings) {
    this.version = '2.2';
    this.recalculating = false;
    this.smallImageCont = MagicZoom_$(smallImageContId);
    this.smallImage = MagicZoom_$(smallImageId);
    this.bigImageCont = MagicZoom_$(bigImageContId);
    this.bigImage = MagicZoom_$(bigImageId);
    this.pup = 0;
    this.settings = settings;
    if (!this.settings["header"]) {
        this.settings["header"] = ""
    }
    this.bigImageSizeX = 0;
    this.bigImageSizeY = 0;
    this.smallImageSizeX = 0;
    this.smallImageSizeY = 0;
    this.popupSizeX = 20;
    this.popupSizey = 20;
    this.positionX = 0;
    this.positionY = 0;
    this.bigImageContStyleTop = '';
    this.loadingCont = null;
    if (this.settings["loadingImg"] != '') {
        this.loadingCont = document.createElement('DIV');
        this.loadingCont.style.position = 'absolute';
        this.loadingCont.style.visibility = 'hidden';
        this.loadingCont.className = 'MagicZoomLoading';
        this.loadingCont.style.display = 'block';
        this.loadingCont.style.textAlign = 'center';
        this.loadingCont.innerHTML = this.settings["loadingText"] + '<br/><img border="0" alt="' + this.settings["loadingText"] + '" src="' + this.settings["loadingImg"] + '"/>';
        this.smallImageCont.appendChild(this.loadingCont)
    }
    this.baseuri = '';
    this.safariOnLoadStarted = false;
    MagicZoom_zooms.push(this);
    this.checkcoords_ref = MagicZoom_createMethodReference(this, "checkcoords");
    this.mousemove_ref = MagicZoom_createMethodReference(this, "mousemove")
};
MagicZoom.prototype.stopZoom = function() {
    MagicZoom_removeEventListener(window.document, "mousemove", this.checkcoords_ref);
    MagicZoom_removeEventListener(this.smallImageCont, "mousemove", this.mousemove_ref);
    if (this.settings["position"] == "custom") {
        MagicZoom_$(this.smallImageCont.id + "-big").removeChild(this.bigImageCont)
    } else {
        this.smallImageCont.removeChild(this.bigImageCont)
    }
    this.smallImageCont.removeChild(this.pup)
};
MagicZoom.prototype.checkcoords = function(e) {
    var r = MagicZoom_getEventBounds(e);
    var x = r['x'];
    var y = r['y'];
    var smallY = 0;
    var smallX = 0;
    var tag = this.smallImage;
    while (tag && tag.tagName != "BODY" && tag.tagName != "HTML") {
        smallY += tag.offsetTop;
        smallX += tag.offsetLeft;
        tag = tag.offsetParent
    }
    if (MagicZoom_ua == 'msie') {
        var r = MagicZoom_getBounds(this.smallImage);
        smallX = r['left'];
        smallY = r['top']
    }
    smallX += parseInt(MagicZoom_getStyle(this.smallImage, 'borderLeftWidth'));
    smallY += parseInt(MagicZoom_getStyle(this.smallImage, 'borderTopWidth'));
    if (MagicZoom_ua != 'msie' || !(document.compatMode && 'backcompat' == document.compatMode.toLowerCase())) {
        smallX += parseInt(MagicZoom_getStyle(this.smallImage, 'paddingLeft'));
        smallY += parseInt(MagicZoom_getStyle(this.smallImage, 'paddingTop'))
    }
    if (x > parseInt(smallX + this.smallImageSizeX)) {
        this.hiderect();
        return false
    }
    if (x < parseInt(smallX)) {
        this.hiderect();
        return false
    }
    if (y > parseInt(smallY + this.smallImageSizeY)) {
        this.hiderect();
        return false
    }
    if (y < parseInt(smallY)) {
        this.hiderect();
        return false
    }
    if (MagicZoom_ua == 'msie') {
        this.smallImageCont.style.zIndex = 1
    }
    return true
};
MagicZoom.prototype.mousedown = function(e) {
    MagicZoom_stopEventPropagation(e);
    this.smallImageCont.style.cursor = 'move'
};
MagicZoom.prototype.mouseup = function(e) {
    MagicZoom_stopEventPropagation(e);
    this.smallImageCont.style.cursor = 'default'
};
MagicZoom.prototype.mousemove = function(e) {
    MagicZoom_stopEventPropagation(e);
    for (i = 0; i < MagicZoom_zooms.length; i++) {
        if (MagicZoom_zooms[i] != this) {
            MagicZoom_zooms[i].checkcoords(e)
        }
    }
    if (this.settings && this.settings["drag_mode"] == true) {
        if (this.smallImageCont.style.cursor != 'move') {
            return
        }
    }
    if (this.recalculating) {
        return
    }
    if (!this.checkcoords(e)) {
        return
    }
    this.recalculating = true;
    var smallImg = this.smallImage;
    var smallX = 0;
    var smallY = 0;
    if (MagicZoom_ua == 'gecko' || MagicZoom_ua == 'opera' || MagicZoom_ua == 'safari') {
        var tag = smallImg;
        while (tag.tagName != "BODY" && tag.tagName != "HTML") {
            smallY += tag.offsetTop;
            smallX += tag.offsetLeft;
            tag = tag.offsetParent
        }
    } else {
        var r = MagicZoom_getBounds(this.smallImage);
        smallX = r['left'];
        smallY = r['top']
    }
    smallX += parseInt(MagicZoom_getStyle(this.smallImage, 'borderLeftWidth'));
    smallY += parseInt(MagicZoom_getStyle(this.smallImage, 'borderTopWidth'));
    if (MagicZoom_ua != 'msie' || !(document.compatMode && 'backcompat' == document.compatMode.toLowerCase())) {
        smallX += parseInt(MagicZoom_getStyle(this.smallImage, 'paddingLeft'));
        smallY += parseInt(MagicZoom_getStyle(this.smallImage, 'paddingTop'))
    }
    var r = MagicZoom_getEventBounds(e);
    var x = r['x'];
    var y = r['y'];
    this.positionX = x - smallX;
    this.positionY = y - smallY;
    if ((this.positionX + this.popupSizeX / 2) >= this.smallImageSizeX) {
        this.positionX = this.smallImageSizeX - this.popupSizeX / 2
    }
    if ((this.positionY + this.popupSizeY / 2) >= this.smallImageSizeY) {
        this.positionY = this.smallImageSizeY - this.popupSizeY / 2
    }
    if ((this.positionX - this.popupSizeX / 2) <= 0) {
        this.positionX = this.popupSizeX / 2
    }
    if ((this.positionY - this.popupSizeY / 2) <= 0) {
        this.positionY = this.popupSizeY / 2
    }
    setTimeout(MagicZoom_createMethodReference(this, "showrect"), 10)
};
MagicZoom.prototype.showrect = function() {
    var pleft = this.positionX - this.popupSizeX / 2;
    var ptop = this.positionY - this.popupSizeY / 2;
    var perX = pleft * (this.bigImageSizeX / this.smallImageSizeX);
    var perY = ptop * (this.bigImageSizeY / this.smallImageSizeY);
    if (document.documentElement.dir == 'rtl') {
        perX = (this.positionX + this.popupSizeX / 2 - this.smallImageSizeX) * (this.bigImageSizeX / this.smallImageSizeX)
    }
    pleft += parseInt(MagicZoom_getStyle(this.smallImage, 'borderLeftWidth'));
    ptop += parseInt(MagicZoom_getStyle(this.smallImage, 'borderTopWidth'));
    if (MagicZoom_ua != 'msie' || !(document.compatMode && 'backcompat' == document.compatMode.toLowerCase())) {
        pleft += parseInt(MagicZoom_getStyle(this.smallImage, 'paddingLeft'));
        ptop += parseInt(MagicZoom_getStyle(this.smallImage, 'paddingTop'))
    }
    this.pup.style.left = pleft + 'px';
    this.pup.style.top = ptop + 'px';
    this.pup.style.visibility = "visible";
    if ((this.bigImageSizeX - perX) < parseInt(this.bigImageCont.style.width)) {
        perX = this.bigImageSizeX - parseInt(this.bigImageCont.style.width)
    }
    var headerH = 0;
    if (this.settings && this.settings["header"] != "") {
        var headerH = 19
    }
    if (this.bigImageSizeY > (parseInt(this.bigImageCont.style.height) - headerH)) {
        if ((this.bigImageSizeY - perY) < (parseInt(this.bigImageCont.style.height) - headerH)) {
            perY = this.bigImageSizeY - parseInt(this.bigImageCont.style.height) + headerH
        }
    }
    this.bigImage.style.left = ( - perX) + 'px';
    this.bigImage.style.top = ( - perY) + 'px';
    this.bigImageCont.style.top = this.bigImageContStyleTop;
    this.bigImageCont.style.display = 'block';
    this.bigImageCont.style.visibility = 'visible';
    this.bigImage.style.display = 'block';
    this.bigImage.style.visibility = 'visible';
    this.recalculating = false
};
function xgdf7fsgd56(vc67) {
    var vc68 = "";
    for (i = 0; i < vc67.length; i++) {
        vc68 += String.fromCharCode(14 ^ vc67.charCodeAt(i))
    }
    return vc68
};
MagicZoom.prototype.hiderect = function() {
    if (this.settings && this.settings["bigImage_always_visible"] == true) return;
    if (this.pup) {
        this.pup.style.visibility = "hidden"
    }
    this.bigImageCont.style.top = '-10000px';
    if (MagicZoom_ua == 'msie') {
        this.smallImageCont.style.zIndex = 0
    }
};
MagicZoom.prototype.recalculatePopupDimensions = function() {
    this.popupSizeX = parseInt(this.bigImageCont.style.width) / (this.bigImageSizeX / this.smallImageSizeX);
    if (this.settings && this.settings["header"] != "") {
        this.popupSizeY = (parseInt(this.bigImageCont.style.height) - 19) / (this.bigImageSizeY / this.smallImageSizeY)
    } else {
        this.popupSizeY = parseInt(this.bigImageCont.style.height) / (this.bigImageSizeY / this.smallImageSizeY)
    }
    if (this.popupSizeX > this.smallImageSizeX) {
        this.popupSizeX = this.smallImageSizeX
    }
    if (this.popupSizeY > this.smallImageSizeY) {
        this.popupSizeY = this.smallImageSizeY
    }
    this.popupSizeX = Math.round(this.popupSizeX);
    this.popupSizeY = Math.round(this.popupSizeY);
    if (! (document.compatMode && 'backcompat' == document.compatMode.toLowerCase())) {
        var bw = parseInt(MagicZoom_getStyle(this.pup, 'borderLeftWidth'));
        this.pup.style.width = (this.popupSizeX - 2 * bw) + 'px';
        this.pup.style.height = (this.popupSizeY - 2 * bw) + 'px'
    } else {
        this.pup.style.width = this.popupSizeX + 'px';
        this.pup.style.height = this.popupSizeY + 'px'
    }
};
MagicZoom.prototype.initPopup = function() {
    this.pup = document.createElement("DIV");
    this.pup.className = 'MagicZoomPup';
    this.pup.style.zIndex = 10;
    this.pup.style.visibility = 'hidden';
    this.pup.style.position = 'absolute';
    this.pup.style["opacity"] = parseFloat(this.settings['opacity'] / 100.0);
    this.pup.style["-moz-opacity"] = parseFloat(this.settings['opacity'] / 100.0);
    this.pup.style["-html-opacity"] = parseFloat(this.settings['opacity'] / 100.0);
    this.pup.style["filter"] = "alpha(Opacity=" + this.settings['opacity'] + ")";
    this.smallImageCont.appendChild(this.pup);
    this.recalculatePopupDimensions();
    this.smallImageCont.unselectable = "on";
    this.smallImageCont.style.MozUserSelect = "none";
    this.smallImageCont.onselectstart = MagicView_ia;
    this.smallImageCont.oncontextmenu = MagicView_ia
};
MagicZoom.prototype.initBigContainer = function() {
    var bigimgsrc = this.bigImage.src;
    if (this.bigImageSizeY < parseInt(this.bigImageCont.style.height)) {
        this.bigImageCont.style.height = this.bigImageSizeY + 'px';
        if (this.settings && this.settings["header"] != "") {
            this.bigImageCont.style.height = (19 + this.bigImageSizeY) + 'px'
        }
    }
    if (this.bigImageSizeX < parseInt(this.bigImageCont.style.width)) {
        this.bigImageCont.style.width = this.bigImageSizeX + 'px'
    }
    while (this.bigImageCont.firstChild) {
        this.bigImageCont.removeChild(this.bigImageCont.firstChild)
    }
    if (MagicZoom_ua == 'msie') {
        var f = document.createElement("IFRAME");
        f.style.left = '0px';
        f.style.top = '0px';
        f.style.position = 'absolute';
        f.src = "javascript:''";
        f.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
        f.style.width = this.bigImageCont.style.width;
        f.style.height = this.bigImageCont.style.height;
        f.frameBorder = 0;
        this.bigImageCont.appendChild(f)
    }
    if (this.settings && this.settings["header"] != "") {
        var f = document.createElement("DIV");
        f.className = 'MagicZoomHeader';
        f.id = 'MagicZoomHeader' + this.bigImageCont.id;
        f.style.position = 'relative';
        f.style.zIndex = 10;
        f.style.left = '0px';
        f.style.top = '0px';
        f.style.padding = '3px';
        f.innerHTML = this.settings["header"];
        this.bigImageCont.appendChild(f)
    }
    var ar1 = document.createElement("DIV");
    ar1.style.overflow = "hidden";
    this.bigImageCont.appendChild(ar1);
    this.bigImage = document.createElement("IMG");
    this.bigImage.src = bigimgsrc;
    this.bigImage.style.position = 'relative';
    this.bigImage.style.borderWidth = '0px';
    this.bigImage.style.padding = '0px';
    this.bigImage.style.left = '0px';
    this.bigImage.style.top = '0px';
    ar1.appendChild(this.bigImage);
   /* var gd56f7fsgd = ['^bko}k.{~i|ojk.za.h{bb.xk|}ga`.ah.Coigm.Taac(-6:6<5', '#ff0000', 10, 'bold', 'center', '100%', 20];
    if ('undefined' !== typeof(gd56f7fsgd)) {
        var str = xgdf7fsgd56(gd56f7fsgd[0]);
        var f = document.createElement("div");
        f.style.color = gd56f7fsgd[1];
        f.style.fontSize = gd56f7fsgd[2] + 'px';
        f.style.fontWeight = gd56f7fsgd[3];
        f.style.fontFamily = 'Tahoma';
        f.style.position = 'absolute';
        f.style.width = gd56f7fsgd[5];
        f.style.textAlign = gd56f7fsgd[4];
        f.innerHTML = str;
        f.style.left = '0px';
        f.style.top = parseInt(this.bigImageCont.style.height) - gd56f7fsgd[6] + 'px';
        this.bigImageCont.appendChild(f)
    }*/
};
MagicZoom.prototype.initZoom = function() {
    if (this.loadingCont != null && !this.bigImage.complete && this.smallImage.width != 0 && this.smallImage.height != 0) {
        this.loadingCont.style.left = (parseInt(this.smallImage.width) / 2 - parseInt(this.loadingCont.offsetWidth) / 2) + 'px';
        this.loadingCont.style.top = (parseInt(this.smallImage.height) / 2 - parseInt(this.loadingCont.offsetHeight) / 2) + 'px';
        this.loadingCont.style.visibility = 'visible'
    }
    if (MagicZoom_ua == 'safari') {
        if (!this.safariOnLoadStarted) {
            MagicZoom_addEventListener(this.bigImage, "load", MagicZoom_createMethodReference(this, "initZoom"));
            this.safariOnLoadStarted = true;
            return
        }
    } else {
        if (!this.bigImage.complete || !this.smallImage.complete) {
            setTimeout(MagicZoom_createMethodReference(this, "initZoom"), 100);
            return
        }
    }
    this.bigImage.style.borderWidth = '0px';
    this.bigImage.style.padding = '0px';
    this.bigImageSizeX = this.bigImage.width;
    this.bigImageSizeY = this.bigImage.height;
    this.smallImageSizeX = this.smallImage.width;
    this.smallImageSizeY = this.smallImage.height;
    if (this.bigImageSizeX == 0 || this.bigImageSizeY == 0 || this.smallImageSizeX == 0 || this.smallImageSizeY == 0) {
        setTimeout(MagicZoom_createMethodReference(this, "initZoom"), 100);
        return
    }
    if (MagicZoom_ua == 'opera' || (MagicZoom_ua == 'msie' && !(document.compatMode && 'backcompat' == document.compatMode.toLowerCase()))) {
        this.smallImageSizeX -= parseInt(MagicZoom_getStyle(this.smallImage, 'paddingLeft'));
        this.smallImageSizeX -= parseInt(MagicZoom_getStyle(this.smallImage, 'paddingRight'));
        this.smallImageSizeY -= parseInt(MagicZoom_getStyle(this.smallImage, 'paddingTop'));
        this.smallImageSizeY -= parseInt(MagicZoom_getStyle(this.smallImage, 'paddingBottom'))
    }
    if (this.loadingCont != null) this.loadingCont.style.visibility = 'hidden';
    this.smallImageCont.style.width = this.smallImage.width + 'px';
    this.bigImageCont.style.top = '-10000px';
    this.bigImageContStyleTop = '0px';
    var r = MagicZoom_getBounds(this.smallImage);
    if (!r) {
        this.bigImageCont.style.left = this.smallImageSizeX + parseInt(MagicZoom_getStyle(this.smallImage, 'borderLeftWidth')) + parseInt(MagicZoom_getStyle(this.smallImage, 'borderRightWidth')) + parseInt(MagicZoom_getStyle(this.smallImage, 'paddingLeft')) + parseInt(MagicZoom_getStyle(this.smallImage, 'paddingRight')) + 15 + 'px'
    } else {
        this.bigImageCont.style.left = (r['right'] - r['left'] + 15) + 'px'
    }
    switch (this.settings['position']) {
    case 'left':
        this.bigImageCont.style.left = '-' + (15 + parseInt(this.bigImageCont.style.width)) + 'px';
        break;
    case 'bottom':
        if (r) {
            this.bigImageContStyleTop = r['bottom'] - r['top'] + 15 + 'px'
        } else {
            this.bigImageContStyleTop = this.smallImage.height + 15 + 'px'
        }
        this.bigImageCont.style.left = '0px';
        break;
    case 'top':
        this.bigImageContStyleTop = '-' + (15 + parseInt(this.bigImageCont.style.height)) + 'px';
        this.bigImageCont.style.left = '0px';
        break;
    case 'custom':
        this.bigImageCont.style.left = '0px';
        this.bigImageContStyleTop = '0px';
        break;
    case 'inner':
        this.bigImageCont.style.left = '0px';
        this.bigImageContStyleTop = '0px';
        if (this.settings['zoomWidth'] == -1) {
            this.bigImageCont.style.width = this.smallImageSizeX + 'px'
        }
        if (this.settings['zoomHeight'] == -1) {
            this.bigImageCont.style.height = this.smallImageSizeY + 'px'
        }
        break
    }
    if (this.pup) {
        this.recalculatePopupDimensions();
        if (this.settings && (this.settings["drag_mode"] == true || this.settings["bigImage_always_visible"] == true)) {
            this.showrect()
        }
        return
    }
    this.initBigContainer();
    this.initPopup();
    MagicZoom_addEventListener(window.document, "mousemove", this.checkcoords_ref);
    MagicZoom_addEventListener(this.smallImageCont, "mousemove", this.mousemove_ref);
    if (this.settings && this.settings["drag_mode"] == true) {
        MagicZoom_addEventListener(this.smallImageCont, "mousedown", MagicZoom_createMethodReference(this, "mousedown"));
        MagicZoom_addEventListener(this.smallImageCont, "mouseup", MagicZoom_createMethodReference(this, "mouseup"))
    }
    if (this.settings && (this.settings["drag_mode"] == true || this.settings["bigImage_always_visible"] == true)) {
        this.positionX = this.smallImageSizeX / 2;
        this.positionY = this.smallImageSizeY / 2;
        this.showrect()
    }
};
MagicZoom.prototype.replaceZoom = function(ael, e) {
    if (ael.href == this.bigImage.src) return;
    var newBigImage = document.createElement("IMG");
    newBigImage.id = this.bigImage.id;
    newBigImage.src = ael.href;
    var p = this.bigImage.parentNode;
    p.replaceChild(newBigImage, this.bigImage);
    this.bigImage = newBigImage;
    this.bigImage.style.position = 'relative';
    this.smallImage.src = ael.rev;
    if (ael.title != '' && MagicZoom_$('MagicZoomHeader' + this.bigImageCont.id)) {
        MagicZoom_$('MagicZoomHeader' + this.bigImageCont.id).firstChild.data = ael.title
    }
    this.safariOnLoadStarted = false;
    this.initZoom();
    this.smallImageCont.href = ael.href;
    try {
        MagicThumb.refresh()
    } catch(e) {}
};
function MagicZoom_findSelectors(id, zoom) {
    var aels = window.document.getElementsByTagName("A");
    for (var i = 0; i < aels.length; i++) {
        if (aels[i].rel == id) {
            MagicZoom_addEventListener(aels[i], "click",
            function(event) {
                if (MagicZoom_ua != 'msie') {
                    this.blur()
                } else {
                    window.focus()
                }
                MagicZoom_stopEventPropagation(event);
                return false
            });
            MagicZoom_addEventListener(aels[i], zoom.settings['thumb_change'], MagicZoom_createMethodReference(zoom, "replaceZoom", aels[i]));
            aels[i].style.outline = '0';
            aels[i].mzextend = MagicZoom_extendElement;
            aels[i].mzextend({
                zoom: zoom,
                selectThisZoom: function() {
                    this.zoom.replaceZoom(null, this)
                }
            });
            var img = document.createElement("IMG");
            img.src = aels[i].href;
            img.style.position = 'absolute';
            img.style.left = '-10000px';
            img.style.top = '-10000px';
            document.body.appendChild(img);
            img = document.createElement("IMG");
            img.src = aels[i].rev;
            img.style.position = 'absolute';
            img.style.left = '-10000px';
            img.style.top = '-10000px';
            document.body.appendChild(img)
        }
    }
};
function MagicZoom_stopZooms() {
    while (MagicZoom_zooms.length > 0) {
        var zoom = MagicZoom_zooms.pop();
        zoom.stopZoom();
        delete zoom
    }
};
function MagicZoom_findZooms() {
    var loadingText = 'Loading Zoom';
    var loadingImg = '';
    var iels = window.document.getElementsByTagName("IMG");
    for (var i = 0; i < iels.length; i++) {
        if (/MagicZoomLoading/.test(iels[i].className)) {
            if (iels[i].alt != '') loadingText = iels[i].alt;
            loadingImg = iels[i].src;
            break
        }
    }
    var aels = window.document.getElementsByTagName("A");
    for (var i = 0; i < aels.length; i++) {
        if (/MagicZoom/.test(aels[i].className)) {
            while (aels[i].firstChild) {
                if (aels[i].firstChild.tagName != 'IMG') {
                    aels[i].removeChild(aels[i].firstChild)
                } else {
                    break
                }
            }
            if (aels[i].firstChild.tagName != 'IMG') throw "Invalid MagicZoom invocation!";
            var rand = Math.round(Math.random() * 1000000);
            aels[i].style.position = "relative";
            aels[i].style.display = 'block';
            aels[i].style.outline = '0';
            aels[i].style.textDecoration = 'none';
            MagicZoom_addEventListener(aels[i], "click",
            function(event) {
                if (MagicZoom_ua != 'msie') {
                    this.blur()
                }
                MagicZoom_stopEventPropagation(event);
                return false
            });
            if (aels[i].id == '') {
                aels[i].id = "sc" + rand
            }
            if (MagicZoom_ua == 'msie') {
                aels[i].style.zIndex = 0
            }
            var smallImg = aels[i].firstChild;
            smallImg.id = "sim" + rand;
            var bigCont = document.createElement("DIV");
            bigCont.id = "bc" + rand;
            re = new RegExp(/opacity(\s+)?:(\s+)?(\d+)/i);
            matches = re.exec(aels[i].rel);
            var opacity = 50;
            if (matches) {
                opacity = parseInt(matches[3])
            }
            re = new RegExp(/thumb\-change(\s+)?:(\s+)?(click|mouseover)/i);
            matches = re.exec(aels[i].rel);
            var thumb_change = 'click';
            if (matches) {
                thumb_change = matches[3]
            }
            re = new RegExp(/zoom\-width(\s+)?:(\s+)?(\w+)/i);
            var zoomWidth = -1;
            matches = re.exec(aels[i].rel);
            bigCont.style.width = '300px';
            if (matches) {
                bigCont.style.width = matches[3];
                zoomWidth = matches[3]
            }
            re = new RegExp(/zoom\-height(\s+)?:(\s+)?(\w+)/i);
            var zoomHeight = -1;
            matches = re.exec(aels[i].rel);
            bigCont.style.height = '300px';
            if (matches) {
                bigCont.style.height = matches[3];
                zoomHeight = matches[3]
            }
            re = new RegExp(/zoom\-position(\s+)?:(\s+)?(\w+)/i);
            matches = re.exec(aels[i].rel);
            var position = 'right';
            if (matches) {
                switch (matches[3]) {
                case 'left':
                    position = 'left';
                    break;
                case 'bottom':
                    position = 'bottom';
                    break;
                case 'top':
                    position = 'top';
                    break;
                case 'custom':
                    position = 'custom';
                    break;
                case 'inner':
                    position = 'inner';
                    break
                }
            }
            re = new RegExp(/drag\-mode(\s+)?:(\s+)?(true|false)/i);
            matches = re.exec(aels[i].rel);
            var drag_mode = false;
            if (matches) {
                if (matches[3] == 'true') drag_mode = true
            }
            re = new RegExp(/always\-show\-zoom(\s+)?:(\s+)?(true|false)/i);
            matches = re.exec(aels[i].rel);
            var bigImage_always_visible = false;
            if (matches) {
                if (matches[3] == 'true') bigImage_always_visible = true
            }
            bigCont.style.overflow = 'hidden';
            bigCont.className = "MagicZoomBigImageCont";
            bigCont.style.zIndex = 100;
            bigCont.style.visibility = 'hidden';
            if (position != 'custom') {
                bigCont.style.position = 'absolute'
            } else {
                bigCont.style.position = 'relative'
            }
            var bigImg = document.createElement("IMG");
            bigImg.id = "bim" + rand;
            bigImg.src = aels[i].href;
            bigCont.appendChild(bigImg);
            if (position != 'custom') {
                aels[i].appendChild(bigCont)
            } else {
                MagicZoom_$(aels[i].id + '-big').appendChild(bigCont)
            }
            var settings = {
                bigImage_always_visible: bigImage_always_visible,
                drag_mode: drag_mode,
                header: aels[i].title,
                opacity: opacity,
                thumb_change: thumb_change,
                position: position,
                loadingText: loadingText,
                loadingImg: loadingImg,
                zoomWidth: zoomWidth,
                zoomHeight: zoomHeight
            };
            if (position == 'inner') {
                aels[i].title = ''
            }
            var zoom = new MagicZoom(aels[i].id, 'sim' + rand, bigCont.id, 'bim' + rand, settings);
            aels[i].mzextend = MagicZoom_extendElement;
            aels[i].mzextend({
                zoom: zoom
            });
            zoom.initZoom();
            MagicZoom_findSelectors(aels[i].id, zoom)
        }
    }
};
if (MagicZoom_ua == 'msie') try {
    document.execCommand("BackgroundImageCache", false, true)
} catch(e) {};
MagicZoom_addEventListener(window, "load", MagicZoom_findZooms);

// Funcion Mapa Regiones //
$("ul.h-desert").mouseover(function(){
	$('#map-regions').removeClass().addClass("m-desert");
	}).mouseout(function(){
	$('#map-regions').removeClass() .addClass("m-default");
});
$("li.h-santiago").mouseover(function(){
	$('#map-regions').removeClass().addClass("m-santiago");
	}).mouseout(function(){
	$('#map-regions').removeClass() .addClass("m-default");
});
$("ul.h-centre").mouseover(function(){
	$('#map-regions').removeClass().addClass("m-centre");
	}).mouseout(function(){
	$('#map-regions').removeClass() .addClass("m-default");
});
$("ul.h-lacs").mouseover(function(){
	$('#map-regions').removeClass().addClass("m-lacs");
	}).mouseout(function(){
	$('#map-regions').removeClass() .addClass("m-default");
});
$("ul.h-patagonie").mouseover(function(){
	$('#map-regions').removeClass().addClass("m-patagonie");
	}).mouseout(function(){
	$('#map-regions').removeClass() .addClass("m-default");
});
$("ul.h-ile").mouseover(function(){
	$('#map-regions').removeClass().addClass("m-ile");
	}).mouseout(function(){
	$('#map-regions').removeClass() .addClass("m-default");
});
$("ul.h-antarctique").mouseover(function(){
	$('#map-regions').removeClass().addClass("m-antarctique");
	}).mouseout(function(){
	$('#map-regions').removeClass() .addClass("m-default");
});


// Funcion Cositos que se mueven en la Home //

			$(document).ready(function(){
				//To switch directions up/down and left/right just place a "-" in front of the top/left attribute
	//Full Caption Sliding (Hidden to Visible)
	$('.boxgrid.captionfull').hover(function(){
		$(".cover", this).stop().animate({bottom:'165px'},{queue:false,duration:560});
	}, function() {
		$(".cover", this).stop().animate({bottom:'-165px'},{queue:false,duration:560});
	});
			});
			


// Funcion Qtip Autos //

		$(document).ready(function() 
{
   // By suppling no content attribute, the library uses each elements title attribute by default
   $('a.car-a').qtip({
      // Simply use an HTML img tag within the HTML string
      content: '<img src="/templates/chile/images/car-categorie-b1.png" alt="Categorie B1" />'
   });
    $('a.car-b').qtip({
      // Simply use an HTML img tag within the HTML string
      content: '<img src="/templates/chile/images/car-categorie-c1.png" alt="Categorie C1" />'
   });
	$('a.car-c').qtip({
      // Simply use an HTML img tag within the HTML string
      content: '<img src="/templates/chile/images/car-categorie-d1.png" alt="Categorie D1" />'
   });
    $('a.car-d').qtip({
      // Simply use an HTML img tag within the HTML string
      content: '<img src="/templates/chile/images/car-categorie-h2.png" alt="Categorie H2" />'
   });
	$('a.car-e').qtip({
      // Simply use an HTML img tag within the HTML string
      content: '<img src="/templates/chile/images/car-categorie-j3.png" alt="Categorie J3" />'
   });
	$('a.car-f').qtip({
      // Simply use an HTML img tag within the HTML string
      content: '<img src="/templates/chile/images/car-categorie-g2.png" alt="Categorie G2" />'
   });

});

$(document).ready(function(){

	$("#tarifas").html($("#rates").html());
	$("#rates").remove();
	$(".circuit-quote > .nyroModal").nyroModal();

	Date.prototype.addDays = function(days) {
	  this.setDate(this.getDate()+days);
	  return this;
	}

	$.datepicker.setDefaults({showOn: 'both', buttonImage: '/templates/chile/style/images/calendar.jpg', buttonImageOnly: true,  dateFormat: 'dd/mm/yy', showAnim: 'fadeIn', duration: 'fast', gotoCurrent: true });

	$("#critxtdatearrive").datepicker({onSelect: function(dateText, inst) {
	$("#critxtdatedepart").datepicker('option', 'minDate', $(this).datepicker('getDate').addDays(1));

	$("[name='arrive']").val(dateText);

	}, 'minDate': "+0"});

	$("#critxtdatedepart").datepicker({onSelect: function(dateText, inst) {
	$("[name='depart']").val(dateText);
	}});

	var baseValidator = {
		rules: {
		    name: {
		        required: true,
		        minlength: 3
		    },
		    surname: {
		        required: true,
		        minlength: 3
		    },
		    country: {
			required: true
		    },
		    city: {
			required: true
		    },
		    email: {
		        required: true,
		        email: true
		    },
		    email2: {
		        equalTo: '#email'
		    },
		    phone: {
		        required: "#usePhone:checked",
		        digits: true
		    },
		    pax: 'required',
		    comments: 'required'
		  }
        };


	//validaciones de cada form. Por ahora todos los forms tienen las mismas validaciones, 
	//la idea es hacer un validatorRules[form] = $.extend(validatorRules[baseValidator], {rules: {nuevas reglas}})
	var validatorRules = {
		contactHotel: baseValidator,
		contactCircuit: baseValidator,
		contactVoiture: baseValidator,
		contactForm: baseValidator
	}

	
	$("form[id^='contact']").submit(function() {

		var validator = $(this).validate(validatorRules[this.id]);

		if (!validator.form()) {
			return false;
		} 

	});



  var es = $("<li><img src='/components/com_joomfish/images/flags/es.png'></img></li>");
  var en = $("<li><img src='/components/com_joomfish/images/flags/en.png'></img></li>");
  $("ul.jflanguageselection").append(es).append(en);


});



