// contact.js

function loadContactForm() {
	xmlhttpCall('', contact-form.php, displayContactForm);
}

function contactZVI(){
	
	var field_names = Array('first_name','last_name','email','company','city','state','zip','message','newsletter','submit');
	var fields = '';
	var description = '';
	
	for (i=0; i<field_names.length; i++) {
		
		if (field_names[i] == 'message') {
			if (description != '') {
				description += "\n\n";
			}
			description += "Visitor Message: \n"+document.getElementById(field_names[i]).value;
		} else if (field_names[i] == 'newsletter') {
			if (document.getElementById(field_names[i]).checked == true) {
				if (description != '') {
					description += "\n\n";
				}
				description += "Newsletter: \nPlease subscribe me to the ZviDance Newsletter";
			}
		} else if (document.getElementById(field_names[i])) {
			if (fields != '') {
				fields += '&';
			}
			fields += field_names[i]+"=";
			fields += document.getElementById(field_names[i]).value;
		}
	}
	
	fields += '&description='+description;
	
	if (fields != '') {
		fields += '&formSub=true';
		var target = 'process-contact-form.php';
		xmlhttpCall(fields, target, displayContactStatus);
	}
}

function displayContactStatus(responseText) {
	WriteByID('contact_status',null,responseText);
	if (responseText.search(/Thanks/i)) {
		setTimeout("hideContactForm()",2500);
	}
}

function showContactForm() {
	document.getElementById('dialog').style.visibility = "visible";
	$('#dialog').dialog('open');
	if (home_visible == true) {
		hideHomeAnnouncement();
		home_override = true;
	}
}
function hideContactForm() {
	$('#dialog').dialog('close');
	if (home_visible != undefined) {
		home_override = false;
	}
}