﻿String.prototype.lTrim=function(){return this.replace(/^\s*/,"");};
String.prototype.rTrim=function(){return this.replace(/\s*$/,"");};
String.prototype.trim=function(){return this.rTrim().lTrim();};
function enc(s){
	return s==null?null:s.toString ().replace(/\%/g,"%00").replace(/=/g,"%3D");
}
function req(operation,options){
    return new Ajax.Request('/req.ashx?act='+operation,options);
}
function requestQuery(key){
    var rutrunVal = null;
    var query = location.search;
    if(key==null || typeof key == 'undefined')
        return query;
    var pkey = key+'=';
    if(query.length > 0){
       query = query.substring(1,query.length);
       if(query.indexOf(pkey)!=-1){
            query = query.split('&');
            query.each(function(parm){
                if(parm.startsWith(pkey)){
                    rutrunVal = parm.replace(pkey,'');
                }
            });
       }
    }
    return unescape(rutrunVal);
}
Element.addMethods({
    isEmpty:function(element){
        element = $(element);
        if($F(element) == ''){
            $(element).setStyle({backgroundColor: '#ffeffd'});
            return true;
        }else{
            $(element).setStyle({backgroundColor: ''});
            return false;
        }
    }
});
var addToOnload = function(fn){
    Event.observe(window, 'load',fn);
};
function setCookie(name,value,day){
	var expdate=new Date();
	var argv=setCookie.arguments;
	var argc=setCookie.arguments.length;
	var expires=(argc>2)?argv[2]:null;
	var path=(argc>3)?argv[3]:null;
	var domain=(argc>4)?argv[4]:null;
	var secure=(argc>5)?argv[5]:false;
	if(expires!=null) expdate.setTime(expdate.getTime()+(expires*3600000*24));
	document.cookie=name+"="+escape(value)+((expires==null)?"":("; expires="+expdate.toGMTString()))+((path==null)?"":("; path="+path))+((domain==null)?"":("; domain="+domain))+((secure==true)?"; secure":"");
}
function deleteCookie(name){
	var exp=new Date();
	exp.setTime(exp.getTime()-1);
	var cval=getCookie(name);
	document.cookie=name+"="+cval+"; expires="+exp.toGMTString();
}
function getCookie(cn){
	var dc=document.cookie;
	var prefix=cn+"=";
	var begin=dc.indexOf("; "+prefix);
	if(begin==-1){
		begin=dc.indexOf(prefix);
		if(begin!=0)return null;
	}else {
		begin+=2;
	}var end=document.cookie.indexOf(";",begin);
	if(end==-1){
		end=dc.length;
	}
	return unescape(dc.substring(begin+prefix.length,end));
}
function getWindowSize(){
	var myWidth=0,myHeight=0;
	if(typeof(window.innerWidth)=='number'){
		myWidth=window.innerWidth;
		myHeight=window.innerHeight;
	}else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){
		myWidth=document.documentElement.clientWidth;
		myHeight=document.documentElement.clientHeight;
	}else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){
		myWidth=document.body.clientWidth;
		myHeight=document.body.clientHeight;
	}
	return {width:myWidth,height:myHeight};
}
function getDocumentSize(){
    var winSize = getWindowSize();
    var docHeight=0,docWidth=0;
    if (window.innerWidth && window.scrollMaxX) {
        docWidth = window.innerWidth + window.scrollMaxX;
    } else if (document.body.scrollWidth > document.body.offsetWidth){
        docWidth = document.body.scrollWidth;
    } else {
        docWidth = document.body.offsetWidth;
    }
    if(docWidth < winSize.Width) docWidth = winSize.Width;
    if (window.innerHeight && window.scrollMaxY) {
        docHeight = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){
        docHeight = document.body.scrollHeight;
    } else {
        docHeight = document.body.offsetHeight;
    }
    if(docHeight < winSize.Height) docHeight = winSize.Height;
    if(document.body.offsetWidth && docWidth > document.body.offsetWidth)
        docWidth = document.body.offsetWidth;
    return {width:docWidth,height:docHeight};
}
function getWindowScroll(w) {
    var T, L, W, H;
    with (w.document) {
      if (w.document.documentElement && documentElement.scrollTop) {
        T = documentElement.scrollTop;
        L = documentElement.scrollLeft;
      } else if (w.document.body) {
        T = body.scrollTop;
        L = body.scrollLeft;
      }
      if (w.innerWidth) {
        W = w.innerWidth;
        H = w.innerHeight;
      } else if (w.document.documentElement && documentElement.clientWidth) {
        W = documentElement.clientWidth;
        H = documentElement.clientHeight;
      } else {
        W = body.offsetWidth;
        H = body.offsetHeight
      }
    }
    return { top: T, left: L, width: W, height: H };
}
var randnum = function()
{
    now = new Date();
    return now.getTime();
};
function DisableAll(){

    $('Form1').getElements().each(function(el){
        
        el.disabled = true;
    });
}

window.onresize=setWinSize;

 function setWinSize()
 {
     if(isIE6())
    {
        var obj=document.getElementsByTagName("body")[0];
        if(!obj)
        {
            return;
        }
        var sz=getWindowSize();
        if(sz.width<1023)
        {
            obj.style.width='1023';
        }
        else
        {
            obj.style.width=sz.width;
        }
    }
 }


function isIE6()
{
    if(!(window.attachEvent && !window.opera))
    {
        return false;
    }
    var ua = window.navigator.userAgent;
    var re = /MSIE( )(\d+(\.\d+)?)/;
    if(re.test(ua))
    {
        return (parseInt(RegExp.$2)==6);
    }
}




function setAllSelectVisibility(val) 
{ 
    var selects = document.getElementsByTagName("SELECT"); 
    for(var i = 0 ; i <selects.length;i++) 
    { 
        selects[i].style.visibility = val; 
    } 
} 

function DisableButton(val)
{
    if(!val) return ;    
    $A($('divRightContainer').getElementsByTagName('*')).each(function(el){
        if(el.type=="button")
            el.disabled=true;                   
    });
}


function getFormatDateEx(date_obj, date_templet){
    var year,month,day,hour,minutes,seconds,short_year,full_month,full_day,full_day,full_hour,full_minutes,full_seconds;
    if(!date_templet)date_templet = "yyyy-mm-dd hh:ii:ss";
    year = date_obj.getFullYear().toString();
    short_year = year.substring(2,4);
    month = (date_obj.getMonth()+1).toString();
    month.length == 1 ? full_month = "0" + month : full_month = month;
    day = date_obj.getDate().toString();
    day.length == 1 ? full_day = "0" + day : full_day = day;
    hour = date_obj.getHours().toString();
    hour.length == 1 ? full_hour = "0" + hour : full_hour = hour;
    minutes = date_obj.getMinutes().toString();
    minutes.length == 1 ? full_minutes = "0" + minutes : full_minutes = minutes;
    seconds = date_obj.getSeconds().toString();
    seconds.length == 1 ? full_seconds = "0" + seconds : full_seconds = seconds;
    return date_templet.replace("yyyy", year).replace("mm", full_month).replace("dd", full_day).replace("yy", short_year).replace("m", month).replace("d", day).replace("hh", full_hour).replace("ii", full_minutes).replace("ss", full_seconds).replace("h", hour).replace("i", minutes).replace("s", seconds);
}

/*星级标志*/
function showStart(srvCount)
{
    if(!srvCount)
    {
        return ;
    }
    var NUM=['零','一','二','三','四','五',]
    var starts=parseInt(srvCount/100);
    var span='<span>';
    if(starts>5)
    {
        starts =5;
    }
    for(var i=0;i<starts;i++)
    {
        span+='<img src="/Images/star2.gif" title="'+NUM[starts]+'星级义工" alt="'+NUM[starts]+'星级义工"/>';
    }
    span+='</span>';
    document.write(span);
}

function showSin(srvCount)
{

}


function ToDBCCase(inputStr)
{
    var rtStr='';
    for(var i=0; i<inputStr.length; i++)
    {
        var code=inputStr.charCodeAt(i);

        if (code== 12288)
        {
            code = 32;
        }
        else if (code> 65280 && code < 65375)
        {
            code = code - 65248;  
        }
        rtStr+=String.fromCharCode(code);
    }
    return rtStr;
}