

// JavaScript Document
	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"
			}
		]
	
	};
	BrowserDetect.init();
	
	function findPosition(oLink) 
	{
		if(oLink.offsetParent) 
		{
			for( var posX = 0, posY = 0; oLink.offsetParent; oLink = oLink.offsetParent ) 
			{
				posX += oLink.offsetLeft;
				posY += oLink.offsetTop;
			}
			
			return [ posX, posY ];
		} 
		else 
		{
			return [ oLink.x, oLink.y ];
		}
	}

	function getPageSize()
	{ 		
		var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
	
		if (self.innerHeight) {	// all except Explorer
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
			yScroll = document.documentElement.scrollHeight;
			
			if(windowWidth == undefined) windowWidth = screen.width;
			if(windowHeight == undefined) windowHeight = screen.height;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
	
	
	
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
		
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}
		
		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
		
		return arrayPageSize;
	}

	Object.prototype.getChildLink = function(parent)
	{
		var parent 	= new Object(this.getElementsByTagName(parent));
		var child	= new Array();

		for(var i=0; i < parent.length; i++)
		{
			var aChild = parent[i].getElementsByTagName('a');

				if(typeof(aChild[0]) == 'object')
				{
					var xml = document.createElement('rdf:data');
						xml.setAttribute('url', aChild[0].href);
						xml.setAttribute('target', (aChild[0].target != "") ? aChild[0].target : '_top');
						parent[i].appendChild(xml);	
						parent[i].onclick = function()
						{
							window.open(this.lastChild.getAttribute('url'), this.lastChild.getAttribute('target'), null)
						}
						
						try 
						{
							parent[i].style.cursor = 'pointer';
						} 
						catch(e){}
				}
		}
	}
	
	function getChildLink(object, parent)
	{
		var parent 	= new Object(object.getElementsByTagName(parent));
		var child	= new Array();
		
		for(var i=0; i < parent.length; i++)
		{
			var aChild = parent[i].getElementsByTagName('a')

				if(typeof(aChild[0]) == 'object')
				{
					var xml = document.createElement('rdf:data');
						xml.setAttribute('url', aChild[0].href);
						xml.setAttribute('target', (aChild[0].target != "") ? aChild[0].target : '_top');
						parent[i].appendChild(xml);	
						parent[i].onclick = function()
						{
							window.open(this.lastChild.getAttribute('url'), this.lastChild.getAttribute('target'), null)
						}
						
						try 
						{
							parent[i].style.cursor = 'pointer';
						} 
						catch(e){}
				}
		}
	}
	
	var interval = new Array();

	function switchMenu(show, id)
	{
		var elementById = null;
		var elementByTagName = null;
		
		try
		{
			elementById = document.getElementById(id);
		}
		catch(e) {}
		
		if(elementById != null)
		{
			try
			{
				elementByTagName = elementById.getElementsByTagName('ul');
			}
			catch(e) {}
			
			if(typeof(elementByTagName) == 'object')
			{
				if(show == true)
				{
					clearInterval(interval[id]);
					
					if(elementByTagName.length > 0)
						elementById.style.display = 'block';	
				}
				else
				{
					interval[id] = 	setInterval(function() 
									{
										document.getElementById(id).style.display = 'none';
									}, 500)
				}
			}
		}
	}
	
	function setMenuPosition(id, pos)
	{
		var elementById = null;
		
		try
		{
			elementById = document.getElementById(id);
		}
		catch(e) {}
		
		if(elementById != null)
			elementById.style.marginLeft = pos + 'px';
	}
	
	function setMenu()
	{
		var object 	= new String();
		var image	= new String();		

		var objects = new Array('services', 'support', 'partners', 'about', 'contact', 'home');
		var images	= new Array('49.png', '50.png', '48.png', '45.png', '46.png', '47.png')
		
		if(section == 'news' || section == 'archive')
			section = 'about';
		else if(section == 'default')
			section = 'home';
	
		for(var i=0; i < objects.length; i++)
		{
			var floatMenu, firstDiv, firstImage;
			var regexp = new RegExp(objects[i].toString())
			
			if(BrowserDetect.browser == 'Explorer' && parseFloat(BrowserDetect.version) < 7)
			{
				floatMenu 	= document.getElementById('floatMenu_' + objects[i].toString());
				
				try
				{
					var newImage 		= new Image();	
						newImage.src 	= '/images/51.png';
				
						firstDiv = floatMenu.getElementsByTagName('div')[0];
						
						firstImage	= new Object(firstDiv.getElementsByTagName('img')[0]);
						firstImage.src = newImage.src.toString();
				}
				catch(e){}
			}
			
			if(section.toString().match(regexp) != null)
			{
				object 	= objects[i].toString();
				image	= images[i].toString();		
				
				try
				{
					floatMenu = document.getElementById('floatMenu_' + objects[i].toString());

					if(typeof(floatMenu) == 'object')
					{
						floatMenu.style.display	= 'block';
						
						pos = findPosition(document.getElementById(objects[i].toString()))[0] - findPosition(document.getElementById('baseOfContent'))[0];
						
						setMenuPosition('floatMenu_' + objects[i].toString(), pos);
					}
				}
				catch(e){}
			}
			else
			{	
				try
				{
					floatMenu = document.getElementById('floatMenu_' + objects[i].toString());

					if(typeof(floatMenu) == 'object')
					{
						document.getElementById(objects[i]).onmouseover = function()
						{
							pos = findPosition(this)[0] - findPosition(document.getElementById('baseOfContent'))[0];
							
							switchMenu(true, 'floatMenu_' + this.id);
							setMenuPosition('floatMenu_' + this.id, pos);
						}
						
						document.getElementById(objects[i]).onmouseout = function()
						{
							switchMenu(false, 'floatMenu_' + this.id);
						}

						document.getElementById('floatMenu_' + objects[i]).onmouseover = function()
						{
							switchMenu(true, this.id);
						}
						
						document.getElementById('floatMenu_' + objects[i]).onmouseout = function()
						{
							switchMenu(false, this.id);
						}
					}
				}
				catch(e){}
			}

		}

		if(object != '')
		{
			var element 	= document.getElementById(object);
				element.src = '/images/' + image;
		}
	}

	window.addEvent('domready', function(){

		setMenu();
		
		if(BrowserDetect.browser == 'Explorer')
			getChildLink(document.getElementById('columnOnePosts'), 'div');	
		else
			document.getElementById('columnOnePosts').getChildLink('div');
			
		links = document.getElementsByTagName('ul');
		
		for(var i=0; i < links.length; i++)
		{
			if(BrowserDetect.browser == 'Explorer')
				getChildLink(links[i], 'li');	
			else
				links[i].getChildLink('li');	
		}

		// highlite active left menu item
		var as = $('columnOnePosts').getElements('a');
		for(var i=0;i< as.length; i++){
			if(document.location.href.indexOf(as[i].href) > -1){
				as[i].set('class', 'active');
			}
		}
	});



	
	