/** document.getElementById(aId) */
function _e(aId){
    return document.getElementById(aId);
}
/** return Date String */
function _now(){
    var d = new Date();
	var m=new String(d.getMilliseconds()+1000);
    return d.toLocaleTimeString()+'.'+m.substring(1,m.length);
}
/** Log console error if console avalable
 */
function _console(){
    if (typeof console != "undefined"&&arguments.length>0) {
		var commands = ["log","error","warn","info","time","timeEnd",
				"debug","track","profile","profileEnd"];
		var ElogCom=4;
		var type=arguments[arguments.length - 1];
//		if(!type) type="log";
//		else arguments.length--;
		var ind=commands.indexOf(type);
		if (ind < 0) {
			type = "log";
			ind = 0;
		}
		else 
			arguments.length--;
		if(ind<ElogCom)arguments[0]=_now()+' '+arguments[0];
		var ev='console.'+type+'(arguments[0]';
		for(var i=1;i<arguments.length;i++)ev+=',arguments['+i+']';
		ev+=')';
		eval(ev);
	}
}

function getWindowHeight(){
    if (window.self && self.innerHeight) {
        return self.innerHeight;
    }
    if (document.documentElement && document.documentElement.clientHeight) {
        return document.documentElement.clientHeight;
    }
    return 0;
}

function getWindowWidth(){
    if (window.self && self.innerHeight) {
        return self.innerWidth;
    }
    if (document.documentElement && document.documentElement.clientWidth) {
        return document.documentElement.clientWidth;
    }
    return 0;
}

function resize(){
//    _console("Start resize()");
    var mainD = _e("main");
    var offsetTop = _e("header").offsetTop+_e("header").offsetHeight; //mainD.offsetTop;
//    _console("offsetTop:"+offsetTop+" header.Top:"+_e("header").offsetTop+" header.Height:"+_e("header").offsetHeight);	
    var height = getWindowHeight() - offsetTop - _e("footer").offsetHeight - 10;
//	_console("height:"+height+" WindowHeight"+getWindowHeight()+" footer.Height"+_e("footer").offsetHeight);
	
    if (height >= 250) {
        mainD.style.height = height + "px";
        _e("left").style.height = (height-1) + "px";
    } else {
        mainD.style.height = "";
        _e("left").style.height = "";
	}
/*    var adsD = _e("ads_right");
    var adsW = 0;
    if (adsD) 
        adsW = adsD.offsetWidth;
    var w = getWindowWidth() - _e("leftbar").offsetWidth - adsW - 10;
    if (w > 0) 
        mainD.style.width = w + "px";*/
	if(typeof(mainOnLoad) != "undefined")mainOnLoad();
}

function P7_limit(a, b){
    document.p7limit = a;
    document.p7min = b;
    if (document.getElementById && navigator.appVersion.indexOf("MSIE") > -1 && !window.opera) {
        if (window.attachEvent) {
            window.attachEvent("onresize", P7_setMinWidth);
            window.attachEvent("onload", P7_setMinWidth);
        }
        else {
            onload = P7_setMinWidth;
            onresize = P7_setMinWidth;
        }
    }
}

P7_limit('wrapper', 750);
function P7_setMinWidth(){//
    var cw, w, pl, pr, ml, mr, br, bl, ad, theDiv = document.p7limit;
    var g = document.getElementById(theDiv);
    w = parseInt(document.p7min);
    if (g && document.body && document.body.clientWidth) {
        gs = g.currentStyle;
        cw = parseInt(document.body.clientWidth);
        pl = parseInt(gs.paddingLeft);
        pr = parseInt(gs.paddingRight);
        ml = parseInt(gs.marginLeft);
        mr = parseInt(gs.marginRight);
        bl = parseInt(gs.borderLeftWidth);
        br = parseInt(gs.borderRightWidth);
        ml = ml ? ml : 0;
        mr = mr ? mr : 0;
        pl = pl ? pl : 0;
        pr = pr ? pr : 0;
        bl = bl ? bl : 0;
        br = br ? br : 0;
        ad = pl + pr + ml + mr + bl + br;
        if (cw <=
        w) {
            w -= ad;
            g.style.width = w + "px";
        }
        else {
            g.style.width = "auto";
        }
    }
}
