
	
// ***************************************************************************************************
//											Utility Functions
// ***************************************************************************************************

function FormatPercent(decValue, bShowPercentSign, bShowParenthesis, bRound)
{
	var strValue;
	
	strValue = (decValue*100.00) + '';// converts to string
	
	if(bRound) strValue = FormatCurrency((decValue*100.00),false); //Rounds as currency
		
	if(bShowPercentSign == true)
	{
		strValue = strValue + "%";
	}
	if(bShowParenthesis == true)
	{
		strValue = "(" + strValue + ")";
	}
		
	return strValue;
}	

function FormatString_RemoveSpaces(strValue)
{
	return strValue.replace(/ /g,'');
}		

function FormatCurrency(num, bShowDollarSign)
{
	var strFormattedValue; /* (mcb, 051001) */
		
	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));
				
	strFormattedValue = ((sign)?'':'-');
	if(bShowDollarSign == true)
	{
		strFormattedValue = strFormattedValue + '$';
	}
	strFormattedValue = strFormattedValue + num + '.' + cents;
	
	return (strFormattedValue);
			
}

function UnFormatCurrency(nValue)
{
	var sReg = /\$|\,/g;
	nValue = Number(nValue.replace(sReg,''));
	
	//alert('UnFormatCurrency: nValue = ' + nValue);
	return nValue;			
}


function oNetMessage(erMessage)
{
	var strBrowserType = navigator.userAgent.toLowerCase();
	if(strBrowserType.search('msie')<0) alert(erMessage);	
}
	
function oBrwType(strType)
{
	//alert('oBrwType(strType) = ' + strType);
	var oType;
	if(document.getElementById)
	{
		//alert('oBrwType: document.getElementById');
		oType = document.getElementById(strType);
	}
	else if(document.all.item)
	{
		//alert('oBrwType: document.all.item');
		oType = document.all.item(strType);
	}
	return oType;		
}
	
function oBrwTypeInner(strType)
{
	var oType = oBrwType(strType);
	var oObject;
	if(oType!=null)
	{
		if(!oType.innerHTML)
		{
			oObject = oType.innerHTML;			
		}
		else
		{
			oObject = oType.innerText;
		}
	}
	return oObject;
}


function oBrwTypeInner_Write(strType, strWrite)
{
	var oType = oBrwType(strType);
	if(oType!=null)
	{
		if(!oType.innerHTML)
		{
			oType.innerHTML = strWrite;			
		}
		else
		{
			oType.innerText = strWrite;
		}
	}
}

function GetBType()
{
	if(document.getElementById)
	{
		//alert('one');
		return bType_ID;
	}
	else if(document.all)
	{
		//alert('two');
		return bType_ALL;
	}
	else
	{
		//alert('three');
		return bType_ALERT;
	}		
}


function GetNumber(ot)
{
	var sReg = /\$|\,/g;
	var nValue = Number(ot.value.replace(sReg,''));
	
	//alert('GetNumber: nValue = ' + nValue);
	return nValue;	
}

function SetDA(nNumber, ot, ol)
{
	var sValue = FormatCurrency(nNumber, true);
	if(ot!=null) ot.value = sValue;
	oBrwTypeInner_Write(ol, sValue);
	
	nNumber = UnFormatCurrency(sValue, true);
	
	return nNumber;
}



// ***************************************************************************************************
//											PopUp Functions
// ***************************************************************************************************
var TOP100		= 'http://www.top100webshops.com/';
var TOPDEPO		= 'http://www.topdepo.com/';
var BBB			= 'http://www.bbbonline.org/cks.asp?id=102102114284927058';
var MART		= 'http://www.onlinemarts.com/incoming.asp?i=3104';
var MART2		= 'http://www.onlinemarts.com/';

var TOP100IMG		= 'http://www.top100webshops.com/isapi/track2.dll?T?3006&green';
var TOPDEPOIMG		= 'http://www.topdepo.com/isapi/Tracker.dll?T?2354&1&1';

function WST(strSRC)
{
	var strURL = '';
	if(strSRC=='TOP100')
	{
		strURL = TOP100;
	}
	else if(strSRC=='TOPDEPO')
	{
		strURL = TOPDEPO;
	}
	else if(strSRC=='MART2')
	{
		strURL = MART;
	}
	else if(strSRC=='BBB')
	{
		strURL = BBB;
	}		
	window.status=strURL;
}

function Go(argURL) 
{
	openWin = window.open(argURL,"myWindow","top=100,left=100,buttons=yes,scrollbars=yes,location=yes,menubar=yes,resizable=yes,status=yes,directories=yes,toolbar=yes");
	openWin.focus();
}
function Getsrc(strSRC) 
{
	var strURL = '';
	if(strSRC=='TOP100')
	{
		strURL = TOP100IMG;
	}
	else if(strSRC=='TOPDEPO')
	{
		strURL = TOPDEPOIMG;
	}
	
	return strURL;
}

function ShowPopUp()
{
	var oCookie = document.cookie;
	var oCookieExists = oCookie.indexOf("pop");
	return (oCookieExists==-1);
}
	
function SetPopUpCookie()
{
	document.cookie = "pop=1";
}
	
function ShippingSchedule()
{
	if((ShowPopUp())==true)
	{
		popShippingSchedule();
		SetPopUpCookie();			
	}	
}
	
function popShippingSchedule() 
{
	openWin = window.open("shippingschedule.htm","myWindow","top=100,left=100,width=465,height=515,buttons=no,scrollbars=no,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no");
	openWin.focus();
}

function popHelp(argURL) 
{
	openWin = window.open(argURL,"myWindow","top=100,left=100,width=560,height=560,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=yes,status=no,directories=no,toolbar=no");
	openWin.focus();
}

function popLargeCard(argURL)
{
	
	openWin = window.open(argURL,"myWindow","top=100,left=100,width=700,height=700,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=yes,status=no,directories=no,toolbar=no");
	openWin.focus();
}

function popLargeCard_AP(argURL)
{
	argURL = argURL.replace('_M.jpg','_L.jpg');
	openWin = window.open(argURL,"myWindow","top=100,left=100,width=700,height=700,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=yes,status=no,directories=no,toolbar=no");
	openWin.focus();
}

function popWindow(argURL) 
{
	openWin = window.open(argURL,"myWindow","top=100,left=100,width=680,height=800,buttons=yes,scrollbars=yes,location=yes,menubar=yes,resizable=yes,status=no,directories=no,toolbar=yes");
	openWin.focus();
}

	
