﻿$(document).ready(function() {
var i,l,class_atr,reg, result;
i=1;
page=1;

tempvar=1;

$('#shop_product_').hide();
//$("#slider").hide();

function sliderfunc()
{
	$(".slider-prime").hide();	
	
	$(".slider-prime").load(sliders[tempvar]);		
	$(".slider-prime").fadeIn(500);
	
	if(tempvar==(sliders.length-1))
	{
		tempvar=0;
	}
	else
	{
		tempvar++;
	}


}
sliders = new Array ("/published/publicdata/SMALLPETSDB/attachments/SC/themes/1dogs/slider/slide1.html","/published/publicdata/SMALLPETSDB/attachments/SC/themes/1dogs/slider/slide2.html","/published/publicdata/SMALLPETSDB/attachments/SC/themes/1dogs/slider/slide3.html","/published/publicdata/SMALLPETSDB/attachments/SC/themes/1dogs/slider/slide4.html");
//"/published/publicdata/SMALLPETSDB/attachments/SC/themes/1dogs/slider/slide0.html",

for(tmp=0;tmp<(sliders.length-1);tmp++)
{
	$(".slider-prime").load(sliders[tmp]);	
}

setInterval(sliderfunc, 14000);

function button_use()
{
	var speed_win=350;

	//в форе снимаем активную вкладочку
		for (k=1;k<=4;k++)
	{
		if(k==i){continue;}		
		class_atr=$("#button_"+k).attr('class');		
		reg=/-act/;		
		result=class_atr.replace(reg, "");		
		if($("#button_"+k).hasClass(result+"-act"))
		{	

			$("#button_"+k).removeClass(result+"-act");				
			$("#button_"+k).addClass(result);
			$("#button_"+k).attr("onMouseOver", "this.className='"+result+"-act'");
			$("#button_"+k).attr("onMouseOut", "this.className='"+result+"'");
		}
		$("#but"+k).hide();
	}
		
		$("#but"+i).fadeIn();
		
		$("#button_"+i).removeAttr("onMouseOver")
		$("#button_"+i).removeAttr("onMouseOut")
		class_atr=$("#button_"+i).attr('class');		
		reg=/-act/;		
		result=class_atr.replace(reg, "");	
		$("#button_"+i).addClass(result+"-act"); 

}

	$("#next").click(function(){
		if(page==3)
		{	
		$("#cat_new"+i+(3)).hide();
		page=1;
		$("#cat_new"+i+(page)).fadeIn();
		}
		else
		{		
		$("#cat_new"+i+page).hide();
		page++;
		$("#cat_new"+i+page).fadeIn();	
		}
		return false;
	})
	
	$("#prev").click(function(){
		if(page==1)
		{
		$("#cat_new"+i+(1)).hide();
		page=3;
		$("#cat_new"+i+(page)).fadeIn();
		}
		else
		{
		$("#cat_new"+i+page).hide();
		page--;
		$("#cat_new"+i+page).fadeIn();	
		}
		return false;
	})

$("#button_1").click(function(){
i=1;
page=1;
//var obj = $(this)
button_use();
return false;
});	

$("#button_2").click(function(){
i=2;
//var obj = $(this);
button_use();
return false;
});	
				   
$("#button_3").click(function(){
i=3;
//var obj = $(this);
	button_use();
return false;
});	

$("#button_4").click(function(){
i=4;
//var obj = $(this);
	button_use();
return false;
});	


$("#c_mos").click(function(){
	$("#w_mode").hide();
	$("#w_mode").load("/js/dostavka/s_mos.html");
	$("#w_mode").fadeIn();
return false;
});	

$("#c_reg").click(function(){
	$("#w_mode").hide();
	$("#w_mode").load("/js/dostavka/s_reg.html");
	$("#w_mode").fadeIn();
return false;
});	
$("#c_reg5").click(function(){
	$("#w_mode").hide();
	$("#w_mode").load("/js/dostavka/s_reg5.html");
	$("#w_mode").fadeIn();
return false;
});	
$("#c_reg10").click(function(){
	$("#w_mode").hide();
	$("#w_mode").load("/js/dostavka/s_reg10.html");
	$("#w_mode").fadeIn();
return false;
});	
$("#c_gor").click(function(){
	$("#w_mode").hide();
	$("#w_mode").load("/js/dostavka/s_gor.html");
	$("#w_mode").fadeIn();
return false;
});	
$("#c_per").click(function(){
	$("#w_mode").hide();
	$("#w_mode").load("/js/dostavka/s_per.html");
	$("#w_mode").fadeIn();
return false;
});	
$("#ekonom").click(function(){
	$("#w_mode").hide();
	$("#w_mode").load("/js/dostavka/ekonom1.html");
	$("#w_mode").fadeIn();
return false;
});	


function carouselNext(type)
{
	if($("."+type+" .carousel:visible + .carousel:hidden").length)
		{ $("."+type+" .carousel:visible").hide().next("."+type+" .carousel:hidden").fadeIn(); }
	else
		{ $("."+type+" .carousel:visible").hide().next("."+type+" .carousel:first").fadeIn(); }
}
function carouselPrev(type)
{
	if($("."+type+" .carousel:hidden + .carousel:visible").length)
		{ $("."+type+" .carousel:visible").hide().prev("."+type+" .carousel:hidden").fadeIn(); }
	else
		{ $("."+type+" .carousel:visible").hide().prev("."+type+" .carousel:last").fadeIn(); }
}

}

);
