function show_popup_contact_form(otherinfo,image) {
	window.scrollTo(0,0);
	select_selection = $$('select');
	for (i=0;i<select_selection.length;i++) {
		if(select_selection[i].id != 'contact_reason') {
			select_selection[i].hide();
		}
	}
	$('contact_container').appear({ duration: 1.0 });
	doumentGetElementById('contact_container').addClassName('lock');
	doumentGetElementById('contact_container').style.overflow.('hidden');
	$('contact_current_url').value = window.location.href;
	$('contact_other_info').value = otherinfo;
	if(image != '') {
		$('contact_img_holder').show();
		$('contact_img_holder').innerHTML = "<img alt='"+otherinfo+"' src='"+image+"' />";
	} else {
		$('contact_img_holder').show();
		$('contact_img_holder').innerHTML = "<img alt='"+otherinfo+"' src='images/popupContactForm/general_contact.png' />";
	}
	if(otherinfo != '') {
		$('contact_empty').show();
		$('contact_empty').innerHTML = "Thank you for your interest in "+otherinfo+".";
	}
}
function hide_popup_contact_form() {
	$('contact_description').value = '';
	$('contact_name').value = '';
	$('contact_email').value = '';
	$('contact_phone').value = '';
	$('contact_other_info').value = '';
	//$('contact_empty').innerHTML = '&nbsp;';
	//$('contact_img_holder').innerHTML = '&nbsp;';
	//$('contact_img_holder').hide();
	$('contact_container').fade({ duration: 0.5 });
	select_selection = $$('select');
	for (i=0;i<select_selection.length;i++) {
		if(select_selection[i].id != 'contact_reason') {
			select_selection[i].show();
		}
	}
	return false;
}
function popup_contact_form_is_valid() {
	var contact_fields = $$('div#contact_container .required');
	var is_valid = true;
	var emailRe = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/;
	var phoneRe = /^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/;
	for(i=0;i<contact_fields.length;i++) {
		if (contact_fields[i].value == "") {
			contact_fields[i].addClassName("invalid");
			is_valid = false;
		} else {
			contact_fields[i].removeClassName("invalid");
		}
	}
	var email_fields = $$('div#contact_container .email');
	for(i=0;i<email_fields.length;i++) {
		if (emailRe.test(email_fields[i].value)) {
			email_fields[i].removeClassName("invalid");
		} else {
			email_fields[i].addClassName("invalid");
			is_valid = false;
		}
	}
	var phone_fields = $$('div#contact_container .phone');
	for(i=0;i<phone_fields.length;i++) {
		if (phoneRe.test(phone_fields[i].value)) {
			phone_fields[i].removeClassName("invalid");
		} else {
			phone_fields[i].addClassName("invalid");
			is_valid = false;
		}
	}
	
	if(is_valid) {
		return true;
	} else {
		return false;
	}
}
function send_popup_contact_form() {
	if(popup_contact_form_is_valid()) {
		//$('contact_inner_loader').show();
		var query = 'ajax=true';
		query += "&contact_name="+Base64.encode($('contact_name').value);
		query += "&contact_email="+Base64.encode($('contact_email').value);
		query += "&contact_description="+Base64.encode($('contact_description').value);
		query += "&contact_phone="+Base64.encode($('contact_phone').value);
		query += "&contact_current_url="+Base64.encode($('contact_current_url').value);
		query += "&contact_other_info="+Base64.encode($('contact_other_info').value);
		new Ajax.Request('modules/popupContactForm/processor.php', {
			parameters: query,
			onSuccess: function(transport) {
				var contact_form_response = transport.headerJSON;
				if(contact_form_response.code == "Success") {
					alert(contact_form_response.message);
					//$('contact_inner_loader').hide();
					hide_popup_contact_form();
				} else {
					alert(contact_form_response.code+": "+contact_form_response.message);
					//$('contact_inner_loader').hide();
				}
			},
			onFailure: function(transport) {
				alert('There was an error sending your message. (0)');
				//$('contact_inner_loader').hide();
			}
		});
		return false;
	} else {
		alert('Please enter the required information into the highlighted fields.');
		return false;
	}
}
