﻿$(function(){
	init(); 
	var i = $(".key").length;
	var old_link0= $("#nav_image > div:eq(0) > a").html();
	var old_link1= $("#nav_image > div:eq(1) > a >img").attr("src");
	var old_link2= $("#nav_image > div:eq(2) > a >img").attr("src");
	var old_link3= $("#nav_image > div:eq(3) > a >img").attr("src");
	var old_link4= $("#nav_image > div:eq(4) > a >img").attr("src");
	$("#nav_image > div:eq(0)").hover(
		
	  function(){		  
		$("#nav_image > div:eq(0) > a >img").attr("src","/img/_zh/_cn/wll/index_over_01.jpg");	  
		},function(){
		$("#nav_image > div:eq(0) > a ").html(old_link0);										   
	});
	$("#nav_image > div:eq(1)").hover(
		
	  function(){		  
		$("#nav_image > div:eq(1) > a >img").attr("src","/img/_zh/_cn/wll/index_over_on_02.jpg");	  
		},function(){
		$("#nav_image > div:eq(1) > a >img").attr("src",old_link1);										   
	});
	$("#nav_image > div:eq(2)").hover(
	  
	  function(){		  
		$("#nav_image > div:eq(2) > a >img").attr("src","/img/_zh/_cn/wll/index_over_04.jpg");	  
		},function(){
		$("#nav_image > div:eq(2) > a >img").attr("src",old_link2);										   
	});
	$("#nav_image > div:eq(3)").hover(
	 
	 function(){		  
		$("#nav_image > div:eq(3) > a >img").attr("src","/img/_zh/_cn/wll/index_over_05.jpg");	  
		},function(){
		$("#nav_image > div:eq(3) > a >img").attr("src",old_link3);										   
	});
	$("#nav_image > div:eq(4)").hover(
	 
	 function(){		  
		$("#nav_image > div:eq(4) > a >img").attr("src","/img/_zh/_cn/wll/index_06_over.jpg");	  
		},function(){
		$("#nav_image > div:eq(4) > a >img").attr("src",old_link4);										   
	});
	
	$("#next").click(function(){
		if(temp1==null){
				alert("请进行选择！");
				return false;
		}else{
			temp1=null;
		}
		var flag = false;
		$("#question .key").each(function(j, n){			
			
			if(flag){
				if(i == j+1){
					$("#next").attr("src","/img/_zh/_cn/wll/view-result.gif");
				}
				$(n).css("display","block");	
				$("#question").css("background","url(/img/_zh/_cn/wll/question-"+(j+1)+".gif) no-repeat top right");
				$("#testPic").css("background","url(/img/_zh/_cn/wll/test-pic-"+(j+1)+".jpg) no-repeat top left");
				flag = false;
				return false;
			}
			if($(n).css("display")=="block"){
				flag = true;
				if(i == j+1){
					location.href="/_zh/_cn/wll/white_test_result.aspx";
					var key1=readCookie("key1");
					var key2=readCookie("key2");
					var key3=readCookie("key3");
					var key4=readCookie("key4");
					var score1=0;
					var score2=0;
					var score3=0;
					var score4=0;
					var sum_score=0;
					if(key1=="a")score1=1;
					if(key1=="b")score1=2;
					if(key1=="c")score1=3;
					if(key1=="d")score1=4;
					
					if(key2=="a")score2=1;
					if(key2=="b")score2=2;
					if(key2=="c")score2=3;
					if(key2=="d")score2=4;
					
					
					if(key3=="a")score3=2;
					if(key3=="b")score3=4;
					
					
					if(key4=="a")score4=1;
					if(key4=="b")score4=2;
					if(key4=="c")score4=3;
					if(key4=="d")score4=4;
					sum_score=score1 + score2 + score3 + score4;
					
					if(sum_score>0 && sum_score < 7){
						//alert("1");
						//$("#result").css("display","none");
						//$(".result").css("display","none");
					}
					if(sum_score>=7 && sum_score < 12){
						location.href="/_zh/_cn/wll/white_test_result1.aspx";
						//alert("2");
						//document.getElementById("result").style.display="none";
						//document.getElementById("result1").style.display="inline";
						
					}
					if(sum_score>=12 && sum_score <= 16){
						location.href="/_zh/_cn/wll/white_test_result2.aspx";
					}
					
				}else{
					$(n).css("display","none");	
				}
			}
		});  
	});
	var temp;
	var temp1 = null;
	$("#question .key img").click(function(){
		var name = $(this).attr("id");
		var name1 = name.substring(0,name.indexOf("_"));
		 eraseCookie(name.substring(0,name.indexOf("_")));
		createCookie(name.substring(0,name.indexOf("_")),name.substring(name.indexOf("_")+1));
		$("#question .key img").css("background-position","0 0");
		$(this).css("background-position","0 -22px");
		temp = this;
		temp1 = name1;
	});
	$("#question .key img").hover(
		function(){
			if(this != temp)
				$(this).css("background-position","0 -22px");
		},
		function(){
			if(this != temp)
				$(this).css("background-position","0 0");
		}
	);
});
var init = function(){
	$("#key1").css("display","block");	
}