function checkRes(func) {
  var initRes = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (initRes) {
        initRes();
      }
      func();
    }
  }
}

/****** Browser Check for IE/Netscape/Others ******/
function chkBrowserWidth(){
	if (document.body){return document.body.clientWidth;} 
	else if (document.documentElement && document.documentElement.clientWidth != 0){
		return document.documentElement.clientWidth;	}
	else if (window.innerWidth){
		return window.innerWidth;}	
	return 0;
}
	

checkRes(newRes);
window.onresize = newRes;

function newRes(){
		var fmt = chkBrowserWidth();
		var css = (fmt>0&&fmt<=980)?'aig800':(fmt>980&&fmt<=3000)?'aig1024':'';
		document.getElementById("body_wrapper").className=css;

};

/********************************************************/
/*********** Function for Left Menu Triggering **********/
/********************************************************/
function toggle(id){
    var ul = id;
    var ulElement = document.getElementById(ul);
    if (ulElement){
            if (ulElement.className == 'closed'){
                    ulElement.className = "open";
                    }else{
                    ulElement.className = "closed";
                    }
            }
    }

/********************************************************/


/********************************************************/
/****** Function to equalize the the column height ******/
/********************************************************/

function equalColumns(){
	var c = document.getElementById('gridCenter');
	var r = document.getElementById('gridRight');
	var l = document.getElementById('gridLeft');
	var cenb = document.getElementById('pageBanner');
	var x = navigator;
	var z = x.appName;	
	if(l){ /* Checks for availability of left grid */
		var browser=navigator.appName
		
		if ((browser=="Netscape")){ /* if its otherthan Explorer */  			
			l.style.height = "auto !important"; /* Very important => so that the extended menu pushes the left grid */
			
			/* Check the center height and changes the left section accordingly */
			c.offsetHeight >= l.offsetHeight ? l.style.minHeight = c.offsetHeight + "px" : c.style.height = l.offsetHeight + "px"; 
		}
		else{
			c.offsetHeight >= l.offsetHeight ? l.style.height = c.offsetHeight + "px" : c.style.height = l.offsetHeight + "px";
		}
	}
	if(r){
		/* Check the center height and changes the right section accordingly */
		c.offsetHeight >= r.offsetHeight ? r.style.height = c.offsetHeight + "px" : c.style.height = r.offsetHeight + "px";				
	}
	
	if(cenb){ /* This condition overwrites the above the script if the page banner is available */
				var z = parseInt(c.offsetHeight+cenb.offsetHeight);/* Adding the page banner height with the center section */
				if(l){
				var browser=navigator.appName
				if ((browser=="Netscape"))
					{l.style.height = "auto !important";
					z >= l.offsetHeight ? l.style.minHeight = parseInt(c.offsetHeight+cenb.offsetHeight) + "px" : c.style.height = parseInt(l.offsetHeight-cenb.offsetHeight) + "px";}
				else
					{z >= l.offsetHeight ? l.style.height = parseInt(c.offsetHeight+cenb.offsetHeight) + "px" : c.style.height = parseInt(l.offsetHeight-cenb.offsetHeight) + "px";}
			}
			if(r){
				z >= r.offsetHeight ? r.style.height = c.offsetHeight + "px" : c.style.height = r.offsetHeight + "px";				
			}
		}
}
	window.onload = function(){
    equalColumns(); /* calls the function on page loads */
    }		
/********************************************************/