﻿// JScript File
	//open menu with given ID used on Select Country control
	function openMenu(menuID,linkObj)
	{
		//if the menu code is ready
		if(um.ready)
		{
			//find co-ordinates of link object
			var coords = {
				'x' : um.getRealPosition(linkObj,'x'),
				'y' : um.getRealPosition(linkObj,'y')
				};

			//increase y-position to place it below the link
			coords.y += (linkObj.offsetHeight + 0);

			//activate menu at returned co-ordinates
			um.activateMenu(menuID, (coords.x - 127) + 'px', coords.y + 'px');
		}
	}

	//close menu with given ID
	function closeMenu(menuID)
	{
		//if the menu code is ready
		if(um.ready)
		{
			//deactive menu
			um.deactivateMenu(menuID);
		}
	}
	
//Print Function
function PrintThisPage() 
{ 
   // hide bread crumbs (todo: remove this and find an alternate route)
   if(document.getElementById('ctl00_breadCrumbsPanel')) document.getElementById('ctl00_breadCrumbsPanel').style.display = 'none';

   // get path length
   var path = document.location.pathname;
   var split_url = path.split('/');
   countlevels = split_url.length;
   
   //for dev only
   isdev = path.match('/Mannatech.Web.UI'); 
   if(isdev) countlevels--;
   
   // dotdot slashes for style sheet reference
   if(countlevels == 3) {
        dotdot = "../";
   } else if(countlevels == 4) {
        dotdot = "../../";
   } else if(countlevels == 5) {
        dotdot = "../../../";
   } else {
        dotdot = "./"; // assume current level if not found
   }
   
   var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
       sOption+="scrollbars=yes,width=750,height=600,left=100,top=25"; 

   var sWinHTML = document.getElementById('printerfriendly').innerHTML; 
   
   var logo = "<div style='width:700px;text-align:left;'><img src='http://localhost:8732/Mannatech.Web.UI/App_Themes/Corporate/Images/nav_logo_background.jpg' border='0' alt='Mannatech' width='305' height='68' /></div><br />";
   
   var winprint=window.open("","",sOption); 
       winprint.document.open(); 
       winprint.document.write('<html><link href="'+dotdot+'App_Themes/Corporate/StyleSheet.css" type="text/css" rel="stylesheet" /><style>body{background-color:#FFFFFF;}</style><body>'); 
       winprint.document.write(logo);
       winprint.document.write(sWinHTML);
       winprint.document.write('</body></html>'); 
       winprint.document.close(); 
       winprint.focus(); 
       winprint.print();
}

function checkEnter(){
    if(window.event.keyCode == 13)
        return false;
    else
        return true;
}

function checkAlphaChars(e) {
    var evtobj = window.event ? event : e;
    var unicode = evtobj.charCode ? evtobj.charCode : evtobj.keyCode;
    
    //Disable ALT, CRTL, SHIFT, INSERT and LEFT and RIGHT Arrow keys
    if(evtobj.altKey || evtobj.ctrlKey || evtobj.shiftKey || evtobj.insertKey || unicode == 39 || unicode == 37)
        return true;
        
    //tab, backspace, and delete keys
    if(unicode == 8 || unicode == 9 || unicode == 46)
        return true;
    
    //numeric keys
    if((unicode >= 48 && unicode <= 57) || (unicode >= 96 && unicode <= 105))
        return true;
    else
        return false;
}

// Left Nav Menu Global functions
var popUpWin=0;
function popUpWindow(URLStr, winName, left, top, width, height)
{
  popUpWin = open(URLStr, winName, 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function closeAll()
{
    for(i=1;i<=11;i++) {
        if(document.getElementById("Sub"+i)) {
            document.getElementById("Sub"+i).style.display = 'none';
        }
        if(document.getElementById("Button"+i)) {
            document.getElementById("Button"+i).style.display = 'none';
        }
    }
}

function switchDiv(e1,e2)
{
    //return true; 
    closeAll(); 
    
    OBJ1=document.getElementById(e1);
    OBJ2=document.getElementById(e2);
    if(OBJ1.style.display == 'none')
    {
    OBJ1.style.display = ''; 
    OBJ2.style.display = '';
    }
    else
    {
    OBJ1.style.display = 'none';
    OBJ2.style.display = 'none';
    }
}

// Extend String object with trim prototypes for whitespace removal
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

