/**
 * @author chowa
 */

$(document).ready(function(){

	$("a.sc_btns").each(
		function(btn_index){
			$(this).mouseover(function(){
				toggleInstruct("hide");
				toggleBtnBkg(this,"show",btn_index)
			})
			$(this).mouseout(function(){
				toggleBtnBkg(this,"hide")
			})
			$(this).click(function(){
				togglePop(btn_index,"show");
			})
		}
	);


	$("a.sc_btns_ru").each(
		function(btn_index){
			$(this).mouseover(function(){
				toggleInstruct("hide");
				toggleBtnBkg(this,"show",btn_index)
			})
			$(this).mouseout(function(){
				toggleBtnBkg(this,"hide")
			})
			$(this).click(function(){
				togglePop_ru(btn_index,"show");
			})
		}
	);

	$("a.sc_btns_ua").each(
		function(btn_index){
			$(this).mouseover(function(){
				toggleInstruct("hide");
				toggleBtnBkg(this,"show",btn_index)
			})
			$(this).mouseout(function(){
				toggleBtnBkg(this,"hide")
			})
			$(this).click(function(){
				togglePop_ua(btn_index,"show");
			})
		}
	);

})



$.fn.delay = function(time, callback)
{
    return this.animate({ opacity: '+=0' }, time, callback);
}

function toggleInstruct(x){
	if (x == "hide") {
		$("#sc_instruct img").animate({"left":"-195px"},700);
	}else if (x == "show"){
		$("#sc_instruct img").delay(3000).animate({"left":"0"},700);
	}
};

function toggleBtnBkg(a,b,c){
	if (window.XMLHttpRequest) {
		curBkg = "url(/images/btn_bkgs/btn_" + [c+1]  + ".png) 0 0 no-repeat";
	} else {
		curBkg = "url(/images/btn_bkgs/btn_" + [c+1]  + ".gif) 0 0 no-repeat";
	}

	if (b == "show") {
		$(a).parent().parent().css({
			"background": curBkg
		})
	}else if (b == "hide"){
		$(a).parent().parent().css({
			"background":"none"
		})
	};
}

function togglePop(y,z){

	var loadPO = "/images/sc_popOvers/sc_po_" + [y+1] +".html";

	if (z == "show") {
		$("#backDrop").css({
			"display": "block"
		});
		$("#dyContent").load(loadPO).show();

		$("#sc_1").css({
			"display": "none"
		});
		$("#sc_2").css({
			"display": "none"
		});
		$("#sc_3").css({
			"display": "none"
		});
		$("#sc_4").css({
			"display": "none"
		});
		$("#sc_5").css({
			"display": "none"
		});
		$("#sc_6").css({
			"display": "none"
		});
		$("#sc_7").css({
			"display": "none"
		});
		$("#sc_8").css({
			"display": "none"
		});
		$("#sc_9").css({
			"display": "none"
		});
		$("#sc_10").css({
			"display": "none"
		});
		$("#sc_11").css({
			"display": "none"
		});
		$("#sc_12").css({
			"display": "none"
		});
		$("#sc_13").css({
			"display": "none"
		});



	}else if(z == "hide"){
		$("#backDrop").css({
			"display": "none"
		});

		$("#sc_1").css({
			"display": "block"
		});
		$("#sc_2").css({
			"display": "block"
		});
		$("#sc_3").css({
			"display": "block"
		});
		$("#sc_4").css({
			"display": "block"
		});
		$("#sc_5").css({
			"display": "block"
		});
		$("#sc_6").css({
			"display": "block"
		});
		$("#sc_7").css({
			"display": "block"
		});
		$("#sc_8").css({
			"display": "block"
		});
		$("#sc_9").css({
			"display": "block"
		});
		$("#sc_10").css({
			"display": "block"
		});
		$("#sc_11").css({
			"display": "block"
		});
		$("#sc_12").css({
			"display": "block"
		});
		$("#sc_13").css({
			"display": "block"
		});


		$("#dyContent").css({"top": "100px"}).unload();
	};
}

function togglePop_ua(y,z){

	var loadPO = "/images/sc_popOvers/sc_po_" + [y+1] +"_ua"+".html";

	if (z == "show") {
		$("#backDrop").css({
			"display": "block"
		});
		$("#dyContent").load(loadPO).show();

		$("#sc_1").css({
			"display": "none"
		});
		$("#sc_2").css({
			"display": "none"
		});
		$("#sc_3").css({
			"display": "none"
		});
		$("#sc_4").css({
			"display": "none"
		});
		$("#sc_5").css({
			"display": "none"
		});
		$("#sc_6").css({
			"display": "none"
		});
		$("#sc_7").css({
			"display": "none"
		});
		$("#sc_8").css({
			"display": "none"
		});
		$("#sc_9").css({
			"display": "none"
		});
		$("#sc_10").css({
			"display": "none"
		});
		$("#sc_11").css({
			"display": "none"
		});
		$("#sc_12").css({
			"display": "none"
		});
		$("#sc_13").css({
			"display": "none"
		});


	}else if(z == "hide"){
		$("#backDrop").css({
			"display": "none"
		});

		$("#sc_1").css({
			"display": "block"
		});
		$("#sc_2").css({
			"display": "block"
		});
		$("#sc_3").css({
			"display": "block"
		});
		$("#sc_4").css({
			"display": "block"
		});
		$("#sc_5").css({
			"display": "block"
		});
		$("#sc_6").css({
			"display": "block"
		});
		$("#sc_7").css({
			"display": "block"
		});
		$("#sc_8").css({
			"display": "block"
		});
		$("#sc_9").css({
			"display": "block"
		});
		$("#sc_10").css({
			"display": "block"
		});
		$("#sc_11").css({
			"display": "block"
		});
		$("#sc_12").css({
			"display": "block"
		});
		$("#sc_13").css({
			"display": "block"
		});

		$("#dyContent").css({"top": "100px"}).unload();
	};
}

function togglePop_ru(y,z){

	var loadPO = "/images/sc_popOvers/sc_po_" + [y+1] +"_ru"+".html";

	if (z == "show") {
		$("#backDrop").css({
			"display": "block"
		});
		$("#dyContent").load(loadPO).show();

		$("#sc_1").css({
			"display": "none"
		});
		$("#sc_2").css({
			"display": "none"
		});
		$("#sc_3").css({
			"display": "none"
		});
		$("#sc_4").css({
			"display": "none"
		});
		$("#sc_5").css({
			"display": "none"
		});
		$("#sc_6").css({
			"display": "none"
		});
		$("#sc_7").css({
			"display": "none"
		});
		$("#sc_8").css({
			"display": "none"
		});
		$("#sc_9").css({
			"display": "none"
		});
		$("#sc_10").css({
			"display": "none"
		});
		$("#sc_11").css({
			"display": "none"
		});
		$("#sc_12").css({
			"display": "none"
		});
		$("#sc_13").css({
			"display": "none"
		});


	}else if(z == "hide"){
		$("#backDrop").css({
			"display": "none"
		});

		$("#sc_1").css({
			"display": "block"
		});
		$("#sc_2").css({
			"display": "block"
		});
		$("#sc_3").css({
			"display": "block"
		});
		$("#sc_4").css({
			"display": "block"
		});
		$("#sc_5").css({
			"display": "block"
		});
		$("#sc_6").css({
			"display": "block"
		});
		$("#sc_7").css({
			"display": "block"
		});
		$("#sc_8").css({
			"display": "block"
		});
		$("#sc_9").css({
			"display": "block"
		});
		$("#sc_10").css({
			"display": "block"
		});
		$("#sc_11").css({
			"display": "block"
		});
		$("#sc_12").css({
			"display": "block"
		});
		$("#sc_13").css({
			"display": "block"
		});


		$("#dyContent").css({"top": "100px"}).unload();
	};
}

function toggleExtraContent(g){
	if (g == "show") {
		$("#dyContent").animate({
			"top": "30px"
		});
		$("#extra_cnt").show();
		$("#exp_cnt").hide("fast");
		$("#col_cnt").show("fast");
		$("#exp_cnt2").hide("fast");
		$("#col_cnt2").show("fast");

		$("#blackBox").show("fast");
		$("#btn_expert").show("fast");
	}else if(g == "hide"){
		$("#dyContent").animate({
			"top": "100px"
		});
		$("#extra_cnt").hide();
		$("#exp_cnt").show("fast");
		$("#col_cnt").hide("fast")
		$("#exp_cnt2").show("fast");
		$("#col_cnt2").hide("fast")

		$("#blackBox").hide("fast");
		$("#btn_expert").hide("fast");
	}
};