function slideSwitch() {
    var $active = $('#slider li.active');

    if ( $active.length == 0 ) $active = $('#slider li:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slider li:first');

    $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()", 5000 );
	
	var valore = $.cookie("language");
	if(valore == "it")
		{ $("#mainMenu .it").addClass("sel"); }
	else 
		{ $("#mainMenu .en").addClass("sel"); };
		
	$('span:contains(0,00)').each(function() {
		if($(this).html().length == 5) {
			$(this).html("Prezzo a richiesta");
		}
	});
	$('span:contains(0.00)').each(function() {
		if($(this).html().length == 5) {
			$(this).html("Price under request");
		}
	});
		
	$('.list td').mouseover(function() {
            $(this).addClass('selectedRow');
         }).mouseout(function() {
            $(this).removeClass('selectedRow');
         });
	
	
	$("#address_2, #guest").validate({
				rules: {
					postcode: { required: true }
				},
				messages: {
					postcode: ""
				}
			});
	
	//$.cookie('lang', 'en');
	$('.thickbox').colorbox();
});



$.extend({
getUrlVars: function(){
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
  hash = hashes[i].split('=');
  vars.push(hash[0]);
  vars[hash[0]] = hash[1];
}
return vars;
},
getUrlVar: function(name){
return $.getUrlVars()[name];
}
});

