﻿


function closerRightMenu()
{
    document.oncontextmenu = function() { return false;}
}


function ch(control,mess)
{	

	if(trim(control.value)=="")
	{
		alert(mess);
		control.focus();
		control.select();
		return false;
	}
	return true;
	
}

function lstch(control,mess)
{	

	if(trim(control.value)=="")
	{
		alert(mess);
		control.focus();
		return false;
	}
	return true;
	
}

//是不是一个数字
			
function isNum(control,mess)
{
				
	if(trim(control.value)!="")
	{
		if(isNaN(control.value))
		{
			alert(mess);
   			control.focus();
   			 return false;
		}
	}   
	return true;			

}

//是不是一个整数
function isNumber(control,mess)
{
				
	var re = /^[0-9]+$/i;
     if(re.test(control.value))
     {      
        return true;
     }
     else
     {
        alert(mess);
        control.focus();
        control.select();
        return false;
     }					

}

function isIntNumber(control,mess)
{
				
	 var re = /^[0-9]+$/i;
     if(re.test(control.value))
     {      
        return true;
     }
     else
     {
        alert(mess);
        control.focus();
        control.select();
        return false;
     }			

}

//控件值是否是否大于等于value
function pricecompare(control,comparevalue,mess)
{
				
	if(trim(control.value)!="")
	{
		if(control.value<comparevalue)
		{
			alert(mess);
   			control.focus();
   			control.select();
   			 return false;
		}
	}   
	return true;			

}

			

//去前后空格
function trim(value)
{
	return  value.replace(/(^\s*)  |(\s*$)/g,  "");
}

//删除确认
function DeleteInfo()
{
    if (confirm("您确认要执行删除操作吗？") != 0)
         return true;
    else
         return false;
}

 
function DeleteUnitAndShop()
{
    if (confirm("您确认删除街道和街道中的店铺吗？") != 0)
         return true;
    else
         return false;
}

function DeleteShop()
{
    if (confirm("您确认删除店铺吗？") != 0)
         return true;
    else
         return false;
}

function GoBack()
{
    history.back();
}

function openHelp(helpFile)
{
	window.open(helpFile,"","toolbar=no,menubar=no,location=true,scrollbars=yes,resizable=yes,status=yes");
}

function equ(control1,control2,mess)
{
	if(control1.value != control2.value)
	{
		alert(mess);
		control2.focus();
		return false;
	}
	return true;
}


function selectDate(ctrlid)
{
    window.open("common/calender.htm?ctrlId=" + ctrlid,"newwin","width=180,height=180,resize=no,scrollbars=no");
}

//价格验证(四位小数)
function moneycheck(control,mess)
{   
    var re = /^[0-9]{1,15}(.[0-9]{0,2})?$/i;
     if(re.test(control.value))
     {      
        return true;
     }
     else
     {
        alert(mess);
        control.focus();
        control.select();
        return false;
     }
          
}

//验证是不是小数(两位小数)
function numbercheck(control,mess)
{   
    var re = /^[0-9]+(.[0-9]{2})?$/i;
     if(re.test(control.value))
     {      
        return true;
     }
     else
     {
        alert(mess);
        control.focus();
        control.select();
        return false;
     }
          
}

//密码检测
function passcheck(control,mess)
{   
    var re = /^[a-zA-Z0-9]{3,15}$/i;
     if(re.test(control.value))
     {      
        return true;
     }
     else
     {
        alert(mess);
        control.focus();
        control.select();
        return false;
     }
          
}

//非法字符
function nonlicetchar(control,mess)
{
//     var re = "'";
//     var i;
//     var str = control.value;
//     for(i=0;i<str.length;i++)
//     {
//         var c = str.charAt(i);
//         if(re.indexOf(c) >= 0)         
//         {  
//             alert(mess);
//             control.focus();
//             control.select();
//             return false;              
//         }         
//     }
     
     return true;
}

//是否有网页脚本
function isHaveHtmlScript(control,mess)
{
     var re = /(<(.)+>)/i;
     var str = control.value.toLowerCase();
     if(re.test(str))
     {
        alert(mess);
        control.focus();
        control.select();
        return false;
     }
     return true;
}

//是否有客户端脚本
function isHaveJavaScript(control,mess)
{
     var re = /(script)/i;
     var str = control.value.toLowerCase();
     if(re.test(str))
     {
        alert(mess);
        control.focus();
        control.select();
        return false;
     }
     return true;
     
}

//只能输入数字,字母,下划线,汉字
function strcheck1(control,mess)
{
     var re = /^\w+$|^[\u4e00-\u9fa5]{0,}$/i;
     if(re.test(control.value))
     {      
        return true;
     }
     else
     {
        alert(mess);
        control.focus();
        control.select();
        return false;
     }
}

//身份证位数验证
function identitycardcheck(control,mess)
{
     var re = /^\d{15}$|^\d{18}$/i;
     if(re.test(control.value))
     {  
        return true;
     }
     else
     {
        alert(mess);
        control.focus();
        control.select();
        return false;
     }
}

function intcheck(control,mess)
{
     var re = /^[0-9]*$/i;
     if(re.test(control.value))
     {      
        return true;
     }
     else
     {
        alert(mess);
        control.focus();
        control.select();
        return false;
     }
}

function emailcheck(control,mess)
{
     var re = /^[\w.-]+@([0-9a-z][\w-]+\.)+[a-z]{2,3}$/i;
     if(re.test(control.value))
     {      
        return true;
     }
     else
     {
        alert(mess);
        control.focus();
        control.select();
        return false;
     }  
}


function urlcheck(control,mess)
{
     var re = /^(http[s]{0,1}:\/\/(.)*)/i;
     var str = control.value.toLowerCase();
     if(re.test(str))
     {      
        return true;
     }
     else
     {
        alert(mess);
        control.focus();
        control.select();
        return false;
     }  
}

function strlen(str){
	var len;
	var i;
	len = 0;
	for (i=0;i<str.length;i++){
		if (str.charCodeAt(i)>255) len+=2; else len++;
	}
	return len;
}

function maxLength(control,MaxLen,mess)
{
    var ml;
	ml=MaxLen;
	if(strlen(control.value)>ml)
	{
		alert(mess);
   		control.focus();
   		control.select();
   		return false;
	}
	return true;
}
			

function strlen2(str){
	var len;
	var i;
	len = 0;
	for (i=0;i<str.length;i++){
		if (str.charCodeAt(i)>255) return true;
	}
	return false;
}


function GetParam(name)
{
var input = document.location.href.split('#')[0];
var result = input.replace(/\?/g," ").replace(/\&/g," ");
var items = result.split(' ');
var m = new RegExp("^" + name + "=","i");
var param = "";
for(var i=0;i<items.length;i++)
{
var temp = items[i];
temp = temp.replace(/\s/g,"");
if(temp=="")
continue;
if(temp.match(m))
{
if(param!="")
param += ",";
param += temp.replace(m,"");
}
}
return param;
} 

function SetSelectedIndex(name,value)
{

    slt = document.getElementById(name);
    if(slt!=null)
    {        
        for(i=0;i<slt.options.length;i++)
        {
            if(slt.options[i].value==value)
            {
                slt.selectedIndex=i;
                break;
            }
         }
     }
}

function SetCookie(sName, sValue) 
{ 
 document.cookie = sName + "=" + escape(sValue) + "; path=/"; 
} 
function GetCookie(sName) 
{ 
 var aCookie = document.cookie.split("; "); 
 for (var i=0; i < aCookie.length; i++) 
 { 
   
  var aCrumb = aCookie[i].split("="); 
  if (sName == aCrumb[0])  
  return unescape(aCrumb[1]); 
 } 
  
} 
function DelCookie(sName,sValue) 
{ 
document.cookie = sName + "=" + escape(sValue) + "; path=/; expires=Fri, 31 Dec 1999 23:59:59 GMT;"; 
} 


function   showToDay()   
  {   
  var   Nowdate=new   Date();   
  M=Number(Nowdate.getMonth())+1   
  return   Nowdate.getYear()+"-"+M+"-"+Nowdate.getDate();   
  }