﻿	var pagesize=10;
	function LoadScript( url )
	{
		document.write( '<script type="text/javascript" src="' + url + '" onerror="alert(\'Error loading \' + this.src);"><\/script>' ) ;
	}

	function show_car_content()
	{
		var id = GetCookie("CCodes");
		var content,nr;
		var all_money=0;
		var all_num=0;
		if(id!=null)
		{
			tt1=id.split("|");
			for(ii=0;ii<= tt1.length-1;ii++)
			{
				content = GetCookie("CCode"+tt1[ii]);
				if(content!=null)
				{
					nr=content.split("|");
					money=parseFloat(nr[2])*parseFloat(nr[3]);
					all_money=parseFloat(all_money)+nr[2]*parseInt(nr[3]);
					all_num=all_num+parseInt(nr[3]);
				}
			}
		}
		document.write("\r\n<div class=\"CartInfoWrap\">\r\n  <div class=\"body\">\r\n    <div class=\"info\">A total of choice:"+all_num+ "<br/>\r\n      Total amount：<br/>\r\n      <strong>￥"+all_money+"</strong>Dollars</div>\r\n    <ul>\r\n      \r\n    </ul>\r\n    <div class=\"button\"><a href=\"show_car.php\" target=\"_blank\">goincart>>></a></div>\r\n  </div>\r\n</div>\r\n");
	}
	
	function show_denglu_content()
	{
		var typeid = GetCookie("usertype");
		var userid=GetCookie("userid");
		if(typeid!=null)
		{
			document.write('<DIV class=IndexLoginWrap style="margin-top:10px;">');
			document.write('<DIV class=loginbox style="padding-left:10px;padding-top:20px;"><STRONG>'+userid+'</STRONG> 欢迎您的到来！ ');
			var admintype = GetCookie("usertype");
			if(admintype!=null||admintype!='0')
			{
				document.write('<div class="layer10"><a href="manage/index.php">To Manage </a></div>');
			}
			document.write('<DIV class=button><A href="user_information.php"><IMG alt="Enter the Member Center" src="images/icon18.gif"></A><A href="logout.php" onClick="return if_logout()"><IMG alt="Logout" src="images/icon19.gif"></A></DIV></DIV></DIV>');
		}
		else
		{
			document.write('<FORM name=FORM_TPL_LOGIN onsubmit="return Form_Validator(this)" action=login_result.php method=post>');
document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0" style="float:left;">');
document.write('<tr>');
document.write('<td width="24%" height="30">用户名:</td>');
document.write('<td colspan="2"><input name="username" type="text" class="input1" size="21"  id="UserLogIn1_txtUid" /></td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td height="30">密&nbsp;  码:</td>');
document.write('<td colspan="2"><input type="password" class="input1" size="21" name="userpassword" id="UserLogIn1_txtPwd" /></td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td height="30">&nbsp;</td>');
document.write('<td width="25%" align="right"><input id=Submit type=submit name=Submit class="buttom3" value="Login" onclick=""/></td>');
document.write('<td width="51%" align="center"><input name="button" type="button" class="buttom4" value="Register now" onclick=\"window.location=\'shengming.php\'\" /></td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td height="30">&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td align="center" class="td1"><a href="mima.php">Forgotten passwords?</a></td>');
document.write('</tr>');
document.write('</table>');
document.write('</form>');
		}
	}
	
	function if_logout()
	{
		return confirm("You want to exit?");
	}
	
function  Form_Validator_(frm) 
{
    if(frm.username.value=="")
    {
		alert("Please Input the username");
		return false;
    }
    if(frm.userpassword.value=="") 
    {
		alert("Please Input the password");
		return false; 
    }
}
	
function show_price(id)
{
	var usertype = GetCookie("usertype");
	allprices=eval("CCode"+id);
	allprice=allprices[2];
	if(allprice&&usertype!=null)
	{
		typeneme=GetCookie("typeneme");
		cd=allprice.split(usertype+":");
		old_cd=allprice.split("0:");
		if(cd.length>1)
		{
			jiage=cd[1].split("|");
			price=jiage[0];
			old_jiage=old_cd[1].split("|");
			cha_price=old_jiage[0]-price;
			cha_price=parseFloat(cha_price).toFixed(2);
			//document.write("<li>"+typeneme+"：<span class='p14redb'>￥"+price+"</span></li>");
			document.write("<li>Immediate savings：￥"+cha_price+"</li>");
		}
		else
		{
			old_jiage=old_cd[1].split("|");
			cha_price='0';
			//document.write("<li>"+typeneme+"：<span class='p14redb'>￥"+old_jiage[0]+"</span></li>");
			document.write("<li>Immediate savings：￥"+cha_price+"</li>");
		}
	}
}

function save_product(product_id)
{
	var typeid = null;
	typeid = GetCookie("usertype");
	if(typeid!=null)
	{
		var if_select=false;
		var id = GetCookie("CCodes");
		if(id!=null)
		{
			tt=id.split("|");
			for(i=0;i< tt.length;i++)
			{
				if(tt[i]==product_id)
				{
					alert("You have ordered it!");
					if_select=true;
					break;
				}
			}
		}
		if(if_select!=true)
		{
			alert("Choose successfully!");
			var tt=eval("CCode"+product_id);
			usertype=GetCookie("usertype");
			//cd=tt[2].split(":");
			//price=tt[2];
			value=tt[0]+'|'+tt[1]+'|'+tt[2]+'|'+tt[3]+'|'+tt[4]+'|1';
			SetCookie("CCode"+product_id, value, null, "/");
			if(id!=null)
				var bbb= id+product_id+'|';
			else
				bbb= product_id+'|';
			SetCookie("CCodes", bbb, null, "/");
			top.location="car.php";
		}
	}
	else
	{
		alert("Please Login in！");
	}
}
	
function show_class_content()
{
	if(id_num!=null)
	{
		yuanshi_url=document.URL;
		bb=yuanshi_url.split("#");
		htm_url=bb[0];
		aa=htm_url.split("page=");
		if(aa.length==2)
		{
			bb=aa[1].split("|");
			page=bb[0];
		}
		else
			page=1;
		first=(page-1)*pagesize;
		end=first+pagesize;
		if(end> id_num.length)
			end=id_num.length;
		for(i=first;i< end;i++)
		{
			ids=id_num[i].split(":");
			nr=eval("CCode"+ids[2]);
			if(typeof(nr)!="undefined")
			{
				oldp=nr[2].split("0:");
				tt=oldp[1].split("|");
				old_price=tt[0];
				first="000"+nr[0];
				ss=first.length-4;
				dd=first.length-2;
				first_mulu="product/"+first.substr(ss,2)+'/'+first.substr(dd,2)+'/'+nr[3];
				document.write('<div class="items clearfix" style="margin-bottom:10px;float:left;"> ');
				document.write('<div class="goodpic"  style="float:left;width:120px;"><a href="product_detail.htm?id='+nr[0]+'" target="_blank"><img src="'+first_mulu+'" alt="'+nr[1]+'" width="120" border="0" /></a></div>');
				document.write('<div class="clearfix" style="float:left;width:600px;margin-left:10px;">');
				document.write('<h1 style="margin:0px;"><img src="images/1.gif" border="0" alt="" style="margin-right:5px;"/><a href="product_detail.htm?id='+nr[0]+' "target="_blank">'+nr[1]+'</a></h1>');
				document.write(' <ul style="line-height:150%;margin:0px;margin-left:25px;list-style-type:none;">');
				//document.write('<li>市&nbsp;场&nbsp;价：￥'+old_price+'</li>');
				show_price(nr[0]);
				//document.write('<li class="intro">介&nbsp;&nbsp;&nbsp;&nbsp;     绍：'+nr[9]+'</li>');
				document.write('</ul>');
				document.write('</div>');
				document.write('<div class="button"  style="margin-left:25px;margin-top:5px;float:left;"><a href="#" onclick="save_product('+nr[0]+' )";return false"><img src="images/buy.gif" border="0" alt="" /></a> <a href="product_detail.htm?id='+nr[0]+'" target="_blank"><img alt=详细 src="images/details.gif" border=0/></a> <a href="user_save.php?id='+nr[0]+'"><img alt=收藏 src="images/icon21.gif" border=0 /></a> </div>');
				document.write('</div>');
				document.write('<br style="clear:both" />');
			}
		 }
	 }
}

function show_class_content_other()
{
	if(id_num!=null)
	{
		yuanshi_url=document.URL;
		bb=yuanshi_url.split("#");
		htm_url=bb[0];
		aa=htm_url.split("page=");
		if(aa.length==2)
		{
			bb=aa[1].split("|");
			page=bb[0];
		}
		else
			page=1;
		first=(page-1)*pagesize;
		end=first+pagesize;
		if(end> id_num.length)
			end=id_num.length;
		for(i=first;i< end;i++)
		{
			ids=id_num[i].split(":");
			nr=eval("CCode"+ids[1]);
			if(typeof(nr)!="undefined")
			{
				oldp=nr[2].split("0:");
				tt=oldp[1].split("|");
				old_price=tt[0];
				first="000"+nr[0];
				ss=first.length-4;
				dd=first.length-2;
				first_mulu="product/"+first.substr(ss,2)+'/'+first.substr(dd,2)+'/'+nr[3];
				document.write('<div class="items clearfix">');
				document.write('<div class="goodpic"><a href="product_detail.htm?id='+nr[0]+'" target="_blank"><img src="'+first_mulu+'" alt="'+nr[1]+'" width="80" height="80" border="0" /></a></div>');
				document.write('<div class="clearfix">');
				document.write('<h1><a href="product_detail.htm?id='+nr[0]+' "target="_blank">'+nr[1]+'</a></h1>');
				document.write(' <ul>');
				//document.write('<li>市场价：￥'+old_price+'</li>');
				show_price(nr[0]);
				document.write('<li class="intro">'+nr[9]+'</li>');
				document.write('</ul>');
				document.write('</div>');
				document.write('<div class="button"><a href="#" onclick="save_product('+nr[0]+' )";return false"><img src="images/buy.gif" border="0" alt="" /></a> <a href="product_detail.htm?id='+nr[0]+'" target="_blank"><img alt=详细 src="images/details.gif" border=0/></a> <a href="user_save.php?id='+nr[0]+'"><img alt=收藏 src="images/fav.gif" border=0 /></a> </div>');
				document.write('</div>');
				document.write('<br style="clear:both" />');
			}
		 }
	 }
}

function show_page()
{
	if(id_num!=null)
		all_num=id_num.length;
	else
		all_num=0;
	allpage=Math.ceil((all_num / pagesize));
	yuanshi_url=document.URL;
	bb=yuanshi_url.split("#");
	htm_url=bb[0];
	aa=htm_url.split("page=");
	if(aa.length==2)
	{
		bb=aa[1].split("|");
		page=parseInt(bb[0]);
	}
	else
		page=1;
	//document.write('<p class="PagerWrap"><span>total'+all_num+'Num</span> <span style="color:#ff9900;">'+page+'/'+allpage+'page</span></font> ');		
	htm_url=document.URL;
	htm_urls=htm_url.split("?");
	first_url=htm_urls[0];
	lj_html=first_url+"?";
	old_html=first_url+"?";
	if(htm_urls.length==2)
	{
		hh=htm_urls[1].split("|");
		for(kk=0;kk< hh.length;kk++)
		{
			if(hh[kk].substr(0,5)!="page=")
			{
				if(old_html==lj_html)
					lj_html=lj_html+hh[kk];
				else
					lj_html=lj_html+"|"+hh[kk];
			}
		}
	}
	if(page>1)
	{
		if(old_html==lj_html)
			document.write('<a href=" '+lj_html+'page=1">home</a> <a href=" '+lj_html+'page='+(page-1)+'">Pre</a> ');
		else
			document.write('<a href=" '+lj_html+'|page=1">home</a> <a href=" '+lj_html+'|page='+(page-1)+'">Pre</a> ');
	}
	else
	{
		document.write('home Pre ');
	}
	if(page>=1&&page< allpage)
	{
		if(old_html==lj_html)
			document.write('<a href=" '+lj_html+'page='+(page+1)+'">Pre</a> <a href=" '+lj_html+'page='+allpage+'">Last</a>');
		else
			document.write('<a href=" '+lj_html+'|page='+(page+1)+'">Pre</a> <a href=" '+lj_html+'|page='+allpage+'">Last</a>');
	}
	else
	{
		document.write('Pre Last');
	}
	document.write('Go <input name="page" type="text" size="2" class="inputstyle" value='+page+'>page');
	document.write('<input type="button" name="Submit" class="inputstyle" value="go" onclick="go_htm()">');
}

function go_htm()
{
	aa=document.all("page").value;
	htm_url=document.URL;
	htm_urls=htm_url.split("?");
	first_url=htm_urls[0];
	lj_html=first_url+"?page="+aa;
	if(htm_urls.length==2)
	{
		hh=htm_urls[1].split("|");
		for(kk=0;kk< hh.length;kk++)
		{
			if(hh[kk].substr(0,5)!="page=")
			{
				if(hh[kk]!='')
					lj_html=lj_html+"|"+hh[kk];
			}
		}
	}
	if(aa)
		document.location=lj_html;
	else
		return false;
}


function product_type()
{
	for(i=0;i< first_type.length;i++)
	{
		first_content=first_type[i].split("|");
		document.write('<div class="box_main_top"><A href="class.php?type='+first_content[0]+'">'+first_content[1]+'</A> </div><div class="box_main_bottom">');
		end_type=eval("end_type"+first_content[0]);
		for(j=0;j< end_type.length;j++)
		{
			end_content=end_type[j].split("|");
			document.write('<li><A title="'+end_content[1]+'" href="class2.php?type='+end_content[0]+'">'+end_content[1]+'</A> </li> ');
		}
		document.write('</div><img src="images/icon3.gif" />');
	}
}

function show_first_name()
{
	for(i=0;i< first_type.length;i++)
	{
		nn=first_type[i].split("|");
		if(nn[0]==curtype)
		{
			document.write('<span style="font-size: 10px">&gt;</span> <a href="class.php?type='+nn[0]+'">'+nn[1]+'</a>');
			break;
		}
	}
}

function show_end_name()
{
	for(j=0;j< first_type.length;j++)
	{
		ff=first_type[j].split("|");
		end_type=eval("end_type"+ff[0]);
		for(i=0;i< end_type.length;i++)
		{
			nn=end_type[i].split("|");
			if(nn[0]==curtype)
			{
				document.write('<span style="font-size: 10px">&gt;</span> <a href="class.php?type='+ff[0]+'">'+ff[1]+'</a>');
				document.write('<span style="font-size: 10px">&gt;</span> <a href="class2.php?type='+nn[0]+'">'+nn[1]+'</a>');
				if_show=GetCookie("userifshow");
				if(if_show=='1')
					document.write('&nbsp;&nbsp; <a href="class_list.htm?type='+nn[0]+'">Quick purchase</a>');
				break;
			}
		}
	}
}

function show_product_content()
{
	rights=GetCookie("usertype");
	if(curproduct[5]=='0'||(curproduct[5]==rights&&rights!=null))
	{
		oldp=curproduct[2].split("0:");
		tt=oldp[1].split("|");
		old_price=tt[0];
		first="000"+curproduct[0];
		ss=first.length-4;
		dd=first.length-2;
		first_mulu="product/"+first.substr(ss,2)+'/'+first.substr(dd,2)+'/'+curproduct[3];
		first_mulu1="product/"+first.substr(ss,2)+'/'+first.substr(dd,2)+'/'+curproduct[4];
		/*
		document.write('<div class="info">');
		document.write('<table width="100%">');
		document.write('<tr><td width="26%" valign="top" align="center"><div class="pic">');
		document.write('<p><a href="'+first_mulu1+'"><img src="'+first_mulu+'" alt="'+curproduct[1]+'" width="150" height="150" border="0" /> </a></p>');
		document.write('</div><br/><a href="'+first_mulu1+'" target="_blank"><img src="images/icon24.gif" border="0" alt="Show AP" /></a><br/>');
		document.write('<br/> </td><td width="74%" valign="top"><h1>'+curproduct[1]+'</h1>');
		document.write('<table  border="0" cellspacing="0" cellpadding="3" class="subinfo">');
		document.write('<tr><td width=100>商品Specifications： </td><td align="left">'+curproduct[6]+'</td></tr>');
		document.write('<tr><td>商品品牌：</td> <td align="left">'+curproduct[7]+'</td></tr>');
		document.write('<tr><td>计量单位：</td><td align="left">'+curproduct[8]+'</td></tr>');
		document.write('<tr><td>市场价格：</td><td align="left">￥'+old_price+'</td></tr>');
		document.write('<tr><td colspan="2" class="memberprice"><script> show_price('+curproduct[0]+') </script></td></tr></table>');
		document.write('<BR><a href="#" onclick="save_product('+curproduct[0]+');return false"><img src="images/buy.gif" border="0" alt="" /></a> <a href="user_save.php?id='+curproduct[0]+'"><img src="images/icon21.gif" alt="收藏" /></a><br />');
		document.write('<div class="GoodsDetailsWarp" style="line-height:150%;">');
		document.write('<h1>详细介绍</h1>'+curproduct[9]+'</div> </td>');
		document.write('</tr></table></div></div>');
		*/

	}
}

function product_detail_type()
{
	curtype=curproduct[10];
	for(j=0;j< first_type.length;j++)
	{
		ff=first_type[j].split("|");
		end_type=eval("end_type"+ff[0]);
		for(i=0;i< end_type.length;i++)
		{
			nn=end_type[i].split("|");
			if(nn[0]==curtype)
			{
				document.write('<span style="font-size: 10px">&gt;</span> <a href="class.php?type='+ff[0]+'">'+ff[1]+'</a>');
				document.write('<span style="font-size: 10px">&gt;</span> <a href="class2.php?type='+nn[0]+'">'+nn[1]+'</a>');
				break;
			}
		}
	}
}

