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

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_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

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 MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function P7_autoLayers() { //v1.4 by PVII
 var g,b,k,f,args=P7_autoLayers.arguments;a=parseInt(args[0]);if(isNaN(a))a=0;
 if(!document.p7setc){p7c=new Array();document.p7setc=true;for(var u=0;u<10;u++){
 p7c[u]=new Array();}}for(k=0;k<p7c[a].length;k++){if((g=MM_findObj(p7c[a][k]))!=null){
 b=(document.layers)?g:g.style;b.visibility="hidden";}}for(k=1;k<args.length;k++){
 if((g=MM_findObj(args[k]))!=null){b=(document.layers)?g:g.style;b.visibility="inherit";f=false;
 for(var j=0;j<p7c[a].length;j++){if(args[k]==p7c[a][j]) {f=true;}}
 if(!f){p7c[a][p7c[a].length++]=args[k];}}}
}

//Customized to delay before closing, also must include onmouseover="clearTimeout(TOut);" in the div.
var menudiv;
var TOut;
function P7_hideDiv(evt) { //v1.3 by PVII
 var relT,mT=false; 
 if(document.layers){menudiv=evt.target;if(menudiv.p7aHide){
  TOut=setTimeout('menudiv.style.visibility=\'hidden\';',750)}else{routeEvent(evt);}
 }else if(document.all&&!window.opera){menudiv=event.srcElement;
  while(menudiv!=null){if(menudiv.tagName=="DIV" && menudiv.p7ahD){mT=true;break;}menudiv=menudiv.parentElement;}
  if(!menudiv.contains(event.toElement)){TOut=setTimeout('menudiv.style.visibility=\'hidden\';',750)}
 }else if(document.getElementById){menudiv=evt.currentTarget;relT=evt.relatedTarget;
  while(relT!=null){if(menudiv==relT){mT=true;break;}
  relT=relT.parentNode;}if(!mT){TOut=setTimeout('menudiv.style.visibility=\'hidden\';',750)}}
}

function P7_autoHide() { //v1.3 by PVII
 var i,g,args=P7_autoHide.arguments;
 for(i=0;i<args.length;i++){if((g=MM_findObj(args[i]))!=null){
  g.p7aHide=true;if(document.layers){
  g.captureEvents(Event.MOUSEOUT);}g.onmouseout=P7_hideDiv;g.p7ahD=true;}}
}


var currthumb=0;

function swapthumbs() {
	var newthumb=document.jumpform.jumpmenu.options[document.jumpform.jumpmenu.selectedIndex].value;
	//alert('new:'+newthumb+'curr:'+currthumb);
	document.getElementById(currthumb).style.visibility="hidden";
	document.getElementById(newthumb).style.visibility="visible";
	currthumb=newthumb;
}

function loadCard(num) {
	if (flash)
		flash.loadCardInFlash(num);
}

function getCardInfo() {
	if (flash) {
		var card = flash.getCardFromFlash();
		alert(dumpObj(card, "card", "   ", 1));
	}
}

/*
function updatePricing(card) {
	//alert(dumpObj(card, "card", "   ", 1));
	var quantity = $('qty1').value, price;
	if (quantity < 10) {
		price = 3 * quantity;
	} else if (quantity >= 10 && quantity < 25) {
		price = 2.5 * quanity;
	} else if (quantity >= 25 && quantity < 50) {
		if (card.custom) {
			if (card.customizable == "y") price = 2.5 * quantity;
			if (card.customizable == "p") price = 3 * quantity;
		} else price = 2.25 * quantity;
	} else if (quantity >= 50 && quantity < 100) {
		if (card.custom) {
			if (card.customizable == "y") price = 2.25 * quantity;
			if (card.customizable == "p") price = 2.75 * quantity;
		} else price = 2 * quantity;
	} else if (quantity >= 100) {
		if (card.custom) {
			if (card.customizable == "y") price = 2 * quantity;
			if (card.customizable == "p") price = 2.5 * quantity;
		} else price = 1.75 * quantity;
	}
	$('subtotal').value = formatCurrency(price);
}
*/

/*
function updatePricing(card) {
	//alert(dumpObj(card, "card", "   ", 1));
	var quantity = $('qty1').value, price;
	if (quantity < 10 && !card.custom) {
		price = 3 * quantity;
		$('price1').value = 3;
	} else if (quantity >= 10 && quantity < 25 && !card.custom) {
		price = 2.5 * quanity;
		$('price1').value = 2.5;
	} else if (quantity >= 25 && quantity < 50 || quantity < 10 && card.custom || quantity >= 10 && quantity < 25 && card.custom) {
		if (card.custom) {
			if (card.customizable == "y") {
				if(quantity < 10 && card.custom || quantity >= 10 && quantity < 25 && card.custom) $('qty1').value = 25; quantity = 25; 
				price = 2.5 * quantity;
				$('price1').value = 2.5;
			}
			if (card.customizable == "p") {
				if(quantity < 10 && card.custom || quantity >= 10 && quantity < 25 && card.custom) $('qty1').value = 25; quantity = 25; 
				price = 3 * quantity;
				$('price1').value = 3;
			}
		} else { 
			price = 2.25 * quantity;
			$('price1').value = 2.5;
		}
	} else if (quantity >= 50 && quantity < 100) {
		if (card.custom) {
			if (card.customizable == "y") {
				price = 2.25 * quantity;
				$('price1').value = 2.25;
			}
			if (card.customizable == "p") {
				price = 2.75 * quantity;
				$('price1').value = 2.75;
			}
		} else {
			price = 2 * quantity;
			$('price1').value = 2;
		}
	} else if (quantity >= 100) {
		if (card.custom) {
			if (card.customizable == "y") {
				price = 2 * quantity;
				$('price1').value = 2;
			}
			if (card.customizable == "p") {
				price = 2.5 * quantity;
				$('price1').value = 2.5;
			}
		} else {
			price = 1.75 * quantity;
			$('price1').value = 1.75;
		}
	}
	$('subtotal').value = formatCurrency(price);
}
*/

function formatCurrency(amount) {
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}

// this function merely dumps an object so you can see what's inside
var MAX_DUMP_DEPTH = 10;
function dumpObj(obj, name, indent, depth) {
      if (depth > MAX_DUMP_DEPTH) {
             return indent + name + ": <Maximum Depth Reached>\n";
      }
      if (typeof obj == "object") {
             var child = null;
             var output = indent + name + "\n";
             indent += "\t";
             for (var item in obj)
             {
                   try {
                          child = obj[item];
                   } catch (e) {
                          child = "<Unable to Evaluate>";
                   }
                   if (typeof child == "object") {
                          output += dumpObj(child, item, indent, depth + 1);
                   } else {
                          output += indent + item + ": " + child + "\n";
                   }
             }
             return output;
      } else {
             return obj;
      }
}
