var pat=/^[0-9]{1,}$/;
var Sys = {};
var ua = navigator.userAgent.toLowerCase();
var s;
(s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :
(s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
(s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
(s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
(s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;

//全选
var checked;
function CheckAll(checked)
{
	var chks = document.getElementsByTagName("input");	
	for(var i=0;i<chks.length;i++)
	{
		if(chks[i].id.indexOf('ChkBox')!=-1)
		{
			chks[i].checked = checked;            
			chks[i].parentNode.style.color = checked?'red':'black';
		}
		if(chks[i].type=='checkbox' && chks[i].id.indexOf('vip')<0)
		{
			chks[i].checked = checked;
		} 
	}
}
//确认操作
function Confirm(Msg)
{
	if(confirm(Msg))
	{
		return true;
	}
	return false;
}

//登陆页表单验证
function chklogin()
{
	if($("#UserName").val()=="")
	{
		alert("请输入用户名!");
		$("#UserName").focus();
		return false;
	}
	if($("#UserPwd").val()=="")
	{
		alert("请输入登陆密码!");
		$("#UserPwd").focus();
		return false;
	}
	if($("#ChkCode").val()=="")
	{
		alert("请输入验证码!");
		$("#ChkCode").focus();
		return false;
	}
}

//修改类别
function EditClass(ParentID,ClassID,ClassName,SortID)
{
	var myOptions = document.getElementById("BigCategory").options;
    if (ParentID == '0') {
        myOptions.selectedIndex = 0;
    }
    else {
        var isNew = 0;
        for (var i = 0; i < myOptions.length; i++) {
            if (myOptions[i].value == ParentID) {
                myOptions.selectedIndex = i;				
                isNew = 1;
                break;
            }
        }
        if (isNew == 0) {
            myOptions.selectedIndex == 0;
        }
    }
	
	$("#SubCategory").val(ClassName);
	$("#SortID").val(SortID);
	$("#ID").val(ClassID);
}

//修改管理员密码
function ShowModiPwd(UserName)
{
	var Str = '<div style="width:100%; margin-top:20px; text-align:left; padding-left:20px" id="ShowInfor">';	
	Str += "用户名：" + UserName;
	Str += '<br />用户密码：<input name="UserPwd" id="UserPwd" type="password" class="txt" value="" /><input type="button" class="btn" value="修改" onclick="ModiPwd(\''+UserName+'\')" >';
	Str += '</div>';
	document.getElementById("lightbox").innerHTML=Str;
	document.getElementById("overlay").style.display="block";
	document.getElementById("lightbox").style.display="block";	
	document.getElementById("overlay").style.height=document.body.offsetHeight + "px";
}
function ModiPwd(UserName)
{
	var UserPwd=$("#UserPwd").val().replace(" ","");	
	if(UserPwd=="")
	{
		alert("请输入用户密码!");
		return false;
	}
	var Url="System/Submit.asp?Action=ModiAdminPwd&UserName=" + UserName + "&UserPwd=" + UserPwd;
	XMLHttpUser.sendReq("get", Url, null, ReturnModiPwd);
}
function ReturnModiPwd(Obj)
{
	if($("#UserPwd")) $("#UserPwd").val("");
	$("#ShowInfor").html(Obj.responseText);
	setTimeout(HiddenLightDiv,2000);
}
//隐藏遮罩层
function HiddenLightDiv()
{
	$("#overlay").css("display","none");
	$("#lightbox").css("display","none");
	if($("#UserPwd")) $("#UserPwd").val("");
}

//显示日期
function ShowDate()
{
	var week; 
	if(new Date().getDay()==0)          week="星期日"
	if(new Date().getDay()==1)          week="星期一"
	if(new Date().getDay()==2)          week="星期二" 
	if(new Date().getDay()==3)          week="星期三"
	if(new Date().getDay()==4)          week="星期四"
	if(new Date().getDay()==5)          week="星期五"
	if(new Date().getDay()==6)          week="星期六"
	document.write("日期：" + (new Date().getYear())+"年"+(new Date().getMonth()+1)+"月"+new Date().getDate()+"日 "+week);
}
//日历表
function CAL(){ 
	var bsYear;  
	var bsDate;  
	var bsWeek;  
	var arrLen=8; 
	var sValue=0;  
	var dayiy=0;  
	var miy=0;  
	var iyear=0; 
	var dayim=0; 
	var spd=86400; 
	 
	var year1999="30;29;29;30;29;29;30;29;30;30;30;29"; //354  
	var year2000="30;30;29;29;30;29;29;30;29;30;30;29"; //354  
	var year2001="30;30;29;30;29;30;29;29;30;29;30;29;30"; //384  
	var year2002="30;30;29;30;29;30;29;29;30;29;30;29"; //354  
	var year2003="30;30;29;30;30;29;30;29;29;30;29;30"; //355  
	var year2004="29;30;29;30;30;29;30;29;30;29;30;29;30"; //384  
	var year2005="29;30;29;30;29;30;30;29;30;29;30;29"; //354  
	var year2006="30;29;30;29;30;30;29;29;30;30;29;29;30";  
	 
	var month1999="正月;二月;三月;四月;五月;六月;七月;八月;九月;十月;十一月;十二月"  
	var month2001="正月;二月;三月;四月;闰四月;五月;六月;七月;八月;九月;十月;十一月;十二月"  
	var month2004="正月;二月;闰二月;三月;四月;五月;六月;七月;八月;九月;十月;十一月;十二月"  
	var month2006="正月;二月;三月;四月;五月;六月;七月;闰七月;八月;九月;十月;十一月;十二月"  
	var Dn="初一;初二;初三;初四;初五;初六;初七;初八;初九;初十;十一;十二;十三;十四;十五;十六;十七;十八;十九;二十;廿一;廿二;廿三;廿四;廿五;廿六;廿七;廿八;廿九;三十";  
	 
	var Ys=new Array(arrLen);  
	Ys[0]=919094400;Ys[1]=949680000;Ys[2]=980265600;  
	Ys[3]=1013443200;Ys[4]=1044028800;Ys[5]=1074700800;  
	Ys[6]=1107878400;Ys[7]=1138464000;  
	 
	var Yn=new Array(arrLen); //农历年的名称  
	Yn[0]="己卯年";Yn[1]="庚辰年";Yn[2]="辛巳年";  
	Yn[3]="壬午年";Yn[4]="癸未年";Yn[5]="甲申年";  
	Yn[6]="乙酉年";Yn[7]="丙戌年";  
	var D=new Date();  
	var yy=D.getYear();  
	var mm=D.getMonth()+1;  
	var dd=D.getDate();  
	var ww=D.getDay();  
	if (ww==0) ww="<font color=RED>星期日";  
	if (ww==1) ww="星期一";  
	if (ww==2) ww="星期二";  
	if (ww==3) ww="星期三";  
	if (ww==4) ww="星期四";  
	if (ww==5) ww="星期五";  
	if (ww==6) ww="<font color=RED>星期六";  
	ww=ww;  
	var ss=parseInt(D.getTime() / 1000);  
	if (yy<100) yy="19"+yy;  
	 
	for (i=0;i<arrLen;i++)  
	if (ss>=Ys[i]){  
	iyear=i;  
	sValue=ss-Ys[i]; //当年的秒数  
	}  
	dayiy=parseInt(sValue/spd)+1; //当年的天数  
	 
	var dpm=year1999;  
	if (iyear==1) dpm=year2000;  
	if (iyear==2) dpm=year2001;  
	if (iyear==3) dpm=year2002;  
	if (iyear==4) dpm=year2003;  
	if (iyear==5) dpm=year2004;  
	if (iyear==6) dpm=year2005;  
	if (iyear==7) dpm=year2006;  
	dpm=dpm.split(";");  
	 
	var Mn=month1999;  
	if (iyear==2) Mn=month2001;  
	if (iyear==5) Mn=month2004;  
	if (iyear==7) Mn=month2006;  
	Mn=Mn.split(";");  
	 
	var Dn="初一;初二;初三;初四;初五;初六;初七;初八;初九;初十;十一;十二;十三;十四;十五;十六;十七;十八;十九;二十;廿一;廿二;廿三;廿四;廿五;廿六;廿七;廿八;廿九;三十";  
	Dn=Dn.split(";");  
	 
	dayim=dayiy;  
	 
	var total=new Array(13);  
	total[0]=parseInt(dpm[0]);  
	for (i=1;i<dpm.length-1;i++) total[i]=parseInt(dpm[i])+total[i-1];  
	for (i=dpm.length-1;i>0;i--)  
	if (dayim>total[i-1]){  
	dayim=dayim-total[i-1];  
	miy=i;  
	}  
	bsWeek=ww;  
	bsDate=yy+"年"+mm+"月";  
	bsDate2=dd;  
	bsYear="农历"+Yn[iyear];  
	bsYear2=Mn[miy]+Dn[dayim-1];  
	if (ss>=Ys[7]||ss<Ys[0]) bsYear=Yn[7];  
	 
	document.write("<table border='1' cellspacing='3' width='105' bordercolor='#000000' bgcolor='#FFFFFF' height='110' cellpadding='2'");  
	document.write("<tr><td align='center'><b><font color=#008040>"+bsDate+"</font><br><font face='Arial' size='6' color=#FF8040>"+bsDate2+"</font><br><font color=#008040><span style='FONT-SIZE: 10.5pt'>");  
	document.write(bsWeek+"</span><br>"+"<br></b><font color=#9B4E00>");  
	document.write(bsYear+"<br>"+bsYear2+"</td></tr></table>");  
}  

function ShowPageTitle(StrTitle)
{
	$("#PageTitle").html(StrTitle);
}

function GetCity(id){
	$.ajax({
	   type: "Get",
	   url: "/Ajax.asp",
	   data: "action=GetCity&id="+ id,
	   success: function(msg){			   
		   var ArrOption=new Array();
		   ArrOption=msg.split("{$}");	
	   	   $("#city").html(ArrOption[1]);		   
		   GetArea(ArrOption[0]);
	   }
	});
}
function GetArea(id){
	$.ajax({
	   type: "Get",
	   url: "/Ajax.asp",
	   data: "action=GetArea&id="+ id,
	   success: function(msg){
	   	   $("#area").html(msg);
	   }
	});
}

///////////////////////////////////////////////
function ChangeSortID(id){
	$.ajax({
	   type: "Get",
	   url: "../Public/Ajax.asp",
	   data: "action=ChangeSortID&SortID=" + $("#"+id).val() +"&id="+ id,
	   success: function(msg){
	   	   if(msg=='success')
	   			$("#img_"+id).html("<img src='../images/(01,10).png' />");
		   else
		  	 	$("#img_"+id).html("<img src='../images/(28,45).png' />");
	   }
	});
}
function ChangeBrandSortID(id){
	$.ajax({
	   type: "Get",
	   url: "../Public/Ajax.asp",
	   data: "action=ChangeBrandSortID&SortID=" + $("#"+id).val() +"&id="+ id,
	   success: function(msg){
	   	   if(msg=='success')
	   			$("#img_"+id).html("<img src='../images/(01,10).png' />");
		   else
		  	 	$("#img_"+id).html("<img src='../images/(28,45).png' />");
	   }
	});
}
/////////////////////////////////////////////////////////////////////////////////////////////
//后台框架页菜单效果
function ShowMenuBg(Obj)
{
	if(Obj.currentStyle.backgroundImage.toLowerCase().indexOf("topmenu.gif")<0)
		Obj.style.background="url('images/TopMenu_1.gif') center center no-repeat";
}
function HiddenMenuBg(Obj)
{
	if(Obj.currentStyle.backgroundImage.toLowerCase().indexOf("topmenu.gif")<0)
		Obj.style.background="";
}
function ChangeMenuBg(Obj,SubMenu)
{
	$("dt").css("background","");
	$("dd").css("background","");
	for(var i=0;i<16;i++)
	{
		$("#SubMenu"+i).removeClass("TopColumnMenu1Center DisplayBlock");
		$("#SubMenu"+i).addClass("TopColumnMenu1Center DisplayNone");
	}
	$("#"+SubMenu).addClass("TopColumnMenu1Center DisplayBlock");
	Obj.style.background="url('images/TopMenu.gif') center bottom no-repeat";
}