window.onload = function(){
	
	get_height_banner();
	get_height();
	
	
}



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: "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"
		}
	]

};




	

    function get_height_banner()  {
    	    
   		/*test for all pages to make the page header be at the right size*/
    	var height_header = document.getElementById('pageheader').offsetHeight;
    	document.getElementById('siteheader').style.height = height_header+15 + "px";
    	  	
    } 
    
 
    
    function get_height()  {
    	
    	/*test for the search page to make both side fit together*/
    	if ((document.getElementById('searchcontent') != null ) && (document.getElementById('paid') != null )) {   
    		
    		
    		
    		var height_keywords = document.getElementById('searchcontent').offsetHeight;
    		var height_paid = document.getElementById('paid').offsetHeight;
    		
  		
    		if (height_keywords >= height_paid) { 
    			height_paid = height_keywords; 					
    			document.getElementById('paid').style.height = height_paid + "px";
    			document.getElementById('searchimages').style.height = height_paid+5 + "px";
    			document.getElementById('searchtable').style.height = height_paid+5 + "px";
    			document.getElementById('searchcontentrightside').style.height = height_paid+5 + "px";
    			
    			
    		} else { 
    			height_keywords = height_paid; 
    			document.getElementById('searchtable').style.height = height_keywords-6 + "px";
    			document.getElementById('searchimages').style.height = height_keywords+5 + "px";
    			document.getElementById('searchcontentrightside').style.height = height_keywords+6 + "px";
    		}
    		
    		document.getElementById('menu_right1').style.paddingTop="10px";
   		 	document.getElementById('menu_right1').style.paddingBottom="10px";
   		 	document.getElementById('menu_right2').style.paddingTop="10px";
   		 	document.getElementById('menu_right2').style.paddingBottom="10px";
    		
 				var menu1 = document.getElementById('menu_right1').offsetHeight;
				var menu2 = document.getElementById('menu_right2').offsetHeight;
				if (menu1 > menu2) { 
					document.getElementById('menu_right2').style.height = menu1-20 + "px";;
					var menu_global_3 = menu1 + menu1;
				}
				if (menu1 < menu2) { 
					document.getElementById('menu_right1').style.height = menu2-20 + "px";;
					var menu_global_3 = menu2 + menu2;
				}
				
				if (menu1 == menu2) {
					var menu_global_3 = menu1 + menu2;
				}
				
				var menu_global_1 = document.getElementById('paid_global').offsetHeight;
							
				BrowserDetect.init();
			
				if ((BrowserDetect.browser == 'Explorer') && (BrowserDetect.version == 6 )){ 
					var menu_global4 = 16; 
				}else{
					var menu_global4 = 5; 
				}
				var menu_global_2 = height_keywords + menu_global_3 + menu_global4 ;
								
				if (menu_global_2 > menu_global_1) { 
					difference = menu_global_2 - menu_global_1; 
					document.getElementById('searchsearch').style.paddingBottom = difference + "px";

   		 	}else { 
   		 		difference = menu_global_1 - menu_global_2; 
   				document.getElementById('searchtable').style.paddingBottom = difference + "px";
    			document.getElementById('searchimages').style.paddingBottom = difference + "px";
   		 	}
			
 			//document.getElementById('pagecontent').style.height = menu_global_1 + "px";
 			
    }	
    	
    	
    	
    	
    	
    	
    	
    	
    }    

