function clearForm(form) { // iterate over all of the inputs for the form // element that was passed in for(var i=1;i<=15;i++) { jQuery('#radio'+i).parent().removeAttr('class'); jQuery('#check'+i).parent().removeAttr('class'); //jQuery('#select'+i+'_title').parent().find('span').html('0'); var oHandler = jQuery('#select'+i).msDropDown().data("dd"); if(oHandler) { oHandler.set("selectedIndex", 0); } } jQuery(':input', form).each(function(e) { //e.removeAttr('class'); var type = this.type; var tag = this.tagName.toLowerCase(); // normalize case // it's ok to reset the value attr of text inputs, // password inputs, and textareas if (type == 'text' || type == 'password' || tag == 'textarea') this.value = ""; // checkboxes and radios need to have their checked state cleared // but should *not* have their 'value' changed else if (type == 'checkbox' || type == 'radio') this.checked = false; // select elements need to have their 'selectedIndex' property set to -1 // (this works for both single and multiple select elements) else if (tag == 'select') this.selectedIndex = 0; }); jQuery('#pMessage').val(''); }; var message=false; function focusMessage(){ if(!message) { message = confirm("Once you have altered the generated text in accordance with the selection above, it cannot be kept up-to-date with further changes to the selection above. Are you sure you want to proceed?"); $('pMessage').focus(); } } function doUncheck(check){ if(jQuery('#'+check).parent().attr('class') == 'checked') { $(check).checked=''; jQuery('#'+check).parent().removeAttr('class'); } else { $(check).checked='true'; jQuery('#'+check).parent().attr('class','checked'); } } function doCheck(select,check){ if($(select).value>0) { $(check).checked='true'; jQuery('#'+check).parent().attr('class','checked'); } else { $(check).checked=''; jQuery('#'+check).parent().removeAttr('class'); $(select).value=0; jQuery('#'+select).parent().find('span').html('0'); } } function doSingleCheck(check){ if(jQuery('#'+check).parent().attr('class') == 'checked') { $(check).checked=''; jQuery('#'+check).parent().removeAttr('class'); } else { $(check).checked='true'; jQuery('#'+check).parent().attr('class','checked'); } } function set(index){ for(var i=1;i<=5;i++) { if(i==index) { $('radio'+i).checked='checked'; jQuery('#radio'+i).parent().attr('class','checked'); } else { jQuery('#radio'+i).parent().removeAttr('class'); jQuery('#select'+i).parent().find('span').html('0'); var oHandler = jQuery('#select'+i).msDropDown().data("dd"); if(oHandler) { oHandler.set("selectedIndex", 0); } } } } function clear_form(txt){ var txt_confirm=txt; if (confirm(txt_confirm)) { document.form2.reset(); } calculate(); $('pMessage').update(''); $('pMessage').innerHTML; return true; } function refactorStage() { var labels = new Array(); if (jQuery('select#squares').val() == 2) { jQuery('select#select10 > option').each(function(i) { this.text = this.value+' sq m'; labels[i] = this.value+' sq m'; if (this.selected) { jQuery('span#select10_title .ddlabel').html(this.value+' sq m'); } }); jQuery('div#select10_child ul > li span.ddlabel').each(function(i) { jQuery(this).text(labels[i]); }); } else if (jQuery('select#squares').val() == 1) { jQuery('select#select10 > option').each(function(i) { this.text = Math.ceil(this.value*10.76391041671)+' sq ft'; labels[i] = Math.ceil(this.value*10.76391041671)+' sq ft'; if (this.selected) { jQuery('span#select10_title .ddlabel').html(Math.ceil(this.value*10.76391041671)+' sq ft'); } }); jQuery('div#select10_child ul > li span.ddlabel').each(function(i) { jQuery(this).text(labels[i]); }); } } function calculate() { refactorStage(); var tmppeople =0; var sum=0; var factors=new Array(); var perPax=new Array(); factors[0]=0.75; factors[1]=1.5; factors[2]=2; factors[3]=1; factors[4]=1.5; factors[5]=15; factors[6]=10; factors[7]=15; factors[8]=0.75; perPax[0]=1; perPax[1]=1; perPax[2]=1; perPax[3]=1; perPax[4]=1; perPax[5]=0; perPax[6]=0; perPax[7]=0; perPax[8]=1; for (i=0; i<9;i++) { factors[i] = factors[i].toFixed(2); } var m=""; if(jQuery('#radio1').parent().attr('class') == 'checked' && $('select1').value>0){ tmppeople=$('select1').value; var temp=factors[0]; if(perPax[0]>0) temp=temp*Math.floor(tmppeople/perPax[0]) sum+=temp*1; m+="Theatre Style Seating "+$('select1').value+" People\n"; } if(jQuery('#radio2').parent().attr('class') == 'checked' && $('select2').value>0){ tmppeople=$('select2').value; var temp=factors[1]; if(perPax[1]>0) temp=temp*Math.floor(tmppeople/perPax[1]) sum+=temp*1; m+="Conference Style Seating "+$('select2').value+" People\n"; } if(jQuery('#radio3').parent().attr('class') == 'checked' && $('select3').value>0){ tmppeople=$('select3').value; var temp=factors[2]; if(perPax[2]>0) temp=temp*Math.floor(tmppeople/perPax[2]) sum+=temp*1; m+="Round Table Style Seating "+$('select3').value+" People\n"; } if(jQuery('#radio4').parent().attr('class') == 'checked' && $('select4').value>0){ tmppeople=$('select4').value; var temp=factors[3]; if(perPax[3]>0) temp=temp*Math.floor(tmppeople/perPax[3]) sum+=temp*1; m+="Beerfest Style Seating "+$('select4').value+" People\n"; } if(jQuery('#radio5').parent().attr('class') == 'checked' && $('select5').value>0){ tmppeople=$('select5').value; var temp=factors[4]; if(perPax[4]>0) temp=temp*Math.floor(tmppeople/perPax[4]); sum+=temp*1; m+="Cocktail Tables "+$('select5').value+" People\n"; } if(jQuery('#check6').parent().attr('class') == 'checked' && $('select6').value>0){ var temp=factors[5]*$('select6').value; if(perPax[5]>0) temp=temp*Math.floor(tmppeople/perPax[5]) sum+=temp; m+=$('select6').value+" Bar Areas\n"; } if(jQuery('#check7').parent().attr('class') == 'checked' && $('select7').value>0){ var temp=factors[6]*$('select7').value; if(perPax[6]>0) temp=temp*Math.floor(tmppeople/perPax[6]) sum+=temp; m+=$('select7').value+" Buffet Table\n"; } if(jQuery('#check8').parent().attr('class') == 'checked' && $('select8').value>0){ var temp=factors[7]*$('select8').value; if(perPax[7]>0) temp=temp*Math.floor(tmppeople/perPax[7]) sum+=temp; m+=$('select8').value+" Waiter Stations\n"; } if(jQuery('#check9').parent().attr('class') == 'checked'){ var temp=factors[8]*1; if(perPax[8]>0) temp=temp*Math.floor(tmppeople/perPax[8]) sum+=temp; m+="Dance Floor "+tmppeople+" People\n"; } if(jQuery('#check10').parent().attr('class') == 'checked'){ var temp=jQuery('#select10').val()*1; var size=jQuery('#select10 > option:selected').html(); //if(perPax[9]>0) //temp=temp*Math.floor(tmppeople/perPax[9]) sum+=temp; m+="Band stage "+size+"\n"; } /*if(jQuery('#check11').parent().attr('class') == 'checked'){ var temp=factors[10]*1; if(perPax[10]>0) temp=temp*Math.floor(tmppeople/perPax[10]) sum+=temp; m+="Stage 2 (40 sqm/130 sqft)\n"; }*/ var oHandler = jQuery('#squares').msDropDown().data("dd"); if(oHandler) { var dimension = oHandler.get("selectedOptions").val(); } if(dimension==2){ m+="\ntotal space required: "+sum+" sq m\n\n"; }else { sum=Math.ceil(sum*10.76391041671) m+="\ntotal space required: "+sum+" sq ft\n\n"; } jQuery("#pMessage").val(m); jQuery("#resultfield").val(sum); }