function checknull(theField,theAlert)
{
	if (theField.value==""){
		alert(theAlert); 
		theField.focus();
		return false;
	}else{
		tmp=theField.value;
		while(tmp.charAt(0)==" ")
			tmp=tmp.substring(1);
		if (tmp==""){
			alert(theAlert);
			theField.focus();
			return false;
		}
	}
	return true;
}

function checkbox(theField,theAlert){
   if (theField.value){
		if (!theField.checked){
				alert(theAlert); 
			return false;
			}
   }else{
		len=theField.length;
		flag=false;
		for (i=0;i<len;i++)
		{
			if ( theField[i].checked)
				flag=true;
		}
		if (!flag){
			alert(theAlert);
			return false;
		}
   } 
   return true;
 }

function checksize(theField,theNum,theAlert)
{
	if (theField.value.length>=theNum){
		alert(theAlert);
		return false;
	}
	return true;
}

function checkemail(theField,theAlert)
{
	temp=theField.value
	if ((temp == null) || (temp.length == 0)){
	    window.alert(theAlert);	
		theField.focus();
		return false;
	}		
	len = temp.length;
	if(len>0)
	{
	  if (len > 100)
	  {
		window.alert(theAlert);
		theField.focus();
		return false;
	  }
	  pos1 = temp.indexOf("@");
	  pos2 = temp.indexOf(".");
	  pos3 = temp.lastIndexOf("@");
	  pos4 = temp.lastIndexOf(".");
	  if ((pos1 <= 0)||(pos1 == len)||(pos2 <= 0)||(pos2 == len))
	  {
		window.alert(theAlert);
		theField.focus();
		return false;
	  }
	  else
	  {
		if( (pos1 == pos2 - 1)||(pos1 == pos2 + 1)||( pos1 != pos3 )||( pos4 < pos3 ) )
		{
			window.alert(theAlert);
		    theField.focus();
		    return false;
		}
	  }		
	}
	return true;
}

function load(Object)
{ 
	if (Object.selectedIndex > 0) 
		location = Object.options[Object.selectedIndex].value;
}

function load1(Object)
{ 
	if (Object.selectedIndex >= 0) 
		location = Object.options[Object.selectedIndex].value;
}

function showPic()
{
 	return window.showModalDialog("../uploadfile/selectfile.php");
}

function OpenUpload(theField)
{
	if(showPic) {
		var str=null;
		str=showPic();
		if (str!=null)	
			theField.value=str;
	}	
	else
		alert("该功能在此处无效！")
}

function OpenIndex(theIndex){
	if(showIndex) {
		var str=null;
		var strindex=null;
		str=showIndex();
		if (str!=null){
			strindex=str;			
			theIndex.value=strindex;
		}
	}	
	else
		alert("该功能在此处无效！")
}

function showCity()
{
	return window.showModalDialog("/include/selectprov.php","","status:no;resizable:no;dialogHeight:180px;dialogWidth:500px;unadorne:yes");
}

function OpenCities(theProv,theProvId,theCity,theCityId){
	if(showCity) {
		var str=null;
		var strprov=null;
		var strcity=null;
		var strprovname=null;
		var strprovid=null;
		var strcityname=null;
		var strcityid=null;
		str=showCity();
		if (str!=null){
			strprov=str.substring(0,str.indexOf("|"));
			strcity=str.substring(str.indexOf("|")+1,str.lastIndexOf("|"));
			strprovname=strprov.substring(0,strprov.indexOf("&"));
			strprovid=strprov.substring(strprov.indexOf("&")+1,strprov.lastIndexOf("&"));
			strcityname=strcity.substring(0,strcity.indexOf("&"));
			strcityid=strcity.substring(strcity.indexOf("&")+1,strcity.lastIndexOf("&"));		
			theProv.value=strprovname;
			theProvId.value=strprovid;
			theCity.value=strcityname;
			theCityId.value=strcityid;
		}
	}	
	else
		alert("该功能在此处无效！")
}

function showEmpl()
{
	return window.showModalDialog("/include/selectempl.php","","status:no;resizable:no;dialogHeight:100px;dialogWidth:400px;unadorne:yes");
}

function OpenEmpls(theName,theCont,theAddr,theTel,theFax,theIndus,theAttri){
	if(showEmpl) {
		var str=null;
		var strname=null;
		var strcont=null;
		var straddr=null;
		var strtel=null;
		var strfax=null;
		var strindus=null;
		var strattri=null;
		str=showEmpl();
		if (str!=null){
			strname  =  str.substring(0,str.indexOf("|"));
			strcont  =  str.substring(str.indexOf("|")+1,str.lastIndexOf("}"));
			straddr  =  str.substring(str.indexOf("}")+1,str.lastIndexOf("{"));
			strtel   =  str.substring(str.indexOf("{")+1,str.lastIndexOf("]"));
			strfax   =  str.substring(str.indexOf("]")+1,str.lastIndexOf("["));
			strindus =  str.substring(str.indexOf("[")+1,str.lastIndexOf("/"));
			strattri =  str.substring(str.indexOf("/")+1,str.indexOf("%"));
			theName.value=strname;
			theCont.value=strcont;
			theAddr.value=straddr;
			theTel.value=strtel;
			theFax.value=strfax;
			theIndus.value=strindus;
			theAttri.value=strattri;
		}
	}	
	else
		alert("该功能在此处无效！")
}

function checkdel(theField)
{
	if (!checkvalue(theField))
		return false;
    if (confirm("删除记录可能造成不确定后果，确认删除吗？"))
		return true;
		else
		return false;
}

function checkoperate(theField)
{
	if (!checkvalue(theField))
		return false;
    if (confirm("确认操作吗？"))
		return true;
		else
		return false;
}

function checkvalue(theField)
{
   if (theField.value){
		if (!theField.checked){
				alert("请选择纪录！"); 
			return false;
			}
   }else{
		len=theField.length;
		flag=false;
		for (i=0;i<len;i++)
		{
			if ( theField[i].checked)
				flag=true;
		}
		if (!flag){
			alert("请选择纪录！");
			return false;
		}
   } 
   return true;
 }

function cfmdel()
{
    if (confirm("删除记录可能造成不确定后果，确认删除吗？"))
		return true;
		else
		return false;
}

function cfmclick(theAlert)
{
    if (confirm(theAlert))
		return true;
		else
		return false;
}

function cfmreset()
{
    if (confirm("确认清空表单吗？"))
		return true;
		else
		return false;
}

//function openWindow(theURL,winName,features) { 
  //window.open(theURL,winName,features);
//}

function openWindow(theURL,winName,features) { 
  window.showModalDialog(theURL,winName,features);
}

function switchmenu(td,submenu,count)
{
	document.fm1.currentID.value=submenu;
	for (i=0;i<count;i++)
	{
		if(i!=submenu)
		{
			document.all("A_"+i).style.backgroundColor="#8FC3EA";
			document.all("B_"+i).style.display="none";
		}
	}
	td.style.backgroundColor="#F47E24";
	document.all("B_"+submenu).style.display="block";
	document.fm1.currentID.value=submenu;
	return true;
}
function onColor(td)
{
	td.style.backgroundColor='#F47E24';
	td.style.color='#FFFFFF';
}
function offColor(td,submenu)
{
	if (document.fm1.currentID.value == submenu){
		td.style.backgroundColor='#F47E24';
		td.style.color='#333333';
	}else{
		td.style.backgroundColor='#8FC3EA';
		td.style.color='#333333';	
	}
}

function checkfrm_search()
{
	if(document.searchform.keystr.value=="请输入关键词查询>>")
	{
		alert("请输入关键词");
		document.searchform.keystr.focus();
		return false;
	}
	if(!checknull(document.searchform.keystr,"请输入关键词")) return false;
	return true;
}

function checkfrm_maillist(){
	if(!checkemail(document.form_maillist.email,"请输入您的电子邮件")) return false;
	if(!checknull(document.form_maillist.mailclassify,"请选择订阅分类")) return false;
	return true;
}

function checkfrm_feedback(){
	if(!checknull(document.form_feedback.note_name,"请输入您的姓名")) return false;
	if(!checkemail(document.form_feedback.note_email,"请输入E-mail地址。我们将把对您留言的回复直接发送到您的电子信箱！")) return false;
	if(!checknull(document.form_feedback.note_title,"请输入您留言的标题")) return false;
	if(!checknull(document.form_feedback.note_cont,"请输入您留言的内容")) return false;
	return true;
}

function checkfrm_feedbacken(){
	if(!checknull(document.form_feedback.note_name,"Please enter your name.")) return false;
	if(!checkemail(document.form_feedback.note_email,"Please provide your email address which the reply to this message could be sent to.")) return false;
	if(!checknull(document.form_feedback.note_title,"Please enter title for your feedback.")) return false;
	if(!checknull(document.form_feedback.note_cont,"Please enter details of your feedback.")) return false;
	return true;
}

function polls_submit()
{
	if(document.polls_form.polls.value=="")
	{
		alert("请选择答案！");
		return false;
	}
	else
	{
		var temp = document.polls_form;
		var poll_parent_id = temp.poll_parent_id.value;
		var flag = temp.polls.value; window.open("/polls_result.php?poll_id="+flag+"&poll_parent_id="+poll_parent_id,"Polls","toolbar=no,location=left,resizable=0,scrollbars=yes,width=550,height=300");
	}
}

function polls_result()
{
	   var poll_parent_id=document.polls_form.poll_parent_id.value;
	   window.open("/polls_result.php?poll_parent_id="+poll_parent_id,"Polls","toolbar=no,location=left,resizable=0,scrollbars=yes,width=550,height=300");

}
function polls_error() {
  alert("您投票次数过多！");
  return false;
}

