// JavaScript Document
$(".photo_link").click(function() {
	$("#loader_wrapper").show();
	$("#fraImageFrame").attr("src", "_photo.php?id=" + $("#intPropertyID").val() + "&f=" + $(this).attr("rel"));
});

$("#contact_agent").click(function() {
	jQuery.facebox(function() {
		jQuery.get(	"_contact.php",
					{
						id: $("#intPropertyID").val()
					}, 
					function(txtData) {
						jQuery.facebox(txtData)
					})
	});
});

$("#email_listing").click(function() {
	jQuery.facebox(function() {
		jQuery.get(	"_email.php",
					{
						id: $("#intPropertyID").val()
					}, 
					function(txtData) {
						jQuery.facebox(txtData)
					})
	});
});

function contactSubmit() {
	boolErrorFound			= false;
	
	if ($("#strPopupName").val().length == 0) {
		setError(" - Please enter your name.\n");
	}
	if ($("#strPopupEmail").val().length == 0) {
		setError(" - Please enter your e-mail address.\n");
	}
	if ($("#txtPopupComments").val().length == 0) {
		setError(" - Please type in your question/comments.\n");
	}
	
	if (!boolErrorFound) {
		$("#lyrPopupSubmit").hide();
		$("#lyrPopupWorking").show();
		
		$.get(	"_contact-send.php", 
				{
					id: $("#intID").val(), 
					name: $("#strPopupName").val(), 
					email: $("#strPopupEmail").val(), 
					comments: $("#txtPopupComments").val()
				}, 
				function(txtData) {
					$("#lyrPopupSend").hide();
					$("#lyrPopupSuccess").show();
					setTimeout(function() { $.facebox.close(); }, 5000);
				}, 
				"json");
	} else {
		alert(STR_STANDARD_ERROR + strErrorsFound);
	}
	
	return false;
}

function emailPropertySubmit() {
	boolErrorFound			= false;
	
	if ($("#strPopupEmail").val().length == 0) {
		setError(" - Please enter your e-mail address.\n");
	}
	
	if (!boolErrorFound) {
		$("#lyrPopupSubmit").hide();
		$("#lyrPopupWorking").show();
		
		$.get(	"_email-send.php", 
				{
					id: $("#intID").val(), 
					email: $("#strPopupEmail").val() 
				}, 
				function(txtData) {
					$("#lyrPopupSend").hide();
					$("#lyrPopupSuccess").show();
					setTimeout(function() { $.facebox.close(); }, 5000);
				}, 
				"json");
	} else {
		alert(STR_STANDARD_ERROR + strErrorsFound);
	}
	
	return false;
}

