/*

post-jobs.js

*/


/* Ajax code for getting contact information */
function getContactInfo(){
	exhib_id = document.getElementById('exhibs').value;
	var ajaxRequest;  // The variable that makes Ajax possible!

	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function()
	{
		if(ajaxRequest.readyState == 4){
			document.getElementById('ContactInfo').innerHTML = ajaxRequest.responseText;
		}
	}
	ajaxRequest.open("GET", "find_user_contact_info.php?&exhib_id="+exhib_id, true);
	ajaxRequest.send(null);
}

// We need to validate the form data and then process the credit card transaction (if applicable)
function submitEventForm() {
	// Build a hash of all the form variables.
	
	return false;
}

// Script to run when the DOM is loaded and ready
window.addEvent('domready', function() {

	/* All of the validation calls, excluding those for credit card processing, which are in their form_CC_insert.php */
	var organization = new LiveValidation('organization', { onlyOnSubmit: true, onValid: function(){ } });
	organization.add(Validate.Presence);

	var title = new LiveValidation('title', { onlyOnSubmit: true, onValid: function(){ } });
    title.add(Validate.Presence);

	var fname = new LiveValidation('fname', { onlyOnSubmit: true, onValid: function(){ } });
	fname.add(Validate.Presence);

	var lname = new LiveValidation('lname', { onlyOnSubmit: true, onValid: function(){ } });
	lname.add(Validate.Presence);

	var address1 = new LiveValidation('address1', { onlyOnSubmit: true, onValid: function(){ } });
	address1.add(Validate.Presence);

    var venue = new LiveValidation('venue', {onlyOnSubmit: true, onValid: function(){ } });
    venue.add(Validate.Presence);

	var city = new LiveValidation('city', { onlyOnSubmit: true, onValid: function(){ } });
	city.add(Validate.Presence);

	var zip = new LiveValidation('zip', { onlyOnSubmit: true, onValid: function(){ } });
	zip.add(Validate.Presence);

	var event_title = new LiveValidation('event_title', { onlyOnSubmit: true, onValid: function(){ } });
	event_title.add(Validate.Presence);

    var email = new LiveValidation('email', { onlyOnSubmit: true, onValid: function(){}, });
	email.add(Validate.Email);
	email.add(Validate.Presence);

	var org_website = new LiveValidation('organization_website',{ onlyOnSubmit: true,onValid:function(){}});
	org_website.add(Validate.Presence);	

	var state = new LiveValidation('state', { onlyOnSubmit: true, onValid: function(){ } });
	state.add(Validate.Exclusion, {within: ['0'], failureMessage: "Please select a state!"});

	/* Capture the submit activity, validate the form and then call the AJAX submission function */
	var automaticOnSubmit = organization.form.onsubmit;
	organization.form.onsubmit = function(){
		var validFormData = automaticOnSubmit();
		// If this comes back true, we can process the form, including the credit card
		if (validFormData) { return true;}
		return false;
	}
});
