var OConnorShannon =
{
	Page:
	{
		prices:[],
		rents:[],
		emailAlertAreas:[],
		emailAlertPostcodes:[],
		emailAlertGenerals:[],

		init:function()
		{
			for(var i = 0; i < 8250; i += 250)
			{
				OConnorShannon.Page.rents.push(i);
			}

			for(var i = 0; i < 1000000; i += 100000)
			{
				OConnorShannon.Page.prices.push(i);
			}

			$("nav ol li .children").css(
			{
				display:"none"
			});

			$("nav ol li").hover(function()
			{
				$(this).find(".children:first").css(
				{
					visibility:"visible",
					display:"none"
				}).show();
			},function()
			{
				$(this).find(".children:first").css(
				{
					visibility:"hidden"
				});
			});

			$.preLoadImages(
				"/wp-content/themes/oconnorshannon/assets/img/ajax-loader.gif",
				"/wp-content/themes/oconnorshannon/assets/img/exclamation.png",
				"/wp-content/themes/oconnorshannon/assets/img/tick.png",
				"/wp-content/themes/oconnorshannon/assets/img/homepage-body-banner.png",
				"/wp-content/themes/oconnorshannon/assets/img/homepage-body-center.png",
				"/wp-content/themes/oconnorshannon/assets/img/homepage-body-bottom.png",
				"/wp-content/themes/oconnorshannon/assets/img/homepage-body-top.png",
				"/wp-content/themes/oconnorshannon/assets/img/homepage-header-banner.png",
				"/wp-content/themes/oconnorshannon/assets/img/page-divider.png",
				"/wp-content/themes/oconnorshannon/assets/img/homepage-our-services-sales.png",
				"/wp-content/themes/oconnorshannon/assets/img/homepage-our-services-lettings.png",
				"/wp-content/themes/oconnorshannon/assets/img/homepage-our-services-valuations.png",
				"/wp-content/themes/oconnorshannon/assets/img/hover-shadow.png",
				"/wp-content/themes/oconnorshannon/assets/img/find-out-more-arrow.png",
				"/wp-content/themes/oconnorshannon/assets/img/current-offers-graphic-1.png",
				"/wp-content/themes/oconnorshannon/assets/img/current-offers-graphic-2.png",
				"/wp-content/themes/oconnorshannon/assets/img/current-offers-graphic-3.png",
				"/wp-content/themes/oconnorshannon/assets/img/testimonials-bubble.png",
				"/wp-content/themes/oconnorshannon/assets/img/content-body-top.png",
				"/wp-content/themes/oconnorshannon/assets/img/content-body-center.png",
				"/wp-content/themes/oconnorshannon/assets/img/content-body-bottom.png",
				"/wp-content/themes/oconnorshannon/assets/img/content-sidebar-top.png",
				"/wp-content/themes/oconnorshannon/assets/img/content-sidebar-center.png",
				"/wp-content/themes/oconnorshannon/assets/img/content-sidebar-bottom.png",
				"/wp-content/themes/oconnorshannon/assets/img/bullet-arrow-right.png",
				"/wp-content/themes/oconnorshannon/assets/img/bullet-arrow-left.png"
			);

			if($("a.thumbnail").length)
			{
				$("a[rel=group]").fancybox(
				{
					"showCloseButton":true,
					"hideOnContentClick":false,
					"titlePosition":"over",
					"transitionIn":"fade",
					"transitionOut":"fade",
					"centerOnScroll":true,
					"onComplete":function()
					{
						$("#fancybox-wrap").hover(function()
						{
							$("#fancybox-title").show();
						},
						function()
						{
							$("#fancybox-title").hide();
						});
					}
				});
			}

			if($("select[name=property-search-results-sort-by-top],select[name=property-search-results-sort-by-bottom]").length)
			{
				$("select[name=property-search-results-sort-by-top]").change(function()
				{
					if($(this).val() == "high-to-low")
					{
						$("select[name=property-search-results-sort-by-bottom] option:eq(1)").attr("selected","selected");

						$("ul#results>li").tsort("div p.meta",{order:"desc"});
					}
					else
					{
						$("select[name=property-search-results-sort-by-bottom] option:eq(0)").attr("selected","selected");

						$("ul#results>li").tsort("div p.meta",{order:"asc"});
					}
				},function(){});

				$("select[name=property-search-results-sort-by-bottom]").change(function()
				{
					if($(this).val() == "high-to-low")
					{
						$("select[name=property-search-results-sort-by-top] option:eq(1)").attr("selected","selected");

						$("ul#results>li").tsort("div p.meta",{order:"desc"});
					}
					else
					{
						$("select[name=property-search-results-sort-by-top] option:eq(0)").attr("selected","selected");

						$("ul#results>li").tsort("div p.meta",{order:"asc"});
					}
				},function(){});
			}

  			if($("input[name=passwordStrength]").length)
  			{
  				if($("input[name=accountRegisterPassword]").val() == "" || $("input[name=myProfileNewPassword]").val() == "")
  				{
  					$("input[name=passwordStrength]").val("Password Strength Indicator");
  				}

  				$("input[name=accountRegisterPassword]").keyup(function()
  				{
  					$("input[name=passwordStrength]").val(passwordStrength($(this).val(),""));

  				},function(){}).blur(function()
  				{
  					if($(this).val() == "")
  					{
  						$("input[name=passwordStrength]").val("Password Strength Indicator");
  					}
  				},function(){});

				$("input[name=myProfileNewPassword]").keyup(function()
  				{
  					$("input[name=passwordStrength]").val(passwordStrength($(this).val(),""));

  				},function(){}).blur(function()
  				{
  					if($(this).val() == "")
  					{
  						$("input[name=passwordStrength]").val("Password Strength Indicator");
  					}
  				},function(){});
			}

			if($(".autohide").length && $(".autohide").is(":visible"))
			{
				setTimeout(function()
				{
					$(".autohide").slideUp("fast");
				},6000);
			}

			if($("form[name=homepageSearch]").length)
			{
				$("input[name=homepageSearchType]").each(function()
				{
					$(this).attr("checked","");
				});

				$.ajax(
				{
					cache:true,
					type:"POST",
					dataType:"text",
					url:document.location.href,
					data:"action=count-investment-properties",
					success:function(data,textStatus,XMLHttpRequest)
					{
						var labels = new Array("Residential","Commercial","Sites/Land", "Investment");

						if(data == 0)
						{
						}
						else
						{
							//labels.push("Investments");
						}

						OConnorShannon.Page.loadForSaleSearchType(labels);
					},
					error:function(XMLHttpRequest,textStatus,errorThrown)
					{
						//alert(XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
					},
					complete:function(XMLHttpRequest,textStatus)
					{
					}
				});

				$("input[name=homepageSearchType]").bind("click",function()
				{
					var labels = new Array();

					if($("input[name=homepageSearchType]:checked").val() == 1)
					{
						$.ajax(
						{
							cache:true,
							type:"POST",
							dataType:"text",
							url:document.location.href,
							data:"action=count-investment-properties",
							success:function(data,textStatus,XMLHttpRequest)
							{
								labels.push("Residential","Commercial","Sites/Land", "Investment");

								if(data == 0)
								{
								}
								else
								{
									//labels.push("Investments");
								}

								OConnorShannon.Page.loadHomepageSearchOptions(labels);

								//$(".group2 li span label").html("Price");

								$("select[name=homepageSearchMinValue],select[name=homepageSearchMaxValue]").html(
									$("<option/>").attr(
									{
										"value":"all-prices"
									}).append("All Prices")
								);

								$.each(OConnorShannon.Page.prices,function(counter,price)
								{
									$("select[name=homepageSearchMinValue],select[name=homepageSearchMaxValue]").append(
										$("<option/>").attr(
										{
											"value":price
										}).append("&euro;" + OConnorShannon.Page.numberFormat(price,0,"",","))
									);
								});
							},
							error:function(XMLHttpRequest,textStatus,errorThrown)
							{
								//alert(XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
							},
							complete:function(XMLHttpRequest,textStatus)
							{
							}
						});
					}
					else if($("input[name=homepageSearchType]:checked").val() == 2)
					{
						labels.push("Residential","Commercial", "Investment");

						OConnorShannon.Page.loadHomepageSearchOptions(labels);

						//$(".group2 li span label").html("Rent");

						$("select[name=homepageSearchMinValue],select[name=homepageSearchMaxValue]").html(
							$("<option/>").attr(
							{
								"value":"all-rents"
							}).append("All Rents")
						);

						$.each(OConnorShannon.Page.rents,function(counter,rent)
						{
							$("select[name=homepageSearchMinValue],select[name=homepageSearchMaxValue]").append(
								$("<option/>").attr(
								{
									"value":rent
								}).append("&euro;" + OConnorShannon.Page.numberFormat(rent,0,"",","))
							);
						});
					}
				},function(){});

				$("button[name=homepageSearchBtn]").bind("click",function()
				{
					$("form[name=homepageSearch]").get(0).submit();
				},function(){});
			}

			if($("form[name=sidebarEmailAlertForm]").length)
			{
				var labels = new Array("For Sale","For Let","Investments");

				$.each(labels,function(counter,label)
				{
					$("select[name=sidebarEmailAlertSearchType]").append(
						$("<option/>").attr(
						{
							"value":counter + 1
						}).append(label)
					);
				});

				var labels = new Array();

				labels.push("Residential","Commercial","Sites/Land", "Investment");

				var options = "";

				$.each(labels,function(counter,option)
				{
					options += '<option value="' + counter + '">' + option + '</option>';
				});

				$("select[name=sidebarEmailAlertPropertyType]").html(options);

				OConnorShannon.Page.loadXMLGenerals();
				OConnorShannon.Page.loadXMLPostcodes();
				OConnorShannon.Page.loadXMLAreas();

				$(".search .values span label").html("Price");

				$("select[name=sidebarEmailAlertMinValue],select[name=sidebarEmailAlertMaxValue]").append(
					$("<option/>").attr(
					{
						"value":"all-prices"
					}).append("All Prices")
				);

				$.each(OConnorShannon.Page.prices,function(counter,price)
				{
					$("select[name=sidebarEmailAlertMinValue]").append(
						$("<option/>").attr(
						{
							"value":price
						}).append("&euro;" + OConnorShannon.Page.numberFormat(price,0,"",","))
					);

					$("select[name=sidebarEmailAlertMaxValue]").append(
						$("<option/>").attr(
						{
							"value":price
						}).append("&euro;" + OConnorShannon.Page.numberFormat(price,0,"",","))
					);
				});

				$("select[name=sidebarEmailAlertSearchType]").change(function()
				{
					var labels = new Array();

					if($("select[name=sidebarEmailAlertSearchType]").val() == 1)
					{
						labels.push("Residential","Commercial","Sites/Land", "Investment");

						var options = "";

						$.each(labels,function(counter,option)
						{
							options += '<option value="' + counter + '">' + option + '</option>';
						});

						$("select[name=sidebarEmailAlertPropertyType]").html(options);

						$("select[name=sidebarEmailAlertMinValue],select[name=sidebarEmailAlertMaxValue]").empty();

						$(".search .values span label").html("Price");

						$("select[name=sidebarEmailAlertMinValue],select[name=sidebarEmailAlertMaxValue]").append(
							$("<option/>").attr(
							{
								"value":"all-prices"
							}).append("All Prices")
						);

						$.each(OConnorShannon.Page.prices,function(counter,price)
						{
							$("select[name=sidebarEmailAlertMinValue]").append(
								$("<option/>").attr(
								{
									"value":price
								}).append("&euro;" + OConnorShannon.Page.numberFormat(price,0,"",","))
							);

							$("select[name=sidebarEmailAlertMaxValue]").append(
								$("<option/>").attr(
								{
									"value":price
								}).append("&euro;" + OConnorShannon.Page.numberFormat(price,0,"",","))
							);
						});
					}
					else if($("select[name=sidebarEmailAlertSearchType]").val() == 2)
					{
						labels.push("Residential","Commercial");

						var options = "";

						$.each(labels,function(counter,option)
						{
							options += '<option value="' + counter + '">' + option + '</option>';
						});

						$("select[name=sidebarEmailAlertPropertyType]").html(options);

						$("select[name=sidebarEmailAlertMinValue],select[name=sidebarEmailAlertMaxValue]").empty();

						$("select[name=sidebarEmailAlertMinValue],select[name=sidebarEmailAlertMaxValue]").append(
							$("<option/>").attr(
							{
								"value":"all-rents"
							}).append("All Rents")
						);

						$(".search .values span label").html("Rent");

						$.each(OConnorShannon.Page.rents,function(counter,rent)
						{
							$("select[name=sidebarEmailAlertMinValue]").append(
								$("<option/>").attr(
								{
									"value":rent
								}).append("&euro;" + OConnorShannon.Page.numberFormat(rent,0,"",","))
							);

							$("select[name=sidebarEmailAlertMaxValue]").append(
								$("<option/>").attr(
								{
									"value":rent
								}).append("&euro;" + OConnorShannon.Page.numberFormat(rent,0,"",","))
							);
						});
					}
					else if($("select[name=sidebarEmailAlertSearchType]").val() == 3)
					{
						$.ajax(
						{
							cache:true,
							type:"POST",
							dataType:"html",
							url:document.location.href,
							data:"action=get-investment-property-types",
							success:function(data,textStatus,XMLHttpRequest)
							{
								var tmpPropertySearchTypes = data.split("|");

								$.each(tmpPropertySearchTypes,function(counter,tmpPropertySearchType)
								{
									labels.push(tmpPropertySearchType);
								});

								var options = "";

								$.each(labels,function(counter,option)
								{
									if(option.substring(0,1) == "_")
									{
										options += '<option value="' + counter + '">' + option.substring(1,option.length) + '</option>';
									}
									else
									{
										options += '<option value="' + counter + '">' + option + '</option>';
									}
								});

								$("select[name=sidebarEmailAlertPropertyType]").html(options);
							},
							error:function(XMLHttpRequest,textStatus,errorThrown)
							{
								//alert(XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
							},
							complete:function(XMLHttpRequest,textStatus)
							{
							}
						});

						$("select[name=sidebarEmailAlertMinValue],select[name=sidebarEmailAlertMaxValue]").empty();

						$("select[name=sidebarEmailAlertMinValue],select[name=sidebarEmailAlertMaxValue]").append(
							$("<option/>").attr(
							{
								"value":"all-prices"
							}).append("All Prices")
						);

						$(".search .values span label").html("Prices");

						$.each(OConnorShannon.Page.prices,function(counter,price)
						{
							$("select[name=sidebarEmailAlertMinValue]").append(
								$("<option/>").attr(
								{
									"value":price
								}).append("&euro;" + OConnorShannon.Page.numberFormat(price,0,"",","))
							);

							$("select[name=sidebarEmailAlertMaxValue]").append(
								$("<option/>").attr(
								{
									"value":price
								}).append("&euro;" + OConnorShannon.Page.numberFormat(price,0,"",","))
							);
						});
					}
				},function(){});

				$("button[name=sidebarEmailAlertBtn]").bind("click",function()
				{
					var errors = 0;

	  				if($("input[name=sidebarEmailAlertName]").val())
	  				{
	  					$("label#sidebarEmailAlertNameLabel").css("color","rgb(82,82,82)");

	  					var name = $("input[name=sidebarEmailAlertName]").val();
	  				}
  					else
  					{
  						errors++;

  						$("label#sidebarEmailAlertNameLabel").css("color","rgb(205,57,70)");
  					}

  					if(errors == 0)
					{
						var userID = $("input[name=currentUserID]").val();
						var searchtype = $("select[name=sidebarEmailAlertSearchType]").val();
						var propertytype = $("select[name=sidebarEmailAlertPropertyType]").val();
						var location = $("select[name=sidebarEmailAlertLocation]").val();
						var minvalue = $("select[name=sidebarEmailAlertMinValue]").val();
						var maxvalue = $("select[name=sidebarEmailAlertMaxValue]").val();

						$(".email-alert-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/ajax-loader.gif' alt='Submitting'> Submitting...").slideDown("fast");

						$.ajax(
						{
							cache:false,
							type:"POST",
							url:document.location.href,
							data:"action=add-email-alert&name=" + escape(name) + "&searchtype=" + escape(searchtype) + "&propertytype=" + escape(propertytype) + "&location=" + escape(location) + "&minvalue=" + escape(minvalue) + "&maxvalue=" + escape(maxvalue),
							success:function(data,textStatus,XMLHttpRequest)
							{
								$("p#none").fadeOut("fast");

								$("#tableContainer").before("<p class='notification'><img src='/wp-content/themes/oconnorshannon/assets/img/information.png' alt='Information'> 1 New email alert added! Please <a href='' title=''>refresh this page</a> to upload your Email Alert list.</p>").fadeIn("slow");
							},
							error:function(XMLHttpRequest,textStatus,errorThrown)
							{
								//alert(XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
							},
							complete:function(XMLHttpRequest,textStatus)
							{
								$(".email-alert-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/tick.png' alt='Submitted'> Submitted! Thank you.");

								setTimeout(function()
								{
						  			$(".email-alert-form-result").slideUp("fast");

						  			$("label#sidebarEmailAlertNameLabel").css("color","rgb(82,82,82)");

						    		$("#sidebarEmailAlertForm").get(0).reset();

						    		$(".search .values span label").html("All Prices");

						    		$("select[name=sidebarEmailAlertMinValue],select[name=sidebarEmailAlertMaxValue]").append(
										$("<option/>").attr(
										{
											"value":"all-prices"
										}).append("All Prices")
									);

									$.each(OConnorShannon.Page.prices,function(counter,price)
									{
										$("select[name=sidebarEmailAlertMinValue]").append(
											$("<option/>").attr(
											{
												"value":price
											}).append("&euro;" + OConnorShannon.Page.numberFormat(price,0,"",","))
										);

										$("select[name=sidebarEmailAlertMaxValue]").append(
											$("<option/>").attr(
											{
												"value":price
											}).append("&euro;" + OConnorShannon.Page.numberFormat(price,0,"",","))
										);
									});
						    	},6000);
							}
						});
					}
					else
					{
						$(".email-alert-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Sending'> Please provide a label for this Email Alert.").slideDown("fast");
	  				}
				},function(){});
			}

			if($("form[name=sidebarSearchForm]").length)
			{
				var labels = new Array("For Sale Properties","Rental Properties");

				$.each(labels,function(counter,label)
				{
					$("select[name=sidebarSearchType]").append(
						$("<option/>").attr(
						{
							"value":counter + 1
						}).append(label)
					);
				});

				$.ajax(
				{
					cache:true,
					type:"POST",
					dataType:"text",
					url:document.location.href,
					data:"action=count-investment-properties",
					success:function(data,textStatus,XMLHttpRequest)
					{
						var labels = new Array();

						labels.push("Residential","Commercial","Sites/Land", "Investment");

						if(data == 0)
						{

						}
						else
						{
							//labels.push("Investments");
						}

						OConnorShannon.Page.loadSidebarSearchOptions(labels);

						$(".search .values span label").html("Price");

						$("select[name=sidebarSearchMinValue],select[name=sidebarSearchMaxValue]").html(
							$("<option/>").attr(
							{
								"value":"all-prices"
							}).append("All Prices")
						);

						$.each(OConnorShannon.Page.prices,function(counter,price)
						{
							$("select[name=homepageSearchMinValue],select[name=homepageSearchMaxValue]").append(
								$("<option/>").attr(
								{
									"value":price
								}).append("&euro;" + OConnorShannon.Page.numberFormat(price,0,"",","))
							);
						});
					},
					error:function(XMLHttpRequest,textStatus,errorThrown)
					{
						//alert(XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
					},
					complete:function(XMLHttpRequest,textStatus)
					{
					}
				});

				$("select[name=sidebarSearchType]").change(function()
				{
					var labels = new Array();

					if($("select[name=sidebarSearchType]").val() == 1)
					{
						$.ajax(
						{
							cache:true,
							type:"POST",
							dataType:"text",
							url:document.location.href,
							data:"action=count-investment-properties",
							success:function(data,textStatus,XMLHttpRequest)
							{
								labels.push("Residential","Commercial","Sites/Land", "Investment");

								if(data == 0)
								{
								}
								else
								{
									//labels.push("Investments");
								}

								OConnorShannon.Page.loadSidebarSearchOptions(labels);

								$(".search .values span label").html("Price");

								$("select[name=sidebarSearchMinValue],select[name=sidebarSearchMaxValue]").html(
									$("<option/>").attr(
									{
										"value":"all-prices"
									}).append("All Prices")
								);

								$.each(OConnorShannon.Page.prices,function(counter,price)
								{
									$("select[name=homepageSearchMinValue],select[name=homepageSearchMaxValue]").append(
										$("<option/>").attr(
										{
											"value":price
										}).append("&euro;" + OConnorShannon.Page.numberFormat(price,0,"",","))
									);
								});
							},
							error:function(XMLHttpRequest,textStatus,errorThrown)
							{
								//alert(XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
							},
							complete:function(XMLHttpRequest,textStatus)
							{
							}
						});
					}
					else if($("select[name=sidebarSearchType]").val() == 2)
					{
						labels.push("Residential","Commercial", "Investment");

						OConnorShannon.Page.loadSidebarSearchOptions(labels);

						$(".search .values span label").html("Rent");

						$("select[name=sidebarSearchMinValue],select[name=sidebarSearchMaxValue]").html(
							$("<option/>").attr(
							{
								"value":"all-rents"
							}).append("All Rents")
						);

						$.each(OConnorShannon.Page.rents,function(counter,rent)
						{
							$("select[name=homepageSearchMinValue],select[name=homepageSearchMaxValue]").append(
								$("<option/>").attr(
								{
									"value":rent
								}).append("&euro;" + OConnorShannon.Page.numberFormat(rent,0,"",","))
							);
						});
					}
				},function(){});

				$("button[name=sidebarSearchBtn]").bind("click",function()
				{
					$("form[name=sidebarSearchForm]").get(0).submit();
				},function(){});
			}

			if($(".currentOffers ul").length > 0)
			{
				$(".currentOffers ul").cycle(
				{
					fx:"scrollRight",
					speed:1000,
					timeout:6000,
					cleartype:1
					/*continuous:1*/
				});
			}

			if($(".testimonialsSlider ul").length > 0)
			{
				$(".testimonialsSlider").cycle(
				{
					fx:"fade",
					speed:500,
					timeout:8000,
					cleartype:1
				});
			}

			if($(".testimonials ul").length > 0)
			{
				$(".testimonials").cycle(
				{
					fx:"fade",
					speed:1000,
					timeout:8000,
					cleartype:1
				});
			}

			if($(".salesContainer, .lettingsContainer, .valuationsContainer").length)
			{
				$(".salesContainer").hover(function()
				{
					$(".salesContainer .sales p").hide();

					$(".salesContainer .sales ol").css(
					{
						"margin-top":"2px"
					});

					$(".salesContainer .sales").animate(
					{
						"top":"-122px"
					},"fast");
				},function()
				{
					$(".salesContainer .sales p").show();

					$(".salesContainer .sales ol").css(
					{
						"margin-top":"0px"
					});

					if($.browser.webkit || $.browser.opera)
					{
						$(".salesContainer .sales").animate(
						{
							"top":"-55px"
						},"fast");
					}
					else
					{
						$(".salesContainer .sales").animate(
						{
							"top":"-56px"
						},"fast");
					}
				});

				$(".lettingsContainer").hover(function()
				{
					$(".lettingsContainer .lettings p").hide();

					$(".lettingsContainer .lettings ol").css(
					{
						"margin-top":"2px"
					});

					$(".lettingsContainer .lettings").animate(
					{
						"top":"-122px"
					},"fast");
				},function()
				{
					$(".lettingsContainer .lettings p").show();

					$(".lettingsContainer .lettings ol").css(
					{
						"margin-top":"0px"
					});

					if($.browser.webkit || $.browser.opera)
					{
						$(".lettingsContainer .lettings").animate(
						{
							"top":"-55px"
						},"fast");
					}
					else
					{
						$(".lettingsContainer .lettings").animate(
						{
							"top":"-56px"
						},"fast");
					}
				});

				$(".valuationsContainer").hover(function()
				{
					$(".valuationsContainer .valuations p").hide();

					$(".valuationsContainer .valuations ol").css(
					{
						"margin-top":"2px"
					});

					$(".valuationsContainer .valuations").animate(
					{
						"top":"-122px"
					},"fast");
				},function()
				{
					$(".valuationsContainer .valuations p").show();

					$(".valuationsContainer .valuations ol").css(
					{
						"margin-top":"0px"
					});

					if($.browser.webkit || $.browser.opera)
					{
						$(".valuationsContainer .valuations").animate(
						{
							"top":"-55px"
						},"fast");
					}
					else
					{
						$(".valuationsContainer .valuations").animate(
						{
							"top":"-56px"
						},"fast");
					}
				});
			}

			if($("#contactUsMap").length)
			{
				var latlng = new google.maps.LatLng(53.3247565,-6.2652793);

				var options =
				{
					zoom:12,
					center:latlng,
					mapTypeControl:false,
					mapTypeId:google.maps.MapTypeId.ROADMAP
				};

				var infowindow = new google.maps.InfoWindow(
				{
					content:"Thats us - O'Connor Shannon!"
				});

				var map = new google.maps.Map($("#contactUsMap").get(0),options);

				var marker = new google.maps.Marker(
				{
					position:latlng,
					map:map,
					title:"Thats us - O'Connor Shannon!"
				});

				google.maps.event.addListener(marker,"click",function()
				{
					infowindow.open(map,marker);
				});
			}

			if($("#sidebarMailingListForm").length)
			{
				$("button[name=sidebarJoinBtn]").bind("click",function()
  				{
  					var errors = 0;

	  				if($("input[name=sidebarMailingListName]").val())
	  				{
	  					$("label#sidebarMailingListNameLabel").css("color","rgb(82,82,82)");

	  					var fullname = $("input[name=sidebarMailingListName]").val();
	  				}
  					else
  					{
  						errors++;

  						$("#sidebarMailingListNameLabel").css("color","rgb(205,57,70)");
  					}

  					if($("input[name=sidebarMailingListEmail]").val())
	  				{
	  					if(!$("input[name=sidebarMailingListEmail]").val().match(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.@-]+\.[A-Za-z]{2,6}$/))
	  					{
	  						errors++;
	  					}
	  					else
	  					{
	  						$("label#sidebarMailingListEmailLabel").css("color","rgb(82,82,82)");

	  						var email = $("input[name=sidebarMailingListEmail]").val();
	  					}
	  				}
  					else
  					{
  						errors++;

  						$("label#sidebarMailingListEmailLabel").css("color","rgb(205,57,70)");
  					}

  					if(errors == 0)
					{
						$(".mailing-list-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/ajax-loader.gif' alt='Submitting'> Submitting...").slideDown("fast");

						$.ajax(
						{
							cache:false,
							type:"POST",
							url:document.location.href,
							data:"action=mailinglist&fullname=" + escape(fullname) + "&email=" + escape(email),
							success:function(data,textStatus,XMLHttpRequest)
							{
							},
							error:function(XMLHttpRequest,textStatus,errorThrown)
							{
								//alert(XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
							},
							complete:function(XMLHttpRequest,textStatus)
							{
								$(".mailing-list-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/tick.png' alt='Submitted'> Submitted! Thank you for your interest.");

								setTimeout(function()
								{
						  			$(".mailing-list-form-result").slideUp("fast");

						  			$("label#mailingListFormNameLabel").css("color","rgb(82,82,82)");
				  					$("label#mailingListFormEmailLabel").css("color","rgb(82,82,82)");

						    		$("#sidebarMailingListForm").get(0).reset();
						    	},6000);
							}
						});
					}
					else
					{
						$(".mailing-list-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Sending'> Please fill in your Full Name and Email address.").slideDown("fast");
	  				}
  				},function(){});
  			}

			if($("#contactUsForm").length)
			{
				$("button[name=contactUsFormSendBtn]").bind("click",function()
  				{
  					var errors = 0;

	  				if($("input[name=contactUsFormName]").val())
	  				{
	  					$("label#contactUsFormNameLabel").css("color","rgb(82,82,82)");

	  					var fullname = $("input[name=contactUsFormName]").val();
	  				}
  					else
  					{
  						errors++;

  						$("#contactUsFormNameLabel").css("color","rgb(205,57,70)");
  					}

  					if($("input[name=contactUsFormEmail]").val())
	  				{
	  					if(!$("input[name=contactUsFormEmail]").val().match(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.@-]+\.[A-Za-z]{2,6}$/))
	  					{
	  						errors++;
	  					}
	  					else
	  					{
	  						$("label#contactUsFormEmailLabel").css("color","rgb(82,82,82)");

	  						var email = $("input[name=contactUsFormEmail]").val();
	  					}
	  				}
  					else
  					{
  						errors++;

  						$("label#contactUsFormEmailLabel").css("color","rgb(205,57,70)");
  					}

  					var telephone = $("input[name=contactUsFormTelephone]").val();

  					if($("textarea[name=contactUsFormMessage]").val())
	  				{
	  					$("label#contactUsFormMessageLabel").css("color","rgb(82,82,82)");

	  					var message = $("textarea[name=contactUsFormMessage]").val();
	  				}
  					else
  					{
  						errors++;

  						$("label#contactUsFormMessageLabel").css("color","rgb(205,57,70)");
  					}

					if(errors == 0)
					{
						$(".contact-us-form-result").removeClass("fail").html("<img src='/wp-content/themes/oconnorshannon/assets/img/ajax-loader.gif' alt='Sending'> Sending...").slideDown("fast");

						$.ajax(
						{
							cache:false,
							type:"POST",
							url:document.location.href,
							data:"action=contact&fullname=" + escape(fullname) + "&email=" + escape(email) + "&telephone=" + escape(telephone) + "&message=" + escape(message),
							success:function(data,textStatus,XMLHttpRequest)
							{
							},
							error:function(XMLHttpRequest,textStatus,errorThrown)
							{
								//alert(XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
							},
							complete:function(XMLHttpRequest,textStatus)
							{
								$(".contact-us-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/tick.png' alt='Sent'> Sent! Thank you for your interest and contacting us.");

								setTimeout(function()
								{
						  			$(".contact-us-form-result").slideUp("fast");

						  			$("label#contactUsFormNameLabel").css("color","rgb(82,82,82)");
				  					$("label#contactUsFormEmailLabel").css("color","rgb(82,82,82)");
				  					$("label#contactUsFormMessageLabel").css("color","rgb(82,82,82)");

						    		$("#contactUsForm").get(0).reset();
						    	},6000);
							}
						});
					}
					else
					{
						$(".contact-us-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Sending'> Please fill in your Full Name, a valid Email address and your Message.").slideDown("fast");
	  				}
  				});
  			}

				if($("#enquiryForm").length)
			{
				$("button[name=enquiryFormSendBtn]").bind("click",function()
  				{
  					var errors = 0;
	  				var address = $("input[name=enquiryFormAddress]").val();
	  				var description = $("input[name=enquiryFormDescription]").val();

	  				if($("input[name=enquiryFormName]").val())
	  				{
	  					$("label#enquiryFormNameLabel").css("color","rgb(82,82,82)");

	  					var fullname = $("input[name=enquiryFormName]").val();
	  				}
  					else
  					{
  						errors++;

  						$("#enquiryFormNameLabel").css("color","rgb(205,57,70)");
  					}

  					if($("input[name=enquiryFormEmail]").val())
	  				{
	  					if(!$("input[name=enquiryFormEmail]").val().match(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.@-]+\.[A-Za-z]{2,6}$/))
	  					{
	  						errors++;
	  					}
	  					else
	  					{
	  						$("label#enquiryFormEmailLabel").css("color","rgb(82,82,82)");

	  						var email = $("input[name=enquiryFormEmail]").val();
	  					}
	  				}
  					else
  					{
  						errors++;

  						$("label#enquiryFormEmailLabel").css("color","rgb(205,57,70)");
  					}

  					var telephone = $("input[name=enquiryFormTelephone]").val();

  					if($("textarea[name=enquiryFormMessage]").val())
	  				{
	  					$("label#enquiryFormMessageLabel").css("color","rgb(82,82,82)");

	  					var message = $("textarea[name=enquiryFormMessage]").val();
	  				}
  					else
  					{
  						errors++;

  						$("label#enquiryFormMessageLabel").css("color","rgb(205,57,70)");
  					}

					if(errors == 0)
					{
						$(".contact-us-form-result").removeClass("fail").html("<img src='/wp-content/themes/oconnorshannon/assets/img/ajax-loader.gif' alt='Sending'> Sending...").slideDown("fast");

						$.ajax(
						{
							cache:false,
							type:"POST",
							url:document.location.href,
							data:"action=enquiry&fullname=" + escape(fullname) + "&email=" + escape(email) + "&telephone=" + escape(telephone) + "&message=" + escape(message) + "&address=" + escape(address) + "&description=" + escape(description) + '&url=' + window.location,
							success:function(data,textStatus,XMLHttpRequest)
							{
							},
							error:function(XMLHttpRequest,textStatus,errorThrown)
							{
								//alert(XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
							},
							complete:function(XMLHttpRequest,textStatus)
							{
								$(".contact-us-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/tick.png' alt='Sent'> Sent! Thank you for your interest and contacting us.");

								setTimeout(function()
								{
						  			$(".contact-us-form-result").slideUp("fast");

						  			$("label#enquiryFormNameLabel").css("color","rgb(82,82,82)");
				  					$("label#enquiryFormEmailLabel").css("color","rgb(82,82,82)");
				  					$("label#enquiryFormMessageLabel").css("color","rgb(82,82,82)");

						    		$("#enquiryForm").get(0).reset();
						    	},6000);
							}
						});
					}
					else
					{
						$(".contact-us-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Sending'> Please fill in your Full Name, a valid Email address and your Message.").slideDown("fast");
	  				}
  				});
  			}

  			if($("#tellAFriendForm").length)
			{
				$("button[name=tellAFriendFormSendBtn]").bind("click",function()
  				{
  					var errors = 0;

	  				if($("input[name=tellAFriendFormName]").val())
	  				{
	  					$("label#tellAFriendFormNameLabel").css("color","rgb(82,82,82)");

	  					var name = $("input[name=tellAFriendFormName]").val();
	  				}
  					else
  					{
  						errors++;

  						$("#tellAFriendFormNameLabel").css("color","rgb(205,57,70)");
  					}

  					if($("input[name=tellAFriendFormFriendName]").val())
	  				{
	  					$("label#tellAFriendFormFriendNameLabel").css("color","rgb(82,82,82)");

	  					var friendname = $("input[name=tellAFriendFormFriendName]").val();
	  				}
  					else
  					{
  						errors++;

  						$("#tellAFriendFormFriendNameLabel").css("color","rgb(205,57,70)");
  					}

  					if($("input[name=tellAFriendFormEmail]").val())
	  				{
	  					if(!$("input[name=tellAFriendFormEmail]").val().match(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.@-]+\.[A-Za-z]{2,6}$/))
	  					{
	  						errors++;
	  					}
	  					else
	  					{
	  						$("label#tellAFriendFormEmailLabel").css("color","rgb(82,82,82)");

	  						var email = $("input[name=tellAFriendFormEmail]").val();
	  					}
	  				}
  					else
  					{
  						errors++;

  						$("label#tellAFriendFormEmailLabel").css("color","rgb(205,57,70)");
  					}

  					if($("input[name=tellAFriendFormFriendEmail]").val())
	  				{
	  					if(!$("input[name=tellAFriendFormFriendEmail]").val().match(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.@-]+\.[A-Za-z]{2,6}$/))
	  					{
	  						errors++;
	  					}
	  					else
	  					{
	  						$("label#tellAFriendFormFriendEmailLabel").css("color","rgb(82,82,82)");

	  						var friendemail = $("input[name=tellAFriendFormFriendEmail]").val();
	  					}
	  				}
  					else
  					{
  						errors++;

  						$("label#tellAFriendFormFriendEmailLabel").css("color","rgb(205,57,70)");
  					}

  					var subject = $("input[name=tellAFriendFormSubject]").val();

  					if($("textarea[name=tellAFriendFormMessage]").val())
	  				{
	  					$("label#tellAFriendFormMessageLabel").css("color","rgb(82,82,82)");

	  					var message = $("textarea[name=tellAFriendFormMessage]").val();
	  				}
  					else
  					{
  						errors++;

  						$("label#tellAFriendFormMessageLabel").css("color","rgb(205,57,70)");
  					}

					if(errors == 0)
					{
						$(".tell-a-friend-form-result").removeClass("fail").html("<img src='/wp-content/themes/oconnorshannon/assets/img/ajax-loader.gif' alt='Sending'> Sending...").slideDown("fast");

						$.ajax(
						{
							cache:false,
							type:"POST",
							url:document.location.href,
							data:"action=share&subject=" + escape(subject) + "&name=" + escape(name) + "&email=" + escape(email) + "&friendname=" + escape(friendname) + "&friendemail=" + escape(friendemail) + "&message=" + escape(message),
							success:function(data,textStatus,XMLHttpRequest)
							{
							},
							error:function(XMLHttpRequest,textStatus,errorThrown)
							{
								//alert(XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
							},
							complete:function(XMLHttpRequest,textStatus)
							{
								$(".tell-a-friend-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/tick.png' alt='Sent'> Sent! Thank you for your interest and telling your friend.");

								setTimeout(function()
								{
						  			$(".tell-a-friend-form-result").slideUp("fast");

						  			$("label#tellAFriendFormNameLabel").css("color","rgb(82,82,82)");
				  					$("label#tellAFriendFormEmailLabel").css("color","rgb(82,82,82)");
				  					$("label#tellAFriendFormFriendNameLabel").css("color","rgb(82,82,82)");
				  					$("label#tellAFriendFormFriendEmailLabel").css("color","rgb(82,82,82)");
				  					$("label#tellAFriendFormMessageLabel").css("color","rgb(82,82,82)");

						    		$("#tellAFriendForm").get(0).reset();
						    	},6000);
							}
						});
					}
					else
					{
						$(".tell-a-friend-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Sending'> Please fill in all fields.").slideDown("fast");
	  				}
  				},function(){});
  			}

			if($("#accountLoginForm").length)
			{
				$("button[name=accountLoginLoginBtn]").bind("click",function()
  				{
  					var errors = 0;

  					if($("input[name=accountLoginUsername]").val())
	  				{
	  					$("label#accountLoginUsernameLabel").css("color","rgb(82,82,82)");

	  					var username = $("input[name=accountLoginUsername]").val();
	  				}
  					else
  					{
  						errors++;

  						$("#accountLoginUsernameLabel").css("color","rgb(205,57,70)");
  					}

  					if($("input[name=accountLoginPassword]").val())
	  				{
	  					$("label#accountLoginPasswordLabel").css("color","rgb(82,82,82)");

	  					var password = $("input[name=accountLoginPassword]").val();
	  				}
  					else
  					{
  						errors++;

  						$("#accountLoginPasswordLabel").css("color","rgb(205,57,70)");
  					}

  					if(errors == 0)
					{
						$(".login-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/ajax-loader.gif' alt='Checking credentials...'> Checking credentials...").slideDown("fast");

						$.ajax(
						{
							cache:false,
							type:"POST",
							url:document.location.href,
							dataType:"html",
							data:"action=login&username=" + escape(username) + "&password=" + escape(password),
							success:function(data,textStatus,XMLHttpRequest)
							{
								if(data == "passed1")
								{
									$(".login-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/tick.png' alt='Found'> Found! Redirecting...");

									setTimeout(function()
									{
							  			$(".login-form-result").slideUp("fast");

							  			$("label#accountLoginFormUsernameLabel").css("color","rgb(82,82,82)");
					  					$("label#accountLoginFormPasswordLabel").css("color","rgb(82,82,82)");

							    		$("#accountLoginForm").get(0).reset();

							    		window.location.href = "/wp-admin/";
							    	},1000);
								}
								else if(data == "passed2")
								{
									$(".login-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/tick.png' alt='Found'> Found! Redirecting...");

									setTimeout(function()
									{
							  			$(".login-form-result").slideUp("fast");

							  			$("label#accountLoginFormUsernameLabel").css("color","rgb(82,82,82)");
					  					$("label#accountLoginFormPasswordLabel").css("color","rgb(82,82,82)");

							    		$("#accountLoginForm").get(0).reset();

							    		window.location.href = "/my-account/";
							    	},1000);
								}
								else
								{
									$(".login-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Failed'> Incorrect Username and Password!");
								}
							},
							error:function(XMLHttpRequest,textStatus,errorThrown)
							{
								//alert(XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
							},
							complete:function(XMLHttpRequest,textStatus)
							{
							}
						});
					}
					else
					{
						$(".login-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Error'> Please fill in your Username and Password.").slideDown("fast");
	  				}
  				},function(){});
  			}

  			if($("#accountForgottenPasswordForm").length)
			{
				$("button[name=accountForgottenPasswordBtn]").bind("click",function()
  				{
  					var errors = 0;

  					if($("input[name=accountForgottenPasswordUsername]").val())
	  				{
	  					$("label#accountForgottenPasswordUsernameLabel").css("color","rgb(82,82,82)");

	  					var username = $("input[name=accountForgottenPasswordUsername]").val();
	  				}
  					else
  					{
  						errors++;

  						$("#accountForgottenPasswordUsernameLabel").css("color","rgb(205,57,70)");
  					}

  					if(errors == 0)
					{
						$(".forgotten-password-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/ajax-loader.gif' alt='Resetting password...'> Resetting password...").slideDown("fast");

						$.ajax(
						{
							cache:false,
							type:"POST",
							url:document.location.href,
							dataType:"html",
							data:"action=forgotten&username=" + escape(username),
							success:function(data,textStatus,XMLHttpRequest)
							{
								if(data == "reset")
								{
									$(".forgotten-password-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/tick.png' alt='Successful'> Successful! A new Password has been sent to your registered Email Address.");

									setTimeout(function()
									{
							  			$(".forgotten-password-form-result").slideUp("fast");

							  			$("label#accountForgottenPasswordUsernameLabel").css("color","rgb(82,82,82)");

							    		$("#accountForgottenPasswordForm").get(0).reset();
							    	},10000);
								}
								else
								{
									$(".forgotten-password-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Failed'> There is no user registered with that Username or Email Address.");
								}
							},
							error:function(XMLHttpRequest,textStatus,errorThrown)
							{
								//alert(XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
							},
							complete:function(XMLHttpRequest,textStatus)
							{
							}
						});
					}
					else
					{
						$(".forgotten-password-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Error'> Please fill in your Username or Email Address.").slideDown("fast");
	  				}
  				},function(){});
  			}

  			if($("#accountRegisterForm").length)
			{
  				$("button[name=accountRegisterRegisterBtn]").bind("click",function()
  				{
  					var errors = 0;
  					var confirm_errors = 0;

  					if($("input[name=accountRegisterFirstName]").val())
	  				{
	  					$("label#accountRegisterFirstNameLabel").css("color","rgb(82,82,82)");

	  					var firstname = $("input[name=accountRegisterFirstName]").val();
	  				}
  					else
  					{
  						errors++;

  						$("#accountRegisterFirstNameLabel").css("color","rgb(205,57,70)");
  					}

  					if($("input[name=accountRegisterLastName]").val())
	  				{
	  					$("label#accountRegisterLastNameLabel").css("color","rgb(82,82,82)");

	  					var lastname = $("input[name=accountRegisterLastName]").val();
	  				}
  					else
  					{
  						errors++;

  						$("#accountRegisterLastNameLabel").css("color","rgb(205,57,70)");
  					}

  					 if($("input[name=accountRegisterUsername]").val())
	  				{
	  					$("label#accountRegisterUsernameLabel").css("color","rgb(82,82,82)");

	  					var username = $("input[name=accountRegisterUsername]").val();
	  				}
  					else
  					{
  						errors++;

  						$("#accountRegisterUsernameLabel").css("color","rgb(205,57,70)");
  					}

  					if($("input[name=accountRegisterEmail]").val())
	  				{
	  					if(!$("input[name=accountRegisterEmail]").val().match(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.@-]+\.[A-Za-z]{2,6}$/))
	  					{
	  						errors++;
	  					}
	  					else
	  					{
	  						$("label#accountRegisterEmailLabel").css("color","rgb(82,82,82)");

	  						var email = $("input[name=accountRegisterEmail]").val();
	  					}
	  				}
  					else
  					{
  						errors++;

  						$("label#accountRegisterEmailLabel").css("color","rgb(205,57,70)");
  					}

  					if($("input[name=accountRegisterPassword]").val())
	  				{
	  					$("label#accountRegisterPasswordLabel").css("color","rgb(82,82,82)");

	  					var password = $("input[name=accountRegisterPassword]").val();
	  				}
  					else
  					{
  						errors++;

  						$("#accountRegisterPasswordLabel").css("color","rgb(205,57,70)");
  					}

  					if($("input[name=accountRegisterConfirmPassword]").val())
	  				{
	  					$("label#accountRegisterConfirmPasswordLabel").css("color","rgb(82,82,82)");

	  					var confirm = $("input[name=accountRegisterConfirmPassword]").val();
	  				}
  					else
  					{
  						errors++;

  						$("#accountRegisterConfirmPasswordLabel").css("color","rgb(205,57,70)");
  					}

  					if($("input[name=accountRegisterPassword]").val() && $("input[name=accountRegisterConfirmPassword]").val())
  					{
  						if($("input[name=accountRegisterPassword]").val() === $("input[name=accountRegisterConfirmPassword]").val())
  						{
  						}
  						else
  						{
  							confirm_errors++;

  							$("#accountRegisterPasswordLabel").css("color","rgb(205,57,70)");

  							$("#accountRegisterConfirmPasswordLabel").css("color","rgb(205,57,70)");
  						}
  					}

  					if(errors == 0 && confirm_errors == 0)
					{
						$(".register-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/ajax-loader.gif' alt='Registering'> Registering...").slideDown("fast");

						$.ajax(
						{
							cache:false,
							type:"POST",
							url:document.location.href,
							dataType:"html",
							data:"action=register&firstname=" + escape(firstname) + "&lastname=" + escape(lastname) + "&username=" + escape(username) + "&email=" + escape(email) + "&password=" + escape(password),
							success:function(data,textStatus,XMLHttpRequest)
							{
								if(data == "registered")
								{
									$(".register-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/tick.png' alt='Successful'> Successful! Thank you for registering an account with us. Please check your email in a few moments.");

									setTimeout(function()
									{
							  			$(".register-form-result").slideUp("fast");

							  			$("label#accountRegisterFirstNameLabel").css("color","rgb(82,82,82)");
							  			$("label#accountRegisterLastNameLabel").css("color","rgb(82,82,82)");
							  			$("label#accountRegisterUsernameLabel").css("color","rgb(82,82,82)");
							  			$("label#accountRegisterEmailLabel").css("color","rgb(82,82,82)");
					  					$("label#accountRegisterPasswordLabel").css("color","rgb(82,82,82)");
					  					$("label#accountRegisterConfirmPasswordLabel").css("color","rgb(82,82,82)");

							    		$("#accountRegisterForm").get(0).reset();
							    	},10000);
								}
								else if(data == "error_occurred")
								{
									$(".register-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Error'> A problem occurred while trying to create your account.").slideDown("fast");
								}
								else if(data == "error_occurred")
								{
									$(".register-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Error'> A problem occurred while trying to create your account.").slideDown("fast");
								}
								else if(data == "email_already_exists")
								{
									$(".register-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Error'> This Email Address is already registered, please choose another one.").slideDown("fast");
								}
								else if(data == "username_already_exists")
								{
									$(".register-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Error'> This Username is already registered, please choose another one.").slideDown("fast");
								}
								else if(data == "username_not_valid")
								{
									$(".register-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Error'> This Username is invalid. Please enter a valid Username.").slideDown("fast");
								}
							},
							error:function(XMLHttpRequest,textStatus,errorThrown)
							{
								//alert(XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
							},
							complete:function(XMLHttpRequest,textStatus)
							{
							}
						});
					}
					else
					{
						$(".register-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Error'> Please fill in all fields.").slideDown("fast");

	  					if(confirm_errors > 0)
	  					{
	  						$(".register-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Error'> Passwords do not match.").slideDown("fast");
	  					}
	  				}
  				},function(){});
  			}

  			if($("#myProfileForm").length)
			{
  				$("button[name=myProfileUpdateBtn]").bind("click",function()
  				{
  					var errors = 0;

  					var id = $("input[name=myProfileUserID]").val();

  					if($("input[name=myProfileUsername]").val())
	  				{
	  					$("label#myProfileUsernameLabel").css("color","rgb(82,82,82)");

	  					var username = $("input[name=myProfileUsername]").val();
	  				}
  					else
  					{
  						errors++;

  						$("#myProfileUsernameLabel").css("color","rgb(205,57,70)");
  					}

  					if($("input[name=myProfileFirstName]").val())
	  				{
	  					$("label#myProfileFirstNameLabel").css("color","rgb(82,82,82)");

	  					var firstname = $("input[name=myProfileFirstName]").val();
	  				}
  					else
  					{
  						errors++;

  						$("label#myProfileFirstNameLabel").css("color","rgb(205,57,70)");
  					}

  					 if($("input[name=myProfileLastName]").val())
	  				{
	  					$("label#myProfileLastNameLabel").css("color","rgb(82,82,82)");

	  					var lastname = $("input[name=myProfileLastName]").val();
	  				}
  					else
  					{
  						errors++;

  						$("#myProfileLastNameLabel").css("color","rgb(205,57,70)");
  					}

  					if($("input[name=myProfileEmail]").val())
	  				{
	  					if(!$("input[name=myProfileEmail]").val().match(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.@-]+\.[A-Za-z]{2,6}$/))
	  					{
	  						errors++;
	  					}
	  					else
	  					{
	  						$("label#myProfileEmailLabel").css("color","rgb(82,82,82)");

	  						var email = $("input[name=myProfileEmail]").val();
	  					}
	  				}
  					else
  					{
  						errors++;

  						$("label#myProfileEmailLabel").css("color","rgb(205,57,70)");
  					}

  					if(errors == 0)
					{
						$(".my-profile-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/ajax-loader.gif' alt='Updating'> Updating...").slideDown("fast");

						$.ajax(
						{
							cache:false,
							type:"POST",
							url:document.location.href,
							dataType:"html",
							data:"action=profile-update&id=" + escape(id) + "&firstname=" + escape(firstname) + "&lastname=" + escape(lastname) + "&username=" + escape(username) + "&email=" + escape(email),
							success:function(data,textStatus,XMLHttpRequest)
							{
								if(data == "updated")
								{
									$(".my-profile-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/tick.png' alt='Successful'> Successful!  Your profile details have been updated.");

									setTimeout(function()
									{
							  			$(".my-profile-form-result").fadeOut("slow",function()
							  			{
							  				$(".my-profile-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/information.png' alt='Information'> Changes to your profile have been detected. Please <a href='' title=''>refresh this page</a> to view these changes.</p>").fadeIn("slow");
							  			},function(){});

							  			$("label#myProfileFirstNameLabel").css("color","rgb(82,82,82)");
							  			$("label#myProfileLastNameLabel").css("color","rgb(82,82,82)");
							  			$("label#myProfileUsernameLabel").css("color","rgb(82,82,82)");
							  			$("label#myProfileEmailLabel").css("color","rgb(82,82,82)");

							    		$("#myProfileForm").get(0).reset();
							    	},6000);
								}
								else if(data == "error_occurred")
								{
									$(".my-profile-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Error'> A problem occurred while trying to create your account.").slideDown("fast");
								}
								else if(data == "error_occurred")
								{
									$(".my-profile-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Error'> A problem occurred while trying to create your account.").slideDown("fast");
								}
								else if(data == "email_already_exists")
								{
									$(".my-profile-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Error'> This Email Address is already registered, please choose another one.").slideDown("fast");
								}
								else if(data == "username_already_exists")
								{
									$(".my-profile-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Error'> This Username is already registered, please choose another one.").slideDown("fast");
								}
								else if(data == "username_not_valid")
								{
									$(".my-profile-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Error'> This Username is invalid. Please enter a valid Username.").slideDown("fast");
								}
							},
							error:function(XMLHttpRequest,textStatus,errorThrown)
							{
								//alert(XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
							},
							complete:function(XMLHttpRequest,textStatus)
							{
							}
						});
					}
					else
					{
						$(".my-profile-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Error'> Please fill in all fields.").slideDown("fast");
	  				}
  				},function(){});
  			}

  			if($("#myProfilePasswordForm").length)
			{
  				$("button[name=myProfileChangeBtn]").bind("click",function()
  				{
  					var errors = 0;
  					var confirm_errors = 0;

  					var id = $("input[name=myProfileUserID]").val();

  					if($("input[name=myProfilePassword]").val())
	  				{
	  					$("label#myProfilePasswordLabel").css("color","rgb(82,82,82)");

	  					var oldpassword = $("input[name=myProfilePassword]").val();
	  				}
  					else
  					{
  						errors++;

  						$("#myProfilePasswordLabel").css("color","rgb(205,57,70)");
  					}

  					if($("input[name=myProfileNewPassword]").val())
	  				{
	  					$("label#myProfileNewPasswordLabel").css("color","rgb(82,82,82)");

	  					var newpassword = $("input[name=myProfileNewPassword]").val();
	  				}
  					else
  					{
  						errors++;

  						$("#myProfileNewPasswordLabel").css("color","rgb(205,57,70)");
  					}

  					if($("input[name=myProfileConfirmPassword]").val())
	  				{
	  					$("label#myProfileConfirmPasswordLabel").css("color","rgb(82,82,82)");

	  					var confirm = $("input[name=myProfileConfirmPassword]").val();
	  				}
  					else
  					{
  						errors++;

  						$("#myProfileConfirmPasswordLabel").css("color","rgb(205,57,70)");
  					}

  					if($("input[name=myProfileNewPassword]").val() && $("input[name=myProfileConfirmPassword]").val())
  					{
  						if($("input[name=myProfileNewPassword]").val() === $("input[name=myProfileConfirmPassword]").val())
  						{
  						}
  						else
  						{
  							confirm_errors++;

  							$("#myProfileConfirmPasswordLabel").css("color","rgb(205,57,70)");

  							$("#myProfileNewPassword").css("color","rgb(205,57,70)");
  						}
  					}

  					if(errors == 0 && confirm_errors == 0)
					{
						$(".my-profile-password-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/ajax-loader.gif' alt='Changing'> Changing...").slideDown("fast");

						$.ajax(
						{
							cache:false,
							type:"POST",
							url:document.location.href,
							dataType:"html",
							data:"action=password-change&id=" + escape(id) + "&old=" + escape(oldpassword) + "&new=" + escape(newpassword),
							success:function(data,textStatus,XMLHttpRequest)
							{
								if(data == "changed")
								{
									$(".my-profile-password-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/tick.png' alt='Successful'> Successful! Your profile password has been changed.");

									setTimeout(function()
									{
							  			$(".my-profile-password-form-result").slideUp("fast");

							  			$("label#myProfilePasswordLabel").css("color","rgb(82,82,82)");
					  					$("label#myProfileNewPasswordLabel").css("color","rgb(82,82,82)");
					  					$("label#myProfileConfirmPasswordLabel").css("color","rgb(82,82,82)");

							    		$("#myProfilePasswordForm").get(0).reset();
							    	},10000);
								}
								else if(data == "failed")
								{
									$(".my-profile-password-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Error'> A problem occurred while trying to change your password.  Please make sure your old password is correct.").slideDown("fast");
								}
							},
							error:function(XMLHttpRequest,textStatus,errorThrown)
							{
								//alert(XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
							},
							complete:function(XMLHttpRequest,textStatus)
							{
							}
						});
					}
					else
					{
						$(".my-profile-password-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Error'> Please fill in all fields.").slideDown("fast");

	  					if(confirm_errors > 0)
	  					{
	  						$(".my-profile-password-form-result").html("<img src='/wp-content/themes/oconnorshannon/assets/img/exclamation.png' alt='Error'> Passwords do not match.").slideDown("fast");
	  					}
	  				}
  				},function(){});
  			}

  			$("select[name=homepageSearchPropertyType]").change(function()
			{
				OConnorShannon.Page.resetSearchOptions("homepage",new Array("Location","MinValue","MaxValue"));

				$.ajax(
				{
					cache:true,
					type:"POST",
					url:document.location.href,
					dataType:"html",
					data:"action=get-locations&property-type=" + $("select[name=homepageSearchPropertyType]").val() + "&search-type=" + $("input[name=homepageSearchType]:checked").val(),
					success:function(data,textStatus,XMLHttpRequest)
					{
						$("select[name=homepageSearchLocation]").html(data);
					},
					error:function(XMLHttpRequest,textStatus,errorThrown)
					{
						//alert("ACTION: get-locations 1: homepageSearchPropertyType\n\n" + XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
					},
					complete:function(XMLHttpRequest,textStatus)
					{
						$.ajax(
						{
							cache:true,
							type:"POST",
							url:document.location.href,
							dataType:"html",
							data:"action=get-values&location=" + escape($("select[name=homepageSearchLocation]").val()) + "&property-type=" + $("select[name=homepageSearchPropertyType]").val() + "&search-type=" + $("input[name=homepageSearchType]:checked").val(),
							success:function(data,textStatus,XMLHttpRequest)
							{
								$("select[name=homepageSearchMinValue],select[name=homepageSearchMaxValue]").html(data);
							},
							error:function(XMLHttpRequest,textStatus,errorThrown)
							{
								//alert("ACTION: get-locations 2: homepageSearchPropertyType\n\n" + XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
							},
							complete:function(XMLHttpRequest,textStatus)
							{
							}
						});
					}
				});
			},function(){});

			$("select[name=sidebarEmailAlertSearchType]").change(function()
			{
				OConnorShannon.Page.resetSearchOptions("sidebarEmailAlert",new Array("Location","MinValue","MaxValue"));
			},function(){});

			$("select[name=sidebarEmailAlertPropertyType]").change(function()
			{
				OConnorShannon.Page.resetSearchOptions("sidebarEmailAlert",new Array("MinValue","MaxValue"));
			},function(){});

			$("select[name=sidebarSearchPropertyType]").change(function()
			{
				OConnorShannon.Page.resetSearchOptions("sidebar",new Array("Location","MinValue","MaxValue"));

				$.ajax(
				{
					cache:true,
					type:"POST",
					url:document.location.href,
					dataType:"html",
					data:"action=get-locations&property-type=" + $("select[name=sidebarSearchPropertyType]").val() + "&search-type=" + $("select[name=sidebarSearchType]").val(),
					success:function(data,textStatus,XMLHttpRequest)
					{
						$("select[name=sidebarSearchLocation]").html(data);
					},
					error:function(XMLHttpRequest,textStatus,errorThrown)
					{
						//alert("ACTION: get-values 1: sidebarSearchPropertyType\n\n" + XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
					},
					complete:function(XMLHttpRequest,textStatus)
					{
						$.ajax(
						{
							cache:true,
							type:"POST",
							url:document.location.href,
							dataType:"html",
							data:"action=get-values&location=" + escape($("select[name=sidebarSearchLocation]").val()) + "&property-type=" + $("select[name=sidebarSearchPropertyType]").val() + "&search-type=" + $("select[name=sidebarSearchType]").val(),
							success:function(data,textStatus,XMLHttpRequest)
							{
								$("select[name=sidebarSearchMinValue],select[name=sidebarSearchMaxValue]").html(data);
							},
							error:function(XMLHttpRequest,textStatus,errorThrown)
							{
								//alert("ACTION: get-values 2: sidebarSearchPropertyType\n\n" + XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
							},
							complete:function(XMLHttpRequest,textStatus)
							{
							}
						});
					}
				});
			},function(){});

			$("select[name=homepageSearchLocation]").change(function()
			{
				OConnorShannon.Page.resetSearchOptions("homepage",new Array("MinValue","MaxValue"));

				$.ajax(
				{
					cache:true,
					type:"POST",
					url:document.location.href,
					dataType:"html",
					data:"action=get-values&location=" + escape($("select[name=homepageSearchLocation]").val()) + "&property-type=" + $("select[name=homepageSearchPropertyType]").val() + "&search-type=" + $("input[name=homepageSearchType]:checked").val(),
					success:function(data,textStatus,XMLHttpRequest)
					{
						$("select[name=homepageSearchMinValue],select[name=homepageSearchMaxValue]").html(data);
					},
					error:function(XMLHttpRequest,textStatus,errorThrown)
					{
						//alert("ACTION: get-values: homepageSearchLocation\n\n" + XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
					},
					complete:function(XMLHttpRequest,textStatus)
					{
					}
				});
			},function(){});

			$("select[name=sidebarSearchLocation]").change(function()
			{
				OConnorShannon.Page.resetSearchOptions("sidebar",new Array("MinValue","MaxValue"));

				$.ajax(
				{
					cache:true,
					type:"POST",
					url:document.location.href,
					dataType:"html",
					data:"action=get-values&location=" + escape($("select[name=sidebarSearchLocation]").val()) + "&property-type=" + $("select[name=sidebarSearchPropertyType]").val() + "&search-type=" + $("select[name=sidebarSearchType]").val(),
					success:function(data,textStatus,XMLHttpRequest)
					{
						$("select[name=sidebarSearchMinValue],select[name=sidebarSearchMaxValue]").html(data);
					},
					error:function(XMLHttpRequest,textStatus,errorThrown)
					{
						//alert("ACTION: get-values: sidebarSearchLocation\n\n" + XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
					},
					complete:function(XMLHttpRequest,textStatus)
					{
					}
				});
			},function(){});

			$("select[name=homepageSearchMinValue]").change(function()
			{
				OConnorShannon.Page.resetSearchOptions("homepage",new Array("MaxValue"));
			},function(){});

			$("select[name=sidebarSearchMinValue]").change(function()
			{
				OConnorShannon.Page.resetSearchOptions("sidebar",new Array("MaxValue"));
			},function(){});

			$("select[name=sidebarEmailAlertMinValue]").change(function()
			{
				OConnorShannon.Page.resetSearchOptions("sidebarEmailAlert",new Array("MaxValue"));
			},function(){});

			$("select[name=homepageSearchMaxValue]").change(function()
			{
				if($("select[name=homepageSearchMaxValue]").val() == "All Prices" || $("select[name=homepageSearchMaxValue]").val() == "All Rents")
				{
				}
				else
				{
					if(parseInt($("select[name=homepageSearchMaxValue]").val()) < parseInt($("select[name=homepageSearchMinValue]").val()))
					{
						alert("The maximum value cannot be less than the minimum value.");

						OConnorShannon.Page.resetSearchOptions("homepage",new Array("MaxValue"));
					}
				}
			},function(){});

			$("select[name=sidebarSearchMaxValue]").change(function()
			{
				if($("select[name=sidebarSearchMaxValue]").val() == "All Prices" || $("select[name=sidebarSearchMaxValue]").val() == "All Rents")
				{
				}
				else
				{
					if(parseInt($("select[name=sidebarSearchMaxValue]").val()) < parseInt($("select[name=sidebarSearchMinValue]").val()))
					{
						alert("The maximum value cannot be less than the minimum value.");

						OConnorShannon.Page.resetSearchOptions("sidebar",new Array("MaxValue"));
					}
				}
			},function(){});

			$("select[name=sidebarEmailAlertMaxValue]").change(function()
			{
				if($("select[name=sidebarEmailAlertMaxValue]").val() == "All Prices" || $("select[name=sidebarEmailAlertMaxValue]").val() == "All Rents")
				{
				}
				else
				{
					if(parseInt($("select[name=sidebarEmailAlertMaxValue]").val()) < parseInt($("select[name=sidebarEmailAlertMinValue]").val()))
					{
						alert("The maximum value cannot be less than the minimum value.");

						OConnorShannon.Page.resetSearchOptions("sidebarEmailAlert",new Array("MaxValue"));
					}
				}
			},function(){});

			$("a").filter(function()
			{
				return this.hostname && this.hostname !== window.location.hostname;

			},function(){}).click(function()
			{
				window.open(this.href);

				return false;
			},function(){});

			if($("form").length)
			{
				if($("#myProfileForm").length || $("input[name=passwordStrength]").length)
				{
				}
				else
				{
					$("input[type=text]").focus(function()
					{
						if($(this).val() == $(this).attr("defaultValue"))
						{
  							$(this).val("");
						}
					},function(){}).blur(function()
					{
						if($(this).val() == "")
						{
		 			 		$(this).val($(this).attr("defaultValue"));
						}
					},function(){});
				}
			}
		},

		deleteEmailAlert:function(alertID,userID,rowID)
		{
			$.ajax(
			{
				cache:true,
				type:"POST",
				url:document.location.href,
				data:"action=delete-alert&alert=" + alertID + "&user=" + userID,
				success:function(data,textStatus,XMLHttpRequest)
				{
					$("#" + rowID).fadeOut("slow");

					if(data == 0)
					{
						$(".grid").fadeOut("slow");

						$("#tableContainer").html("<p class='notification'><img src='/wp-content/themes/oconnorshannon/assets/img/information.png' alt='Information'> Sorry, we have no saved email alerts for you at the moment.</p>").fadeIn("slow");
					}
				},
				error:function(XMLHttpRequest,textStatus,errorThrown)
				{
					//alert(XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
				},
				complete:function(XMLHttpRequest,textStatus)
				{
				}
			});
		},

		addFavorite:function(propertyID,userID,adType,propertyHost)
		{
			$.ajax(
			{
				cache:true,
				type:"POST",
				url:document.location.href,
				data:"action=add-favorite&property=" + propertyID + "&user=" + userID + "&type=" + adType + "&host=" + propertyHost,
				success:function(data,textStatus,XMLHttpRequest)
				{
					$("#p" + propertyID + ".favorite_notification").html("<img src='/wp-content/themes/oconnorshannon/assets/img/tick.png' alt='Successful'> Added to your Favorites list.").slideDown("fast");

					$("#f" + propertyID).html("<img src='/wp-content/themes/oconnorshannon/assets/img/tick.png' style='vertical-align:middle;margin-bottom:2px;' alt=''> Marked as Favorite");

					setTimeout(function()
					{
			  			$("#p" + propertyID + ".favorite_notification").slideUp("fast");
			    	},6000);
				},
				error:function(XMLHttpRequest,textStatus,errorThrown)
				{
					//alert(XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
				},
				complete:function(XMLHttpRequest,textStatus)
				{
				}
			});
		},

		deleteFavorite:function(favoriteID,userID,rowID)
		{
			$.ajax(
			{
				cache:true,
				type:"POST",
				url:document.location.href,
				data:"action=delete-favorite&favorite=" + favoriteID + "&user=" + userID,
				success:function(data,textStatus,XMLHttpRequest)
				{
					$("#" + rowID).fadeOut("slow");

					if(data == 0)
					{
						$(".grid").fadeOut("slow");

						$("#tableContainer").html("<p class='notification'><img src='/wp-content/themes/oconnorshannon/assets/img/information.png' alt='Information'> Sorry, we have no saved favorites for you at the moment.</p>").fadeIn("slow");
					}
				},
				error:function(XMLHttpRequest,textStatus,errorThrown)
				{
					//alert(XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
				},
				complete:function(XMLHttpRequest,textStatus)
				{
				}
			});
		},

		resetSearchOptions:function(where,formElements)
		{
			$.each(formElements,function(counter,formElement)
			{
				if(where == "sidebar" || where == "homepage")
				{
					$("select[name=" + where + "Search" + formElement + "] option:eq(0)").attr("selected","selected");
				}
				else
				{
					$("select[name=" + where + formElement + "] option:eq(0)").attr("selected","selected");
				}
			});
		},

		loadForSaleSearchType:function(labels)
		{
			$("input[name=homepageSearchType]:first").attr("checked","checked");

			OConnorShannon.Page.loadHomepageSearchOptions(labels);
		},

		loadHomepageSearchOptions:function(labels)
		{
			var options = "";

			$.each(labels,function(counter,option)
			{
				if(option.substring(0,1) == "_")
				{
					options += '<option value="' + option.substring(1,option.length) + '">' + option.substring(1,option.length) + '</option>';
				}
				else
				{
					options += '<option value="' + counter + '">' + option + '</option>';
				}
			});

			$("select[name=homepageSearchPropertyType]").html(options);

			$.ajax(
			{
				cache:true,
				type:"POST",
				dataType:"html",
				url:document.location.href,
				data:"action=get-locations&property-type=" + $("select[name=homepageSearchPropertyType]").val() + "&search-type=" + $("input[name=homepageSearchType]:checked").val(),
				success:function(data,textStatus,XMLHttpRequest)
				{
					$("select[name=homepageSearchLocation]").html(data);
				},
				error:function(XMLHttpRequest,textStatus,errorThrown)
				{
					//alert("ACTION: get-values 1\n\n" + XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
				},
				complete:function(XMLHttpRequest,textStatus)
				{
					$.ajax(
					{
						cache:true,
						type:"POST",
						dataType:"html",
						url:document.location.href,
						data:"action=get-values&location=all-locations&property-type=" + $("select[name=homepageSearchPropertyType]").val() + "&search-type=" + $("input[name=homepageSearchType]:checked").val(),
						success:function(data,textStatus,XMLHttpRequest)
						{
							$("select[name=homepageSearchMinValue],select[name=homepageSearchMaxValue]").html(data);
						},
						error:function(XMLHttpRequest,textStatus,errorThrown)
						{
							//alert("ACTION: get-values 2\n\n" + XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
						},
						complete:function(XMLHttpRequest,textStatus)
						{
						}
					});
				}
			});
		},

		loadSidebarSearchOptions:function(labels)
		{
			var options = "";

			$.each(labels,function(counter,option)
			{
				if(option.substring(0,1) == "_")
				{
					options += '<option value="' + option.substring(1,option.length) + '">' + option.substring(1,option.length) + '</option>';
				}
				else
				{
					options += '<option value="' + counter + '">' + option + '</option>';
				}
			});

			$("select[name=sidebarSearchPropertyType]").html(options);

			$.ajax(
			{
				cache:true,
				type:"POST",
				dataType:"html",
				url:document.location.href,
				data:"action=get-locations&property-type=" + $("select[name=sidebarSearchPropertyType]").val() + "&search-type=" + $("select[name=sidebarSearchType]").val(),
				success:function(data,textStatus,XMLHttpRequest)
				{
					$("select[name=sidebarSearchLocation]").html(data);
				},
				error:function(XMLHttpRequest,textStatus,errorThrown)
				{
					//alert("ACTION: get-locations 1\n\n" + XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
				},
				complete:function(XMLHttpRequest,textStatus)
				{
					$.ajax(
					{
						cache:true,
						type:"POST",
						dataType:"html",
						url:document.location.href,
						data:"action=get-values&location=all-locations&property-type=" + $("select[name=sidebarSearchPropertyType]").val() + "&search-type=" + $("select[name=sidebarSearchType]").val(),
						success:function(data,textStatus,XMLHttpRequest)
						{
							$("select[name=sidebarSearchMinValue],select[name=sidebarSearchMaxValue]").html(data);
						},
						error:function(XMLHttpRequest,textStatus,errorThrown)
						{
							//alert("ACTION: get-locations 2\n\n" + XMLHttpRequest.statusText + "\n\n" + textStatus + "\n\n" + errorThrown);
						},
						complete:function(XMLHttpRequest,textStatus)
						{
						}
					});
				}
			});
		},

		loadXMLGenerals:function()
		{
			var request = false;

			if(window.XMLHttpRequest)
			{
				request = new XMLHttpRequest();

				if(request.overrideMimeType)
				{
					request.overrideMimeType("text/xml");
				}
			}
			else if(window.ActiveXObject)
			{
				request = new ActiveXObject("Microsoft.XMLHTTP");
			}

			request.open("GET","/wp-content/themes/oconnorshannon/generals.xml",true);

			request.onreadystatechange = function()
			{
				if(request.readyState != 4)
				{
					return;
				}

				if(request.status != 200 && request.status != 304)
				{
					return;
				}

				var xmlDoc = "";

				if($.browser.msie)
				{
					xmlDoc = OConnorShannon.Page.stringtoXML(request.responseText);
				}
				else
				{
					xmlDoc = request.responseXML;
				}

				var options = "";

				$.each(xmlDoc.documentElement.getElementsByTagName("general"),function(counter,general)
				{
					options += '<option value="general_areas|' + general.getAttribute("id") + '">' + general.getAttribute("title") + '</option>';
				});

				$("select[name=sidebarEmailAlertLocation]").append(options);
			}

			if(request.readyState == 4)
			{
				return;
			}

			request.send(null);
		},

		loadXMLPostcodes:function()
		{
			var request = false;

			if(window.XMLHttpRequest)
			{
				request = new XMLHttpRequest();

				if(request.overrideMimeType)
				{
					request.overrideMimeType("text/xml");
				}
			}
			else if(window.ActiveXObject)
			{
				request = new ActiveXObject("Microsoft.XMLHTTP");
			}

			request.open("GET","/wp-content/themes/oconnorshannon/postcodes.xml",true);

			request.onreadystatechange = function()
			{
				if(request.readyState != 4)
				{
					return;
				}

				if(request.status != 200 && request.status != 304)
				{
					return;
				}

				var xmlDoc = "";

				if($.browser.msie)
				{
					xmlDoc = OConnorShannon.Page.stringtoXML(request.responseText);
				}
				else
				{
					xmlDoc = request.responseXML;
				}

				var options = "";

				$.each(xmlDoc.documentElement.getElementsByTagName("postcode"),function(counter,postcode)
				{
					options += '<option value="postcodes|' + postcode.getAttribute("id") + '">' + postcode.getAttribute("title") + '</option>';
				});

				$("select[name=sidebarEmailAlertLocation]").append(options);
			}

			if(request.readyState == 4)
			{
				return;
			}

			request.send(null);
		},

		loadXMLAreas:function()
		{
			var request = false;

			if(window.XMLHttpRequest)
			{
				request = new XMLHttpRequest();

				if(request.overrideMimeType)
				{
					request.overrideMimeType("text/xml");
				}
			}
			else if(window.ActiveXObject)
			{
				request = new ActiveXObject("Microsoft.XMLHTTP");
			}

			request.open("GET","/wp-content/themes/oconnorshannon/areas.xml",true);

			request.onreadystatechange = function()
			{
				if(request.readyState != 4)
				{
					return;
				}

				if(request.status != 200 && request.status != 304)
				{
					return;
				}

				var xmlDoc = "";

				if($.browser.msie)
				{
					xmlDoc = OConnorShannon.Page.stringtoXML(request.responseText);
				}
				else
				{
					xmlDoc = request.responseXML;
				}

				var options = "";

				$.each(xmlDoc.documentElement.getElementsByTagName("area"),function(counter,area)
				{
					options += '<option value="areas|' + area.getAttribute("id") + '">' + area.getAttribute("title") + '</option>';
				});

				$("select[name=sidebarEmailAlertLocation]").append(options);
			}

			if(request.readyState == 4)
			{
				return;
			}

			request.send(null);
		},

		stringtoXML:function(text)
		{
			if(window.ActiveXObject)
			{
				var doc = new ActiveXObject("Microsoft.XMLDOM");

				doc.async = "false";

				doc.loadXML(text);
			}
			else
			{
				var parser = new DOMParser();

				var doc = parser.parseFromString(text,"text/xml");
			}

			return doc;
		},

		createCookie:function(name,value,days)
		{
			if(days)
			{
				var date = new Date();

				date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));

				var expires = ";expires=" + date.toGMTString();
			}
			else
			{
				var expires = "";
			}

			document.cookie = name + "=" + value + expires + ";path=/";
		},

		checkCookie:function(name)
		{
			var nameEQ = name + "=";
			var ca = document.cookie.split(";");

			for(var i = 0; i < ca.length; i++)
			{
				var c = ca[i];

				while(c.charAt(0) == " ")
				{
					c = c.substring(1,c.length);
				}

				if(c.indexOf(nameEQ) == 0)
				{
					return c.substring(nameEQ.length,c.length);
				}
			}

			return null;
		},

		deleteCookie:function(name)
		{
			OConnorShannon.Page.createCookie(name,"",-1);
		},

		numberFormat:function(number,decimals,dec_point,thousands_sep)
		{
			var n = !isFinite(+number) ? 0 : +number,

			prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),

			sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,

			dec = (typeof dec_point === 'undefined') ? '.' : dec_point,

			s = '',

			toFixedFix = function (n, prec)
			{
				var k = Math.pow(10, prec);

				return '' + Math.round(n * k) / k;
			};

			s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');

			if (s[0].length > 3)
			{
				s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
			}

			if ((s[1] || '').length < prec)
			{
				s[1] = s[1] || '';

				s[1] += new Array(prec - s[1].length + 1).join('0');
			}

			return s.join(dec);
		},

		loadPropertyMap:function(full_address,lat,lng)
		{
			if($("#propertyMap").length)
			{
				var latlng = new google.maps.LatLng(lat,lng);

				var options =
				{
					zoom:13,
					center:latlng,
					mapTypeControl:true,
					mapTypeId:google.maps.MapTypeId.ROADMAP
				};

				var map = new google.maps.Map($("#propertyMap").get(0),options);

				var marker = new google.maps.Marker(
				{
					position:latlng,
					map:map,
					title:full_address
				});
			}
		},

		goToByScroll:function(anchor)
		{
			$("html,body").animate(
			{
				scrollTop:$("#" + anchor).offset().top
			},"slow");
		}
	}
};

(function($)
{
	var cache = [];

	$.preLoadImages = function()
	{
		var args_len = arguments.length;

		for(var i = args_len; i--;)
		{
			var cacheImage = document.createElement("img");
			cacheImage.src = arguments[i];
			cache.push(cacheImage);
		}
	}
})(jQuery);

var $ = window.jQuery.noConflict();

$(document).ready(function()
{
	OConnorShannon.Page.init();
});
