
function empty(ele,msg) {
if(ele){
	if(ele.value == ''||ele.value.search(/^\s*$/)!=-1) {

		if(msg)alert(msg);

		ele.focus();

		return true;

	}else{
	return false;
	}
  }
}




function checkRe(ele,re,msg) {
if(ele){
	if(ele.value.search(re)==-1) {

		if(msg)alert(msg);

		ele.focus();

		return false;

	}else{
	return true;
	}
	
  }
}





function checked(obj, sTitle)
{
	
if(!obj) return true;

	if (obj.length == undefined)
	{
		if (obj.checked)
		{
			return true;
		}
	}
	else
	{
		  for (i = 0; i < obj.length; i++)
		  {
			  if (obj[i].checked)
				return true;
		  }
	}
  
  if(sTitle)alert(sTitle);
  //obj[0].focus();
  return false;
}





function getcheckedvalue(obj)
{
	
if(!obj) return '';

	if (obj.length == undefined)
	{
		if (obj.checked)
		{
			return obj.value;
		}
	}
	else
	{
		  for (i = 0; i < obj.length; i++)
		  {
			  if (obj[i].checked)
				return obj[i].value;
		  }
	}
  
  return '';
}






function fckEmpty(ele,msg) {
if(FCKeditorAPI.GetInstance(ele)){
	if(FCKeditorAPI.GetInstance(ele).GetXHTML(true) == '') {

		if(msg)alert(msg);
		
		return true;

	}else{
	return false;
	}
  }	
}




function goUrl(url) {
	window.location.href=url;
}



function alertGo(msg,url) {
	alert(msg);
	goUrl(url);
}



function alertBack(msg) {
	alert(msg);
	history.go(-1);
}


function back() {
	history.go(-1);
}



function goCon(msg,url) {
	
	if(confirm(msg))
	goUrl(url);

}


function redMsg(msg){

	var str = "";

	str = "<font color=\"red\">"+msg+"</font>";

	return str;

}




function checkEmail(ele,msg){

  var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid

  var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid

  var email=ele.value;



  if (!(!reg1.test(email) && reg2.test(email))) { // if syntax is valid

		alert(msg); // this is also optional

		ele.focus();

		return false;

  }

  return true;

}



function openUrl(theUrl,wlength,hlength)

{

    window.open(theUrl, "","width="+wlength+",height="+hlength+",resizable=yes,toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,top=200,left=250");

}



function redMsg(msg){

	var str = "";

	str = "<font color=\"red\">"+msg+"</font>";

	return str;

}




function $(objName){
	if(document.getElementById){
		return eval('document.getElementById("' + objName + '")');
	}else if(document.layers){
		return eval("document.layers['" + objName +"']");
	}else{
		return eval('document.all.' + objName);
	}
}


function getCheckedRadioKey(obj){

	for(var i=0;i<obj.length;i++){

		if(obj[i].checked)

			return obj[i].value;			

	}

}





function doPrint() {

	var bodystr=document.body.innerHTML;

	var obj = document.body.style;

	var originBgcolor = document.body.style.background;

	var originBgimage = document.body.style.backgroundImage;

	var p_content=document.all.printLayer.innerHTML;

     if (window.print) {

       //document.body.innerHTML = '<center>' + p_content + '</center>';

	   document.body.style.backgroundImage = '';

	   document.body.style.background = 'ffffff';

       document.body.innerHTML =  p_content;

       window.print();

     }

     window.location.reload();

//	document.body.style.backgroundImage=originBgimage;

//	document.body.style.background=originBgcolor;

//	document.body.innerHTML=bodystr;

}



function openPicWindow(basepath){

	var url = "/FCKeditor/editor/filemanager/browser/mcpuk/browser.html?Type=Image&Connector=connectors/php/connector.php";

	if(basepath != ""){

		url = basepath+url;

	}

	openUrl(url,700,500);

}





function str2date(str){


	var aryDate = str.split("-");


	var month = parseInt(aryDate[1]) - 1;



	return new Date(aryDate[0],month,aryDate[2],0,0,0);

}




function moneyformat(expr) {
	
   //return format(expr,2);
   return format(expr,2).split('.')[0];
  }



function format(expr, decplaces) {

   var str = "" + Math.round(eval(expr) * Math.pow(10,decplaces));

	while (str.length <= decplaces) {
    str = "0" + str;
   }

	var decpoint = str.length - decplaces;
	
	
	var leftnum=str.substring(0,decpoint);
	
	
//	逗号格式化
	
	if(!/^(\+|-)?\d+(\.\d+)?$/.test(leftnum)){return leftnum;}

  var re = new RegExp().compile("(\\d)(\\d{3})(,|\\.|$)");

  leftnum += ""; while(re.test(leftnum))

    leftnum = leftnum.replace(re, "$1,$2$3")

//	逗号格式化
	

	
	
   return leftnum + "." + str.substring(decpoint,str.length);
}







function getCookie(name){
		var r = new RegExp("(^|;|\\s)*"+name+"=([^;]*)(;|$)");
		var m = document.cookie.match(r);
		return (!m?"":m[2]);
	}
	
	
	
	
	
function CheckAll()
{
   var AllCKBox = document.getElementsByTagName("input");
   var CKBox1 = document.getElementById("CheckBox1");
   if(CKBox1.checked==true){
   for (var i=0; i<AllCKBox.length; i++)
      if (AllCKBox[i].type == "checkbox") AllCKBox[i].checked = true;
   }
   else
   {
   for (var i=0; i<AllCKBox.length; i++)
      if (AllCKBox[i].type == "checkbox") AllCKBox[i].checked = false;
   }
} 
	
	
	
	
function in_array(stringToSearch, arrayToSearch) {
    for (s = 0; s <arrayToSearch.length; s++) {
        thisEntry = arrayToSearch[s].toString();
        if (thisEntry == stringToSearch) {
            return true;
        }
    }
    return false;
}