// jeuxdefoire.com
// OrderForm022.js
// 2006-2007 umpteenth version
function OrderForm(prefix, precision, firstChoice) {
	this.prefix = prefix ? prefix : '';	
	//names - Set these according to how the html ids are set
	this.FORM_NAME = this.prefix + 'reservefrm';
this.QTY_TOTAL = this.prefix + 'qtyTotal';
	this.BTN_TOTAL = this.prefix + 'btnTotal';
	this.TXT_OUT = this.prefix + 'txtTotal';
this.ONETXT_OUT = this.prefix + 'onetxtTotal';
this.TWOTXT_OUT = this.prefix + 'twotxtTotal';
this.THREETXT_OUT = this.prefix + 'threetxtTotal';
this.GDTXT_OUT = this.prefix + 'gdtxtTotal';	
this.DUETXT_OUT = this.prefix + 'duetxtTotal';	
	// partial names - Set these according to how the html ids are set
	this.CHK = this.prefix + 'radio';
	this.SEL = this.prefix + 'jdf';
this.QTY = this.prefix + 'val';
	this.PRICE = this.prefix + 'txtPrice';
this.ONEPRICE = this.prefix + 'onetxtPrice';
this.TWOPRICE = this.prefix + 'twotxtPrice';
	// precision for the decimal places
	// If not set, then no decimal adjustment is made
	this.precision = precision ? precision : -1;
	// if the drop down has the first choice after index 1
	// this is used when checking or unchecking a checkbox
	this.firstChoice = firstChoice ? firstChoice : 1;
	// form
	this.frm = document.getElementById(this.FORM_NAME);
	// checkboxes
	this.chkReg = new RegExp(this.CHK + '([0-9]+)');
	this.getCheck = function(chkId) {
		return document.getElementById(this.CHK + chkId);
	};
	// selects
	this.selReg = new RegExp(this.SEL + '([0-9]+)');
	this.getSelect = function(selId) {
		return document.getElementById(this.SEL + selId);
	};
	// price spans
	this.priceReg = new RegExp(this.PRICE + '([0-9]+)');
	// price 1spans
	this.onepriceReg = new RegExp(this.ONEPRICE + '([0-9]+)');
	// price 2spans
	this.twopriceReg = new RegExp(this.TWOPRICE + '([0-9]+)');
	// text output
	this.txtOut = document.getElementById(this.TXT_OUT);
// text 1output
	this.onetxtOut = document.getElementById(this.ONETXT_OUT);
// text 2output
	this.twotxtOut = document.getElementById(this.TWOTXT_OUT);
// text 3output
	this.threetxtOut = document.getElementById(this.THREETXT_OUT);
// text output2
	this.gdtxtOut = document.getElementById(this.GDTXT_OUT);
// text output5
	this.duetxtOut = document.getElementById(this.DUETXT_OUT);
	// button
	this.btnTotal = document.getElementById(this.BTN_TOTAL);
	// price array
	this.prices = new Array();
	var o = this;
	this.getCheckEvent = function() {
		return function() {
			o.checkRetotal(o, this);
		};
	};
		this.getSelectEvent = function() {
		return function() {
			o.totalCost(o);
		};
	};
		this.getBtnEvent = function() {
		return function() {
			o.totalCost(o);
		};
	};
	/*
	 * Calculate the cost
	 * 
	 * Required:
	 *  Span tags around the prices with IDs formatted
	 *  so each item's numbers correspond its select elements and input checkboxes.
	 */
	this.totalCost = function(orderObj) {
		var spanObj = orderObj.frm.getElementsByTagName('span');
		var total = 0.0;
var onetotal = 0.0;
var twototal = 0.0;
var threetotal = 0.0;
var gdtotal = 0.0;
var duetotal = 0.0;
		for (var i=0; i<spanObj.length; i++) {
				var regResult = orderObj.priceReg.exec(spanObj[i].id);
			if (regResult) {
				var itemNum = regResult[1];
				var chkObj = orderObj.getCheck(itemNum);
				var selObj = orderObj.getSelect(itemNum);
				var price = orderObj.prices[itemNum];
				var quantity = 0;
var amount = 0;
				if (selObj) {
					quantity = parseFloat(selObj.options[selObj.selectedIndex].text);
					quantity = isNaN(quantity) ? 0 : quantity;
					if (chkObj) chkObj.checked = amount;
				} else if (chkObj) {
					amount = chkObj.checked ? 1 : amount;
				}
				total += quantity;
///quantity is select amounts amount is checkbox amounts
onetotal += quantity * price;
twototal +=  amount * price;
done = total * twototal;
threetotal = done + onetotal;
quarta = 0.25
tri = 0.75
gdtotal = threetotal * quarta;
duetotal = threetotal * tri;
			}
		}
if (this.precision == -1) {
		orderObj.txtOut.value = total;
orderObj.onetxtOut.value = onetotal;
orderObj.twotxtOut.value = twototal;
orderObj.threetxtOut.value = threetotal;
orderObj.gdtxtOut.value = gdtotal;
orderObj.duetxtOut.value = duetotal;
} else {
			orderObj.txtOut.value = total.toFixed(this.precision);
		}	

};

	/*
	 * Handle clicks on the checkboxes
	 *
	 * Required:
	 *  The corresponding select elements and input checkboxes need to be numbered the same
	 *
	 */
	this.checkRetotal = function(orderObj, obj) {
		var regResult = orderObj.chkReg.exec(obj.id);
		if (regResult) {
			var optObj = orderObj.getSelect(regResult[1]);
			if (optObj) {
				if (obj.checked) {
					optObj.selectedIndex = orderObj.firstChoice;
				} else {
					optObj.selectedIndex = 0;
				}
			}
			orderObj.totalCost(orderObj);
		}
	};
	/*
	 * Set up events
	 */
	this.setEvents = function(orderObj) {
		var spanObj = orderObj.frm.getElementsByTagName('span');
		for (var i=0; i<spanObj.length; i++) {
			var regResult = orderObj.priceReg.exec(spanObj[i].id);
			if (regResult) {
				var itemNum = regResult[1];
				var chkObj = orderObj.getCheck(itemNum);
				var selObj = orderObj.getSelect(itemNum);
				if (chkObj) {
					chkObj.onclick = orderObj.getCheckEvent();
				}
				if (selObj) {
					selObj.onchange = orderObj.getSelectEvent();
				}
				if (orderObj.btnTotal) {
					orderObj.btnTotal.onclick = orderObj.getBtnEvent();
				}
			}
		}
	};
	this.setEvents(this);
	/*
	 * Grab the prices from the html
	 * Required:
	 *  Prices should be wrapped in span tags, numbers only.
	 */
	this.grabPrices = function(orderObj) {
		var spanObj = orderObj.frm.getElementsByTagName('span');
		for (var i=0; i<spanObj.length; i++) {
			if (orderObj.priceReg.test(spanObj[i].id)) {
				var regResult = orderObj.priceReg.exec(spanObj[i].id);
				if (regResult) {
					orderObj.prices[regResult[1]] = parseFloat(spanObj[i].innerHTML);
				}
			}
		}
	};

	this.grabPrices(this);
	
// jeuxdefoire.com OrderForm022.js END
}
///AGREE TO TERMS CHECKBOX see page head
//MAIN ORDERFORM
//<![CDATA[
window.onload = setupScripts;
function setupScripts()
{
var anOrder1 = new OrderForm();
var anOrder2 = new OrderForm('a_');
}
//]]>
//ADDING UP TOTALS
function a_plus_b(form) {
//a variable cannot be used twice
//reservation total of 50% tables and supplements and 100% of fake money 
var a=(document.forms["reservefrm"].elements["gdtxtTotal"].value*1)
var b=(document.forms["a_reservefrm"].elements["a_onetxtTotal"].value*1)
var c=a+b
//recall of table and supplement total 
var d=(document.forms["reservefrm"].elements["threetxtTotal"].value*1)
//recall 50% tables and supplements
//a variable cannot be used twice hence e=  f=  
var e=(document.forms["reservefrm"].elements["gdtxtTotal"].value*1)
var f=(document.forms["reservefrm"].elements["duetxtTotal"].value*1)
//recall of table and supplement total 
form.ans3.value = d
//mention to clients that 50% of tables due for reservation--recall "a" from above
form.ans4.value = e 
form.ans5.value = f 
//mention to clients that 100% of fake money is due for reservation--recall "b" from above
form.ans2.value = b
//Adding up reservation total of 50% tables and supplements and 100% of fake money 
form.amount.value = c
//mention to clients that 50% of tables due before beginning of soiree--recall "a" from above
}
 <!--
function copydata() {
//JEUX DE DES
//PRICES 
document.agreeform.txtPrice10.value = document.reservefrm.txtPrice10.value;
document.agreeform.txtPrice11.value = document.reservefrm.txtPrice11.value;
document.agreeform.txtPrice12.value = document.reservefrm.txtPrice12.value;
//NUMBER OF TABLES
document.agreeform.jdf10.value = document.reservefrm.jdf10.value;
document.agreeform.jdf11.value = document.reservefrm.jdf11.value;
document.agreeform.jdf12.value = document.reservefrm.jdf12.value;
//JEUX DE BONNETEAU
//PRICES 
document.agreeform.txtPrice20.value = document.reservefrm.txtPrice20.value;
document.agreeform.txtPrice21.value = document.reservefrm.txtPrice21.value;
document.agreeform.txtPrice22.value = document.reservefrm.txtPrice22.value;
//NUMBER OF TABLES
document.agreeform.jdf20.value = document.reservefrm.jdf20.value;
document.agreeform.jdf21.value = document.reservefrm.jdf21.value;
document.agreeform.jdf22.value = document.reservefrm.jdf22.value;
//TABLE TOTALS
document.agreeform.txtTotal.value = document.reservefrm.txtTotal.value; 
//TABLE PRICE TOTALS
document.agreeform.onetxtTotal.value = document.reservefrm.onetxtTotal.value; 
////SUPPLIMENTARIES
//TENUE DE SOIREE
//PRICES 
document.agreeform.txtPrice30.value = document.reservefrm.txtPrice30.value;
document.agreeform.txtPrice31.value = document.reservefrm.txtPrice31.value;
document.agreeform.txtPrice32.value = document.reservefrm.txtPrice32.value;
document.agreeform.txtPrice33.value = document.reservefrm.txtPrice33.value;
//TYPE OF CLOTHING
//TABLES
//PRICES 
document.agreeform.txtPrice40.value = document.reservefrm.txtPrice40.value;
document.agreeform.txtPrice41.value = document.reservefrm.txtPrice41.value;
document.agreeform.txtPrice42.value = document.reservefrm.txtPrice42.value;
document.agreeform.txtPrice43.value = document.reservefrm.txtPrice43.value;
//TYPE OF TABLES
//SUPPLIMENTARIES TOTALS PER TABLE
document.agreeform.twotxtTotal.value = document.reservefrm.twotxtTotal.value; 
//TABLE & SUPPLIMENTARIES TOTALS
document.agreeform.threetxtTotal.value = document.reservefrm.threetxtTotal.value; 
////FAKE BILLETS
document.agreeform.a_txtPrice1.value = document.a_reservefrm.a_txtPrice1.value;
document.agreeform.a_txtPrice2.value = document.a_reservefrm.a_txtPrice2.value;
//TYPE
//AMOUNT
document.agreeform.select1.value = document.a_reservefrm.select1.value;
document.agreeform.select2.value = document.a_reservefrm.select2.value;
//FAKE BILLETS TOTALS
document.agreeform.a_txtTotal.value = document.a_reservefrm.a_txtTotal.value;
document.agreeform.a_onetxtTotal.value = document.a_reservefrm.a_onetxtTotal.value;
////CONTACT
document.agreeform.name.value = document.contactinfo.name.value;
document.agreeform.phone.value = document.contactinfo.phone.value;
document.agreeform.mobile.value = document.contactinfo.mobile.value;
document.agreeform.contact.value = document.contactinfo.contact.value;
document.agreeform.date.value = document.contactinfo.date.value;
document.agreeform.times.value = document.contactinfo.times.value;
document.agreeform.email.value = document.contactinfo.email.value;
document.agreeform.address.value = document.contactinfo.address.value;
}
//-->
//COPYING THE RADIO BUTTON DATA
function copytenueradioData() {
    for (var x = 0; x < document.reservefrm.tenue.length;x++)
       {if (document.reservefrm.tenue[x].checked)
           {document.agreeform.tenue.value = x;
        }}}
function copytableradioData() {
       for (var y=0;y < document.reservefrm.tables.length;y++)
       {if (document.reservefrm.tables[y].checked)
            {document.agreeform.tables.value = y;
   }}}
function gettinradios() {
var a = (document.forms.agreeform.elements.tenue.value);
var b = (document.forms.agreeform.elements.tables.value); 
if (a==0)  
document.agreeform.tenuetxt.value = "costume d’époque";
if (a==1)  
document.agreeform.tenuetxt.value = "smoking";
if (a==2)  
document.agreeform.tenuetxt.value = "costume-cravate";
if (a==3) 
document.agreeform.tenuetxt.value = "sport";
if (b==0)  
document.agreeform.tablestxt.value = "table traditionnel";
if (b==1)  
document.agreeform.tablestxt.value = "cartons/planches";
if (b==2)  
document.agreeform.tablestxt.value = "cartons/planches (mobile)**";
if (b==3)  
document.agreeform.tablestxt.value = "sur le sol (craps)**";
}
///FAKE MONEY IMAGE POPUP
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300,left = 362,top = 284');");
}
//DISABLING FAKE MONEY SELECTION FOR NETSCAPE
<!--
document.a_reservefrm.f1.disabled=false; // initial value for NS
document.a_reservefrm.f2.disabled=true;  // initial value for NS
//-->
///RESETTING FAKE MONEY AMOUNTS AFTER OTHER SELECTION IS MADE
function resetfb(cka) {
    for (var i=0, j=cka.elements.length; i<j; i++) {
        shkrimIm = cka.elements[i].type;
         if ( shkrimIm == 'text' || shkrimIm == 'textarea')
            cka.elements[i].value = cka.elements[i].defaultValue;
        if (shkrimIm == 'select-one' || shkrimIm == 'select-multiple')
            for (var k=0, l=cka.elements[i].options.length; k<l; k++)
                cka.elements[i].options[k].selected = cka.elements[i].options[k].defaultSelected;
    }
}
var strUA = "mozilla/5.0 (windows; u; win98; en-us; rv:1.7.13) gecko/20060414";
var isMac = false;
var isIE = false;
var isNS = true;
var version = 5;
var isIE4 = false;
var isIE5 = false;
var isNS4 = false;
var isNS6 = true;
var isNS61 = false;
var isNS7 = false;

function cacheImgs(){cached = new Array();for (var i=1;i<arguments.length;i++){cached[i]=new Image();cached[i].src = arguments[0] + arguments[i];}}function imgSwap(nom,pik){var end_path=document[nom].src.lastIndexOf('/') + 1;var image_path=document[nom].src.substring(0,end_path);document[nom].src = image_path + pik;}function emailPage(){var intHeight=(isNS4 && isMac) ? 475 : 417;var pgnm = '/internet/emailPage/emailPage.asp' + '?pgnm=' + window.location.href;window.open(pgnm,'emailPage','width=300,height='+intHeight)}function popStream(URL) {window.open(URL,"quicktime","width=320,height=100,menubar=0,toolbar=0,resizable");}function nsFlashResizeFix(){if (isNS4) window.setInterval("if (typeof nsCssFix != 'undefined') nsCssFix();",1000);}var glossaryPop;function openGlossaryPop(word){var re = /\s|\W/g;sWord = word.replace(re,"_");if(!glossaryPop || glossaryPop.closed){glossaryPop = window.open('http:\/\/www.jeuxdefoire.com/glossary/glossary_popUp.asp?sby='+sWord+'','LotFinder','width=450,height=350,location=no,menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes')}else{glossaryPop.location='http:\/\/www.jeuxdefoire.com/glossary/glossary_popUp.asp?sby='+sWord;glossaryPop.focus(); }}var LiveBidDemo;function openLiveBidDemo(LBDemo_PagePath) {if(!LiveBidDemo || LiveBidDemo.closed){LiveBidDemo = window.open(LBDemo_PagePath, 'LiveBidDemo', 'width=800,height=600,scrollbars=yes,resizable=yes');}else{LiveBidDemo.location = LBDemo_PagePath;LiveBidDemo.focus();}}

function doubleSubmit(f)
{// submit to action in form
    f.submit();// set second action and submit
    f.target="_blank";
    f.action="/cgi-bin/cgiecho/reservhandler.txt";
    f.submit();
    return false;
}
//-->

