function formatCurrency2(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
		num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*10000+0.99999);
	cents = num%10000;
	num = Math.floor(num/10000).toString();
	if(cents<10)
		cents = "000" + cents;
	if((cents>=10)&&(cents<100))
		cents = "00" + cents;
	if((cents>=100)&&(cents<1000))
		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);
}

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.5000000000001);
	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);
}

function fixPosition(id,val,MyForm) {
	var valOption = new Option(htmlDecode(val));
	var valLen = MyForm.Option.length;
	MyForm.Option.options[valLen] = valOption;
	MyForm.Option.options[valLen].value = id;
	if (val == 'Select a product color'){
        MyForm.Option.options[valLen].style.color = 'red';
    }
}

function reInitCategory(MyForm,SelectBox,ID) {
	if (SelectBox == 'Group'){
		var style1 = MyForm.Group.options[MyForm.Group.selectedIndex].text;
		for (i=MyForm.Option.length;i>0;i--) {
			MyForm.Option.options[0] = null;
		}
	}
	else if (SelectBox == 'Option'){
		var style1 = MyForm.Option.options[MyForm.Option.selectedIndex].text;
	}
	else{
		var style1 = MyForm.Qty.options
	}
	//alert(style1);
	//alert(SelectBox)
	InitCategories(MyForm,style1,SelectBox,ID);
	if (SelectBox == 'Group'){
		QtyChange(MyForm,ID);
	}
	return false;
}


function htmlEncode(s) {
        var str = new String(s);
        str = str.replace(/&/g, "&amp;");
        str = str.replace(/</g, "&lt;");
        str = str.replace(/>/g, "&gt;");
        str = str.replace(/"/g, "&quot;");
        return str;
}

function htmlDecode(s) {
        var str = new String(s);
        str = str.replace('&quot;', '"');
        return str;
}


function getObjectform(id)//Gets form objects based on browser
	{if (document.all) return document.all[id];	else return document.getElementById(id);}

function HideArea(theID) {
	var d = getObjectform(theID);
	d.style.display = 'none';
}
function ShowArea(theID) {
	var d = getObjectform(theID);
	d.style.display = 'block';
}


function showImage(QS) {
	try {
		imageWindow = window.open('/products/popup.asp?' + QS,'TifImage','width=600,height=600,scrollbars=yes,resizable=yes');
		imageWindow.focus();
		return false;
		}
	catch(e) {return false;}
}
function checkform(whichForm) {
	try {
		if ((whichForm.Group.selectedIndex==0)||(whichForm.Qty.selectedIndex==0)||(whichForm.Option.selectedIndex==0)) {alert('Please select a value for all three dropdown boxes.');return false;}
		else
			{return true;}
		}
	catch(e) {return false;}
}
function NewWindow(mypage, myname, w, h, scroll) {
var winl = 250;
var wint = 300;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

var rldPage= new Function("window.location.reload();");
window.onresize=rldPage;

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function showMoreDetailPop(ProductID){
try {
		imageWindow = window.open('/products/MorePopUp.asp?ProductID=' + ProductID,'Details','width=600,height=660,scrollbars=yes,resizable=yes');
		imageWindow.focus();
		return false;
		}
	catch(e) {alert(e.number + "\n" + e.description + "\n" + e.message);return false;}
}

function showColorPop(ProductID){
try {
		imageWindow = window.open('/products/ColorPopUp.asp?ProductID=' + ProductID,'Details','width=600,height=660,scrollbars=yes,resizable=yes');
		imageWindow.focus();
		return false;
		}
	catch(e) {alert(e.number + "\n" + e.description + "\n" + e.message);return false;}
}

function showImage(QS) {
	try {
		imageWindow = window.open('/products/popup.asp?' + QS,'TifImage','width=600,height=675,scrollbars=yes,resizable=yes');
		imageWindow.focus();
		return false;
		}
	catch(e) {alert(e);return false;}
}
function checkform(whichForm) {
	try {
		if ((whichForm.Group.selectedIndex==0)||(whichForm.Qty.selectedIndex==0)||(whichForm.Option.selectedIndex==0)) {alert('Please select a value for all three dropdown boxes.');return false;}
		else
			{return true;}
		}
	catch(e) {return false;}
}
function NewWindow(mypage, myname, w, h, scroll) {
var winl = 250;
var wint = 300;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}