
/*
Get correct placement for dropdowns
*/

function  getwidth(whichdropdown){
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;
		}
	
	}
}
		
/*
Show dropdown(s) and place them
*/
function showdropdown(whichdropdown){
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;
  
if(whichdropdown == "1_PROD"){

	//add elemment (div) to show under dropdowns to check if a mouseout occured
	var ni = document.getElementById('resultsControls');
	var newdiv = document.createElement('div');
  	newdiv.setAttribute('id','dropdown1under');
  	newdiv.onmouseover = function(){droptimer('1_Product');};
  	ni.appendChild(newdiv);

  
	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;
	document.getElementById("dropdown1under").style.left=widthfinalunder+'px';
	document.getElementById("dropdown1under").style.top=dropdownundertop+'px';
	document.getElementById("dropdown1under").style.visibility='visible';
}

if(whichdropdown == "1_MR"){

	//add elemment (div) to show under dropdowns to check if a mouseout occured
	var ni = document.getElementById('resultsControls');
	var newdiv = document.createElement('div');
  	newdiv.setAttribute('id','dropdown1under');
  	newdiv.onmouseover = function(){droptimer('1_MR');};
  	ni.appendChild(newdiv);

  
	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("dropdown1under").style.left=widthfinalunder+'px';
	document.getElementById("dropdown1under").style.top=dropdownundertop+'px';
	document.getElementById("dropdown1under").style.visibility='visible';
}

if(whichdropdown == "2_MR"){
	//add elemment (div) to show under dropdowns to check if a mouseout occured
	var ni2 = document.getElementById('resultsControls');
  var newdiv2 = document.createElement('div');
  newdiv2.setAttribute('id','dropdown2under');
  newdiv2.onmouseover = function(){droptimer('2_MR');};
  ni2.appendChild(newdiv2);
	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("dropdown2under").style.left=widthfinalunder+'px';
		document.getElementById("dropdown2under").style.top=dropdownundertop+'px';
		document.getElementById("dropdown2under").style.visibility='visible';
}

if(whichdropdown == "1"){
	//add elemment (div) to show under dropdowns to check if a mouseout occured
	var ni = document.getElementById('resultsControls');
	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 ni2 = document.getElementById('resultsControls');
  var newdiv2 = document.createElement('div');
  newdiv2.setAttribute('id','dropdown2under');
  newdiv2.onmouseover = function(){droptimer(2);};
  ni2.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 == "2_MIN"){
	//add elemment (div) to show under dropdowns to check if a mouseout occured
	var ni2 = document.getElementById('resultsControls');
  var newdiv2 = document.createElement('div');
  newdiv2.setAttribute('id','dropdown2under');
  newdiv2.onmouseover = function(){droptimer(2);};
  ni2.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 ni = document.getElementById('resultsControls');
	var newdiv = document.createElement('div');
  	newdiv.setAttribute('id','dropdown3under');
  	newdiv.onmouseover = function(){droptimer(3);};
  	ni.appendChild(newdiv);
	
	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';
}


}


function droptimer(dropdownnum){
	dropdownnum = dropdownnum;
	dropdownid = "dropdown" +dropdownnum;
	dropdownidunder = "dropdown"+dropdownnum+"under";
	dropdownidright = "dropdown"+dropdownnum+"right";
	
	if(dropdownidunder == "dropdown1_MRunder"){
		dropdownidunder = "dropdown1under";
	}
	
	if(dropdownidunder == "dropdown2_MRunder"){
		dropdownidunder = "dropdown2under";
	}
	
	if(dropdownidunder == "dropdown1_Productunder"){
		dropdownidunder = "dropdown1under";
	}
	
	document.getElementById(dropdownid).style.visibility='hidden';
	document.getElementById(dropdownidunder).style.visibility='hidden';
}



  

			
			
			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"){}
*/