////// MENU START:  BELOW SCRIPT CONTROLS THE MENU BEHAVIOR AND GENERAL PAGE LAYOUT //////
function openURL(url) {
	location.href= url;
}

function selectMenu(Id) {
	var mainRows = document.getElementsByTagName("TD");
	var menuId = "mainMenu" + Id;
//Change the bgcolor of the main menu
	for (i=0; i<mainRows.length;i++){
		var mainRowName = mainRows[i].id;
	
			if(mainRowName != null && mainRowName != "undefined" && mainRowName.indexOf("mainMenu") > -1){
				if (mainRowName != menuId){
					mainRows[i].className = 'menuNav';
				}else{
					mainRows[i].className = 'menuActive';
				}
			}	
	
	}
}
function selectMenu2(Id, Id2) {
	var mainRows = document.getElementsByTagName("TD");
	var menuId = "mainMenu" + Id;
	var menuId2 = "mainMenu" + Id2;
//Change the bgcolor of the main menu
	for (i=0; i<mainRows.length;i++){
		var mainRowName = mainRows[i].id;
	
			if(mainRowName != null && mainRowName != "undefined" && mainRowName.indexOf("mainMenu") > -1){
				pauseScript(5);
				if (mainRowName != menuId){
					mainRows[i].className = 'menuNav';
				}else{
					mainRows[i].className = 'menuNav';
				}
				if (mainRowName == menuId2){
					mainRows[i].className = 'menuActive';
				}
			
			}	
	
	}
}
function selectMenu5(Id) {
	var mainRows = document.getElementsByTagName("TD");
	var menuId = "sideNav" + Id;
//Change the bgcolor of the main menu
	for (i=0; i<mainRows.length;i++){
		var mainRowName = mainRows[i].id;
			if(mainRowName != null && mainRowName != "undefined" && mainRowName.indexOf("sideNav") > -1){
				if (mainRowName != menuId){
					mainRows[i].className = 'rightNav';
				}else{
					mainRows[i].className = 'rightNavActive';
				}
			}	
	
	}
}
function selectMenu6(Id, Id2) {
	var mainRows = document.getElementsByTagName("TD");
	var menuId = "sideNav" + Id;
	var menuId2 = "sideNav" + Id2;
//Change the bgcolor of the main menu
	for (i=0; i<mainRows.length;i++){
		var mainRowName = mainRows[i].id;
	
			if(mainRowName != null && mainRowName != "undefined" && mainRowName.indexOf("sideNav") > -1){
				pauseScript(5);
				if (mainRowName != menuId){
					mainRows[i].className = 'rightNav';
				}else{
					mainRows[i].className = 'rightNav';
				}
				if (mainRowName == menuId2){
					mainRows[i].className = 'rightNavActive';
				}
			
			}	
	
	}
}



function selectMenu3(Id) {
	var mainRows = document.getElementsByTagName("TD");
	var menuId = "altMenu" + Id;
//Change the bgcolor of the main menu
	for (i=0; i<mainRows.length;i++){
		var mainRowName = mainRows[i].id;
	
			if(mainRowName != null && mainRowName != "undefined" && mainRowName.indexOf("altMenu") > -1){
				if (mainRowName != menuId){
					mainRows[i].className = 'menuNav2';
				}else{
					mainRows[i].className = 'menuNav2Active';
				}
			}	
	
	}
}
function selectMenu4(Id, Id2) {
	var mainRows = document.getElementsByTagName("TD");
	var menuId = "altMenu" + Id;
	var menuId2 = "altMenu" + Id2;
//Change the bgcolor of the main menu
	for (i=0; i<mainRows.length;i++){
		var mainRowName = mainRows[i].id;
	
			if(mainRowName != null && mainRowName != "undefined" && mainRowName.indexOf("altMenu") > -1){
				if (mainRowName != menuId){
					mainRows[i].className = 'menuNav2';
				}else{
					mainRows[i].className = 'menuNav2';
				}
				if (mainRowName == menuId2){
					mainRows[i].className = 'menuNav2Active';
				}
			
			}	
	
	}
}

function launchURL(navOption) {
	var navUrl = navOption;

	if(navOption =="0"){
		navUrl = "index.jsp";
	} else {
		navUrl = "mitrix.jsp?page=" + navOption;
	}
	document.location = navUrl;
}

function open_window(url){
	window.open(url,"screenshot_popup","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,width=700,height=550");
}
function setCookie(name, value) {
  var expires = "Fri, 31 Dec 2100 23:59:59 GMT";
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires : "");
  document.cookie = curCookie;
}

function login2x(){
	var f = document.signonForm;
    var isOK = true;
    var errMsg = "The following required field(s) are empty:\n\n"
    // If required fields are ok then submit the form, otherwise alert the user...
	if(f.userId.value==""){
		isOK = false;
		errMsg = errMsg + "Username\n";
	}
	if(f.password.value==""){
		isOK = false;
		errMsg = errMsg + "Password\n";
	}
    if (isOK)
    {
        var userId = f.userId.value;
        setCookie('username1', userId);
        f.submit();
    }
    else
    {
        alert(errMsg);
    }
}
function login3x(){
	var f = document.logForm;
    var isOK = true;
    var errMsg = "The following required field(s) are empty:\n\n"
    // If required fields are ok then submit the form, otherwise alert the user...
	if(f.idUser.value==""){
		isOK = false;
		errMsg = errMsg + "Username\n";
	}
	if(f.idPwd.value==""){
		isOK = false;
		errMsg = errMsg + "Password\n";
	}
    if (isOK)
    {
        var userId = f.idUser.value;
        setCookie('username2', userId);
        f.submit();
    }
    else
    {
        alert(errMsg);
    }
}     	     


function pauseScript(t)
{
d = new Date() //today's date
while (1)
{
mill=new Date() // Date Now
diff = mill-d //difference in milliseconds
if( diff > t ) {break;}
}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function go()
{
}
function changeRegion(){
	box = document.forms[0].languageCode;
	myLanguage = box.options[box.selectedIndex].value;
	var myLink = "";
	if(myLanguage == "jp"){
		myLink = "/jp/";
	}
	if (myLanguage == "sp"){
		myLink = "/sp/";
	}
	if (myLanguage == "tw"){
		myLink = "/tw/";
	}
	if (myLanguage == "en"){
		myLink = "/";
	}
	if (myLanguage) setLangCookie('myLanguage', myLanguage);
	if (myLanguage) location.href = myLink;
}


function setLangCookie(name, value) {
  var expires = "Fri, 31 Dec 2100 23:59:59 GMT";
  var path = "/";
  var cookieValue = "langValue=" + escape(value) + "; path=/; domain=mitrix.pipelinesoftware.com; expires=" + expires;
  document.cookie = cookieValue;
  
}





