// JavaScript Document
$(document).ready(function() {
	
	$box = "";

	$('.deleteFav').click(function() {
		$v = this.id;
		Boxy.confirm("<label class='alert'>Are you sure you want to remove this property on your favorites?</label>", function() { window.location=Common.BaseUrl+'remove-favorites/'+$v; }, {title: 'Message'});
		return false;
	});


	$('#change_photo').click (
		function () {
			if($box == "")
				$box = new Boxy("<div id='Blue'><h3>Loading Please Wait <img src='"+Common.BUrl+"img/load.gif' alt='...' /></h3></div>", {title: 'Change Photo', modal:true});
			else {
				$box.setContent("<div id='Blue'><h3>Loading Please Wait <img src='"+Common.BUrl+"img/load.gif' alt='...' /></h3></div>", {title: 'Change Photo', modal:true});
				$box.center();
				$box.show();
			}
				
			$.ajax({
				url: Common.BaseUrl+"changepic",
				dataType: 'html',
				success: function (html) {
					$box.setContent(html);
					$box.center();
				}
			});	
		}
	);

	$('.inquire').click (
		function () {
			if($box == "")
				$box = new Boxy("<div id='Blue'><h3>Loading Please Wait <img src='"+Common.BUrl+"img/load.gif' alt='...' /></h3></div>", {title: 'Property Inquiry', modal:true});
			else {
				$box.setContent("<div id='Blue'><h3>Loading Please Wait <img src='"+Common.BUrl+"img/load.gif' alt='...' /></h3></div>", {title: 'Property Inquiry', modal:true});
				$box.center();
				$box.show();
			}

			$.ajax({
				url: Common.BaseUrl+"inquire-form/"+this.id,
				dataType: 'html',
				success: function (html)
				{
					$box.setContent(html);
					$box.center();
				}
			});
		}
	);

	$('.send_to_friend').click (
		function () {
			if($box == "")
				$box = new Boxy("<div id='Blue'><h3>Loading Please Wait <img src='"+Common.BUrl+"img/load.gif' alt='...' /></h3></div>", {title: 'Tell a Friend', modal:true});
			else {
				$box.setContent("<div id='Blue'><h3>Loading Please Wait <img src='"+Common.BUrl+"img/load.gif' alt='...' /></h3></div>", {title: 'Tell a Friend', modal:true});
				$box.center();
				$box.show();
			}

			$.ajax({
				url: Common.BaseUrl+"send-to-friend/"+this.id,
				dataType: 'html',
				success: function (html)
				{
					$box.setContent(html);
					$box.center();
				}
			});
		}

	);

	$('.add_to_featured').click(function(){
		$v = this.id;
		$box = Boxy.confirm("<label class='alert'>Are you sure you want to add this property to <b>Featured List</b>?</label>", 
					 function() { 
					 
						$.ajax({
							url: Common.BaseUrl+'add-featured/'+$v,
							dataType: 'html',
							success: function (html)
							{
								$('#fholder_'+$v).remove();
								$box = new Boxy("<div id='Blue'>"+html+"<br><input type='button' value='Close' onclick='$box.hide();'/></div>", {title: 'Tell a Friend', modal:true});
								$box.center();
							}
						});
					 }, {title: 'Add to Featured List'});
		return false;
	});
	$('.deleteFeatured').click(function(){
		$v = this.id;
		$box = Boxy.confirm("<label class='alert'>Are you sure you want to remove this property to Featured List?</label>", 
					 function() { 
						window.location = Common.BaseUrl+'remove-featured/'+$v;
					 }, {title: 'Add to Featured List'});
		return false;
	});


});
