// JavaScript Document
$(document).ready(function() {	
	$("#box1").click(function() {
		$(this).animate({ width: "449px" } ,500);
		$("div.pwrap",this).animate({ width: "446px", opacity: "1" } ,500);
		$("h1",this).animate({ width: "380px", opacity: "1" } ,500);
		$("#boxB div.wrap").animate({ width: "192px", marginLeft: "408px", backgroundPosition: "0px 0px" } ,500);
		$("#box2 div.wrap").animate({ width: "192px", marginLeft: "598px", backgroundPosition: "0px 0px" } ,500);
		$("#box3 div.wrap").animate({ width: "192px", marginLeft: "786px", backgroundPosition: "0px 0px" } ,500);
	});
	$("#boxB").click(function() {
		$("#box1").animate({ width: "200px" } ,500);
		$("#box1 div.pwrap").animate({ width: "130px", opacity: "0.4" } ,500);
		$("#box1 h1").animate({ width: "130px", opacity: "0.4" } ,500);
		$("#boxB div.wrap").animate({ width: "440px", marginLeft: "160px", backgroundPosition: "0px -134px" } ,500);
		$("#box2 div.wrap").animate({ width: "192px", marginLeft: "598px", backgroundPosition: "0px 0px" } ,500);
		$("#box3 div.wrap").animate({ width: "192px", marginLeft: "786px", backgroundPosition: "0px 0px" } ,500);
	});
	$("#box3").click(function() {
		$("#box1").animate({ width: "200px" } ,500);
		$("#box1 div.pwrap").animate({ width: "130px", opacity: "0.4" } ,500);
		$("#box1 h1").animate({ width: "130px", opacity: "0.4" } ,500);
		$("#boxB div.wrap").animate({ width: "192px", marginLeft: "160px", backgroundPosition: "0px 0px" } ,500);
		$("#box2 div.wrap").animate({ width: "192px", marginLeft: "350px", backgroundPosition: "0px 0px" } ,500);
		$("#box3 div.wrap").animate({ width: "438px", marginLeft: "540px", backgroundPosition: "0px -134px" } ,500);
	});
	$("#box2").click(function() { $("#box2 div.wrap").css("background-position", "0px -134px");	});
	
	//specials switcher
	$("#switcher a").click(function() {
		var dir=$(this).attr("class");
		var curelm=$("#switcher span.visible");
		
		// Check whether one of the nav arrows has to be hidden
		if(dir=="swforw") {
			var nextelm=parseInt(curelm.attr("id").substr(7,1))+1;
			var nextelm2=parseInt(curelm.attr("id").substr(7,1))+2;
		} else {
			var nextelm=parseInt(curelm.attr("id").substr(7,1))-1;
			var nextelm2=parseInt(curelm.attr("id").substr(7,1))-2;
		}			
		if($('#special'+nextelm).length) { 
			nextelm=$("#special"+nextelm);
			$("#switcher a.swforw, #switcher a.swback").css("visibility","visible");
			if(!$('#special'+nextelm2).length) { 
				if(dir=="swforw") {
					$("#switcher a.swforw").css("visibility","hidden");
				} else {
					$(" #switcher a.swback").css("visibility","hidden");
				}
			}
			curelm.removeClass("visible").slideUp(300,function() { nextelm.slideDown(300).addClass("visible"); });
		}
		return false;
	});
});

