/********** Initialization ********************/

var menuStyle = "horizontal" // value should be "horizontal" OR "vertical"

var totalSubMenus = 2; // Total number of dropdown menus.

if(menuStyle == "horizontal"){
	
	var menu1LeftPos = 202; // left position of the Dropdown menu 1
	var menu2LeftPos = 253; // left position of the Dropdown menu 2

        
}else if(menuStyle == "vertical"){
	var menuLeftPos = 132; // left position of all the Dropdown menu.
}

var table_width=1003; // Width of the table containing actual contents.

/********** End of Initialization ********************/


/********** Start Function to show menus. ********************/

function show(menuNo){
 	for(i=1; i<=totalSubMenus; i++){ 	
 		document.getElementById("menuComm"+i).style.visibility='hidden'
 	}
 	document.getElementById('menuComm'+menuNo).style.visibility='visible';
}

/********** End Function to show menus. ********************/



/********** Start Function to hide menus. ********************/

function hideAllMenus(){
 	for(i=1; i<=totalSubMenus; i++){	
 		document.getElementById("menuComm"+i).style.visibility='hidden'
 	}
}

/********** End Function to hide menus. ********************/



/********** Start Function to Relocate menus. ********************/
function locateDiv(){
	 var detect = navigator.userAgent.toLowerCase(); // Browser info string.
	 var OS,browser,version,total,thestring;
	 checkBrowser();
	 var x;	
	 if((OS == "Windows")&&(browser == "Internet Explorer")){		
	 x = document.body.offsetWidth; // Window width
	 }else{		
		x = self.innerWidth; // Window width 		
	 }
	 var margine = x-table_width;
	 var leftx = (margine/2);
	 var ieOffset = 11;  // For WINDOWS IE Browser, left border width is 2px and right scrollbar width is 19px
	 var safariOffset = 6;  // For WINDOWS IE Browser, left border width is 2px and right scrollbar width is 19px
	 var mozOffset = 21;  // For WINDOWS IE Browser, left border width is 2px and right scrollbar width is 19px	 
	 // So browser offset is (2+19)/2 that is approx 11px


	/********** Start Function to check OS, Browser, Version string in the Browser info string. ********************/
	function checkIt(string){
		place = detect.indexOf(string) + 1;
		thestring = string;
		return place;
	}
	/********** End Function to check OS, Browser, Version string in the Browser info string. ********************/

	/********** Start Browser Detection ********************/
	function checkBrowser(){
		
	if (checkIt('msie')){		
		browser = "Internet Explorer";
		OS = "Windows";
	}
	else if (checkIt('safari')) browser = "Safari"
	else if (checkIt('firefox')) browser = "Firefox"
	else if (checkIt('netscape')) browser = "Netscape"
	else if (checkIt('omniweb')) browser = "OmniWeb"
	else if (checkIt('opera')) browser = "Opera"
	else if (checkIt('webtv')) browser = "WebTV";
	else if (checkIt('icab')) browser = "iCab"
	else if (checkIt('konqueror')){
		browser = "Konqueror"
		OS = "Linux";
	}else if (!checkIt('compatible')){
		browser = "Netscape"
		version = detect.charAt(8);
	}
	else browser = "An unknown browser";
	//alert("browser = "+browser);
	
	return;
	}
	/********** End Browser Detection********************/


	/********** Start Version Detection********************/
	if (!version) version = detect.charAt(place + thestring.length);
	/********** End Version Detection********************/


	/********** Start OS Detection********************/
	if (!OS){
		if (checkIt('linux')) OS = "Linux";
		else if (checkIt('x11')) OS = "Unix";
		else if (checkIt('mac')) OS = "Mac"
		else if (checkIt('win')) OS = "Windows"
		else OS = "an unknown operating system";
		//alert("OS = "+OS);
	}
	/********** End OS Detection********************/

	//alert('OS = '+OS);
	//alert('browser = '+browser);
	//alert('version = '+version);

	/********** Start Repositioning the menu ********************/
	for(i=1; i<=totalSubMenus; i++){
		if(menuStyle == "horizontal"){
			if(x>table_width) {
				if(((OS == "Windows")&&(browser == "Internet Explorer"))||((OS == "Mac")&&(browser == "Firefox"))){
 					document.getElementById("menuComm"+i).style.left=leftx+eval("menu"+i+"LeftPos")-ieOffset;
				} else if ((OS == "Mac")&&(browser == "Safari")){
					document.getElementById("menuComm"+i).style.left=leftx+eval("menu"+i+"LeftPos")-safariOffset;
				} else {
					document.getElementById("menuComm"+i).style.left=leftx+eval("menu"+i+"LeftPos");
				}
				//alert("menuLeftPos = "+document.getElementById("menuComm"+i).style.left);
			} else {
 				document.getElementById("menuComm"+i).style.left=eval("menu"+i+"LeftPos");
				//alert("menuLeftPos = "+document.getElementById("menuComm"+i).style.left);
			}
		}else if(menuStyle == "vertical"){
			if(x>table_width) {
				if((OS == "Windows")&&(browser == "Internet Explorer")){
 					document.getElementById("menuComm"+i).style.left=leftx+menuLeftPos-ieOffset;
				} else {
					document.getElementById("menuComm"+i).style.left=leftx+menuLeftPos+mozOffset;
				}
			} else {
 				document.getElementById("menuComm"+i).style.left=menuLeftPos;
			}
		}
	}
	/********** End Repositioning the menu ********************/
}

/********** End Function to Relocate menus. ********************/