﻿//全选
function CheckAll(form,operation){
  for (var i=0;i<form.elements.length;i++){
    var e = form.elements[i];
    if (e.name != 'chkAll')
		if(operation==0){
			e.checked = false;
		}else if(operation==2){
			e.checked = !e.checked;
		}else{
			e.checked = true;
		}		
    }
}

//删除
function confirmsubmit(confirminfo,theform,actionurl){
	if(confirm(confirminfo)){
		if(actionurl!=''){ theform.action=actionurl; }
		//theform.submit();
		ajaxFormSubmit(theform);
	}else{
		return false;
	}
}

function getStrLen(str){
   var totallength=0;
   for(var i=0;i<str.length;i++){
		var intCode=str.charCodeAt(i);
		if (intCode>=0&&intCode<=128) {
			totallength=totallength+1; //非中文单个字符长度加 1
		}
		else {
			totallength=totallength+2; //中文字符长度则加 2
		}
   }
   return totallength;
}

function reloadImgSize(imgD,FitWidth,FitHeight){
var image1=new Image();  
image1.onload = function () 
{ 
    if(this.width>0 && this.height>0)  
    {  
        if(this.width/this.height>= FitWidth/FitHeight)  
        {  
            if(this.width>FitWidth)  
            {  
                imgD.width=FitWidth;  
                imgD.height=(this.height*FitWidth)/this.width;  
            }  
            else  
            {  
                imgD.width=this.width;  
                imgD.height=this.height;  
            }  
        }  
        else  
        {  
            if(this.height>FitHeight)  
            {  
                imgD.height=FitHeight;  
                imgD.width=(this.width*FitHeight)/this.height;  
            }  
            else  
            {  
                imgD.width=this.width;  
                imgD.height=this.height;  
            }  
        }  
    } 
    image1 = null; 
} 
image1.src=imgD.src;  
imgD.style.cursor = 'hand';
}

function setCenter(a){
	//thediv=document.getElementById("CenterWin");
	a.style.display='';
	a.style.left=(document.body.clientWidth/2-a.clientWidth/2)+"px";
	a.style.top=(document.body.scrollTop+250)+"px";
	document.body.scrollTop;
}

//manage left box
function manageleftlist_over(theli){
    if(theli.className=='leftMenuList'){
        theli.className='leftMenuList_over';
    }
}
function manageleftlist_out(theli){
    if(theli.className=='leftMenuList_over'){
        theli.className='leftMenuList';
    }
}
function GetCookieVal(offset){
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
    endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
    }
    
function getCookie(name){
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen){
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
        return GetCookieVal (j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
    } 
function getmanageleftlist_selected(){
    var theselectedlistid=getCookie("manageleftlistselected");
    //alert(theselectedlistid);
    if(theselectedlistid==''||theselectedlistid==null){
        return false;
    }else{
        document.getElementById(theselectedlistid).className='leftMenuList_selected';
    }
}
