$(function(){

var focus='1';

var ii=1;

buttons_num=($(".buttons").length)/2;
cont_tall=buttons_num*170;


var i=1;
var num=6 //$(".ads_cont").length;


var x=0;
var num_small=6 //$(".ads_cont").length;
var ads_tot_width=((num_small/2)+2)*780;







$("#prev_ad").click(function(){
focus='0';
if(i==1){
xx=(parseInt(num-1))*780;	
	
$("#ads_container").animate({right:'-5462px'},0);
$("#ads_container").animate({right:'+=780px'},1000);
i=num;
}else{
$("#ads_container").animate({right:'+=780px'},1000);
i--;
}
});



$("#next_ad").click(function(){
focus='0';	
if(i==num){
$("#ads_container").animate({right:'-2px'},0);	
$("#ads_container").animate({right:'-=780px'},1000);	
i=1;
}
else{
$("#ads_container").animate({right:'-=780px'},1000);
i++;
}	
});

/////////////////////

$("#prev_ad_small").click(function(){
focus='0';
if(x==0){
xx=(parseInt(num-1))*780;	
ads_tot_width-=780;

$("#ads_container_small").animate({right:'-'+ads_tot_width},0);
$("#ads_container_small").animate({right:'+=780px'},1000);
x=num_small-2;
}else{
$("#ads_container_small").animate({right:'+=780px'},1000);
x=x-2;
}
});

$("#next_ad_small").click(function(){
focus='0';	
if(x==num_small){
$("#ads_container_small").animate({right:'-780px'},0);	
$("#ads_container_small").animate({right:'-=780px'},1000);	
x=2;
}
else{
$("#ads_container_small").animate({right:'-=780px'},1000);
x=x+2;
}	
});


////////////////////////


$("#next_button").click(function(){
focus='0';
if(ii==1){
xx=(parseInt(buttons_num)-1)*170;	
	
$("#buttons_container").animate({right:'-'+ cont_tall +'px'},0);
$("#buttons_container").animate({right:'+=170px'},700);
ii=buttons_num;
}else{
$("#buttons_container").animate({right:'+=170px'},700);
ii--;
}
});

$("#prev_button").click(function(){
focus='0';	
if(ii==buttons_num){
$("#buttons_container").animate({right:'170px'},0);	
$("#buttons_container").animate({right:'-=170px'},700);	
ii=1;
}
else{
$("#buttons_container").animate({right:'-=170px'},1000);
ii++;
}	
});









});
