/*######################################################################################################################################################
																Status
																	
######################################################################################################################################################*/
//检车浏览器
function IeType()
{
	if (window.navigator.userAgent.indexOf("MSIE")>=1)
	{
	//浏览器为IE
		return "ie";
	}else{
	if (window.navigator.userAgent.indexOf("Firefox")>=1)
	{
	//浏览器为Firefox
		return "ff";
	}else{
	//浏览器为其他
		return "none";
	}
	}
}

function setCookie(name,value)//Write To COOKIES
{
    var Days = 30;
    var exp  = new Date();    //new Date("December 31, 9998");
        exp.setTime(exp.getTime() + Days*24*60*60*1000);
        document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
function getCookie(name)//Read COOKIES
{
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
        if(arr=document.cookie.match(reg)) 
			return unescape(arr[2]);
        else 
			return null;
}
function delCookie(name)//Delete COOKIES
{
    var exp = new Date();
        exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
        if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}
function IsOpenCookies( )//Test COOKIES
{
	try
	{
		var test = "cncitest";
		setCookie( test , test );
		if (getCookie ( test ) == null || getCookie( test ) != test )
			return false;
		else
			return true;
	}
	catch( e )
	{
		return false;
	}
}

function IsLogin()
{
	if ( getCookie("member_id") =="" || getCookie("member_id") ==null || getCookie("UserName") == "" || getCookie("UserName") == null  )
	{
		return false;
	}
	else
	{
		return true;
	}
}

//2005-9-6
//功能相当于Asp的Request("name"),如Request["name"]
//
function QueryString()
{
	//构造参数对象并初始化
	 var name,value='',i;
	 var str=location.href.toString().toLowerCase();  //获得浏览器地址栏URL串
	 var num=str.indexOf("?")
	 str=str.substr(num+1);  //截取“?”后面的参数串
	 var arrtmp=str.split("&"); //将各参数分离形成参数数组
	 for(i=0;i < arrtmp.length;i++)
	 {
		  num=arrtmp[i].indexOf("=");
		  if(num>0)
		  {
			   name=arrtmp[i].substring(0,num);//取得参数名称
			   value=arrtmp[i].substr(num+1); //取得参数值
			   this[name]=value;    //定义对象属性并初始化
		  }  
	 }  
}


/*######################################################################################################################################################
																Login
######################################################################################################################################################*/
function Login( Path )
{
	var actionPath = Path+'ajax/index.aspx?action=login';
	if ( IsLogin() )
	{
		document.writeln( '<table width="98%" border="0" cellpadding="4" cellspacing="0">' );
		document.writeln( '<tr><td>'+ getCookie("UserName") +'您已经登录</td></tr>' );
		document.writeln( '<tr><td><a href="' + Path + 'member/main.aspx' + '" target="_parent">&gt;我的帐户</a></td></tr>' );
		document.writeln( '<tr><td><a href="' + Path + 'member/infomation.aspx' + '" target="_parent">&gt;更新我的基本信息</a></td></tr>' );
		document.writeln( '<tr><td><a href="' + Path + 'member/product.aspx' + '" target="_parent">&gt;发布产品</a></td></tr>' );
		document.writeln( '<tr><td><a href="' + Path + 'member/manage_product.aspx' + '"  target="_parent">&gt;查看我发布过的产品</a></td></tr>' );
		document.writeln( '<tr><td><a href="' + Path + 'member/guestbook.aspx' + '" target="_parent">&gt;查看我收到的留言</a></td></tr>' );
		document.writeln( '<tr><td><a href="' + Path + 'member/guestbook.aspx?action=me' + '" target="_parent">&gt;查看我发送的留言</a></td></tr>' );
		document.writeln( '<tr><td><a href="' + Path + 'member/changepassword.aspx' + '" target="_parent">&gt;修改密码</a></td></tr>' );
		document.writeln( '<tr><td><a href="' + Path + 'ajax/index.aspx?action=loginout' + '" target="_parent">&gt;退出登陆</a></td></tr>' );
		document.writeln( '</table>' );
	}
	else
	{
		document.writeln('<form method="post" action="'+ actionPath +'" name="loginform" target="_parent">');
		document.writeln('	<table width="98%" border="0" cellpadding="0" cellspacing="0">');
		document.writeln('	  <tr>');
		document.writeln('	    <td align="right">用户名：</td>');
		document.writeln('        <td><input type="text" name="username" size="12" style="width:80px;"></td>');
		document.writeln('      </tr>');
		document.writeln('  <tr>');
		document.writeln('    <td align="right">密码：</td>');
		document.writeln('    <td><input type="password" name="password"  size="12"  style="width:80px;"></td>');
		document.writeln('  </tr>');
		document.writeln('  <tr align="center">');
		document.writeln('    <td colspan="2"><input type="submit" name="Submit" value="提交"></td>');
		document.writeln('    </tr>');
		document.writeln('  <tr>');
		document.writeln('    <td align="center" colspan="2"><a href="' + Path +  'member/register.aspx" target="_parent">免费注册</a>  |  <a href="http://www.cnci.gov.cn/findpassword.html">忘记密码</a></td>');
		document.writeln('    <td>&nbsp;</td>');
		document.writeln('  </tr>');
		document.writeln('  </table>');
		
		document.writeln('</form>');
		document.writeln('<script language="javascript" type="text/javascript">');
		document.writeln('document.loginform.onsubmit=function()');
		document.writeln('{');
		document.writeln('var username = document.loginform.username;');
		document.writeln('var password = document.loginform.password');
		document.writeln('if( username.value=="" )');
		document.writeln('{');
		document.writeln('alert("请填写用户名！");');
		document.writeln('username.focus();');
		document.writeln('return false;');
		document.writeln('}');
		document.writeln('if( password.value=="" )');
		document.writeln('{');
		document.writeln('alert("请填写密码！");');
		document.writeln('password.focus();');
		document.writeln('return false;');
		document.writeln('}');
		
		document.writeln('}');
		document.writeln('</script>');
	}
}

