//
if($.cookie("css")) {
	$("link.shakinAchin").attr("href",$.cookie("css"));
	$("link.shakinAchinComm").attr("href",$.cookie("cssComm"));
};

function goToShakin(){
	$("link.shakinAchin").attr("href","/shared/css/shakin.css"); //swap css file
	$("link.shakinAchinComm").attr("href","/shared/css/community_shakin.css"); //swap css file
	$.cookie("css","/shared/css/shakin.css", {expires: 365, path: '/'}); //cookie
	$.cookie("cssComm","/shared/css/community_shakin.css", {expires: 365, path: '/'}); //cookie
	window.location.href = '/home.aspx';
};
function goToAchin(){
	$("link.shakinAchin").attr("href","/shared/css/achin.css"); //swap css file
	$("link.shakinAchinComm").attr("href","/shared/css/community_achin.css"); //swap css file
	$.cookie("css","/shared/css/achin.css", {expires: 365, path: '/'}); //cookie
	$.cookie("cssComm","/shared/css/community_achin.css", {expires: 365, path: '/'}); //cookie
	window.location.href = '/home.aspx';
};

$(document).ready(function(){
	var title = document.title;
	if (title == "The Official Website of Laura Bell Bundy :: Discography") {
		$("#discography .album .coverInfo .cover a").attr("href","javascript:void(0);");
		$("#discography .album .coverInfo h3 a").attr("href","javascript:void(0);");
	}

	$("a.swapCss, a.btn_swapCss").toggle(function() {
		if($.cookie("css") == "/shared/css/shakin.css"){
			shakin();
			shakinComm();
		} else {
			achin();
			achinComm();
		}
	}, function () {
	    if($.cookie("css") == "/shared/css/achin.css"){
			achin();
			achinComm();
		} else {
			shakin();
			shakinComm();
		}
	});
	
	// community
	$("a.btn_swapCssComm").toggle(function() {
		if($.cookie("cssComm") == "/shared/css/community_shakin.css"){
			shakin();
			shakinComm();
		} else {
			achin();
			achinComm();
		}					   
	}, function () {
	    if($.cookie("cssComm") == "/shared/css/community_achin.css"){
			achin();
			achinComm();
		} else {
			shakin();
			shakinComm();
		}
	});

	var $pics = $("#pics .photo");
	function shakin() {
		$pics.each(function(){
			var imgWidth = $(this).find('img').width();
			var imgHeight = $(this).find('img').height();
			$(this).find(".stack1, .stack2, .stack3").css({
				width: imgWidth+16,
				height: imgHeight+14
			});
			$(this).find(".stack4").css({
				width: imgWidth,
				height: imgHeight
			});
		});
		
		if($(this).is(".shakin")){
			$(this).attr("rel", "/shared/css/shakin.css");
			$(".iecss").attr("rel", "/shared/css/shakinIE.css");
		} else {
			$(this).attr("rel", "/shared/css/achin.css");
			$(".iecss").attr("rel", "/shared/css/achinIE.css");
		}
		$(this).toggleClass(".shakin");
		
		$("link.shakinAchin").attr("href",$(this).attr('rel')); //swap css file
		$(".iecss").attr("href", $(this).attr('rel')); //swap css file for ie6
		$.cookie("css",$(this).attr('rel'), {expires: 365, path: '/'}); //cookie
		return false;
	}
	
	function achin() {
		$pics.each(function(){
			$(this).find(".stack1, .stack2, .stack3, .stack4").css({
				width: "110px",
				height: "110px"
			});
		});
		
		if($(this).is(".shakin")){
			$(this).attr("rel", "/shared/css/achin.css");
			$(".iecss").attr("rel", "/shared/css/achinIE.css");
		} else {
			$(this).attr("rel", "/shared/css/shakin.css");
			$(".iecss").attr("rel", "/shared/css/shakinIE.css");
		}
		$(this).toggleClass(".shakin");
		
		$("link.shakinAchin").attr("href",$(this).attr('rel')); //swap css file
		$(".iecss").attr("href", $(this).attr('rel')); //swap css file for ie6
		$.cookie("css",$(this).attr('rel'), {expires: 365, path: '/'}); //cookie
		return false;
	}
	
	//community
	function shakinComm() {
		if($(this).is(".shakinComm")){
			$(this).attr("rel", "/shared/css/community_shakin.css");
			$(".iecss").attr("rel", "/shared/css/shakinIE.css");
		} else {
			$(this).attr("rel", "/shared/css/community_achin.css");
			$(".iecss").attr("rel", "/shared/css/achinIE.css");
		}
		$(this).toggleClass(".shakinComm");
		
		$("link.shakinAchinComm").attr("href",$(this).attr('rel')); //swap css file
		$(".iecss").attr("href", $(this).attr('rel')); //swap css file for ie6
		$.cookie("cssComm",$(this).attr('rel'), {expires: 365, path: '/'}); //cookie
		return false;
	}
	
	function achinComm() {
		if($(this).is(".shakinComm")){
			$(this).attr("rel", "/shared/css/community_achin.css");
			$(".iecss").attr("rel", "/shared/css/achinIE.css");
		} else {
			$(this).attr("rel", "/shared/css/community_shakin.css");
			$(".iecss").attr("rel", "/shared/css/shakinIE.css");
		}
		$(this).toggleClass(".shakinComm");
		
		$("link.shakinAchinComm").attr("href",$(this).attr('rel')); //swap css file
		$(".iecss").attr("href", $(this).attr('rel')); //swap css file for ie6
		$.cookie("cssComm",$(this).attr('rel'), {expires: 365, path: '/'}); //cookie
		return false;
	}
	
});
