/**
 * @author chowa
 */

var cur_dy;
var cur_dy_num;
 
$(document).ready(function(){

	var objects=$("a.sc_btns");
	objects.each(
		function(btn_index){
			var myrel=objects[btn_index].rel;
			$(this).mouseover(function(){
				toggleInstruct("hide");
				toggleBtnBkg(this,"show",btn_index)
			})
			$(this).mouseout(function(){
				toggleBtnBkg(this,"hide")
			})
			$(this).click(function(){
				togglePop(myrel,"show");
			})
		}
	);
	
//	var t_div = $("div.sc_title");
//	t_div.mouseover(function(){toggleInstruct("show")});
	
})


$.fn.delay = function(time, callback)
{
    return this.animate({ opacity: '+=0' }, time, callback);
}

function toggleInstruct(x){
	if (x == "hide") {
		$("#sc_instruct img").stop();
		$("#sc_instruct img").animate({"left":"-195px"},700);
	}else if (x == "show"){
		$("#sc_instruct img").stop();
		$("#sc_instruct img").animate({"left":"0"},700);
	}
};

function toggleBtnBkg(a,b,c){
//	if (window.XMLHttpRequest) {
		curBkg = "url(/images/skinproblems/btn_bkgs/btn_" + [c+1]  + ".png) 0 0 no-repeat";
//	} else {
//		curBkg = "url(/images/skinproblems/btn_bkgs/btn_" + [c+1]  + ".gif) 0 0 no-repeat";
//	}

	if (b == "show") {
		//alert($(a).parent().prevObject);
		$(a).parent().prev().css({
			"background": curBkg
		})
	}else if (b == "hide"){
		$(a).parent().prev().css({
			"background":"none"
		})
	};
}

function togglePop(y,z){
	var loadPO = "/beauty/advise/skincare/solve/solve_" + [y] + ".html?isNaked=1&rand=" + Math.random();

	if (z == "show") {
		if (y==49) {
			cur_dy = "#dyContent_1";
		} else { 
			cur_dy = "#dyContent";
		}
		cur_dy_num = y;
		$("#backDrop").css({
			"display": "block"
		});
		$(cur_dy).load(loadPO).show();
		
	}else if(z == "hide"){
		if (cur_dy_num==49) {
			cur_dy = "#dyContent_1";
		} else { 
			cur_dy = "#dyContent";
		}
		$("#backDrop").css({
			"display": "none"
		});
		$(cur_dy).css({"top": "000px"});
		$(cur_dy)[0].innerHTML='';
	};
}

function toggleExtraContent(g){
	if (g == "show") {
		$(cur_dy).animate({
			"top": "30px"
		});
		$("#extra_cnt").show();
		$("#extra_cnt_2").show();
		$("#exp_cnt").hide("fast");
		$("#col_cnt").show("fast");
		$("#exp_cnt2").hide("fast");
		$("#exp_cnt3").hide("fast");
		$("#col_cnt2").show("fast");
		$("#col_cnt3").show("fast");
		
		$("#blackBox").show("fast");
		$("#btn_expert").show("fast");
	}else if(g == "hide"){
		$(cur_dy).animate({
			"top": "100px"
		});
		$("#extra_cnt").hide();
		$("#extra_cnt_2").hide();
		$("#exp_cnt").show("fast");
		$("#col_cnt").hide("fast")
		$("#exp_cnt2").show("fast");
		$("#col_cnt2").hide("fast")
		
		$("#blackBox").hide("fast");
		$("#btn_expert").hide("fast");
	}
};
