// JavaScript Document
//Cookie日期修正函数 function FixCookieDate(date)
function FixCookieDate(date){
var base = new Date(0);
var skew = base.getTime();
if (skew > 0)date.setTime(date.getTime() - skew);
}
//设置Cookie函数 function SetCookie(name,value,expires,path,domain,secure)
function SetCookie(name,value,expires,path,domain,secure){
document.cookie = name + "=" + escape(value) + ((expires)? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
}
//设置Cookie相应名值对中值的函数 function getCookieVal(offset)
function getCookieVal(offset) {
var endstr = document.cookie.indexOf(";",offset);
if (endstr == -1) endstr = document.cookie.length;
return unescape(document.cookie.substring(offset,endstr));
}	
//设置Cookie函数 function GetCookie(name)
function GetCookie(name){
var arg = name + '=';
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
var flag = ''
while (i<clen) {
var j = i + alen;
if (document.cookie.substring(i,j) == arg) flag = getCookieVal(j);
i = document.cookie.indexOf(" ",i) + 1;
if (i == 0) break;
}
return flag;
}
function DelCookie(name)
{
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
}
function FwerCookie(name,value){
var expdate = new Date();
FixCookieDate(expdate);//修正MAC机器的BUG
expdate.setTime(expdate.getTime() + (1000*60*60*24*365));//设置Cookie的有效期为1年
SetCookie(name,value,expdate,'/','');
}
function GetRandomNum(Min,Max){   
        var Range = Max - Min;   
        var Rand = Math.random();   
        return(Min + Math.round(Rand * Range));   
}
function getInfo(strFull,strName) 
{ 
	strFull=strFull.strip();
	var arrTmp = strFull.split("|"); 
	for(var i = 0; i < arrTmp.length; i++) 
	{ 
		var arrTemp = arrTmp[i].split("^"); 
		if(arrTemp[0].toUpperCase() == strName.toUpperCase()) return arrTemp[1]; 
	} 
	return ""; 
}
function reAsk(sStr)
{
    return confirm(sStr);
}
function lie(exp1, exp2)//整除 注:a%b,js里面的余数函数
{
    var n1 = Math.round(exp1); //四舍五入
    var n2 = Math.round(exp2); //四舍五入    
    var rslt = n1 / n2; //除    
    if (rslt >= 0)
    {
        rslt = Math.floor(rslt); //返回值为小于等于其数值参数的最大整数值。
    }
    else
    {
        rslt = Math.ceil(rslt); //返回值为大于等于其数字参数的最小整数。
    }    
    return rslt;
}
function getFileName(o)
{
    var pos=o.value.lastIndexOf("\\");
    return o.value.substring(pos+1);//文件名
    
}
function GetFileExt(o)
{
    //return o.value.replace(/.+\./,"");
	return o.replace(/.+\./,"");
}
function getInfo(strFull,strName) 
{ 
	strFull=strFull.strip();
	var arrTmp = strFull.split("|"); 
	for(var i = 0; i < arrTmp.length; i++) 
	{ 
		var arrTemp = arrTmp[i].split("^"); 
		if(arrTemp[0].toUpperCase() == strName.toUpperCase()) return arrTemp[1]; 
	} 
	return ""; 
}
function iskong(id)
{if ($(id).value.strip()==''){alert('此字段必须录入,不得为空!');$(id).focus();return true;} else return false;}
function isk(id)
{return ($(id).value.strip()=='');}	
/*--------------------------------字符串属性扩展-----------------------------------*/

String.prototype.len = function(){return this.replace(/[^\x00-\xff]/g,"**").length;};
String.prototype.isSj = function()
{
	return /^13\d{9}$/g.test(this)||(/^15[8,9]\d{8}$/g.test(this))
}

String.prototype.isEmail = function()
{
  return /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(this);
}
String.prototype.isUrl = function()
{
     return /^http[s]?:\/\/([\w-]+\.)+[\w-]+([\w-./?%&=]*)?$/i.test(this);
}
String.prototype.isDh = function()
{
     if (this.indexOf('-')==-1)return false
	 else	 
	 	return /(^[0-9]{3,4}\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/.test(this);
}
String.prototype.isYb = function()
{
   return /^[\\d]{6}$/.test(this);
}
String.prototype.isHz = function()
{    
     return /^[\x00-\xff]*$/.test(this);
}
String.prototype.left = function(len)
{

        if(isNaN(len)||len==null)
        {
                len = this.length;
        }
        else
        {
                if(parseInt(len)<0||parseInt(len)>this.length)
                {
                        len = this.length;
                }
        }
        
        return this.substr(0,len);
}
String.prototype.right = function(len)
{

        if(isNaN(len)||len==null)
        {
                len = this.length;
        }
        else
        {
                if(parseInt(len)<0||parseInt(len)>this.length)
                {
                        len = this.length;
                }
        }
        
        return this.substring(this.length-len,this.length);
}
String.prototype.mid = function(start,len)
{
        return this.substr(start,len);
}
function kefuqq(id,qq)
{
	$(id).href='tencent://message/?uin='+qq+'&amp;Site=客户服务&amp;Menu=yes';
	$(id).click();
}

