function parentCheck(el, fieldID){ // alert('AAA'); var value = el.value; //alert(value); if(el.type == 'checkbox') { value = el.name.substring(el.name.indexOf('[') + 1, el.name.length -1); $$('TR[class="sec-'+fieldID+'-'+value+'-"]').each(function(tr) { if(el.checked) { tr.show(); } else { tr.select('input[type="radio"]', 'input[type="checkbox"]', 'select').each(function(zEL) { if(zEL.type == 'checkbox') { zFieldID = zEL.name.substring(0, zEL.name.indexOf('[')).replace('field', ''); zEL.checked = false; } else { zFieldID = zEL.name.replace('field', ''); if(zEL.type == 'radio') { zEL.checked = false; zEL.setAttribute('originalValue', zEL.value); } zEL.value = ''; } parentCheck(zEL, zFieldID); }); if(el.getAttribute('originalValue')) { el.value = el.getAttribute('originalValue'); } tr.select('input[type="text"]', 'textarea').each(function(tEL) { if(tEL.tagName == 'input') tEL.value = ''; else tEL.innerHTML = ''; }); tr.hide(); } }); } else { // alert(fieldID); // $$('TR[class*="sec-'+fieldID+'-"]').each(function(tr) { $$('tr').each(function(tr) { if(tr.className.indexOf('sec-' + fieldID + '-') != 0) return false; // console.log('tr', tr); if(tr.className.indexOf('-' + value + '-') > -1) { tr.show(); } else { tr.select('input[type="radio"]', 'input[type="checkbox"]', 'select').each(function(zEL) { if(zEL.type == 'checkbox') { zFieldID = zEL.name.substring(0, zEL.name.indexOf('[')).replace('field', ''); zEL.checked = false; } else { zFieldID = zEL.name.replace('field', ''); if(zEL.type == 'radio') { zEL.checked = false; //zEL.setAttribute('originalValue', zEL.value); } //zEL.value = ''; } parentCheck(zEL, zFieldID); if(zEL.getAttribute('originalValue')) { // zEL.value = zEL.getAttribute('originalValue'); } }); tr.select('input[type="text"]', 'textarea').each(function(tEL) { if(tEL.tagName.toLowerCase() == 'input') tEL.value = ''; else tEL.innerHTML = ''; //alert(tEL.tagName); }); tr.hide(); } }); } return false; } function checkAccDates(){ if($('departuredate') && $('arrivaldate')){ if($('departuredate').value && $('arrivaldate').value){ dd = $('departuredate').value.split("-"); ad = $('arrivaldate').value.split("-"); var strdeparture = new Date(dd[0], dd[1]-1, dd[2]); var strarrival = new Date(ad[0], ad[1]-1, ad[2]); if(strarrival > strdeparture){ $('departuredate').value=""; $('arrivaldate').value = ""; alert("Error: Date Range!"); } } $$('input[type="radio"]', 'select').each(function(el) { FieldID = el.name.replace('field', ''); //el.value if(el.checked){ diff = strdeparture.getTime()-strarrival.getTime(); $('quantityField' + FieldID + '|' + el.value).value = diff/86400000; }else{ $('quantityField' + FieldID + '|' + el.value).value =""; } }) } checkPlata(); } function accommodationDate(fieldID, radioID){ if($('departuredate').value && $('arrivaldate').value){ dd = $('departuredate').value.split("-"); ad = $('arrivaldate').value.split("-"); var strdeparture = new Date(dd[0], dd[1]-1, dd[2]); var strarrival = new Date(ad[0], ad[1]-1, ad[2]); $$('input[type="radio"]', 'select').each(function(el) { //el.value if(el.checked){ diff = strdeparture.getTime()-strarrival.getTime(); $('quantityField' + fieldID + '|' + radioID).value = diff/86400000; }else{ $('quantityField' + fieldID + '|' + el.value).value =""; $$('input[type="checkbox"]', 'select').each(function(zEL) { //$('accType[' + el.value + '][' + zEL.name + ']').value =""; if(zEL.name.substring(0, 7) == "accType"){ if(zEL.checked){ $(zEL.name).checked = false; } } }) } }) }else{ if($('accList'+radioID)){ $('accList'+radioID).checked = false; } alert(JStext.select_daterange_JS); return false; } checkPlata(); } function radioDeselect(field){ fieldID = ""; $$('input[name="' + field + '"]').each(function(el) { el.checked = false; if($('el')) $(el.name + el.value).value = 0; fieldID = field.replace('field', ''); if(fieldID) $('quantityField'+fieldID+'|'+el.value).value=''; }); $$('.serv').each(function(el) { if(el.type=="checkbox" && el.name.substring(0, 7) == "accType"){ el.checked=false; } }) $('arrivaldate').value =''; $('departuredate').value =''; checkPlata(); } // window.onload = checkPlata; document.observe("dom:loaded", function() { checkPlata(); }); function checkPlata (cle){ //console.log('checkPlata_Original'); var numChecked = 0; totalPrice = new Array(); $$('.currentCurrencies').each(function(cc) { if(cc.name){ totalPrice[cc.name] = ""; $$('.serv').each(function(el) { if(el.value) { if(el.type=="radio"){ if(el.checked){ //Tip taza de inregistrare if($(el.name + '|' + el.value + '|price|'+cc.name)){ totalPrice[cc.name] = totalPrice[cc.name] * 1 + $(el.name + '|' + el.value + '|price|'+cc.name).innerHTML * 1; } }else{ totalPrice[cc.name] = totalPrice[cc.name] * 1; } }else if(el.type=="checkbox"){ if(el.checked){ if(cle && cle.name && el.name != cle.name){ //avem deja selectat un camp //alert(el.name + ' - ' + numChecked); $(el.name).checked = false; return false; }else{ if(el.name.substring(0, 5) == "field"){ //fieldID = el.name.substring(5, el.name.lenght); fieldID = el.name.replace('field', ''); }else{ fieldID = ""; } if(el.name.substring(0, 7) == "accType"){ hotelIDvalue = el.name.substring(el.name.indexOf('[')+1, el.name.indexOf(']')); checkIDvalue = el.name.substring(el.name.indexOf('][')+2, el.name.length -1); if($('accList' + hotelIDvalue)){ fieldID = $('accList' + hotelIDvalue).name.replace('field', ''); quantity = $('quantityField'+fieldID+'|'+hotelIDvalue).value; if($(el.name + '|price|'+cc.name)) totalPrice[cc.name] = totalPrice[cc.name] * 1 + $(el.name + '|price|'+cc.name).innerHTML * quantity; } }else if(fieldID && $('quantityField'+fieldID)){ if($(el.name + '|price|'+cc.name)){ totalPrice[cc.name] = totalPrice[cc.name] * 1 + $(el.name + '|price|'+cc.name).innerHTML * $('quantityField'+fieldID).value; } }else if($(el.name + '|price|'+cc.name)){ if($(el.name + '|price|'+cc.name)) totalPrice[cc.name] = totalPrice[cc.name] * 1 + $(el.name + '|price|'+cc.name).innerHTML * 1; } numChecked +=1; } }else{ totalPrice[cc.name] = totalPrice[cc.name] * 1; } } } }) if(totalPrice[cc.name]){ $('TotalToBePaidTR').style.display = ''; $('totalPriceDiv').style.display =''; //$('totalStep' + cc.name).innerHTML = Math.ceil(totalPrice[cc.name] * $('stepPriceCoef').value); //$('totalStep' + cc.name).innerHTML = Math.ceil(totalPrice[cc.name] * $('stepPriceCoef').value * 100)/100; $('totalStep' + cc.name).innerHTML = (Math.ceil((totalPrice[cc.name] * $('stepPriceCoef').value).toFixed(1) * 100)/100).toFixed(1); }else{ if($('totalStep' + cc.name)) $('totalStep' + cc.name).innerHTML = 0; } //alert(totalPrice.length); /*if(totalPrice && totalPrice.length && typeof(totalPrice) == 'object' && (totalPrice instanceof Array)) $('TotalToBePaidTR').style.display = '';*/ $('totalPriceTD' + cc.name).style.display = ''; // $('totalPrice' + cc.name).innerHTML = $('totalPrice' + cc.name).getAttribute('initialValue') * 1 + totalPrice[cc.name] * 1; //var totalStep = parseInt($('totalStep' + cc.name).innerHTML); var totalStep = parseFloat($('totalStep' + cc.name).innerHTML); // var totalStep = 0; if ($('totalStep' + cc.name)) { $('totalStep' + cc.name).getAttribute('initialValue'); } if (!$('totalPrice' + cc.name).getAttribute('_initialValue')){ //$('totalPrice' + cc.name).setAttribute('_initialValue', $('totalPrice' + cc.name).getAttribute('initialValue') * 1 - totalStep * 1); $('totalPrice' + cc.name).setAttribute('_initialValue', ($('totalPrice' + cc.name).getAttribute('initialValue')*1).toFixed(1)*1 - totalStep*1); } //$('totalPrice' + cc.name).innerHTML = $('totalPrice' + cc.name).getAttribute('_initialValue') * 1 + totalStep * 1; $('totalPrice' + cc.name).innerHTML = ($('totalPrice' + cc.name).getAttribute('_initialValue')*1).toFixed(1)*1 + totalStep * 1; } }) } var Timer; var TotalSeconds; function CreateTimer(TimerID, Time) { Timer = document.getElementById(TimerID); TotalSeconds = Time; UpdateTimer() window.setTimeout("Tick()", 1000); } function Tick() { if (TotalSeconds <= 0) { $('gateway').submit(); return; } TotalSeconds -= 1; UpdateTimer() window.setTimeout("Tick()", 1000); } function UpdateTimer() { Timer.innerHTML = TotalSeconds; }