    function clearCookies()
    {
    	document.cookie = 'back_href=null;expires=Thu, 01-Jan-70 00:00:01 GMT;path=/';
    	document.cookie = 'back_name=null;expires=Thu, 01-Jan-70 00:00:01 GMT;path=/';
    }
	function saveTestCookie(id){
		document.cookie="test_result="+id+";expires=at end of session;path=/";
	}
	function goBack(strLang,strCountry, TestID,strDefault,iType)
	{
		var strBackHref = getCookie("back_href");
		clearCookies();
		if(strBackHref != null && strBackHref != "null" && strBackHref != '')window.location = strBackHref;
		else 
		{
			var sLink=strDefault;			
			if (iType==1) sLink = sLink+"_"+strLang+strCountry+ "_"+TestID+".kin";
			if (iType==0) sLink = sLink+"?lang="+strLang + "&ctry"+strCountry +"&id="+TestID+".jsp";

			window.location=sLink;
		}
	}
 
	function goBack2(strLang,strCountry,strDefault,iType)
	{
		var strBackHref = getCookie("back_href");
		clearCookies();
		if(strBackHref != null && strBackHref != "null" && strBackHref != '')window.location = strBackHref;
		else 
		{
			var sLink=strDefault;			
			if (iType==1) sLink = sLink+"_"+strLang+strCountry+".kin";
			if (iType==0) sLink = sLink+"?lang="+strLang + "&ctry"+strCountry +".jsp";
			
			window.location.href=sLink;
		}
	}

	function changeImage(flg){
		if(flg){
    		document.next_test.src='images/next_test_gray_img.gif';
    		document.next.src='images/next_img.gif';
		}else{
    		document.next_test.src='images/next_test_img.gif';
    		document.next.src='images/next_gray_img.gif';
		}
	}
		
	function checkRow(index)
	{
		if(document.all){
    		i=0
    		while(document.all["r"+i]){
    		document.all["r"+i].bgColor="ffffff";
    		i++;
    		}
    		document.all["r"+index].bgColor="ffcccc";
		}
	}
	
    function setTestResult(id){
        checkRow(id);
        var pain = getCookie("test_result");
        var flg = 1;
        if(id > pain)flg = 0;
		changeImage(flg);
	}
	function setResult(id,flg){
        checkRow(id);
        saveTestCookie(id);
		changeImage(flg);
	}

	function getCookie(name)
	{
    	var dc = document.cookie;
    	var prefix = name + "=";
    	var begin = dc.indexOf("; " + prefix);
    	if (begin == -1)
    	{
        	begin = dc.indexOf(prefix);
        	if (begin != 0) return null;
    	}
    	else
    	{
        	begin += 2;
    	}
    	var end = document.cookie.indexOf(";", begin);
    	if (end == -1)
    	{
        	end = dc.length;
    	}
    	return unescape(dc.substring(begin + prefix.length, end));
	}

	function openVideo(url, name)
	{
		window.open(url,name,'toolbar=no,menubar=no,scrollbars=no,status=no,resizable=yes,location=no,width=360,height=282');
	}

    function redirect(url,href,name)
    {
    	saveCookie(href,name);
    	window.location=url;
    	return false;
    }
    
    
    	function saveCookie(href, name)
    	{
    	    href = escape(href);
    		name = escape(name);
			
			document.cookie="back_name="+name+";expires=at end of session;path=/";
		    document.cookie="back_href="+href+";expires=at end of session;path=/";
		}

	function jumpToMethod(strLang)
	{
		jumpToMethod(strLang,0);
	}
	function jumpToMethod(strLang,strCountry,iType)
	{
		
		var sKinesioID = document.getElementById('changetest').value;
		var sLink = "functional";	
		
		if (sKinesioID.charAt(0) == 't')
		{
			sLink = "tapespec";
			sKinesioID = sKinesioID.substring(1);
		}
		
		if (iType==1) sLink = sLink+"_"+strLang+strCountry+ "_"+sKinesioID+".kin";
		if (iType==0) sLink = sLink+".jsp?lang="+strLang + "&ctry"+strCountry +"&id="+sKinesioID;
		window.location = sLink;
	}

    function doAccount()
    {
        window.open('../../../menu/myaccframe.html','_top');
    }
        
    function jumpURL(strURL)
    {
        window.location.href = strURL;
        return false;
    }
    
    function setResultConf(id){
        checkRow(id);
        var pain = getCookie("test_result");
        var flg = 1;
        if(id > pain)flg = 0;
		changeImageConf(flg);
	}
    function changeImageConf(flg){
		if(flg){
    		document.top.src='images/top_gray_img.gif';
    		document.next_test.src='images/next_test_img.gif';
		}else{
    		document.top.src='images/top_img.gif';
    		document.next_test.src='images/next_test_gray_img.gif';
		}
	}
