/* global variables usefull for discounts */ var discount = false; var discount_package; var discount_student; var discount_proceedings; var discount_onlytutos; var discount_social; var discount_free = false; var discount_amount = 0; function expand(id) { /*document.getElementById(id).style.pixelWidth = '650px';*/ } function contract(id) { /*document.getElementById(id).style.pixelWidth = '330px';*/ } /* function library dedicated to registration */ window.addEvent('domready', function(){ check = new FormCheck('formular', { display : { showErrors : 1, errorsLocation : 1, indicateErrors : 1 } }); }); window.addEvent('domready', function() { new Uniform('formular',{ valid_class: 'valid', invalid_class: 'invalid', focused_class: 'focused', holder_class: 'ctrlHolder', field_selector: 'input, select, textarea' }); }); /* actions to be done first ! */ function load() { if (typeof(check)=="undefined") { check = new FormCheck('formular', { display : { showErrors : 1, errorsLocation : 1, indicateErrors : 1 } }); new Uniform('formular',{ valid_class: 'valid', invalid_class: 'invalid', focused_class: 'focused', holder_class: 'ctrlHolder', field_selector: 'input, select, textarea' }); } if ($chk($('pconf'))) { submit_paper(); compute_program(); $('discount_update').addEvent('click', function(){ discountRequest(); }); } if ($chk($('final_form'))) { $('final_form').submit(); } } /* update the "paper information" part */ function submit_paper() { /* if the participant has submitted a paper */ if (($('pconf').value != "none")) { /* display fields for paper information */ $('holder_pid').setStyle('display', 'block'); $('holder_ptitle').setStyle('display', 'block'); /* add constraints on those fields */ var pid = $('pid'); check.dispose(pid); pid.addClass("validate['required','num']"); check.register(pid); /* idem */ var ptitle = $('ptitle'); check.dispose(ptitle); ptitle.addClass("validate['required']"); check.register(ptitle); /* otherwise, paper information are not necessary */ } else { $('holder_pid').setStyle('display', 'none'); $('holder_ptitle').setStyle('display', 'none'); check.dispose($('pid')); check.dispose($('ptitle')); } } /* select & update "conference information" part */ function compute_program() { /* get the package value */ var type = $('package').value; /* hide all fields (start state) */ $('work_program_2days').setStyle('display', 'none'); $('work_program_1day').setStyle('display', 'none'); $('conf_program').setStyle('display', 'none'); /* if the package is the "full" one */ if (type == "full") { $('work_program_2days').setStyle('display', 'block'); $('conf_program').setStyle('display', 'block'); /* basically, the social event is included into this package */ /* but, in case of special discount, the social event can be excluded */ if (discount && !discount_social) { $('social_event').set('checked',false); $('social_event').set('disabled',false); } else { $('social_event').set('checked',true); $('social_event').set('disabled',true); } /* add cosntraints to the conference selector */ var confchoice = $('pn09'); check.dispose(confchoice); confchoice.addClass("validate['required']"); check.register(confchoice); /* if the package is the "conf-plus" one */ } else if (type == "conf-plus") { $('work_program_1day').setStyle('display', 'block'); $('conf_program').setStyle('display', 'block'); /* basically, the social event is included into this package */ /* but, in case of special discount, the social event can be excluded */ if (discount && !discount_social) { $('social_event').set('checked',false); $('social_event').set('disabled',false); } else { $('social_event').set('checked',true); $('social_event').set('disabled',true); } /* add constraints to the conference selector */ var confchoice = $('pn09'); check.dispose(confchoice); confchoice.addClass("validate['required']"); check.register(confchoice); /* if the package is the "conf" one */ } else if (type == "conf") { $('conf_program').setStyle('display', 'block'); /* basically, the social event is included into this package */ /* but, in case of special discount, the social event can be excluded */ if (discount && !discount_social) { $('social_event').set('checked',false); $('social_event').set('disabled',false); } else { $('social_event').set('checked',true); $('social_event').set('disabled',true); } /* add constraints to the conference selector */ var confchoice = $('pn09'); check.dispose(confchoice); confchoice.addClass("validate['required']"); check.register(confchoice); /* if the package is the "tut-two" one */ } else if (type =="tut-two") { /* uncheck conference selector */ $('pn09').set('checked',false); $('rsp09').set('checked',false); $('work_program_2days').setStyle('display', 'block'); /* basically, the social event is included into this package */ /* but, in case of special discount, the social event can be excluded */ if (discount && discount_social) { $('social_event').set('checked',true); $('social_event').set('disabled',true); } else { $('social_event').set('checked',false); $('social_event').set('disabled',false); } /* remove constraints on conference selector */ var confchoice = $('pn09'); check.dispose(confchoice); /* if the package is the "tut-two" one */ } else if (type =="tut-one") { $('pn09').set('checked',false); $('rsp09').set('checked',false); $('work_program_1day').setStyle('display', 'block'); /* basically, the social event is included into this package */ /* but, in case of special discount, the social event can be excluded */ if (discount && discount_social) { $('social_event').set('checked',true); $('social_event').set('disabled',true); } else { $('social_event').set('checked',false); $('social_event').set('disabled',false); } /* remove constraints on conference selector */ var confchoice = $('pn09'); check.dispose(confchoice); } /* proceedings must be updated among the type of selected conferences */ update_proceedings(); } /* select & update the "proceedings part" */ function update_proceedings() { /* fetch and store current state of proceedings checkbox */ var prev_pn_proceedings = ($('pn_proceedings').get('disabled'))?false:$('pn_proceedings').get('checked'); var prev_rsp_proceedings = ($('rsp_proceedings').get('disabled'))?false:$('rsp_proceedings').get('checked'); /* if pn09 conference is selected... */ if ($('pn09').get('checked') == true) { /* if the discount does not include the proceedings... */ if (discount && !discount_proceedings) { $('pn_proceedings').set('checked',false); $('pn_proceedings').set('disabled',false); } else { $('pn_proceedings').set('checked',true); $('pn_proceedings').set('disabled',true); } /* display petri nets specific reduction fields */ $('reduc_pn').setStyle('display','block'); $('reduc_pn').set('disabled',false); var sig = $('sig'); check.register(sig); var eatcs = $('eatcs'); check.register(eatcs); } /* if pn09 is not selected */ if ($('pn09').get('checked') == false) { $('pn_proceedings').set('checked',prev_pn_proceedings); $('pn_proceedings').set('disabled',false); /* hide petri nets specific reduction fields */ $('reduc_pn').value = 0; $('reduc_pn').setStyle('display','none'); $('reduc_pn').set('disabled',true); var sig = $('sig'); check.dispose(sig); var eatcs = $('eatcs'); check.dispose(eatcs); } /* if rsp09 conference is selected... */ if ($('rsp09').get('checked') == true) { if (discount && !discount_proceedings) { $('rsp_proceedings').set('checked',false); $('rsp_proceedings').set('disabled',false); } else { $('rsp_proceedings').set('checked',true); $('rsp_proceedings').set('disabled',true); } var ieee = $('ieee'); check.register(ieee); /* display petri nets specific reduction fields */ $('reduc_rsp').setStyle('display','block'); $('reduc_rsp').set('disabled',false); } /* if rsp09 is not selected */ if ($('rsp09').get('checked') == false) { $('rsp_proceedings').set('checked',prev_rsp_proceedings); $('rsp_proceedings').set('disabled',false); /* hide petri nets specific reduction fields */ $('reduc_rsp').value = 0; $('reduc_rsp').setStyle('display','none'); $('reduc_rsp').set('disabled',true); var ieee = $('ieee'); check.dispose(ieee); } /* in case of student status, reduction cannot apply */ if ($('student_state').get('checked')) { $('reduc_rsp').setStyle('display','none'); $('reduc_rsp').set('disabled',true); $('reduc_pn').setStyle('display','none'); $('reduc_pn').set('disabled',true); } /* must update fees to take into account proceedings and reductions */ update_fees(); } /* compute the fees */ function update_fees() { var total = 0; var student = ($('student_state').get('checked') == true); var rsp_reduc = ($('ieee').value > 0)?100:0; var pn_reduc = ($('eatcs').value > 0)?50:($('sig').value > 0)?50:0; var type_package = $('package').value; var dayone = $('program_day1').value; var daytwo = $('program_day2').value; var cost_package = 0; var cost_proceedings = 0; var cost_banquet = 0; var discount_status = (discount || (discount_amount > 0) || discount_free); // Package if (type_package == "full") { cost_package = (!student)?650:400; cost_package -= (!student && !discount_status)?rsp_reduc:0; cost_package -= (!student && !discount_status)?pn_reduc:0; /* in case of discount, package is free */ if (discount && (discount_package == "full")) { cost_package = 0; } /* check whether the social event is included into the discount */ if (!discount || (discount && discount_social)) { cost_banquet = -75; } /* check whether the proceedings is included into the discount */ if (!discount || (discount && discount_proceedings)) { cost_proceedings = -45; } } else if (type_package == "conf-plus") { cost_package = (!student)?650:350; cost_package -= (!student && !discount_status)?rsp_reduc:0; cost_package -= (!student && !discount_status)?pn_reduc:0; /* in case of discount, package is free */ if (discount && (discount_package == "conf-plus")) { cost_package = 0; } /* check whether the social event is included into the discount */ if (!discount || (discount && discount_social)) { cost_banquet = -75; } /* check whether the proceedings is included into the discount */ if (!discount || (discount && discount_proceedings)) { cost_proceedings = -45; } } else if (type_package == "conf") { cost_package = (!student)?500:300; cost_package -= (!student && !discount_status)?rsp_reduc:0; cost_package -= (!student && !discount_status)?pn_reduc:0; /* in case of discount, package is free */ if (discount && (discount_package == "conf")) { cost_package = 0; } /* check whether the social event is included into the discount */ if (!discount || (discount && discount_social)) { cost_banquet = -75; } /* check whether the proceedings is included into the discount */ if (!discount || (discount && discount_proceedings)) { cost_proceedings = -45; } } else if (type_package == "tut-two") { cost_package = (!student)?200:100; /* in case of discount, package is free */ if (discount && (discount_package == "tut-two")) { cost_package = 0; } } else if (type_package == "tut-one") { cost_package = (!student)?150:75; /* in case of discount, package is free */ if (discount && (discount_package == "tut-one")) { cost_package = 0; } } /* proceedings */ if ($('rsp_proceedings').get('checked')) { cost_proceedings += 45; }; if ($('pn_proceedings').get('checked')) { cost_proceedings += 45; }; /* cost of the social event */ if ($('social_event').get('checked')) { cost_banquet += 75; }; /* are there any extra ticket ordered ? */ var extra = $('social').value * 75; /* check wether a tutorial restriction is applied and if workshop have been selected */ if (discount && discount_onlytutos) { if ((dayone != "") && ((type_package == "tut-one") || (type_package == "conf-plus"))) { if ((dayone == "1d_1") || (dayone == "1d_3") || (dayone == "1d_14")) { cost_package += 50; } } else if ((daytwo != "") && ((type_package == "tut-two") || (type_package == "full"))) { if ((daytwo == "2d_1") || (daytwo == "2d_2") || (daytwo == "2d_3") || (daytwo == "2d_4") || (daytwo == "2d_5") || (daytwo == "2d_6") || (daytwo == "2d_7") || (daytwo == "2d_8") || (daytwo == "2d_9") || (daytwo == "2d_29") || (daytwo == "2d_30") || (daytwo == "2d_31") || (daytwo == "2d_10") || (daytwo == "2d_32") || (daytwo == "2d_33") || (daytwo == "2d_31") || (daytwo == "2d_30") || (daytwo == "2d_34")) { cost_package += 50; } } } /* final computation */ if (cost_proceedings < 0) { cost_proceedings = 0 }; total = cost_proceedings + cost_package + cost_banquet + extra; /* if an aboslute discount is required */ if (discount_amount > 0) { total -= discount_amount; } /* if a free ticket is used */ if (discount_free) { total = 0; } if (total < 0) { total = 0 }; $('total').set('html',total); } /* ask for a discount */ function discountRequest(){ var discount_code = $('discount').value; var req = new Request({ url: 'lib/promo.php?promo_code='+discount_code, /* in cas of success */ onSuccess: function(ret){ if (ret == "") { $('package').set('disabled',false); $('social_event').set('disabled',false); $('student_state').set('disabled',false); $('discount_result').setStyle('display','none'); discount = false; discount_package = ""; discount_student = ""; discount_proceedings = ""; discount_onlytutos = ""; discount_social = ""; discount_free = false; discount_amount = 0; compute_program(); return; } if (ret == "invalid") { $('package').set('disabled',false); $('social_event').set('disabled',false); $('student_state').set('disabled',false); discount = false; discount_package = ""; discount_student = ""; discount_proceedings = ""; discount_onlytutos = ""; discount_social = ""; discount_free = false; discount_amount = 0; $('discount_result').setStyle('display','block'); $('discount_result').setStyle('color','#BE3C42'); $('discount_result').setText('This code is invalid'); compute_program(); return; } if (ret == "used") { $('package').set('disabled',false); $('social_event').set('disabled',false); $('student_state').set('disabled',false); discount = false; discount_package = ""; discount_student = ""; discount_proceedings = ""; discount_onlytutos = ""; discount_social = ""; discount_free = false; discount_amount = 0; $('discount_result').setStyle('display','block'); $('discount_result').setStyle('color','#BE3C42'); $('discount_result').setText('This code has already been used'); compute_program(); return; } /* split the return in several parts */ var reg=new RegExp("@", "g"); var constraints=ret.split(reg); /* browse all constraints */ for (var i=0; i