
/********************************************************* 
### 函数名  : getUrlParam()
### 功能    : 从URL中读取类似CGI参数值
### 入参    : 变量名
### 出参    : 变量值
### 作者    : mokymo 
### 创建日期: 2004.11.08
### 最后修改: 2005.08.02
*********************************************************/
function getUrlParam(varName)
{
    var url = window.location.href;
    var urlArray=url.split("?");
    if (urlArray.length<2) return null;
    var paramArray=urlArray[1].split("&");
    var paramStr;
    for(i=0;i<paramArray.length;i++)
    {
        paramStr=paramArray[i].split("=");
        if (paramStr.length<2) continue;
        if(paramStr[0]==varName) return unescape(paramStr[1]);
    }
    return null;
}
/*
//	测试URL: getUrlParam.html?gr_id=gid&parent_gname=p_gname&child_gname=c_gname
document.writeln("gr_id="+getUrlParam("gr_id"));
document.writeln("parent_gname="+getUrlParam("parent_gname"));
document.writeln("child_gname="+getUrlParam("child_gname"));
*/


/**
 *	function:
 *		get value from cookie
 *	# in :	sKey
 *	# out:	null on error|value on success
 *	history:
 *		<author>	<time>		<version >	<desc>
 *		moky mo		2004/12/29	0.1			create
 *		moky mo		2005/06/07	0.2			modify
 */
function getCookie(sKey)
{
	var sCookie = document.cookie;
	var sTag = sKey + "=";
	
	var iBegin = sCookie.indexOf(sTag);
	if (iBegin < 0)	return null;
	
	iBegin += sTag.length;
	
	var iEnd = sCookie.indexOf(";", iBegin);
	if (iEnd < 0)	iEnd = sCookie.length;
	
	return sCookie.substring(iBegin, iEnd);
}

/**
 *	function:
 *		set value to cookie with domain(current domain as default)
 *	# in :	sKey, sValue, sDomain, sPath, sExpires, blSecure
 *	# out:	none
 *	history:
 *		<author>	<time>		<version >	<desc>
 *		moky mo		2005/05/16	0.1			create
 *		moky mo		2005/06/07	1.1			add domain
 */
function setCookie(sKey, sValue, sDomain, sPath, sExpires, blSecure)
{
	var sCookieStr = sKey + "=" + sValue + ";";
	if (sDomain)	sCookieStr += " DOMAIN=" + sDomain + ";";
	if (sPath)		sCookieStr += " PATH=" + sPath + ";";
	if (sExpires)	sCookieStr += " EXPIRES=" + sExpires + ";";
	if (blSecure)	sCookieStr += " SECURE";
	
	document.cookie = sCookieStr;
}

/**
 *	function:
 *			delete cookie
 *	# in :	key
 *	# out:	none
 *	history:
 *		<author>	<time>		<version >	<desc>
 *		moky mo		2005/05/16	0.1			create
 *		moky mo		2005/06/07	0.2			modify
 */
function delCookie(sKey) 
{
	var tNow = new Date();
	setCookie(sKey, "", null, null, tNow.toGMTString(), null);
}

/*
//-- test it.
setCookie("UINSSO", "1292823", "qq.com");
setCookie("Name", "Moky");
 
document.write("<br>");
document.write(getCookie("UINSSO"));
document.write("<br>");
document.write(getCookie("Name"));

delCookie("Name");

document.write("<br>");
document.write(getCookie("Name"));
*/
function answer()
{
	form1.anlist.value='';
    var i=0;
	for(i=0;i<2;i++)
	{
	   if(form1.an1[i].checked==true) 
	   form1.anlist.value+=i.toString();
	}
    for(i=0;i<2;i++)
	{
	   if(form1.an2[i].checked==true) 
	   form1.anlist.value+=i.toString();
	}
	 for(i=0;i<2;i++)
	{
	   if(form1.an3[i].checked==true) 
	   form1.anlist.value+=i.toString();
	}
	 for(i=0;i<2;i++)
	{
	   if(form1.an4[i].checked==true) 
	   form1.anlist.value+=i.toString();
	}
	 for(i=0;i<2;i++)
	{
	   if(form1.an5[i].checked==true) 
	   form1.anlist.value+=i.toString();
	}
	if(form1.anlist.value.length!=5)
	{
	  alert("请回答所有题目！");
	  return false;
	}
	return true;
}
