// JavaScript Document
<!--
function fullscreenWindow() {
	var iMyWidth;
	var iMyHeight;
	//Gets user's resolution.
	iMyWidth = (window.screen.width) - 10; //The screen width(- 5 for the border).
	iMyHeight = (window.screen.height) - 50; //The screen height (- 5 for the border).
	
	window.resizeTo(iMyWidth,iMyHeight);
	window.moveTo(0,0); 
	//document.write(iMyWidth);
	//document.write(iMyHeight);
}

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_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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_showHideNav() { //v6.0
  var i,p,v,obj,args=MM_showHideNav.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')?'block':(v=='hide')?'none':v; }
    obj.display=v; }
}

function GP_AdvOpenWindow(theURL,winName,ft,pw,ph,wa,il,aoT,acT,bl,tr,trT,slT,pu) { //v3.08
  // Copyright(c) George Petrov, www.dmxzone.com member of www.DynamicZones.com
  var rph=ph,rpw=pw,nlp,ntp,lp=0,tp=0,acH,otH,slH,w=480,h=340,d=document,OP=(navigator.userAgent.indexOf("Opera")!=-1),IE=d.all&&!OP,IE5=IE&&window.print,NS4=d.layers,NS6=d.getElementById&&!IE&&!OP,NS7=NS6&&(navigator.userAgent.indexOf("Netscape/7")!=-1),b4p=IE||NS4||NS6||OP,bdyn=IE||NS4||NS6,olf="",sRes="";
  imgs=theURL.split('|'),isSL=imgs.length>1;aoT=aoT&&aoT!=""?true:false;
  var tSWF='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" ##size##><param name=movie value="##file##"><param name=quality value=high><embed src="##file##" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" ##size##></embed></object>'
  var tQT='<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" ##size##><param name="src" value="##file##"><param name="autoplay" value="true"><param name="controller" value="true"><embed src="##file##" ##size## autoplay="true" controller="true" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>'
  var tIMG=(!IE?'<a href="javascript:'+(isSL?'nImg()':'window.close()')+'">':'')+'<img id=oImg name=oImg '+((NS4||NS6||NS7)?'onload="if(isImg){nW=pImg.width;nH=pImg.height}window.onload();" ':'')+'src="##file##" border="0" '+(IE?(isSL?'onClick="nImg()"':'onClick="window.close()"'):'')+(IE&&isSL?' style="cursor:pointer"':'')+(!NS4&&isSL?' onload="show(\\\'##file##\\\',true)"':'')+'>'+(!IE?'</a>':'')
  var tMPG='<OBJECT classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,902" ##size## type="application/x-oleobject"><PARAM NAME="FileName" VALUE="##file##"><PARAM NAME="animationatStart" VALUE="true"><PARAM NAME="transparentatStart" VALUE="true"><PARAM NAME="autoStart" VALUE="true"><PARAM NAME="showControls" VALUE="true"><EMBED type="application/x-mplayer2" pluginspage = "http://www.microsoft.com/Windows/MediaPlayer/" SRC="##file##" ##size## AutoStart=true></EMBED></OBJECT>'
  omw=aoT&&IE5;bl=bl&&bl!=""?true:false;tr=IE&&tr&&isSL?tr:0;trT=trT?trT:1;ph=ph>0?ph:100;pw=pw>0?pw:100;
  re=/\.(swf)/i;isSwf=re.test(theURL);re=/\.(gif|jpg|png|bmp|jpeg)/i;isImg=re.test(theURL);re=/\.(avi|mov|rm|rma|wav|asf|asx|mpg|mpeg)/i;isMov=re.test(theURL);isEmb=isImg||isMov||isSwf;
  if(isImg&&NS4)ft=ft.replace(/resizable=no/i,'resizable=yes');if(b4p){w=screen.availWidth;h=screen.availHeight;}
  if(wa&&wa!=""){if(wa.indexOf("center")!=-1){tp=(h-ph)/2;lp=(w-pw)/2;ntp='('+h+'-nWh)/2';nlp='('+w+'-nWw)/2'}if(wa.indexOf("bottom")!=-1){tp=h-ph;ntp=h+'-nWh'} if(wa.indexOf("right")!=-1){lp=w-pw;nlp=w+'-nWw'}
    if(wa.indexOf("left")!=-1){lp=0;nlp=0} if(wa.indexOf("top")!=-1){tp=0;ntp=0}if(wa.indexOf("fitscreen")!=-1){lp=0;tp=0;ntp=0;nlp=0;pw=w;ph=h}
    ft+=(ft.length>0?',':'')+'width='+pw;ft+=(ft.length>0?',':'')+'height='+ph;ft+=(ft.length>0?',':'')+'top='+tp+',left='+lp;
  } if(IE&&bl&&ft.indexOf("fullscreen")!=-1&&!aoT)ft+=",fullscreen=1";
  if(omw){ft='center:no;'+ft.replace(/lbars=/i,'l=').replace(/(top|width|left|height)=(\d+)/gi,'dialog$1=$2px').replace(/=/gi,':').replace(/,/gi,';')}
  if (window["pWin"]==null) window["pWin"]= new Array();var wp=pWin.length;pWin[wp]=(omw)?window.showModelessDialog(imgs[0],window,ft):window.open('',winName,ft);
  if(pWin[wp].opener==null)pWin[wp].opener=self;window.focus();
  if(b4p){ if(bl||wa.indexOf("fitscreen")!=-1){pWin[wp].resizeTo(pw,ph);pWin[wp].moveTo(lp,tp);}
    if(aoT&&!IE5){otH=pWin[wp].setInterval("window.focus();",50);olf='window.setInterval("window.focus();",50);'}
  } sRes='\nvar nWw,nWh,d=document,w=window;'+(bdyn?';dw=parseInt(nW);dh=parseInt(nH);':'if(d.images.length == 1){var di=d.images[0];dw=di.width;dh=di.height;\n')+

    'if(dw>0&&dh>0){nWw=dw+'+(IE?12:NS7?15:NS6?14:0)+';nWh=dh+'+(IE?32:NS7?50:NS6?1:0)+';'+(OP?'w.resizeTo(nWw,nWh);w.moveTo('+nlp+','+ntp+')':(NS4||NS6?'w.innerWidth=nWw;w.innerHeight=nWh;'+(NS6?'w.outerWidth-=14;':''):(!omw?'w.resizeTo(nWw,nWh)':'w.dialogWidth=nWw+"px";w.dialogHeight=nWh+"px"')+';eh=dh-d.body.clientHeight;ew=dw-d.body.clientWidth;if(eh!=0||ew!=0)\n'+
  	(!omw?'w.resizeTo(nWw+ew,nWh+eh);':'{\nw.dialogWidth=(nWw+ew)+"px";\nw.dialogHeight=(nWh+eh)+"px"}'))+(!omw?'w.moveTo('+nlp+','+ntp+')'+(!(bdyn)?'}':''):'\nw.dialogLeft='+nlp+'+"px";w.dialogTop='+ntp+'+"px"\n'))+'}';
  var iwh="",dwh="",sscr="",sChgImg="";tRep=".replace(/##file##/gi,cf).replace(/##size##/gi,(nW>0&&nH>0?'width=\\''+nW+'\\' height=\\''+nH+'\\'':''))";
  var chkType='re=/\\.(swf)$/i;isSwf=re.test(cf);re=/\\.(mov)$/i;isQT=re.test(cf);re=/\\.(gif|jpg|png|bmp|jpeg)$/i;isImg=re.test(cf);re=/\.(avi|rm|rma|wav|asf|asx|mpg|mpeg)/i;isMov=re.test(cf);';
  var sSize='tSWF=\''+tSWF+'\';\ntQT=\''+tQT+'\';tIMG=\''+tIMG+'\';tMPG=\''+tMPG+'\'\n'+"if (cf.substr(cf.length-1,1)==']'){var bd=cf.lastIndexOf('[');if(bd>0){var di=cf.substring(bd+1,cf.length-1);var da=di.split('x');nW=da[0];nH=da[1];cf=cf.substring(0,bd)}}"+chkType;
  if(isEmb){if(isSL) { 
      sChgImg=(NS4?'var l = document.layers[\'slide\'];ld=l.document;ld.open();ld.write(nHtml);ld.close();':IE?'document.all[\'slide\'].innerHTML = nHtml;':NS6?'var l=document.getElementById(\'slide\');while (l.hasChildNodes()) l.removeChild(l.lastChild);var range=document.createRange();range.setStartAfter(l);var docFrag=range.createContextualFragment(nHtml);l.appendChild(docFrag);':'');
      sscr='var pImg=new Image(),slH,ci=0,simg="'+theURL+'".split("|");'+
      'function show(cf,same){if(same){di=document.images[0];nW=di.width;nH=di.height}'+sRes+'}\n'+
      'function nImg(){if(slH)window.clearInterval(slH);nW=0;nH=0;cf=simg[ci];'+sSize+'document.title=cf;'+
      (tr!=0?';var fi=IElem.filters[0];fi.Apply();IElem.style.visibility="visible";fi.transition='+(tr-1)+';fi.Play();':'')+
      'if (nW==0&&nH==0){if(isImg){nW=pImg.width;nH=pImg.height}else{nW='+pw+';nH='+ph+'}}'+
      (bdyn?'nHtml=(isSwf?tSWF'+tRep+':isQT?tQT'+tRep+':isImg?tIMG'+tRep+':isMov?tMPG'+tRep+':\'\');'+sChgImg+';':'if(document.images)document["oImg"].src=simg[ci];')+
      sRes+';ci=ci==simg.length-1?0:ci+1;cf=simg[ci];re=/\\.(gif|jpg|png|bmp|jpeg)$/i;isImg=re.test(cf);if(isImg)pImg.src=cf;'+
      (isSL?(!NS4?'if(ci>1)':'')+'slH=window.setTimeout("nImg()",'+slT*1000+')}':'');
    } else {sscr='var re,pImg=new Image(),nW=0,nH=0,nHtml="",cf="'+theURL+'";'+chkType+'if(isImg)pImg.src=cf;\n'+
      'function show(){'+sSize+';if (nW==0&&nH==0){if(isImg){;nW=pImg.width;nH=pImg.height;if (nW==0&&nH==0){nW='+pw+';nH='+ph+'}}else{nW='+pw+';nH='+ph+
      '}};nHtml=(isSwf?tSWF'+tRep+':isQT?tQT'+tRep+':isImg?tIMG'+tRep+':isMov?tMPG'+tRep+':\'\');document.write(nHtml)};'}
    pd = pWin[wp].document;pd.open();pd.write('<html><'+'head><title>'+imgs[0]+'</title><'+'script'+'>'+sscr+'</'+'script>'+(!NS4?'<STYLE TYPE="text/css">BODY {margin:0;border:none;padding:0;}</STYLE>':'')+'</head><body '+(NS4&&isSL?'onresize=\'ci--;nImg()\' ':'')+'onload=\''+olf+(isSL?';nImg()':sRes)+'\' bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">'); 
    if(rpw>0){iwh='width="'+rpw+'" ';dwh='width:'+rpw} if(rph>0){iwh+='height="'+rph+'"';dwh+='height:'+rph}
    if(tr!=0) pd.write('<span id=IElem Style="Visibility:hidden;Filter:revealTrans(duration='+trT+');width:100%;height=100%">');
    if(isSL&&bdyn) {pd.write(NS4?'<layer id=slide></layer>':'<span id=slide></span>')} else {pd.write('<'+'script>show()'+'</'+'script>')}   
    if(tr!=0) pd.write('</span>');pd.write('</body></html>');pd.close();
  }else {if(!omw)pWin[wp].location.href=imgs[0];}
  if((acT&&acT>0)||(slT&&slT>0&&isSL)){if(pWin[wp].document.body)pWin[wp].document.body.onunload=function(){if(acH)window.clearInterval(acH);if(slH)window.clearInterval(slH)}}
  if(acT&&acT>0)acH=window.setTimeout("pWin["+wp+"].close()",acT*1000);if(slT&&slT>0&&isSL)slH=window.setTimeout("if(pWin["+wp+"].nImg)pWin["+wp+"].nImg()",slT*1000);  
  if(pu&&pu!=""){pWin[wp].blur();window.focus()} else pWin[wp].focus();document.MM_returnValue=(il&&il!="")?false:true;
}

function clearEmailDetails(){
	bw=new checkBrowser();
	
	if(bw.ie4){
		document.contactform.name.value="";
		document.contactform.email.value="";
		document.contactform.message.value="";
		document.all['name'].className="greenhead";
		document.all['email'].className="greenhead";
		document.all['errortable'].style.display = "none";
	}else{
		document.contactform.name.value="";
		document.contactform.email.value="";
		document.contactform.message.value="";
		document.getElementById("name").className="greenhead";
		document.getElementById("email").className="greenhead";
		document.getElementById("errortable").style.display = "none";
	}
	document.contactform.name.value="";
	document.contactform.email.value="";
	document.contactform.message.value="";
	document.getElementById("name").className="greenhead";
	document.getElementById("email").className="greenhead";
	document.getElementById("errortable").style.display = "none";
}

function clearEmailFriendDetails(){
	bw=new checkBrowser();
	
	if(bw.ie4){
		document.all['YourName'].className="greenhead";
		document.all['YourEmail'].className="greenhead";
		document.all['FriendName'].className="greenhead";
		document.all['FriendEmail'].className="greenhead";
		document.all['errortable'].style.display = "none";
	}
	document.contactform.yourName.value="";
	document.contactform.yourEmail.value="";
	document.contactform.friendName.value="";
	document.contactform.friendEmail.value="";
	document.contactform.message.value="";
	document.contactform.subscribe.checked="true";
	document.getElementById("YourName").className="greenhead";
	document.getElementById("YourEmail").className="greenhead";
	document.getElementById("FriendName").className="greenhead";
	document.getElementById("FriendEmail").className="greenhead";
	document.getElementById("errortable").style.display = "none";
}

function clearEmailInviteDetails(){
	bw=new checkBrowser();
	
	if(bw.ie4){
		document.all['friendEmail'].className="greenhead";
		document.all['errortable'].style.display = "none";
	}
	document.inviteform.friendEmail_0.value="";
	document.inviteform.message.value="";
	document.getElementById("friendEmail").className="greenhead";
	document.getElementById("errortable").style.display = "none";
}

function buttonSwap(buttonName,swapType){

	bw=new checkBrowser();
	
	if(bw.ie4){
		if(swapType=="over"){
			var thisImage = document.all[buttonName];
			thisImage.src = "uploads/images/btn-"+buttonName+"-2.gif";
		}if(swapType=="out"){
			var thisImage = document.all[buttonName];
			thisImage.src = "uploads/images/btn-"+buttonName+"-1.gif";
		}
	}else{
		if(swapType=="over"){
			var thisImage = document.getElementById(buttonName);
			thisImage.src = "uploads/images/btn-"+buttonName+"-2.gif";
		}if(swapType=="out"){
			var thisImage = document.getElementById(buttonName);
			thisImage.src = "uploads/images/btn-"+buttonName+"-1.gif";
		}
	}
}

function setCard(_cardName){
	document.payform.cardType.value=_cardName;
	document.payform.cardType.className="select";
	
	bw=new checkBrowser();
	
	if(bw.ie4){
		document.all['cardTitle'].className="greenhead";
		document.all['cardCell'].className="greenhead";
	}else{
		document.getElementById("cardTitle").className="greenhead";
		document.getElementById("cardCell").className="greenhead";
	}
}

function zeroQuantity(idName){
	document.forms[0].elements[idName].value = "";
}

function enableEmails(idName){
	document.forms[0].elements[idName].disabled = false;
}

function disableEmails(idName){
	document.forms[0].elements[idName].value = "";
	document.forms[0].elements[idName].disabled = true;
}

function resetFilters(){
	document.forms[0].sort.selectedIndex = 0;
	document.forms[0].view.selectedIndex = 0;
	document.forms[0].filter.selectedIndex = 0;
}

function chooseImage(idName, thmNum, hiddenNum, hiddenName){
	document.forms[0].imageID[idName].checked = true;
	//var hiddenName = "Image"+hiddenNum;
	window.opener.document.forms[0].elements[hiddenName].value = thmNum;
	//window.opener.document.forms[0].Image1.value = thmNum;
	window.close();
}

function setSubsect(idName){
	var sectID = document.forms[0].elements[idName].value;
	document.forms[0].imgSubsect.value = sectID;
}

function chooseImageEdit(idName){
	document.forms[0].imageID[idName].checked = true;
	document.forms[0].checkSelected.value = idName;
}

function chooseImageUpload(thmNum, hiddenNum, artNum){
	var hiddenName = "Image"+hiddenNum+"_"+artNum;
	window.opener.document.forms[0].elements[hiddenName].value = thmNum;
}

function setThumb(thmName, imgNum, artNum){

	bw=new checkBrowser();

	var thmID = "thumb"+imgNum+"_"+artNum;
	
	if(bw.ie4){
		var thisImg = window.opener.document.all[thmID];
	}else{
		var thisImg = window.opener.document.getElementById(thmID);
	}
	thisImg.src = thmName;
}

function clearSubscribeDetails(){
	bw=new checkBrowser();
	
	if(bw.ie4){
		document.all['errortable'].style.display = "none";
		document.all['subsFname'].className="greenhead";
		document.all['subsLname'].className="greenhead";
		document.all['subsEmail'].className="greenhead";
		document.all['subsHearAboutTitle'].className="greenhead";
	}else{
		document.getElementById("errortable").style.display = "none";
		document.getElementById("subsFname").className="greenhead";
		document.getElementById("subsLname").className="greenhead";
		document.getElementById("subsEmail").className="greenhead";
		document.getElementById("subsHearAboutTitle").className="greenhead";
	}
	document.subscriptionsform.subsFname.value="";
	document.subscriptionsform.subsLname.value="";
	document.subscriptionsform.subsEmail.value="";
	document.subscriptionsform.subsHearAbout.value="select";
	document.subscriptionsform.subsPassword1.value="";
	document.subscriptionsform.subsPassword2.value="";
}

function clearMailinglistDetails(){
	bw=new checkBrowser();
	
	if(bw.ie4){
		document.all['errortable'].style.display = "none";
		document.all['subsFname'].className="greenhead";
		document.all['subsLname'].className="greenhead";
		document.all['subsEmail'].className="greenhead";
		document.all['subsCity'].className="greenhead";
	}else{
		document.getElementById("errortable").style.display = "none";
		document.getElementById("subsFname").className="greenhead";
		document.getElementById("subsLname").className="greenhead";
		document.getElementById("subsEmail").className="greenhead";
		document.getElementById("subsCity").className="greenhead";
	}
	document.subscriptionsform.subsFname.value="";
	document.subscriptionsform.subsLname.value="";
	document.subscriptionsform.subsEmail.value="";
	document.subscriptionsform.subsCity.value="";
}

function clearPasswordDetails(){
	bw=new checkBrowser();
	
	var emailAddress = window.opener.document.subscriptionsform.subsEmail.value;
	
	if(bw.ie4){
		window.opener.document.all['errortable'].style.display = "none";
		window.opener.document.all['subsFname'].className="greenhead";
		window.opener.document.all['subsLname'].className="greenhead";
		window.opener.document.all['subsEmail'].className="greenhead";
		window.opener.document.all['subsHearAboutTitle'].className="greenhead";
	}else{
		window.opener.document.getElementById("errortable").style.display = "none";
		window.opener.document.getElementById("subsFname").className="greenhead";
		window.opener.document.getElementById("subsLname").className="greenhead";
		window.opener.document.getElementById("subsEmail").className="greenhead";
		window.opener.document.getElementById("subsHearAboutTitle").className="greenhead";
	}
	window.opener.document.subscriptionsform.subsFname.value="";
	window.opener.document.subscriptionsform.subsLname.value="";
	window.opener.document.subscriptionsform.subsEmail.value="";
	window.opener.document.subscriptionsform.subsHearAbout.value="select";
	window.opener.document.subscriptionsform.subsPassword1.value="";
	window.opener.document.subscriptionsform.subsPassword2.value="";
	
	window.opener.document.loginform.username.value = emailAddress;
}

function copyAddress(){
	if(document.payform.sameAddress.checked=true){
		document.payform.deliverFname.value = document.payform.billFname.value;
		document.payform.deliverLname.value = document.payform.billLname.value;
		document.payform.deliverCompany.value = document.payform.billCompany.value;
		document.payform.deliverAddress1.value = document.payform.billAddress1.value;
		document.payform.deliverAddress2.value = document.payform.billAddress2.value;
		document.payform.deliverCity.value = document.payform.billCity.value;
		document.payform.deliverCountry.value = document.payform.billCountry.value;
		
		//document.payform.sameAddress.checked=false;
	}else if(document.payform.sameAddress.checked=false){
		//document.payform.sameAddress.checked=true;
	}
}

function clearAddress(){
	document.payform.deliverFname.value = "";
	document.payform.deliverLname.value = "";
	document.payform.deliverCompany.value = "";
	document.payform.deliverAddress1.value = "";
	document.payform.deliverAddress2.value = "";
	document.payform.deliverCity.value = "";
	document.payform.deliverCountry.value = "New Zealand";
}

function untickAddress(){
	if(document.payform.sameAddress.checked=true){
		document.payform.sameAddress.checked=false;
	}
}

function clearAmount(){
	document.payform.amount[0].checked=false;
	document.payform.amount[1].checked=false;
	document.payform.amount[2].checked=false;
}

function clearOtheramount(){
	document.subscriptionsform.otheramount.value="";
}

function submitForm(formAction){

	bw=new checkBrowser();

	if(document.forms[0].checkSelected.value != ""){
		document.forms[0].action = formAction;
		document.forms[0].submit();
	}else{
		if(bw.ie4){
			document.all['errortable'].style.display = "block";
		}else{
			document.getElementById("errortable").style.display = "block";
		}
	}
}


function checkBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this
}

function setPrice(){

	// split the publicPriceList and membersPriceList variables (set via PHP/Javascript in actual page) into arrays
	var publicPriceArray = publicPriceList.split("|");
	var membersPriceArray = membersPriceList.split("|");
	
	var textMessage = "";
	var thisOptions = document.forms[0].elements["Title"];
	var thisSelection = thisOptions.selectedIndex;
	//alert("dropdown array: "+thisOptions.length);
	//alert("public array: "+publicPriceArray.length);
	//alert("members array: "+membersPriceArray.length);
	for(i=0;i<thisOptions.length;i++){
		if(i==thisSelection){
			if(document.forms[0].elements["MemberNum"].value == "" || document.forms[0].elements["MemberNum"].value == "n/a"){
			
				textMessage = "Price = $"+publicPriceArray[i];
				swapText(textMessage);
			}else{
				textMessage = "Price = $"+publicPriceArray[i]+" public) / $"+membersPriceArray[i]+" (members)";
				swapText(textMessage);
				
			}
		}
	}

}

function checkOther(){
	var thisSelection = document.subscriptionsform.elements["subsHearAbout"].value;
	if(thisSelection=="Other:"){
		showHideTable('othertable','show');
	}else{
		showHideTable('othertable','hide');
	}
}

function showhideDates(){
	if(document.forms[0].elements["filter"][1].checked){
		showHideTable('datetable','show');
	}else{
		showHideTable('datetable','hide');
	}
}

function swapText(message,target){
	document.getElementById(target).replaceChild(
	  document.createTextNode(message), 
	  document.getElementById(target).childNodes[0]);

}

function showHideTable(tableName,displayType){

	bw=new checkBrowser();
	
	if(bw.ie4){
		if(displayType=="show"){
			var thisTable = document.all[tableName];
			thisTable.style.display = "block";
		}if(displayType=="hide"){
			var thisTable = document.all[tableName];
			thisTable.style.display = "none";
		}
	}else{
		if(displayType=="show"){
			var thisTable = document.getElementById(tableName);
			thisTable.style.display = "block";
		}if(displayType=="hide"){
			var thisTable = document.getElementById(tableName);
			thisTable.style.display = "none";
		}
	}
}

function clearFields(fieldName){
	document.forms[0].elements[fieldName].value = "";
}

function toggleShowhide(layerName, tableName, tableHeight, idNum, noOfRecs){

	bw=new checkBrowser();
	
	// get visibility for toggle
	if(bw.ie4){
		var thisLayer = document.all[layerName+idNum];
		var thisTable = document.all[tableName+idNum];
		var visibilityType = thisLayer.style.visibility;
	}else{
		var thisLayer = document.getElementById(layerName+idNum);
		var thisTable = document.getElementById(tableName+idNum);
	}
	
	var visibilityType = thisLayer.style.visibility;
	
	// close all divs	
	for(x=0;x<noOfRecs;x++){
		if(bw.ie4){
			var thisLayer = document.all[layerName+x];
			var thisTable = document.all[tableName+x];
		}else{
			var thisLayer = document.getElementById(layerName+x);
			var thisTable = document.getElementById(tableName+x);
		}
		thisLayer.style.visibility = "hidden";
		thisTable.height = 1;
	}
	
	// toggle show/hide
	if(bw.ie4){
		var thisLayer = document.all[layerName+idNum];
		var thisTable = document.all[tableName+idNum];
		var visibilityType = thisLayer.style.visibility;
	}else{
		var thisLayer = document.getElementById(layerName+idNum);
		var thisTable = document.getElementById(tableName+idNum);
	}
	
	if(visibilityType=="hidden"){
		thisLayer.style.visibility = "visible";
		thisTable.height = tableHeight;
		thisTable.valign = "top";
	}if(visibilityType=="visible"||visibilityType==""){
		thisLayer.style.visibility = "hidden";
		thisTable.height = 1;
		thisTable.valign = "top";
	}
}

function hideAll(layerName, tableName, noOfTimes){
	var thisLayer = layerName;
	var thisTable = tableName;
	for(x=0;x<noOfTimes;x++){
		toggleShowhide(thisLayer+x, thisTable+x, x);
	}
}

function hideSubTables(){
	showHideTable('table1','hide');
	showHideTable('subtitletable','hide');
}

function resetClass(idName, theclassName){

	bw=new checkBrowser();
	
	if(bw.ie4){
		thisElement = document.all[idName];
		thisElement.className = theclassName;
	}else{
		thisElement = document.getElementById(idName);
		thisElement.className = theclassName;
	}
}

function setDateToday(){
	
	document.form1.newsDatewritten.value=document.form1.todaysDate.value;
}

function showSubsect(){

	var tableNum = document.form2.imgGalNum.value;
	var maxNum = 2;
	
	if(tableNum!="select"){
		for(i=1;i<maxNum;i++){
			var theTable = "table"+i;
			
			if(tableNum==i){
				showHideTable(theTable,'show');
				var subTable = theTable;
			}else{
				showHideTable(theTable,'hide');
			}
			
		}
		showHideTable('subtitletable','show');
	}else if(tableNum=="select"){
		hideSubTables();
	}
	resetClass('subsect', 'subhead');
	toggleSubsect(subTable);
}

function toggleSubsect(idName){
	subStatus = document.form2.subStatus.value;
	if(subStatus==""){
		document.form2.subStatus.value = idName;
	}else{
		document.form2.subStatus.value = "";
	}
}

<!-- Dynamic Version by: Nannette Thacker -->
<!-- http://www.shiningstar.net -->
<!-- Original by :  Ronnie T. Moore -->
<!-- Web Site:  The JavaScript Source -->
<!-- Use one function for multiple text areas on a page -->
<!-- Limit the number of characters per textarea -->
<!-- Begin
function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
cntfield.value = maxlimit - field.value.length;
}

// START Menu Time offset routine

var secsOffset;
var timerIDOffset = null;
var timerRunningOffset = false;
var delayOffset = 5000;

function closeDelay(recordNum){
	//var closeLayer = layerName;
	InitializeTimeOffset(recordNum);
}

function InitializeTimeOffset(recordNum)
{
    // Set the length of the timer, in seconds
	//var closeLayer = layerName;
	
    secsOffset = 1;
    StopTheClockOffset();
    StartTheTimeOffset(recordNum);
}

function StopTheClockOffset()
{
    if(timerRunningOffset=true)
        clearTimeout(timerIDOffset);
    timerRunningOffset = false;
}

function StartTheTimeOffset(recordNum)
{
	
    if (secsOffset==0)
    {
        StopTheClockOffset();
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
		//var closeLayer = layerName;

		showHideTable("reviewlinktable_"+recordNum,"show");
		showHideTable("reviewtable_"+recordNum,"hide");

    }
    else
    {
		// self.status = "Window will close in "+secs+" seconds"
		//var closeLayer = layerName;
        secsOffset = secsOffset - 1;
        timerRunningOffset = true;
        timerIDOffset = self.setTimeout("StartTheTimeOffset('"+recordNum+"')", delayOffset);
    }
}

function closeDelayNav(layerName){
	//var closeLayer = layerName;
	InitializeTimeOffsetNav(layerName);
}

function InitializeTimeOffsetNav(layerName)
{
    // Set the length of the timer, in seconds
	//var closeLayer = layerName;
	
    secsOffset = 1;
    StopTheClockOffsetNav();
    StartTheTimeOffsetNav(layerName);
}

function StopTheClockOffsetNav()
{
    if(timerRunningOffset=true)
        clearTimeout(timerIDOffset);
    timerRunningOffset = false;
}

function StartTheTimeOffsetNav(layerName)
{
	
    if (secsOffset==0)
    {
        StopTheClockOffsetNav();
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
		//var closeLayer = layerName;
        MM_showHideNav(''+layerName+'','','hide');
    }
    else
    {
		// self.status = "Window will close in "+secs+" seconds"
		//var closeLayer = layerName;
        secsOffset = secsOffset - 1;
        timerRunningOffset = true;
        timerIDOffset = self.setTimeout("StartTheTimeOffsetNav('"+layerName+"')", delayOffset);
    }
}
// END Menu Time offset routine

function checkSections(){
	var thisSelection = document.forms[0].elements["menuAddSections"].value;
	var thisSelectionCount = document.forms[0].elements["menuAddCount"].value;
	if(thisSelection!=0||thisSelection!=""){
		document.forms[0].elements["menuSectionCount"].value = parseInt(thisSelectionCount) + parseInt(thisSelection);
	}
}

/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Manzi Olivier :: http://www.imanzi.com/ */

// calculate the ASCII code of the given character
function CalcKeyCode(aChar) {
  var character = aChar.substring(0,1);
  var code = aChar.charCodeAt(0);
  return code;
}

function checkNumber(val) {
  var strPass = val.value;
  var strLength = strPass.length;
  var lchar = val.value.charAt((strLength) - 1);
  var cCode = CalcKeyCode(lchar);

  /* Check if the keyed in character is a number
     do you want alphabetic UPPERCASE only ?
     or lower case only just check their respective
     codes and replace the 48 and 57 */

  if (cCode < 48 || cCode > 57 ) {
    var myNumber = val.value.substring(0, (strLength) - 1);
    val.value = myNumber;
  }
  return false;
}

function untickAddress(){
	if(document.payform.sameAddress.checked=true){
		document.payform.sameAddress.checked=false;
	}
}

function checkTerms(){

	var terms = document.forms[0].elements["terms"].checked;
	//alert('terms: '+terms);
	if(terms == false){
		showHideTable('termstable','show');
		showHideTable('buttontable','hide');
	}
	if(terms == true){
		showHideTable('termstable','hide');
		showHideTable('buttontable','show');
	}
	//alert('Checked: '+terms);
}

function setSessionDropdown(formName,target){
	var theValue = document.forms[formName].elements["session"+target].value;
	var displayText = theValue;
	if(theValue == "session"){
		displayText = "In-store session";
	}else if(theValue == "delivery"){
		displayText = "Delivery";
	}else if(theValue == "pickup"){
		displayText = "Pick up";
	}else if(theValue == "select"){
		displayText = "";
	}
	document.forms["filterform"].elements["session"+target+"Value"].value = theValue;
	document.forms["timeform"].elements["session"+target+"Value"].value = theValue;
	//alert(document.forms["timeform"].elements["session"+target+"Value"].value);
	document.getElementById('swappable_'+target).innerHTML = displayText;
}

function submitDate(theForm,theDay,theDate,theTime,theID){
	document.forms[theForm].elements["sessionDay"].value = theDay;
	document.forms[theForm].elements["sessionDate"].value = theDate;
	document.forms[theForm].elements["sessionTime"].value = theTime;
	//document.forms[theForm].elements["sessionTypeValue"].value = document.forms[0].elements["sessionType"].value;
	document.forms[theForm].elements["sessionTimeID"].value = theID;
	document.forms[theForm].submit();
}

function swapMonth(){
	document.forms[0].elements["menuMonth"].value = document.forms[0].elements["menuMonthDropdown"].value;
	document.forms[0].submit();
}

function typeSubmit(formName){
	var type = document.forms[formName].elements["sessionType"].value;
	//alert(type);
	document.forms[formName].elements["sessionTypeValue"].value = type;
	document.forms[formName].submit();
}

function quantitySubmit(formName,target){

	var theValue = document.forms[formName].elements["session"+target].value;
	var displayText = theValue;
	if(theValue == "session"){
		displayText = "In-store session";
	}else if(theValue == "delivery"){
		displayText = "Delivery";
	}else if(theValue == "pickup"){
		displayText = "Pick up";
	}else if(theValue == "select"){
		displayText = "";
	}
	document.forms["filterform"].elements["session"+target+"Value"].value = theValue;
	document.forms["timeform"].elements["session"+target+"Value"].value = theValue;
	//alert(document.forms["timeform"].elements["session"+target+"Value"].value);
	document.getElementById('swappable_'+target).innerHTML = displayText;
	document.forms["filterform"].submit();
}

function addDishes(displayBox,type,dishLimit){

	closeAllDishes();

	dishTotal = document.forms[0].elements["dishTotal"].value;
	var dishNum = document.forms[0].elements[displayBox].value;
	var menuCount = document.forms[0].elements["menuCount"].value;
	var orderText = "<b>Mains:<\/b><br \/>";
	var orderLine = "";
	
	if(dishTotal < dishMax){
		
		if(dishNum < dishLimit){
			if(type == "add"){	
				dishTotal = (parseInt(dishTotal) + 1);
				dishNum = (parseInt(dishNum) + 1);
			}else{
				if(dishTotal == 0){
					dishTotal = 0;
				}else{
					if(dishNum != 0){
						dishTotal = (parseInt(dishTotal) - 1);
					}
				}
				if(dishNum == 0){
					dishNum = 0;
				}else{
					dishNum = (parseInt(dishNum) - 1);
				}
			}
			document.forms[0].elements["dishTotal"].value = dishTotal;
			document.forms[0].elements[displayBox+"_Qty"].value = dishNum;
			document.forms[0].elements[displayBox].value = dishNum;
		}else if(dishNum == dishLimit){
			if(type == "subtract"){
				
				if(dishTotal == 0){
					dishTotal = 0;
				}else{
					if(dishNum != 0){
						dishTotal = (parseInt(dishTotal) - 1);
					}
				}
				
				if(dishNum == 0){
					dishNum = 0;
				}else{
					dishNum = (parseInt(dishNum) - 1);
				}
			}
			document.forms[0].elements["dishTotal"].value = dishTotal;
			document.forms[0].elements[displayBox+"_Qty"].value = dishNum;
			document.forms[0].elements[displayBox].value = dishNum;
		}
		if(dishNum == dishLimit){
			showHideTable(displayBox+"_table","show");
		}else{
			showHideTable(displayBox+"_table","hide");
		}
	}else{
			if(type == "subtract"){
				
				if(dishTotal == 0){
					dishTotal = 0;
				}else{
					if(dishNum != 0){
						dishTotal = (parseInt(dishTotal) - 1);
					}
				}
				
				if(dishNum == 0){
					dishNum = 0;
				}else{
					dishNum = (parseInt(dishNum) - 1);
				}
			}
			document.forms[0].elements["dishTotal"].value = dishTotal;
			document.forms[0].elements[displayBox].value = dishNum;
		
		if(dishNum == dishLimit){
			showHideTable(displayBox+"_table","show");
		}else{
			showHideTable(displayBox+"_table","hide");
		}
	}
	
	//build order line
	//alert('menuCount: '+menuCount+'\ndishTotal: '+dishTotal+'\ndishNum: '+dishNum);
	for($x=0;$x<menuCount;$x++){
		var displayBoxNum = document.forms[0].elements["dishCounter_"+$x].value;
		var orderName = document.forms[0].elements["dishCounter_"+$x+"_Name"].value;
		var orderSplitText = "";
		//alert(document.forms[0].elements["splitDish_"+$x][0].type);
		if(document.forms[0].elements["splitDish_"+$x].type != "hidden"){
			if(document.forms[0].elements["splitDish_"+$x][0].checked){
				orderSplitText = " (split)";
			}
		}
		//alert("order split: "+orderSplitText);
		if(displayBoxNum != 0){
			orderLine = orderLine+displayBoxNum+" x "+orderName+orderSplitText+"<br \/>";
		}
	}
	
	orderText = orderText+orderLine;
	document.forms[0].elements["orderText"].value = orderText;
	//alert(document.forms[0].elements["orderText"].value);
	document.getElementById('swappable_order').innerHTML = orderText;
	//swapText(orderText,'swappable_order');
	
	if(dishTotal == dishMax){
		alert('You have reached your limit of '+dishTotal+' dishes');
		document.forms[0].elements["submit"].disabled = false;
	}else{
		document.forms[0].elements["submit"].disabled = true;
	}
}

function isArray(obj) {
   if(obj.constructor.toString().indexOf("Array") == -1){
   		alert("It's NOT an array!");
      return false;
   }else{
   alert("It's an array!");
      return true;
	}
}

function splitDishes(dishType){

	var menuCount = document.forms[0].elements["menuCount"].value;
	//alert("menu count: "+menuCount);
	if(dishType == "side"){
		var orderText = "<b>Sides:<\/b><br \/>";
	}else{
		var orderText = "<b>Mains:<\/b><br \/>";
	}
	var orderLine = "";
	
	//build order line
	//alert('menuCount: '+menuCount+'\ndishTotal: '+dishTotal+'\ndishNum: '+dishNum);
	for($x=0;$x<menuCount;$x++){
		var displayBoxNum = document.forms[0].elements["dishCounter_"+$x].value;
		var orderName = document.forms[0].elements["dishCounter_"+$x+"_Name"].value;
		var orderSplitText = "";
		//alert(document.forms[0].elements["splitDish_"+$x][0].type);
		if(document.forms[0].elements["splitDish_"+$x].type != "hidden"){
			if(document.forms[0].elements["splitDish_"+$x][0].checked){
				orderSplitText = " (split)";
			}
		}
		//alert("order split: "+orderSplitText);
		if(displayBoxNum != 0){
			orderLine = orderLine+displayBoxNum+" x "+orderName+orderSplitText+"<br \/>";
		}
	}
	
	orderText = orderText+orderLine;
	document.forms[0].elements["orderText"].value = orderText;
	//alert(document.forms[0].elements["orderText"].value);
	document.getElementById('swappable_order').innerHTML = orderText;
	//swapText(orderText,'swappable_order');

	//alert(orderLine);
}

function checkDishMax(){
	if(dishTotal == dishMax){
		alert('You have reached your limit of '+dishTotal+' dishes');
		document.forms[0].elements["submit"].disabled = false;
	}	
}

function reviewDishes(recordNum){
	
	closeAllDishes();
	
	showHideTable("reviewlinktable_"+recordNum,"hide");
	showHideTable("reviewtable_"+recordNum,"show");
	closeDelay(recordNum);
	
	var dishesLeft = (parseInt(dishMax) - parseInt(dishTotal));
	
	var dishPlural = "es";
	if(dishesLeft == 1){
		dishPlural = "";
	}
	
	var dishText = "You have "+dishesLeft+" dish"+dishPlural+" left to choose";
	if(dishesLeft == 0){
		dishText = "All your dishes have been chosen, "+dishTotal+" in total.";
	}
	
	swapText(dishText,'swappable_'+recordNum+'_left');
	//alert('dishMax:'+dishMax+' dishTotal:'+dishTotal+', dishesLeft:'+dishesLeft);
}

function closeAllDishes(){
	for($x=0;$x<menuTotal;$x++){
		showHideTable("reviewlinktable_"+$x,"show");
		showHideTable("reviewtable_"+$x,"hide");
	}
}

function addSideDishes(displayBox,type,dishLimit){

	dishTotal = document.forms[0].elements["dishTotal"].value;
	var dishNum = document.forms[0].elements[displayBox].value;
	var menuCount = document.forms[0].elements["menuCount"].value;
	var orderText = "<b>Sides:<\/b><br \/>";
	var orderLine = "";
	var orderPrice = document.forms[0].elements["orderPrice"].value;
	var orderPriceOriginal = document.forms[0].elements["orderPrice"].value;
	//alert(orderPrice);
	
		if(type == "add"){	
			dishTotal = (parseInt(dishTotal) + 1);
			dishNum = (parseInt(dishNum) + 1);
		}else{
			if(dishTotal == 0){
				dishTotal = 0;
			}else{
				if(dishNum != 0){
					dishTotal = (parseInt(dishTotal) - 1);
				}
			}
			if(dishNum == 0){
				dishNum = 0;
			}else{
				dishNum = (parseInt(dishNum) - 1);
				//alert('dishNum: '+dishNum);
			}
		}
		document.forms[0].elements["dishTotal"].value = dishTotal;
		document.forms[0].elements[displayBox+"_Qty"].value = dishNum;
		document.forms[0].elements[displayBox].value = dishNum;

//build order line
	
	for($x=0;$x<menuCount;$x++){
		var displayBoxNum = document.forms[0].elements["dishCounter_"+$x].value;
		var orderName = document.forms[0].elements["dishCounter_"+$x+"_Name"].value;
		if(displayBoxNum != 0){
			orderLine = orderLine+displayBoxNum+" x "+orderName+"<br \/>";
			//alert('orderPrice: '+parseFloat(orderPrice)+'\ndishPrice: '+parseFloat(document.forms[0].elements["dishCounter_"+$x+"_Price"].value)+'\nboxNum: '+parseFloat(displayBoxNum));
			orderPrice = parseFloat(orderPrice)+(parseFloat(document.forms[0].elements["dishCounter_"+$x+"_Price"].value)*parseFloat(displayBoxNum));
		}
	}
	
	// add up price
	//orderPrice = orderPrice.toFixed(2);
	orderPrice = round_decimals(orderPrice, 2);
	document.forms[0].elements["orderTotal"].value = orderPrice;
	orderPrice = "$"+orderPrice;
	document.getElementById('swappable_price').innerHTML = orderPrice;
	
	orderText = orderText+orderLine;
	document.forms[0].elements["orderText"].value = orderText;
	document.getElementById('swappable_order').innerHTML = orderText;
}

function addWineDishes(displayBox,type,dishLimit){

	dishTotal = document.forms[0].elements["dishTotal"].value;
	var dishNum = document.forms[0].elements[displayBox].value;
	//alert(dishNum);
	var menuCount = document.forms[0].elements["menuCount"].value;
	var orderText = "<b>Wines:<\/b><br \/>";
	var orderLine = "";
	var orderPrice = document.forms[0].elements["orderPrice"].value;
	var orderPriceOriginal = document.forms[0].elements["orderPrice"].value;
	
		if(type == "add"){	
			dishTotal = (parseInt(dishTotal) + 1);
			dishNum = (parseInt(dishNum) + 1);
		}else{
			if(dishTotal == 0){
				dishTotal = 0;
			}else{
				if(dishNum != 0){
					dishTotal = (parseInt(dishTotal) - 1);
				}
			}
			if(dishNum == 0){
				dishNum = 0;
			}else{
				dishNum = (parseInt(dishNum) - 1);
			}
		}
		document.forms[0].elements["dishTotal"].value = dishTotal;
		document.forms[0].elements[displayBox+"_Qty"].value = dishNum;
		document.forms[0].elements[displayBox].value = dishNum;

	//build order line
	for($x=0;$x<menuCount;$x++){
		var displayBoxNum = document.forms[0].elements["dishCounter_"+$x].value;
		var orderName = document.forms[0].elements["dishCounter_"+$x+"_Name"].value;
		if(displayBoxNum != 0){
			orderLine = orderLine+displayBoxNum+" x "+orderName+"<br \/>";
			//alert('orderPrice: '+parseFloat(orderPrice)+'\ndishPrice: '+parseFloat(document.forms[0].elements["dishCounter_"+$x+"_Price"].value)+'\nboxNum: '+parseFloat(displayBoxNum));
			orderPrice = parseFloat(orderPrice)+(parseFloat(document.forms[0].elements["dishCounter_"+$x+"_Price"].value)*parseFloat(displayBoxNum));
		}
	}
	
	// add up price
	//orderPrice = orderPrice.toFixed(2);
	orderPrice = round_decimals(orderPrice, 2);
	document.forms[0].elements["orderTotal"].value = orderPrice;
	orderPrice = "$"+orderPrice;
	document.getElementById('swappable_price').innerHTML = orderPrice;
	
	orderText = orderText+orderLine;
	document.forms[0].elements["orderText"].value = orderText;
	document.getElementById('swappable_order').innerHTML = orderText;
}

function writeToField(from, to, formFrom, formTo2, formTo){
	var textFrom = document.forms[formFrom].elements[from].value;
	document.forms[formTo].elements[to].value = textFrom;
	document.forms[formTo2].elements[to].value = textFrom;
}	

/* This script is Copyright (c) Paul McFedries and 
Logophilia Limited (http://www.mcfedries.com/).
Permission is granted to use this script as long as 
this Copyright notice remains in place.*/

function round_decimals(original_number, decimals) {
    var result1 = original_number * Math.pow(10, decimals)
    var result2 = Math.round(result1)
    var result3 = result2 / Math.pow(10, decimals)
    return pad_with_zeros(result3, decimals)
}

function pad_with_zeros(rounded_value, decimal_places) {

    // Convert the number to a string
    var value_string = rounded_value.toString()
    
    // Locate the decimal point
    var decimal_location = value_string.indexOf(".")

    // Is there a decimal point?
    if (decimal_location == -1) {
        
        // If no, then all decimal places will be padded with 0s
        decimal_part_length = 0
        
        // If decimal_places is greater than zero, tack on a decimal point
        value_string += decimal_places > 0 ? "." : ""
    }
    else {

        // If yes, then only the extra decimal places will be padded with 0s
        decimal_part_length = value_string.length - decimal_location - 1
    }
    
    // Calculate the number of decimal places that need to be padded with 0s
    var pad_total = decimal_places - decimal_part_length
    
    if (pad_total > 0) {
        
        // Pad the string with 0s
        for (var counter = 1; counter <= pad_total; counter++) 
            value_string += "0"
        }
    return value_string
}

//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

//-->