function toggle( targetId ){
  if (document.getElementById){
  		target = document.getElementById( targetId );
  			if (target.style.display == "none"){
  				target.style.display = "";
  			} else {
  				target.style.display = "none";
  			}
  	}
}

function browser_width() {
	if (window.innerWidth) {
		//Non-IE
		return window.innerWidth;
	}
	else {
		if (document.documentElement.clientWidth) {
			//IE 6+ in standards compliant mode
			return document.documentElement.clientWidth;
		} else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			return document.body.clientWidth;
		}
	}
}

alphaFadeObjects = new Object();
alphaFadeTimers = new Object();

function alphaFade(object, destOp, rate, delta){
 if (!document.all)
 return
    if (object != "[object]"){ 
        setTimeout("alphaFade("+object+","+destOp+","+rate+","+delta+")",0);
        return;
    }
    clearTimeout(alphaFadeTimers[object.sourceIndex]);
    diff = destOp-object.filters.alpha.opacity;
    direction = 1;
    if (object.filters.alpha.opacity > destOp){
        direction = -1;
    }
    delta=Math.min(direction*diff,delta);
    object.filters.alpha.opacity+=direction*delta;
    if (object.filters.alpha.opacity != destOp){
        alphaFadeObjects[object.sourceIndex]=object;
        alphaFadeTimers[object.sourceIndex]=setTimeout("alphaFade(alphaFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
    }
    if (object.filters.alpha.opacity == 0) { object.style.visibility='hidden'; }
  }

function loadSelect(caller) {
     var url = caller.options[caller.selectedIndex].value;
     if (url != '') parent.location.href = url;
     return false;
}
function loadSelectItemID(caller) {
     var id = caller.options[caller.selectedIndex].value;
     if (id != '') parent.location.href = "/store/"+caller.name+"/"+id;
     return false;
}

function popSelect(caller) {
     var id = caller.options[caller.selectedIndex].value;
     var url = caller.options[caller.selectedIndex].value;
     if (id != '') Pop(url);
     return false;
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

//NS resize bug fix
if(!window.saveInnerWidth) {
	window.onresize = resizeIt;
	window.saveInnerWidth = window.innerWidth;
	window.saveInnerHeight = window.innerHeight;
}

function resizeIt() {
	if (saveInnerWidth < window.innerWidth || 
		saveInnerWidth > window.innerWidth || 
		saveInnerHeight > window.innerHeight || 
		saveInnerHeight < window.innerHeight ) 
	{
		window.history.go(0);
	}
}

function iPop(img,w,h,ttl)
{
	iPopURL = 'ipop.html' // set as location of ipop.html
	url = iPopURL + '?' + img + (ttl ? '&'+escape(ttl) : '')
	l = (screen.width-w)/2
	t = (screen.height-h)/2
	attribs = 'width='+w+',height='+h+',left='+l+',top='+t
	open(url,'imgWin',attribs)
	return false;
}
function Pop2(url,w,h)
{
	var spoon;
	l = (screen.width-w)/2
	t = (screen.height-h)/2
	attribs = 'width='+w+',height='+h+',left='+l+',top='+t+',scrollbars=1'
	open(url,'popWin',attribs)
	return false;
}
function Pop(url)
{
	var spoon;
	w = (screen.width)
	if (w > 800)
		w = 800
	h = (screen.height)/3
	h = h*2
	l = (screen.width-w)/2
	t = (screen.height-h)/2
	attribs = 'width='+w+',height='+h+',left='+l+',top='+t+',scrollbars=1'
	open(url,'popWin',attribs)
	return false;
}

function changeCost(item_form) {
	if (item_form.os0_cost && item_form.os1_cost) {
		item_form.amount.value=Number(item_form.amount_base.value)+Number(item_form.os0_cost.options[item_form.on0.selectedIndex].value)+Number(item_form.os1_cost.options[item_form.on1.selectedIndex].value);
		item_form.cost.value = formatCurrency(Number(item_form.amount.value));
		item_form.os0.value = formatCurrency(item_form.os0_cost.options[item_form.on0.selectedIndex].value);
		item_form.os1.value = formatCurrency(item_form.os1_cost.options[item_form.on1.selectedIndex].value);
	}
	else if (item_form.os0_cost) {
		item_form.amount.value=Number(item_form.amount_base.value)+Number(item_form.os0_cost.options[item_form.on0.selectedIndex].value)
		item_form.cost.value = formatCurrency(Number(item_form.amount.value));
		item_form.os0.value = formatCurrency(item_form.os0_cost.options[item_form.on0.selectedIndex].value);
	}
}

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);
}


// Courtesy of SimplytheBest.net (http://simplythebest.net/info/dhtml_scripts.html)

 if (document.images)
 {var imglist = new Array (
  "dscript41/aboutuson.jpg"
,
 "dscript41/productson.jpg"
,
 "dscript41/promoon.jpg"
,
 "dscript41/supporton.jpg"
 );
 var imgs = new Array(); var count;
 for (count=0; count<imglist.length; count++)
 {imgs[count]=new Image(); imgs[count].src=imglist[count];}
 }
 function hilite(name,m)
 {if (document.images)
 {imgswap(name, imgs[m])}
 }
 function imgswap(i1,i2)
 {if (document.images)
 {var temp = i1.src; i1.src=i2.src; i2.src=temp;}
 }


// Courtesy of SimplytheBest.net (http://simplythebest.net/info/dhtml_scripts.html)

window.onerror = null;
 var bName = navigator.appName;
 var bVer = parseInt(navigator.appVersion);
 var NS4 = (bName == "Netscape" && bVer >= 4);
 var IE4 = (bName == "Microsoft Internet Explorer" && bVer >= 4);
 var NS3 = (bName == "Netscape" && bVer < 4);
 var IE3 = (bName == "Microsoft Internet Explorer" && bVer < 4);
 var menuActive = 0
 var menuOn = 0
 var onLayer
 var timeOn = null// LAYER SWITCHING CODE
if (NS4 || IE4) {
 if (navigator.appName == "Netscape") {
 layerStyleRef="layer.";
 layerRef="document.layers";
 styleSwitch="";
 }else{
 layerStyleRef="layer.style.";
 layerRef="document.all";
 styleSwitch=".style";
 }
}
 
// SHOW MENU
function showLayer(layerName){
if (NS4 || IE4) {
 if (timeOn != null) {
 clearTimeout(timeOn)
 hideLayer(onLayer)
 }
 if (NS4 || IE4) {
 eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');
 } 
 onLayer = layerName
 }
}// HIDE MENU
function hideLayer(layerName){
 if (menuActive == 0) {
 if (NS4 || IE4) {
 eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');
 }
 }
}// TIMER FOR BUTTON MOUSE OUT
function btnTimer() {
 timeOn = setTimeout("btnOut()",1000)
}// BUTTON MOUSE OUT
function btnOut(layerName) {
 if (menuActive == 0) {
 hideLayer(onLayer)
 }
}// MENU MOUSE OVER 
function menuOver(itemName) {
 clearTimeout(timeOn)
 menuActive = 1
}// MENU MOUSE OUT 
function menuOut(itemName) {
 menuActive = 0 
 timeOn = setTimeout("hideLayer(onLayer)", 400)
 }