/*
Copyright© 2005 FourChain. All Rights Reserved.
-----------------------------------------------------------

 Project Name		:	FourChain
 File Name			:	javabase.js
 Description		:	Contains all the javascript functions used for menu drawing
 Author				:	Muhammad Masood
 Creation Date		:	November 06, 2004
 Links From			:	<The list of screens which invoke this screen>
 Links To			:	<The list of screens which is linked from this screen>  

 Modified By		:	Yasir Amin
 Modified on		:	November 17, 2005
 Modi. Comments		:	Updating the new menus related code for Change Request KST-CHG-005-004
 
-----------------------------------------------------------
*/

<!--
var problemForm;
var RequiredFields = null;
var herecount = 0;
function hideIE6Search(toggle){    
    if (window.location.toString().indexOf("mssrch.aspx")>0){
    var el=document.getElementsByTagName('select'); 
    var tl;  
        if (el!=null){
            for (var i=0;i<el.length;i++){  
                if (el[i].id !="") {
                tl=document.getElementById(el[i].id);}                
                if (tl!=null) {tl.style.visibility =toggle;}   }
        } 
    } else {    
                var kw=this.document.getElementById("kwsearchoptions");
                if (kw != null) kw.style.visibility =toggle;
        }	
}
function hideIE6Right(toggle){
var kw=this.document.getElementById("ddlsort");
if (kw != null) kw.style.visibility =toggle
kw=this.document.getElementById("ddResultPPage");
if (kw != null) kw.style.visibility =toggle
kw=this.document.getElementById("pageselect");
if (kw != null) kw.style.visibility =toggle
}

function showMenu(newmenu)
{
	hideMenu(mnuSelected,problemForm);	
	if(problemForm != null)
	{
		for (x in problemForm)
		{
			elm = eval('document.' + problemForm[x]);			
			if (elm != null)
			elm.style.visibility = 'hidden'			
		}
	}
	
	// Get the browser name
	var strBrowser=fnBrowserName();
	var y=0;
	
	if (strBrowser == "NETSCAPE")
	{
		// For Mozilla
		y=102;
	}
	else if (strBrowser == "MSIE")
	{
		// For explorer
		y=106;
	}
	else
	{
		// for any other browser
		y=106;
	}
	
	document.getElementById(newmenu).style.top = y.toString()+"px";
	document.getElementById(newmenu).style.visibility = 'visible';
	hideIE6Search('hidden');
	mnuSelected = newmenu;
}

function hideMenu(newmenu)
{   hideIE6Search('visible');
	if(problemForm != null)
	{
		for (x in problemForm)
		{
			elm = eval('document.' + problemForm[x]);
			if (elm != null)
			elm.style.visibility = 'visible'
		}
	}
	        	
	if(newmenu!='')
	{
		document.getElementById(newmenu).style.visibility = 'hidden';
	}
}

function showSubMenu(newmenu, y)
{
	hideSubMenu(subMnuSelected);
	if (y>0)
	{
		if (!document.getElementById(newmenu).style.top)
		{
			// Get the browser name
			var strBrowser=fnBrowserName();
			var intCorrectionValue=0;
			
			if (strBrowser == "NETSCAPE")
			{
				// For Mozilla
				intCorrectionValue=56;
			}
			else if (strBrowser == "MSIE")
			{
				// For explorer
				intCorrectionValue=56;
			}
			else
			{
				// for any other browser
				intCorrectionValue=56;
			}
			
			var topadj = document.getElementById(newmenu).offsetTop + y - intCorrectionValue;
            document.getElementById(newmenu).style.top = topadj.toString()+"px";
            var sPath = window.location.pathname;
            var sPage = sPath.substring(sPath.lastIndexOf('/') + 1); 
            var pageName = sPage.substring(sPage.indexOf('.'));
            var pagename_active = sPage;
            if (pageName==".asp")// ||pagename_active == 'activequote.aspx')
            {
		        topadj = topadj + 110;
                 document.getElementById(newmenu).style.top = topadj.toString()+"px";
            }


		}
	}
	
	document.getElementById(newmenu).style.visibility = 'visible';
	subMnuSelected = newmenu;
}

function hideSubMenu(newmenu)
{
	if(newmenu!='')
	{
		document.getElementById(newmenu).style.visibility = 'hidden';
	}
}

function highlightOn(cell)
{
	cell.style.backgroundColor = hlcolor;
}

function highlightOff(cell)
{
	cell.style.backgroundColor = mnucolor;
}

function DataSheet(mfgsku,mfgname)
{
	var dsurl = 'datasheet.asp?mfg_sku=' + escape(mfgsku) + '&mfg_name=' + escape(mfgname);
	myWindow=window.open(dsurl,"datasheet","resizable=yes,toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=0,copyhistory=0,width=700,height=600");
}

function DataSheetWithDesc(mfgsku,mfgname,prodDesc)
{
	var dsurl = 'datasheet.asp?mfg_sku=' + escape(mfgsku) + '&mfg_name=' + escape(mfgname) + '&prodDesc=' + escape(prodDesc);
	myWindow=window.open(dsurl,"datasheet","resizable=yes,toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=0,copyhistory=0,width=700,height=600");
}

function DataSheetCaller(mfgsku,mfgname,prodDesc,iWeight,sCat,sSubCat)
{
	//var dsurl = 'datasheet.asp?mfg_sku=' + escape(mfgsku) + '&mfg_name=' + escape(mfgname) + '&prodDesc=' + escape(prodDesc) + '&Weight=' + escape(iWeight) + '&Cat=' + escape(sCat) + '&SubCat=' + escape(sSubCat) ;
	var dsurl = 'product.aspx?mfg_sku=' + escape(mfgsku);
	myWindow =window.open(dsurl,"datasheet","resizable=yes,toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=1,copyhistory=0,width=700,height=600,top=30, left=200");
}

function RTPandA(productid,mfgsku,description)
{
	var dsurl = 'rt.asp?ProductID=' + productid + '&mfgsku=' + escape(mfgsku) + '&desc=' + escape(description);
	myWindow=window.open(dsurl,"datasheet","resizable=yes,toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=1,copyhistory=0,width=800,height=700, top=30, left=100");
}

function goTo(url)
{
  window.location = url
}

function trim(strText)
{ 
    // this will get rid of leading spaces 
    while (strText.substring(0,1) == ' ')
    { 
        strText = strText.substring(1, strText.length);
	}

    // this will get rid of trailing spaces 
    while (strText.substring(strText.length-1,strText.length) == ' ')
    {
        strText = strText.substring(0, strText.length-1);
	}

   return strText;
} 

function CheckRequiredFields()
{
	if(RequiredFields)
	{
		for (x in RequiredFields)
		{ 
			elm = eval('document.' + RequiredFields[x]);
			if (elm != null)
			{
				if (elm.type=='select-one'||elm.type=='select-multiple')
				{
					if (elm.selectedIndex==-1)
					{
						var elmval = '';
					}
					else
					{
						var elmval = trim(elm[elm.selectedIndex].value);
						
					}
				}
				else
				{
					var elmval = trim(elm.value);
//					alert(elmval);
//					return true;
//					elm.focus();
//                  var elmval = '';
				}
				
				if (elmval == '')
				{
					if (elm.disabled == false)
					{
						alert('You need to enter data into all required fields.');
						elm.focus();
					}
					
					return false;
				}		
			}
		}
	}
	return true;
}

function onHelp(topicId)
{
	url= "LinkTHelp.asp?TopicId=" + topicId;
	myWindow=window.open(url, "helpWindow", "width=600, height=500, resizable=no, top=100, left=200");
}

function openShippingMethod()
{
	url= "ShippingMethods.asp";
	myWindow=window.open(url, "ShippingMethod", "width=600, height=500, resizable=no, top=100, left=200");
}

// This will get the browser name
function fnBrowserName()
{
	// Get the name of the browser
	var strBrowserName=navigator.appName;
	
	// This is for Mozilla and all other compatible browser (Because Mozilla user the Netscape engine)
	if (strBrowserName == "Netscape")
	{
		return "NETSCAPE";
	}
	// Now checking for internet explorer
	else if (strBrowserName == "Microsoft Internet Explorer")
	{	
		return "MSIE";
	}
	
	
	// If you want to define the other option then define it as "OTHER"
	// This is the default value that is returned in case of any other value found
	return "MSIE";
}

function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3);i++)
	num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + '$' + num + '.' + cents); 
}
-->
