function pricerange(type, page) {
	switch (page) {
		case 'property':
			var high = parseInt(document.getElementById('property_price_high').value);
			var low = parseInt(document.getElementById('property_price_low').value);		
			switch (type) {
				case 'low':
					if (low > high)
						document.getElementById('property_price_high').value = low + 100;
					break;
				case 'high':
					if (high < low)
						document.getElementById('property_price_low').value = parseInt(high) - 100;
					break;
			}
			break;
		case 'parking':
			var high = parseInt(document.getElementById('parking_spot_price_high').value);
			var low = parseInt(document.getElementById('parking_spot_price_low').value);			
			switch (type) {
				case 'low':
					if (low > high)
						document.getElementById('parking_spot_price_high').value = low + 100;
					break;
				case 'high':
					if (high < low)
						document.getElementById('parking_spot_price_low').value = parseInt(high) - 100;
					break;
			}
			break;
	}
}

function activeFlip(checkbox, id) {	
	if (checkbox.checked) {
		new Effect.Appear(id, { duration: 1 });
	} else {
		new Effect.Fade(id, { duration: 1 });
	}
}

function reverseFlip(checkbox, id) {	
	if (checkbox.checked) {
		new Effect.Fade(id, { duration: 1 });
	} else {
		new Effect.Appear(id, { duration: 1 });
	}
}
	
function hideLandlord() {
    var id = document.getElementById('user_security_level_id').value;
    if (id == 3) {
        document.getElementById('landlord_div').style.display= 'visible';
		document.getElementById('landlord_div').style.display = "block";
    } else {
        document.getElementById('landlord_div').style.display= 'none';
    }
}


// used for the modal inquire
function displayInquireForm(property_id) {
  new Ajax.Request('/properties/inquire/'+property_id+'?format=js', 
    {update: 'modal_lead_form',
      onSuccess:function(request){ 
        $("modal_lead_form").innerHTML = request.responseText;
        RedBox.showInline('modal_lead_form');
        }
      }); 
  return false;
}

// used for modal lead capture

function getCookie(c_name) {
  if (document.cookie.length>0)
  {
    c_start=document.cookie.indexOf(c_name + "=")
    if (c_start!=-1)
    {
      c_start=c_start + c_name.length+1
      c_end=document.cookie.indexOf(";",c_start)
      if (c_end==-1) c_end=document.cookie.length
      return unescape(document.cookie.substring(c_start,c_end))
    }
  }
  return ""
}

// used in auto_post_requests and channel logins
function fadeAndRemove(element) {
  element.fade({afterFinish: function(e){element.remove();}});
}
