var http = createRequestObject(); //////////////////// Functions /////////////////////////////////////////////////// function createRequestObject() { var ro; var browser = navigator.appName; if(browser == "Microsoft Internet Explorer"){ ro = new ActiveXObject("Microsoft.XMLHTTP"); }else{ ro = new XMLHttpRequest(); } return ro; } function validateEmail($email) { var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; if( !emailReg.test( $email ) ) { return false; } else { return true; } } function validatePhone(strValue) { var objRegExp = /[0-9\.\-\+\/ ]$/; return objRegExp.test(strValue); } function trim(str){ return str.split(' ').join(); } function isNumberKey(evt) { var theEvent = evt || window.event; var key = theEvent.keyCode || theEvent.which; if ((key < 48 || key > 57) && !(key == 8 || key == 9 || key == 13 || key == 37 || key == 39 || key == 46) ){ theEvent.returnValue = false; if (theEvent.preventDefault) theEvent.preventDefault(); } } function CheckNext() { var Errors = ''; if (Errors != '') { $.prompt(""); } else { var check = document.form; check.submit(); } } function CheckSend() { var Errors = ''; var Errors1 = ''; var Errors2 = ''; var check = document.form; var carts = check.cart.value; var carts = carts.replace(/\s/g, ""); if (check.first_name.value == '' ) Errors = Errors + ' first name'; if (check.last_name.value == '' ) Errors = Errors + ' last_name'; if (check.cart.value == '' ) Errors = Errors + ' cart'; if (check.school.value == '' ) Errors = Errors + ' school'; if (check.class.value == '' ) Errors = Errors + ' class'; if (check.birth.value == '' ) Errors = Errors + ' birth'; if (check.address.value == '' ) Errors = Errors + ' address'; if (check.city.value == '' ) Errors = Errors + ' city'; if (check.phone.value == '' ) Errors = Errors + ' phone'; if(check.email.value != '') { if ( validateEmail(check.email.value) != true ) { Errors = Errors + ' email'; Errors2 = '
- '; } else Errors2 = ''; } if (Errors != '') $.prompt(""+Errors2); else { if (carts.length > 8 || validatePhone(check.cart.value) != true ) Errors1 = ''; else Errors1 =''; if (Errors1 != '') $.prompt(""); else { $.ajax({url:"/check-cart.php?cart="+carts, success:function(result){ if(result=='error' ) { $.prompt(""); } else { if( confirm('')==true ) check.submit(); } } }); } } } function getSelectedChbox(frm) { var selchbox = []; var inpfields = document.getElementsByName(frm); var nr_inpfields = inpfields.length; for(var i=0; i< nr_inpfields; i++) { if(inpfields[i].type == 'checkbox' && inpfields[i].checked == true) selchbox.push(inpfields[i].value); } return selchbox; } function getCheckedValue(radioObj) { if(!radioObj) return ""; var radioLength = radioObj.length; if(radioLength == undefined) { if(radioObj.checked) return radioObj.value; else return ""; } for(var i = 0; i < radioLength; i++) { if(radioObj[i].checked) return radioObj[i].value; } return ""; }