
/*
Get correct placement for dropdowns
*/
function  getwidth(whichdropdown){
	try
	{
		dropdown = whichdropdown;
		if (window.innerWidth)
		{
			width = window.innerWidth - 18;
		}
		else if (document.documentElement && document.documentElement.clientWidth) 
		{
			width = document.documentElement.clientWidth;
		}
		else if (document.body && document.body.clientWidth) 
		{
			width = document.body.clientWidth;
		}

		if(dropdown =="1")
		{
			width = width - 982;
			width = width /2;
			widthfinal = width - 49;
			if(widthfinal<293)
			{
				widthfinal = 293;
			}
		}
		else
		{
			width = width - 982;
			width = width /2;
			widthfinal = width - 49;
			if(widthfinal<293)
			{
				widthfinal = 293;
			}
		}
	}
	catch(err)
	{

	}
}
		
/*
Show dropdown(s) and place them
*/
function showdropdown(whichdropdown){
	try{
		whichdropdown = whichdropdown;
		// call function to get placement for dropdowns

		getwidth(whichdropdown);

		//code to get the top postion of resultsControls div
		o = document.getElementById('resultsControls')
		oTop = o.offsetTop 
		while(o.offsetParent!=null) 
		{ 
			oParent = o.offsetParent
			oTop += oParent.offsetTop
			o = oParent
		}
		toppos = oTop ;
		dropdowntop = toppos +5;
		dropdownundertop = toppos -5;
		
		var ni = document.getElementById('resultsControls');
		
		if(whichdropdown == "1_PROD")
		{

			//add elemment (div) to show under dropdowns to check if a mouseout occured
			
			var newdivPR = document.createElement('div');
			newdivPR.setAttribute('id','dropdown1_PRODunder');
			newdivPR.onmouseover = function(){droptimer(4);};
			

			
			document.getElementById("dropdown1_Product").style.left=widthfinal+'px';
			document.getElementById("dropdown1_Product").style.top=dropdowntop+'px';
			document.getElementById("dropdown1_Product").style.visibility='visible';
			widthfinalunder = widthfinal -10;
			newdivPR.style.left=widthfinalunder+'px';
			newdivPR.style.top=dropdownundertop+'px';
			newdivPR.style.visibility='visible';
			ni.appendChild(newdivPR);
		}

		if(whichdropdown == "1_MR"){

			//add elemment (div) to show under dropdowns to check if a mouseout occured
			var newdivMR = document.createElement('div');
			newdivMR.setAttribute('id','dropdown1_MRunder');
			newdivMR.onmouseover = function(){droptimer(5);};
			ni.appendChild(newdivMR);

			document.getElementById("dropdown1_MR").style.left=widthfinal+'px';
			document.getElementById("dropdown1_MR").style.top=dropdowntop+'px';
			document.getElementById("dropdown1_MR").style.visibility='visible';
			widthfinalunder = widthfinal -10;
			document.getElementById("dropdown1_MRunder").style.left=widthfinalunder+'px';
			document.getElementById("dropdown1_MRunder").style.top=dropdownundertop+'px';
			document.getElementById("dropdown1_MRunder").style.visibility='visible';
		}

		if(whichdropdown == "2_MR")
		{
			//add elemment (div) to show under dropdowns to check if a mouseout occured
			var newdivMRS = document.createElement('div');
			newdivMRS.setAttribute('id','dropdown2_MRunder');
			newdivMRS.onmouseover = function(){droptimer(6);};
			ni.appendChild(newdivMRS);
			
			widthfinal = widthfinal +143;
			document.getElementById("dropdown2_MR").style.left=widthfinal+'px';
			document.getElementById("dropdown2_MR").style.top=dropdowntop+'px';
			document.getElementById("dropdown2_MR").style.visibility='visible';
			widthfinalunder = widthfinal -10;
			document.getElementById("dropdown2_MRunder").style.left=widthfinalunder+'px';
			document.getElementById("dropdown2_MRunder").style.top=dropdownundertop+'px';
			document.getElementById("dropdown2_MRunder").style.visibility='visible';
		}

		if(whichdropdown == "1")
		{
			//add elemment (div) to show under dropdowns to check if a mouseout occured
			var newdiv = document.createElement('div');
			newdiv.setAttribute('id','dropdown1under');
			newdiv.onmouseover = function(){droptimer(1);};
			ni.appendChild(newdiv);

			document.getElementById("dropdown1").style.left=widthfinal+'px';
			document.getElementById("dropdown1").style.top=dropdowntop+'px';
			document.getElementById("dropdown1").style.visibility='visible';
			widthfinalunder = widthfinal -10;
			document.getElementById("dropdown1under").style.left=widthfinalunder+'px';
			document.getElementById("dropdown1under").style.top=dropdownundertop+'px';
			document.getElementById("dropdown1under").style.visibility='visible';
		}

		if(whichdropdown == "2")
		{
			//add elemment (div) to show under dropdowns to check if a mouseout occured
			var newdiv2 = document.createElement('div');
			newdiv2.setAttribute('id','dropdown2under');
			newdiv2.onmouseover = function(){droptimer(2);};
			ni.appendChild(newdiv2);
			widthfinal = widthfinal +143;
			document.getElementById("dropdown2").style.left=widthfinal+'px';
			document.getElementById("dropdown2").style.top=dropdowntop+'px';
			document.getElementById("dropdown2").style.visibility='visible';
			widthfinalunder = widthfinal -10;
			document.getElementById("dropdown2under").style.left=widthfinalunder+'px';
			document.getElementById("dropdown2under").style.top=dropdownundertop+'px';
			document.getElementById("dropdown2under").style.visibility='visible';
		}


		if(whichdropdown == "3")
		{
			//add elemment (div) to show under dropdowns to check if a mouseout occured
			var newdiv3 = document.createElement('div');
			newdiv3.setAttribute('id','dropdown3under');
			newdiv3.onmouseover = function(){droptimer(3);};
			ni.appendChild(newdiv3);

			document.getElementById("dropdown3").style.left=widthfinal+'px';
			document.getElementById("dropdown3").style.top=dropdowntop+'px';
			document.getElementById("dropdown3").style.visibility='visible';
			widthfinalunder = widthfinal -10;
			document.getElementById("dropdown3under").style.left=widthfinalunder+'px';
			document.getElementById("dropdown3under").style.top=dropdownundertop+'px';
			document.getElementById("dropdown3under").style.visibility='visible';
		}

	}
	catch(err)
	{

	}
}


function droptimer(dropdownnum){
	try{
		// declare variables using
		var ni = document.getElementById('resultsControls');	
		dropdownnum = dropdownnum;
	
		if (dropdownnum == "4")		
		{
			dropdownnum = "1_PROD";
		}
		if (dropdownnum == "5")		
		{
			dropdownnum = "1_MR";
		}
		
		if (dropdownnum == "6")		
		{
			dropdownnum = "2_MR";
		}		
		var dropdownid = "dropdown" +dropdownnum;
		var dropdownidunder = "dropdown"+dropdownnum+"under";
		var dropdownidright = "dropdown"+dropdownnum+"right";
		
		if (dropdownidunder == "dropdown1_PRODunder")
		{
			dropdownid = "dropdown1_Product";
		}

		var divID = document.getElementById(dropdownid);
		var divUID = ni.getElementById(dropdownidunder);
		// hide it
		if (divID !=null)
		{
			divID.style.visibility='hidden';
		}
		else
		{
			alert("divID IS NULL");	
		}		
		// hide it and  remove it
		if (divUID != null)
		{
			divUID.style.visibility='hidden';
			ni.removeChild(divUID);
		}	
		else
		{
			alert("divUID IS NULL");	
		}

	}
	catch(err)
	{
		// catch any errors
		alert("error");
		alert(err);
	}
}



  

			
			
			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();

/*
alert(BrowserDetect.browser);
if(BrowserDetect.browser == "Explorer"){}
if(BrowserDetect.browser == "Safari"){}
*/