﻿var isIE7pre = (getIEVersonNumber() < 7);

function spliter_click(){
    if(document.getElementById("leftdiv").style.display !== "none"){
        document.getElementById("leftdiv").style.display = "none";
        document.getElementById("spliter").className = "splitertoright";
        document.getElementById("spliterbg").style.left = "0px";
        setCookie("spliter", "onleft");
	if (isIE7pre){
	    var iwidth = parseInt(iebody().offsetWidth);
            if (iwidth > 4) document.getElementById("rightdiv").style.width = iwidth-4;
	}
    }
    else{
        document.getElementById("leftdiv").style.display = "block";
        document.getElementById("spliter").className = "splitertoleft";
        document.getElementById("spliterbg").style.left = "160px";
        document.getElementById("rightdiv").className = "rightdiv";
        delCookie("spliter");
        
        if (isIE7pre){
	    var width = parseInt(iebody().offsetWidth);
            if (width > 195) document.getElementById("rightdiv").style.width = width-195;
	}
    }
}
    
function spliterbg_mouseover(){
     if(document.getElementById("leftdiv").style.display !== "none"){
        document.getElementById("spliterbg").style.marginLeft = "-0px";
        document.getElementById("spliterbg").style.cursor = "pointer";
		document.getElementById("spliter").className = "splitertoleft";
     }
     else{
        document.getElementById("spliterbg").style.marginLeft = "0px";
        document.getElementById("spliterbg").style.cursor = "pointer";
     }
}

function spliterbg_mouseout(){
    document.getElementById("spliterbg").style.margin = "auto";
}

function iebody() {
	return (document.compatMode != "BackCompat"? document.documentElement : document.body);
}

function getIEVersonNumber() {
	var ua = navigator.userAgent;
	var msieOffset = ua.indexOf("MSIE ");
	if(msieOffset < 0) {
		return 0;
	}
	return parseFloat(ua.substring(msieOffset + 5, ua.indexOf(";", msieOffset)));
 }

function setCookie(name,value) {
    var exp  = new Date(); 
    exp.setTime(exp.getTime() + 600*1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}

function getCookie(name) {
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
     if(arr != null) return unescape(arr[2]);
     return null;
}

function delCookie(name) {
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval = getCookie(name);
    if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}