function chkObject (theVal) { if (document.getElementById(theVal) != null) { return true; } else { return false; } } function setupAjaxForm(form_id, form_validations) { var form = '#' + form_id; var form_message = form + '-message'; var disableSubmit = function(val) { $(form + ' input[type=submit]').attr('disabled', val); }; $(form).ajaxSend(function() { }); var options = { dataType: 'json', beforeSubmit: function() { $(form + '_loading').show(); // $(form + '_edit').hide(); if(typeof form_validations == "function" && !form_validations()) { return false; } disableSubmit(true); }, success: function(json) { if (form_id != 'availability_submit') { $(form + '_loading').hide(); } $(form_message).hide(); $(form_message).removeClass().addClass(json.type).html(json.message).fadeIn('slow'); disableSubmit(false); if(json.type == 'success') { if (form_id == 'sendMessage_login') { $('#sendMessage_div').show(); $('#sendMessage_login_div').hide(); } else { if (form_id == 'sendMessage_div') { $('#sendMessage_div').hide(); $('#sendMessage_login_div').hide(); } else { if (form_id == 'sendMessage') { $('#sendMessage_div').hide(); } else { if (form_id == 'loginBox_edit') { $('#loginBox_edit_div').hide(); $('#loginBox_div').show(); } else { if (form_id == 'loginBox') { $('#loginBox_edit_div').show(); $('#loginBox_div').hide(); } else { if (form_id == 'availability_submit') { // showPage('includes/'+form_id+'_show.php',form_id+'_div') // $(form + '_loading').hide(); $("#availability_submit_div").load("includes/availability_submit_show.php", function() { $(form + '_loading').hide(); }); } else { $(form + '_edit_div').hide(); showPage('includes/'+form_id+'_show.php',form_id+'_div'); $(form + '_div').show(); } } } } } } $(form + '_edit').show(); $(form_message).fadeOut(2000); } } }; $(form).ajaxForm(options); } function hideShow(hide,show) { $('#' + hide + '_div').hide(); $('#' + hide + '_edit').hide(); $('#' + show + '_edit_div').show(); } function clearSelect(selectName) { for(var count = document.getElementById(selectName).options.length - 1; count >= 0; count--) { document.getElementById(selectName).options[count] = null; } } var pgeName = ''; $(document).ready(function() { new setupAjaxForm('skills_submit'); new setupAjaxForm('categories_submit'); new setupAjaxForm('availability_submit'); new setupAjaxForm('spotlight_submit'); new setupAjaxForm('experience_submit'); new setupAjaxForm('comments_submit'); new setupAjaxForm('sendMessage'); new setupAjaxForm('sendMessage_login'); new setupAjaxForm('loginBox'); new setupAjaxForm('loginBox_edit'); var sPath = window.location.pathname; var sPage = sPath.substring(sPath.lastIndexOf('/') + 1); if (sPage == 'profile.htm') { contactgetState(document.getElementById('Country').value); } if (sPage == 'profile.htm' || sPage == 'index.htm') { document.getElementById('state').disabled=true; document.getElementById('city').disabled=true; document.getElementById('jobs').disabled=true; } });