//实现全选功能
function ischinese(s){
var ret=true;
for(var i=0;i<s.length;i++)
ret=ret && (s.charCodeAt(i)>=10000);
return ret;
}

function CheckAll(form){
	for (var i=0;i<form.elements.length;i++){
		var e = form.elements[i];
    if (e.name != 'chkall')
       e.checked = form.chkall.checked;
	}
}

//显示隐藏菜单
function showsubmenu(sid)
{
var obj1= "ss" + sid
whichEl = eval("submenu" + sid);
if (whichEl.style.display == "none")
{
eval("submenu" + sid + ".style.display=\"\";");
document.all.item(obj1).src='image/hide.gif';
}
else
{
eval("submenu" + sid + ".style.display=\"none\";");
document.all.item(obj1).src='image/show.gif';
}
}

//显示信息
function popwininfodetail(id){		
  window.open("infodetail.asp?id="+id,"","height=450,width=650,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
}

function popwinlydetail(id){		
  window.open("lydetail.asp?id="+id,"","height=450,width=650,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
}

//显示用户详细信息
function popwinuserdetail(id){		
  window.open("userdetail.asp?id="+id,"","height=450,width=650,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
}

//显示产品详细信息
function popwinproductdetail(id){		
  window.open("productdetail.asp?id="+id,"","height=450,width=650,resizable=yes,scrollbars=yes,status=yes,toolbar=yes,menubar=yes,location=yes");
}

//检测信息输入情况
function check1(){
if (info.info_title.value ==""){
alert("请输入标题");
info.info_title.focus();
return false;
}

if (info.info_title.value.length>40){
alert("标题内容不得超过40个字符");
info.info_title.focus();
return false;
}
if (info.info_detail.value ==""){
alert("请输入内容");
return false;
}
return true;
}



//检测注册表单的信息
function checkform(){
if(regform.username.value =="" || regform.password.value=="" || regform.e_mail.value=="" || regform.address.value=="" || regform.phone.value=="" ){
alert("对不起，应填写所有必填信息");
return false;
}
if(regform.username.value.length>20 || regform.password.value.length>20|| regform.e_mail.value.length>30|| regform.address.value.length>50|| regform.phone.value.length>20){
alert("对不起，数据长度超出规定，请重新填写");
return false;
}
return true;
}

//检测是否输入了小类别名称
function check2(){
  if(addcateform.value==""){
		alert("请输入小类别名称！");		
		return false;
	}
	return true;
}

//检测产品输入的数据有效性
function check3(){
if(pro.product_cate_id.value=="0"){
alert("请选择小类别");
return false;
}
if(pro.product_name.value=="" || pro.product_price.value=="" || pro.product_amount.value=="" || pro.product_home.value=="" || pro.product_detail.value==""){
alert("所有必填内容不得为空");
return false;
}
if (pro.product_name.value.length>30 || pro.product_home.value.length>30){
alert("所填内容超过字符限制！");
return false;
}
return true;
}

function check4(){
  if(Admininfo.Adminname.value=="" || Admininfo.Adminpassword.value==""){
		alert("请输入管理员名和密码！");		
		return false;
	}
	return true;
}

//检验数据是否为大于0的数
function isfloat(s)
{
    var p=/^\d+(\.\d+)?$/
    if (!p.test(s)){
			return false;
		}
    return true;
}
function isint(s)
{
    var p=/^\d+$/g;
    if (!p.test(s)){
			return false;
		}
    return true;
}




//检测筛选表单是否选择了小类别
function check5(){
  if(selectform.product_cate_id.value=="0"){
		alert("请选择小类别！");		
		return false;
	}
	return true;
}


//滚屏
function scroller() {
if (document.all.auto.status==true){ 
	position++; 
	scroll(0,position); 
	clearTimeout(timer); 
	var timer = setTimeout("scroller()",50); 
	timer;
	}
else{
	clearTimeout(timer);
	}
}


//调用JS
function MM_callJS(jsStr) {
  return eval(jsStr)
}

function click() {
if (event.button==2) {
	if(document.all.auto.status==true){document.all.auto.status=false;alert("自动滚屏已经停止了！")}
	scroller();
	}
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function cdel(id,cata,page){
var id;
if (confirm("你真的要删除这条新闻吗？")){
	document.location.href="news.asp?action=del&id="+id+"&cataid="+cata+"&pageno="+page;
	}
}

function view(newsfile) {
	var gt = unescape('%3e');
	var popup = null;
	var over = "Launch Pop-up Navigator";
	popup = window.open('', 'popupnav', 'width=300,height=160,left=200,top=200,,resizable=no,scrollbars=no');
	if (popup != null) {
		if (popup.opener == null) {
		popup.opener = self;
		}
	popup.location.href = newsfile;
	}
}

function saveIt()
{
     document.pub_topic.cnWords.value = document.frames.cnEditBox.getHTML(true);     
     document.pub_topic.imageNum.value = document.frames.cnEditBox.document.all("editImageNum").value;
     document.pub_topic.editFirstImageName.value = document.frames.cnEditBox.document.all("editFirstImageName").value;
	
	if (document.pub_topic.cataid.value=="")
	{ 
	 	alert('请选择新闻的类别！'); 
		document.pub_topic.cataid.focus();
		return false; 
	}
	
	if (document.pub_topic.title.value=="")
	{ 
	 	alert('请输入新闻的标题！'); 
		document.pub_topic.title.focus();
		return false; 
	}
     document.pub_topic.submit();
}

function dodel(){
if (confirm("注意：删除一个栏目，其下面的所有子栏目和产品将全部被清空，\n您确定要进行此操作吗？"))
	{
	document.del.submit();
	}
}


function CContext()
{}
var g_cContext = new CContext();
g_cContext.StaticContentServer = '';


  //查询案件办理情况重新填写
  function QueryCaseReset()
  {
    window.QueryCase.Edit_CASE_ID.value = "";
	window.QueryCase.Edit_CASE_Password.value = "";
        window.QueryCase.Edit_CASE_code.value = "";
	window.QueryCase.Edit_CASE_ID.focus();
  }
  
    //网上报建重新填写
  function wsbjReset()
  {
    usernamebj.value = "";
	pwbj.value = "";
	usernamebj.focus();
  }
  
  var popUpWin=0;
function PopUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

 
  function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function gook() {

	if (usernameshow.value == "")
	{
		alert("用户名不可为空");
		usernameshow.focus();
		return ;
	}

	if (pwshow.value == "")
	{
		alert("密码不可为空");
		pwshow.focus();
		return ;
	}


	f1.saveUser.value = false;
	f1.user.value = usernameshow.value;

	f1.SecEx.value = false;
	f1.pass.value = pwshow.value;

	f1.submit();
}

function gook1() {


	if (usernamebj.value == "")
	{
		alert("用户名不可为空");
		usernamebj.focus();
		return ;
	}

	if (pwbj.value == "")
	{
		alert("密码不可为空");
		pwbj.focus();
		return ;
	}


	formbj.saveUser.value = false;
	formbj.usernamebj.value = usernamebj.value;

	formbj.SecEx.value = false;
	formbj.pwhidden.value = pwbj.value; //encode(  , parseInt(f1.picnum.value))
	//alert(parent.location);
	var str="";
	str='shenpi/login.aspx?ub='+usernamebj.value+'&pwd='+pwbj.value+'&shenpinum=1'+'&shenpinum2=1';
    parent.location=str;
	//alert(parent.location);
	//formbj.submit();
}

function gook2() {

	if (usernamebj.value == "")
	{
		alert("用户名不可为空");
		usernamebj.focus();
		return ;
	}

	if (pwbj.value == "")
	{
		alert("密码不可为空");
		pwbj.focus();
		return ;
	}


	formbj.saveUser.value = false;
	formbj.usernamebj.value = usernamebj.value;

	formbj.SecEx.value = false;
	formbj.pwhidden.value = pwbj.value; //encode(  , parseInt(f1.picnum.value))
	//alert(parent.location);
	var str="";
        
	str='../shenpi/login.aspx?ub='+usernamebj.value+'&pwd='+pwbj.value+'&shenpinum='+code1.value+'&shenpinum2='+shenpiNum.value;
    //alert('<%= Session("GetCode1") %>');
    parent.location=str;
	alert(parent.location);
	//formbj.submit();
}

function encode(datastr, bassnum) {
	var tempstr;
	var tchar;
	var newdata = "";

	for (var i = 0; i < datastr.length; i++)
	{
		tchar = 65535 + bassnum - datastr.charCodeAt(i);
		tchar = tchar.toString();

		while(tchar.length < 5)
		{
			tchar = "0" + tchar;
		}

		newdata = newdata + tchar;
	}

	return newdata;
}

