﻿// JScript File
var ns4 = document.layers;
var op5 = (navigator.userAgent.indexOf("Opera 5")!=-1) ||(navigator.userAgent.indexOf("Opera/5")!=-1);
//var op6 = (navigator.userAgent.indexOf("Opera 6")!=-1) ||(navigator.userAgent.indexOf("Opera/6")!=-1);
//var agt=navigator.userAgent.toLowerCase();
//var mac = (agt.indexOf("mac")!=-1);
//var ie = (agt.indexOf("msie") != -1);
//var mac_ie = mac && ie;

function $(id){
    if (document.getElementById){
        return document.getElementById(id);
    }
    else if(document.all){
        return document.all[id];
    }
    return null;    
}

function getElementWidth(elem) {
	if (ns4) {		
		return parseInt(elem.clip.width);
	} else {		
		if (op5) {
			return parseInt(elem.style.pixelWidth);
		} else {
			return parseInt(elem.offsetWidth);
		}
		return 0;
	}
}
function getElementHeight(elem) {
	if (ns4) {		
		return parseInt(elem.clip.height);
	} else {		
		if (op5) {
			return parseInt(elem.style.pixelHeight);
		} else {
			return parseInt(elem.offsetHeight);
		}
		return 0;
	}
}


var General = {     
  
  agent : navigator.userAgent.toLowerCase(),
     
  addContentOverflow: function() {
    if ($("content") != null) {       
        var contentHeight = this.getWindowSize().height 
            - ( getElementHeight($("topNavigation")) + getElementHeight($("footer")) );
        
        if (contentHeight <= 0)
            contentHeight = 0;
        
        $("content").style.height = contentHeight + "px";                 
        $("content").style.width = this.getWindowSize().width + "px"; 
        
        $("innerContent").style.width = this.getWindowSize().width + "px"; 
        $("innerContent").style.overflow = "scroll";
        
        var contentH = getElementHeight($("innerContent"));
        var leftNavH = getElementHeight($("leftNavigation"));
        
        if (contentHeight >= leftNavH
            && contentHeight >= contentH)
            $("leftNavigation").style.height =  parseInt(contentHeight-2) + "px";
        else {
            if (contentH >= leftNavH)        
                $("leftNavigation").style.height = contentH + "px";        
            else if (contentH < leftNavH)
                $("leftNavigation").style.height = leftNavH + "px";
        }        
            
        //if (this.agent.indexOf("msie 6") != -1)            
          //  $(contentId).style.height = (contentHeight) + "px";
        //else
    }
  },
  
  menuSize: function(idmenu) {
    if ($(idmenu) != null) {
        var pageWidth = this.getWindowSize().width;
        
        var windowW = this.getWindowSize().width;
        var aLI = $(idmenu).getElementsByTagName('li');
        
        var ulWidth = 5; //init width        
        if (aLI.length > 0) {
            for (var i=0;i<aLI.length;i++){                
                if (aLI[i].parentNode.className == "AspNet-Menu"){
                    ulWidth += getElementWidth(aLI[i]);
                }
            }
        }        
        
        if (pageWidth < ulWidth) {
            $(idmenu).style.width = ulWidth + "px";            
        }
        else {
            $(idmenu).style.width = "100%";
        }
    }
    else
        alert(";;");
  },
  
  getBody: function() {
    return document.documentElement? document.documentElement: document.body;
  },
  
  getWindowSize: function() {    
      var myWidth = 0, myHeight = 0;
      if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
      } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
      } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
      }
      return {width:myWidth , height:myHeight};
  },
  
  liBgColorChange: function(id,liBgColor) {    
    if ($(id)) {
        var aLI = $(id);        
        if (aLI != null) {
            this.liBgColor = liBgColor;
            var self = this;
            aLI.onmouseover = function(e) {var ev = (e? e :window.event); self.leftMenuOver(ev,self.liBgColor);};
            aLI.onmouseout = function(e) { var ev = (e? e :window.event); self.leftMenuOut(ev); };       
        }
    }    
  },
  
  leftMenuOver: function(ev, bgcolor) {    
    var el = (ev.target ? ev.target : ev.srcElement);
    if (el.parentNode.tagName.toLowerCase() == "li") el = el.parentNode;
    if (el.tagName.toLowerCase() == "li")
        el.style.backgroundColor = bgcolor;   
  },  
  leftMenuOut: function(ev) {
    var el = (ev.target ? ev.target : ev.srcElement);    
    if (el.parentNode.tagName.toLowerCase() == "li") el = el.parentNode;
    if (el.tagName.toLowerCase() == "li")
        el.style.backgroundColor = "";    
  }
}



