 /* <![CDATA[ */

//*************************************************************************
//***	DOM LIBRARY
//*************************************************************************

//*** GLOBAL VARIABEL
	var blnDOM = false;
	
//*** FUNCTIONS	
	//Advanced dthml check
	if (document.getElementById && document.createElement){
		blnDOM = true;
	}		
	
	//default image switch
	function fjsImgSwitch(id, imgsrc){
		if (blnDOM == true){		
			if (document.getElementById(item)){		
				//Switch image	
				document.getElementById(item).src = imgsrc;			
			}
		}
	}
	
	//Tool, strips away all path info
	function fjsGetFileName(varName) {
		var re = /^.*\/(\S*\.\S*)$/;
		var tmp = new String(varName);
		tmp = tmp.match(re)[1];
			
		return tmp;
	}
	
	//Swap classes for any item
	function fjsSwapClass(strId, class1, class2){
		if (blnDOM == true){			
			//Check if element exists
			if (document.getElementById(strId)){
				//Switch class
				if (document.getElementById(strId).className == class1){
					document.getElementById(strId).className = class2;
				}
				else if(document.getElementById(strId).className == class2){
					document.getElementById(strId).className = class1;
				}
			}
		}
	}
		
	//Change class for any item
	function fjsChangeClass(strId, class1){
		if (blnDOM == true){
			//Check if element exists
			if (document.getElementById(strId)){
				//Change class
				document.getElementById(strId).className = class1;
			}
		}
	}
	
	//Clear input boxes for default data 
	function fjsClearBox(e){			
		e.value = "";
		e.focus();			
	}	
	
	//When IE creates a new element it gives the new element about 84 attributes inherited from IE's default DTD. Oh what fun.
	//And when you try to change an attribute like "class", it actually creates a new attribute so you end up with 2 "class" attributes.
	//So, this function checks your node for a given attribute, if it exists then it changes the attribute value with the one given.
	//If the attribute doesnt exist, it creates a new one and sets its value.
	function fjsToolBox_setAttribute(oNode, strAttribute, strValue) 
	{
		if (oNode.getAttributeNode(strAttribute)) 
		{
			for (var i = 0; i < oNode.attributes.length; i++) {
				var attrName = oNode.attributes[i].name.toUpperCase();
				if (attrName == strAttribute.toUpperCase()) 
				{
					oNode.attributes[i].value = strValue;
				}
			}				
		}
		else {
			//create a new attribute 
			oNode.setAttribute(strAttribute, strValue);
		}
	}

	
	//retrieves content from text nodes
	function fjsToolBox_GetTextNodeContent(n) 
	{			
		var s = '';
		var children = n.childNodes;
		for(var i = 0; i < children.length; i++) 
		{
			var child = children[i];
			if (child.nodeType == 3 /*Node.TEXT_NODE*/) 
			{
				s += child.data;
			}
			else{ 
				s += getTextContent(child);
			}
		}
		return s;
	}	
	
	
	//Removes all content from a Node
	function fjsToolBox_RemoveNodes(oNode)
	{
	    while(oNode.firstChild) 
	    {
	        oNode.removeChild(oNode.firstChild);
        }
	}
	
	if(!document.importNode)
	{
	    document._importNode = function(oNode, bImportChildren)
	    {
		    var oNew;
            var attr;
            
		    if(oNode.nodeType == 1){
			    oNew = document.createElement(oNode.nodeName);
			    /*
			    for(var i = 0; i < oNode.attributes.length; i++){
				    oNew.setAttribute(oNode.attributes[i].name, oNode.attributes[i].value);
			    }
			    */
			    for (var i = 0; i < oNode.attributes.length; i++)
                {
                    attr = oNode.attributes[i];
                    if (attr.nodeValue != null && attr.nodeValue != '')
                    {
                        //oNew.setAttribute(attr.name, attr.nodeValue);
                        fjsToolBox_setAttribute(oNew, attr.name, attr.nodeValue);
                    }
                }
			    oNew.style.cssText = oNode.style.cssText;
		    } else if(oNode.nodeType == 3){
			    oNew = document.createTextNode(oNode.nodeValue);
		    }
    		
		    if(bImportChildren && oNode.hasChildNodes()){
			    for(var oChild = oNode.firstChild; oChild; oChild = oChild.nextSibling){
				    oNew.appendChild(document._importNode(oChild, true));
			    }
		    }
		        		
		    return oNew;
	    }
    }
    
    
    //** Start: Misc design hacking code **//
		
	//Begin: Browser detection
	var BrowserDetect = {
        init: function () {
	        this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
	        this.version = this.searchVersion(navigator.userAgent)
		        || this.searchVersion(navigator.appVersion)
		        || "an unknown version";
	        this.OS = this.searchString(this.dataOS) || "an unknown OS";
        },
        searchString: function (data) {
	        for (var i=0;i<data.length;i++)	{
		        var dataString = data[i].string;
		        var dataProp = data[i].prop;
		        this.versionSearchString = data[i].versionSearch || data[i].identity;
		        if (dataString) {
			        if (dataString.indexOf(data[i].subString) != -1)
				        return data[i].identity;
		        }
		        else if (dataProp)
			        return data[i].identity;
	        }
        },
        searchVersion: function (dataString) {
	        var index = dataString.indexOf(this.versionSearchString);
	        if (index == -1) return;
	        return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
        },
        dataBrowser: [
	        {
		        string: navigator.userAgent,
		        subString: "Chrome",
		        identity: "Chrome"
	        },
	        { 	string: navigator.userAgent,
		        subString: "OmniWeb",
		        versionSearch: "OmniWeb/",
		        identity: "OmniWeb"
	        },
	        {
		        string: navigator.vendor,
		        subString: "Apple",
		        identity: "Safari"
	        },
	        {
		        prop: window.opera,
		        identity: "Opera"
	        },
	        {
		        string: navigator.vendor,
		        subString: "iCab",
		        identity: "iCab"
	        },
	        {
		        string: navigator.vendor,
		        subString: "KDE",
		        identity: "Konqueror"
	        },
	        {
		        string: navigator.userAgent,
		        subString: "Firefox",
		        identity: "Firefox"
	        },
	        {
		        string: navigator.vendor,
		        subString: "Camino",
		        identity: "Camino"
	        },
	        {		// for newer Netscapes (6+)
		        string: navigator.userAgent,
		        subString: "Netscape",
		        identity: "Netscape"
	        },
	        {
		        string: navigator.userAgent,
		        subString: "MSIE",
		        identity: "Explorer",
		        versionSearch: "MSIE"
	        },
	        {
		        string: navigator.userAgent,
		        subString: "Gecko",
		        identity: "Mozilla",
		        versionSearch: "rv"
	        },
	        { 		// for older Netscapes (4-)
		        string: navigator.userAgent,
		        subString: "Mozilla",
		        identity: "Netscape",
		        versionSearch: "Mozilla"
	        }
        ],
        dataOS : [
	        {
		        string: navigator.platform,
		        subString: "Win",
		        identity: "Windows"
	        },
	        {
		        string: navigator.platform,
		        subString: "Mac",
		        identity: "Mac"
	        },
	        {
		        string: navigator.platform,
		        subString: "Linux",
		        identity: "Linux"
	        }
        ]

    };
    BrowserDetect.init();
	//End: Browser detection
	
	//Begin: Gets inner height of window
	function getWindowHeight() {
		var windowHeight = 0;
		if (typeof(window.innerHeight) == 'number') {
			windowHeight = window.innerHeight;
		}
		else {
			if (document.documentElement && document.documentElement.clientHeight) {
				windowHeight = document.documentElement.clientHeight;
			}
			else {
				if (document.body && document.body.clientHeight) {
					windowHeight = document.body.clientHeight;
				}
			}
		}
		return windowHeight;
	}
	//End: Gets inner height of window
	
	//Begin: Function to adjust width by one pixel so that body-background and content background line up
	function fjsAdjustWidth() {
	    
	    
	    var obj = document.getElementById("wrapper")
	    var iWidth = document.getElementById("body").offsetWidth
	    var iAdjust = 0;
	    //var strDebug = '(iWidth%2 != 0)='+ (iWidth%2 != 0) + " iWidth="+ iWidth +" offsetLeft=" + document.getElementById("wrapper").offsetLeft +' body.offsetWidth='+ iWidth;
	    
	    if (iWidth%2 != 0) {
	        if (BrowserDetect.browser.toLowerCase() != 'explorer') {
	            if (BrowserDetect.browser.toLowerCase() == 'firefox') {
	                iAdjust = -1;
	            } else {
	                iAdjust = 1;
	            }
	        }
	    }
	    
	    obj.style.left = iAdjust + 'px';
	    
	    //document.getElementById("debug2").innerHTML = strDebug + ' iAdjust=' + iAdjust;
	}
	//End: Function to adjust width by one pixel so that body-background and content background line up
	
	//Begin: Function that sets height and position af element that displays repeating backround below a certain height
	function setContentHeight() {
	    var iMysticalNumber;
	    //var body= document.getElementsByTagName('body')[0];
	    var objPageContent = document.getElementById('PageContent');
	  
        iMysticalNumber = 25;
	    
		if (document.getElementById) {
			var windowHeight = getWindowHeight();
			
			if (windowHeight > 0) {
			    var headerHeight = document.getElementById('SiteHeader').offsetHeight;
				var contentHeight = document.getElementById('contentSurround').offsetHeight;
				var footerHeight = document.getElementById('SiteFooter').offsetHeight;
				var allElementHeight = headerHeight + contentHeight + footerHeight;
				
				// Debugging :
				// alert('body.offsetHeight='+body.offsetHeight+'. allElementHeight='+allElementHeight+'. windowHeight='+windowHeight);
				
				if (windowHeight > allElementHeight) {
				    objPageContent.style.height = (windowHeight - (headerHeight + footerHeight + iMysticalNumber)) +'px';
				//  body.style.height = windowHeight +'px';
				//  alert('body.style.height = windowHeight -> '+ windowHeight +'?');
				} else {
				    objPageContent.style.height = contentHeight +'px';
				//  body.style.height = allElementHeight +'px';
				//  alert('body.style.height = allElementHeight -> '+ allElementHeight +'?');
				}
				
			}
		}
	}
	//End: Function that sets height and position af element that displays repeating backround below a certain height
	
	//Begin: position footer
	function setFooter() {
	    var iMysticalOffset = 180
	
        if (document.getElementById) {
            var windowHeight=getWindowHeight();
            if (windowHeight>0) {
                var contentHeight = document.getElementById('content').offsetHeight;
                var headerHeight = document.getElementById('header').offsetHeight;
                var footerElement = document.getElementById('footer');
                var footerHeight=footerElement.offsetHeight;
                
                //alert('contentHeight='+ contentHeight +' footerHeight='+ footerHeight +' windowHeight='+ windowHeight)
                
                if (windowHeight-(contentHeight+footerHeight)>= iMysticalOffset) {
                    footerElement.style.position='relative';
                    footerElement.style.top= (windowHeight-(contentHeight+footerHeight+headerHeight))+'px';
                    //footerElement.style.top= windowHeight+'px';
                } else {
                    footerElement.style.position='static';
                }
                //alert('windowHeight='+windowHeight+' headerHeight='+headerHeight+' contentHeight='+contentHeight+' footerHeight='+footerHeight+' top-pos='+parseInt(windowHeight-(contentHeight+footerHeight+headerHeight)));
            }
        }
    }
	//End: position footer
	
	
	window.onload = function() {
	//	setFooter();
	//	setBodyHeight();
		setContentHeight();
	//	fjsAdjustWidth();
	}
	window.onresize = function() {
	//	setFooter();
	//	fjsAdjustWidth();
	}
    
    //*** End: Misc design hacking code ***//
    
    
    function fjsChangeClass(strElementId,strClassName) {
        var obj = document.getElementById(strElementId);
        obj.className = ""+ strClassName +"";
        return true;
    }
    
    /* ]]> */
