/* Author: 

*/

var iteracaoSlider = 1;
var leftNumero = 0;
var maximo;
var tempo = 5000;

var maximotables = 0;

$(document).ready(function()
{
//	$("#mainContainer").corner("bevel");
//$("#overview").corner();


$("#ptClick").click(function(){
	
	alert("Brevemente");
});
	$('.inputT').focus(function() {
	        	if($(this).val() == $(this).attr('alt'))			  									
					$(this).val("");
	});
		
		$(".inputT").focusout(function() {
			$.trim($(this).val());
			if($(this).val() == "" )
			{
				$(this).val($(this).attr('alt'));
			}
		});
 var newwindow;
            $('#bookClick').click(function()
            {
 
                newwindow= window.open('http://brownsclub.com/booking/availability.php', '', 'width=704,height=550,scrollbars=yes');
                 return false;
                });

                $('.bookOnlineClick').click(function (){
 
                   newwindow= window.open('http://brownsclub.com/booking/availability.php', '', 'width=704,height=550,scrollbars=yes');
                    return false;
                });


		//contador
	
	tempoUm = setInterval('slide()',tempo);
	$("#slide-link-1").css('background-position','center 0px');
	$("#slide-nav-div").width((35*maximo)+70+"px");
	//$("#slide-nav-div").css("margin-left",(-((35*maximo)/2))+"px");
	

	$("#slide-link-prev").click(function(){
		
		if(iteracaoSlider != 1)
		{
			if(iteracaoSlider == 0)
				iteracaoSlider =  maximo -2;
			else
				iteracaoSlider = iteracaoSlider-2;
			clearInterval(tempoUm);
			slide();
		}
		

	});
	$("#slide-link-next").click(function(){
		
		//iteracaoSlider = iteracaoSlider +2;
		if(iteracaoSlider != 0)
		{
			clearInterval(tempoUm);
			slide();
		}
	});

	//tabelas prev/next
	var positionTable = 0;
	
	$("#prev").click(function(){
		if(positionTable == 0){}
		else{
			positionTable = positionTable +648;
			$(".slotsRunner").animate({left: positionTable+"px"},{queue:false, duration:1000, easing: 'easeInBack'});
		}
	});
	$("#next").click(function(){
		if(positionTable == -(648*maximotables)){}
		else{
			positionTable = positionTable -648;
			$(".slotsRunner").animate({left: positionTable+"px"},{queue:false, duration:1000, easing: 'easeOutBack'});
		}
		
	});
	












	//HOME PAGE TEMPERATURA
	var controloTempo = 0;
	var siteRoot = "http://www.brownsclub.com/img/header";
     $.simpleWeather({
   		location: 'faro, Portugal',
     	unit: 'c',
        success: function(weather) {
          	$("#temp").html(weather.temp);
        	$("#tempLow").html(weather.low);
        	//alert(weather.image)
                                           
                                           if ((weather.image.slice(40,42) >=31 && weather.image.slice(40,42) <=34) || weather.image.slice(40,42) == 36){$("#tempo").append('<img src="'+siteRoot+'/1.png"/>');controloTempo=1;}
                                           if ((weather.image.slice(40,42) >=21 && weather.image.slice(40,42) <=22) ||(weather.image.slice(40,42) >=27 && weather.image.slice(40,42) <=30) || weather.image.slice(40,42) == 19){$("#tempo").append('<img src="'+siteRoot+'/2.png" />');controloTempo=1;}
                                           if ((weather.image.slice(40,42) >=23 && weather.image.slice(40,42) <=24) || weather.image.slice(40,42) == 26){$("#tempo").append('<img src="'+siteRoot+'/3.png"/>');controloTempo=1;}
                                           if (weather.image.slice(40,42) ==39 || weather.image.slice(40,42) ==45 || weather.image.slice(40,42) == 48){$("#tempo").append('<img src="'+siteRoot+'/4.png"/>');controloTempo=1;}
                                           if ((weather.image.slice(40,42) >=0 && weather.image.slice(40,42) <=4) ||(weather.image.slice(40,42) >=37 && weather.image.slice(40,42) <=38) || weather.image.slice(40,42) == 17 || weather.image.slice(40,42) == 35 || weather.image.slice(40,42) == 47){$("#tempo").append('<img src="'+siteRoot+'/5.png"/>');controloTempo=1;}
                                           if (weather.image.slice(40,42) == 5 || weather.image.slice(40,42) ==8 || weather.image.slice(40,42) ==9 || weather.image.slice(40,42) == 11){$("#tempo").append('<img src="'+siteRoot+'/6.png"/>');controloTempo=1;}
                                           if ((weather.image.slice(40,42) >=12 && weather.image.slice(40,42) <=16) ||(weather.image.slice(40,42) >=40 && weather.image.slice(40,42) <=44) || weather.image.slice(40,42) == 6 || weather.image.slice(40,42) == 7 || weather.image.slice(40,42) == 10 || weather.image.slice(40,42) == 18 || weather.image.slice(40,42) == 25 || weather.image.slice(40,42) == 46){$("#tempo").append('<img src="'+siteRoot+'/7.png"/>');controloTempo=1;}
   											if (controloTempo == 0){$("#tempo").append('<img src="'+siteRoot+'/2.png"/>');}   
                                   },
		error: function(error) {
                 $("#temperatura2").html('<p>'+error+'</p>');
                 }
       });

});


	function slide()
	{
		leftNumero = iteracaoSlider*-1015;
		$("#slide-runner").animate({left: leftNumero+'px'},{queue:false, duration:1500, easing: 'easeOutBack'});	
		$(".linkSlider").css('background-position','center -25px');
		$("#slide-link-"+(iteracaoSlider+1)).css('background-position','center 0px');
		iteracaoSlider = iteracaoSlider+1;
		if(iteracaoSlider == maximo)
		{
			iteracaoSlider = 0;
		}
	}




















