
//我自定义过程和函数————Javascript

//变量表________________________________________________________


//过程__________________________________________________________


//函数__________________________________________________________
function GetRMB(invalue){
    //返回大写人民币金额
    if(!(invalue!="" && !isNaN(invalue))) return ""
    strNUM=new Array("零","壹","贰","叁","肆","伍","陆","柒","捌","玖");
	strDW=new Array("仟","佰","拾","万","仟","佰","拾","元","角","分");
	strRMB="";
	tint=parseInt(invalue);
	for(i=0;i<invalue.length-1;i++) 
	   if(invalue.charAt(i)==".") break;
	tf=(invalue+"00").substr(i+1,2);
	tf=isNaN(tf)?0:parseInt(tf)
	n=0;
	show=false;
	for(i=10000000;i>=1;i/=10){
	    temp=parseInt(tint/i);
		tint=parseInt(tint%i)
		if(temp!=0) show=true;
		if(show)
		   strRMB=strRMB+strNUM[temp]+strDW[n];
		n=n+1;
	}
	for(i=10;i>=1;i/=10){
	    temp=parseInt(tf/i);
		tf=parseInt(tf%i);
		strRMB=strRMB+strNUM[temp]+strDW[n];
		n=n+1;
	}
	return strRMB;
}

function isValidString(FieldControl,inStr,Message){
   //判断控件值是否在指定的字符内
   if(!IsInString(inStr,FieldControl.value)){
	   alert(Message);
	   FieldControl.focus();
	   return false;
	 }
   else{
       return true;
	 }
}

function GetBrowser(){
    //得么浏览器名
    return navigator.appName
}

function isValidNull(FieldControl, Message){ 
	//判断控件值是否为空
	if (Trim(FieldControl.value) == "" || FieldControl.value==null || Trim(FieldControl.value) == "NULL") {
		FieldControl.focus();
        alert(Message);
        return false;
    }else{
		return true;
    }
}

function isValidNumber(FieldControl, Message){
	//判断控件值是否为数字
	if (Trim(FieldControl.value) == "" || FieldControl.value==null) {
		return true;
	}else{
		if (isNaN(FieldControl.value)) {
			FieldControl.focus();
			alert(Message);
			return false;
		}else{
			return true;
		}
	}
}

function isValidEmail(FieldControl, Message){
	//判断控件值是否为合法的电子邮件
	if (Trim(FieldControl.value) == "" || FieldControl.value==null) {
		return true;
	}else{
		if (FieldControl.value.charAt(0)=="." ||FieldControl.value.charAt(0)=="@"||FieldControl.value.indexOf('@', 0) == -1||FieldControl.value.indexOf('.', 0) == -1||FieldControl.value.lastIndexOf("@")==FieldControl.value.length-1||FieldControl.value.lastIndexOf(".")==FieldControl.value.length-1) {
			FieldControl.focus();
			alert(Message);
			return false;
		}else{
			return true;
		}
	}
}

function chkdate(ctl,datestr,Message,isCheckNull,fchar)
         //判断控件值是否为YYYY/MM/DD格式的日期型
{
		
	if (isCheckNull==false){
		if (datestr==null || datestr==""){
			return true;
		}
	}
	
	if (datestr==null || datestr==""){
		alert(Message);
		ctl.focus();
		return false;
	}
	
	var lthdatestr;
	lthdatestr= datestr.length;
	var tmpy="";
	var tmpm="";
	var tmpd="";
	var status;
	status=0;

	for (i=0;i<lthdatestr;i++){
		if (datestr.charAt(i)== fchar){
			status++;
		}
		if (status>2){
			alert(Message);
			ctl.focus();
			return false;
		}
		if ((status==0) && (datestr.charAt(i)!=fchar)){
			tmpy=tmpy+datestr.charAt(i)
		}
		if ((status==1) && (datestr.charAt(i)!=fchar)){
			tmpm=tmpm+datestr.charAt(i)
		}
		if ((status==2) && (datestr.charAt(i)!=fchar)){
			tmpd=tmpd+datestr.charAt(i)
		}
	}

	year=new String (tmpy);
	month=new String (tmpm);
	day=new String (tmpd)
	if ((tmpy.length!=4) || (tmpm.length>2) || (tmpd.length>2))
	{
		alert(Message);
		ctl.focus();
		return false;
	}
	if (!((1<=month) && (12>=month) && (31>=day) && (1<=day)) )
	{
		alert (Message);
		ctl.focus();
		return false;
	}
	if (!((year % 4)==0) && (month==2) && (day==29))
	{
		alert (Message);
		ctl.focus();
		return false;
	}
	if ((month<=7) && ((month % 2)==0) && (day>=31))
	{
		alert (Message);
		ctl.focus();
		return false;
	}
	if ((month>=8) && ((month % 2)==1) && (day>=31))
	{
		alert (Message);
		ctl.focus();
		return false;
	}
	if ((month==2) && (day==30))
	{
		alert(Message);
		ctl.focus();
		return false;
	}
	
	if(month<10){
		month="0" + eval(tmpm);
	}
	if(day<10){
		day="0" + eval(tmpd);
	}
	
	//ctl.value=year + fchar + month + fchar + day;
	return true;
}

function chktime(ctl,datestr,Message,isCheckNull)
         //判断控件值是否为hh:mm:ss格式的时间型
{
		
	if (isCheckNull==false){
		if (datestr==null || datestr==""){
			return true;
		}
	}
	
	if (datestr==null || datestr==""){
		alert(Message);
		ctl.focus();
		return false;
	}
	
	var lthdatestr;
	lthdatestr= datestr.length;
	var tmpy="";
	var tmpm="";
	var tmpd="";
	var status;
	status=0;

	for (i=0;i<lthdatestr;i++){
		if (datestr.charAt(i)== ':'){
			status++;
		}
		if (status>2){
			alert(Message);
			ctl.focus();
			return false;
		}
		if ((status==0) && (datestr.charAt(i)!=':')){
			tmpy=tmpy+datestr.charAt(i)
		}
		if ((status==1) && (datestr.charAt(i)!=':')){
			tmpm=tmpm+datestr.charAt(i)
		}
		if ((status==2) && (datestr.charAt(i)!=':')){
			tmpd=tmpd+datestr.charAt(i)
		}
	}

	year=new String (tmpy);
	month=new String (tmpm);
	day=new String (tmpd)
	if ((tmpy.length>2) || (tmpm.length>2) || (tmpd.length>2))
	{
		alert(Message);
		ctl.focus();
		return false;
	}
	if (!(0<=year && year<=23))
	{
		alert (Message);
		ctl.focus();
		return false;
	}
	
	if (!((0<=month) && (59>=month) && (59>=day) && (0<=day)) )
	{
		alert (Message);
		ctl.focus();
		return false;
	}
	if(year<10){
		year="0" + eval(tmpy);
	}
	if(month<10){
		month="0" + eval(tmpm);
	}
	if(day<10){
		day="0" + eval(tmpd);
	}
	
	//ctl.value=year + "/" + month + "/" + day;
	return true;
}

function CheckChars(sText){
	//判断实参是否仅包含数字和字母或者是下划线和减号
	var ValidChars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_";
	var IsChars=true;
	var Char;
	
	for(i=0;i<sText.length && IsChars==true;i++){
		Char=sText.charAt(i);
		if (ValidChars.indexOf(Char)==-1){
			IsChars=false;
		}
	}
	return IsChars;
}

function IsInString(sString,sText){
	//判断sText是否仅包含于sString内
	var ValidChars=sString
	var IsChars=true;
	var Char;
	
	for(i=0;i<sText.length && IsChars==true;i++){
		Char=sText.charAt(i);
		if (ValidChars.indexOf(Char)==-1){
			IsChars=false;
		}
	}
	return IsChars;
}

function Trim(TRIM_VALUE){
	//去左右空格
	if(TRIM_VALUE.length < 1){
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
		return "";
	}
	else{
			return TRIM_VALUE;
	}
}

function RTrim(VALUE){
	//去右边空格
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	
	if(v_length < 0){
		return"";
	}
	var iTemp = v_length -1;
	
	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){}
    	else{
    		strTemp = VALUE.substring(0,iTemp +1);
    		break;
    	}
    	iTemp = iTemp-1;
    }
    return strTemp;
}


function LTrim(VALUE){
	//去左边空格
	var w_space = String.fromCharCode(32);

	if(v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";
	var iTemp = 0;

	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){}
		else{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
    	iTemp = iTemp + 1;
    }
    return strTemp;
}

function open_new_window(Url,left,top,width,height){ 
   var win_open; 
   win_open=window.open(""+Url,'Win_prodw','toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,location=no,directiories=no,left='+left+',top='+top+',width='+width+',height='+height+'');
   win_open.focus(); 
}

function viewPage(page)
{
	var fm = document.myForm;
	fm.page.value = page;
	fm.submit();
}

function search_word(invalue){
if(invalue=="" ) return "Products Search"
if(invalue!="" ) return invalue
}



function openWindow(thehref,inwidth,inheight,inleft,intop)
{
	window.open(thehref,"new","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+inwidth+",height="+inheight+",left="+inleft+",top="+intop+"");
	return false;
}

function openWindow_home(thehref,inwidth,inheight,inleft,intop)
{
	window.open(thehref,"new","");
	return false;
}



  function check_number(thisvalue){ 
  var val = thisvalue.value; 
  var parten = /[0-9]/; 
  if(parten.exec(val)){ 
   // alert("ok"); 
  }else{ 
    thisvalue.value="";
    alert("只能输入数字"); 
	
  } 
  return false; 
}




function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}


