
$(document).ready(function(){
	$().pngFix();
       
    $("#fpackage").dropdownchecklist({ width: 154 });
	$('ul#bannerAni').innerfade({
		speed: 1000,
		timeout: 20000,
		type: 'random',
		containerheight: '108px'
	});
	
	/* Tests BodyID against menu classes to set active states */
	var bodyID = $("body").attr("id");
	$("ul#menu a").each(function(){
		if($(this).attr("class").indexOf(bodyID) != -1){
			$(this).addClass("active");
		}
	});
	
	/* used to make bullet points orange in ul list */
	$("ul.orange li").each(function(){
		$(this).wrapInner('<span>'+$(this).html()+'</span>');
	});
	
	$("div.tabs").tabs(".slider > div.slide", {         
		effect: "fade",
		fadeOutSpeed: "slow",
		rotate: true
	}).slideshow({
		clickable: false,
		interval: 10000
	});
	
	$(document).ready(function(){
		if($("div.tabs").length != 0){
			setTimeout('$("div.tabs").tabs().play()',10000);
		}
	});
	
	$("a.play").css("display","none");
	
	$("a.stop").click(function(){
		$("div.tabs").tabs().stop();
		$("a.play").css("display","block");
		$(this).css("display","none");
		return false;
	});
	
	$("a.play").click(function(){
		$("div.tabs").tabs().play();
		$("a.stop").css("display","block");
		$(this).css("display","none");
		return false;
	});
	
	$(".controls .tabs a").click(function(){
		$("div.tabs").tabs().stop();
		$("a.play").css("display","block");
		$("a.stop").css("display","none");
		return false;
	});
	
	if($("body").attr("id") == "aboutus"){
		if (GBrowserIsCompatible()) {
			var map = new GMap2(document.getElementById("map_canvas"));
		
			map.setCenter(new GLatLng(-27, 134), 4);
		
		
			var marker1 = new GMarker(new GLatLng(-35.316061, 149.098489)); <!--act-->
			var marker2 = new GMarker(new GLatLng(-33.874082, 151.216827)); <!--nsw-->
			var marker3 = new GMarker(new GLatLng(-27.478223, 152.989304)); <!--qld-->
			var marker4 = new GMarker(new GLatLng(-34.940902, 138.611317)); <!--sa-->
			var marker5 = new GMarker(new GLatLng(-37.811836, 145.01349)); <!-- vic taz-->
			var marker6 = new GMarker(new GLatLng(-31.946447, 115.821214)); <!--wa-->
		
			map.addOverlay(marker1);
			map.addOverlay(marker2);
			map.addOverlay(marker3);
			map.addOverlay(marker4);
			map.addOverlay(marker5);
			map.addOverlay(marker6);
		
			map.addControl(new GSmallMapControl());
			map.addControl(new GMapTypeControl());
		
			window.map = map;
		}
	}
	
	//Quote Submit
	$(".quoteWrap input.quote").click(function() {
		// validate and process form here
		var fields = ["fname","fcompany","fphonenumber","femail", "fpostcode", "fstate", "fpackage"];
		
		jQuery.each(fields, function() {
			$("#" + this).removeClass("error");
		});
		var NoErrors="yes";
		jQuery.each(fields, function() {
			if ($("#" + this).val() == "") {
				$("#" + this).addClass("error");
				$("#" + this).focus();
				NoErrors = "no";
			}
		});
		if(NoErrors == "yes") {
			var licensed = $(".quoteWrap input#flicensed").is(':checked');
			$.ajax({
				type: "POST",
				url: "/wp-content/themes/hubonline/mail_quote.php",
				data: $(".quoteWrap form").serialize(),
				success: function() {
					pageTracker._trackPageview('/getaquote.php');
					$(".quoteWrap form").html("<div id='message' style='text-align:center;'></div>");
					if(licensed == true){
						$('#message').html("<h2>Thankyou for<br/>your quote request</h2>")
						.append("<p>One of our sales representatives will endeavor to contact you in the next 48hrs.</p>")
						.append("<p><em>Must know right now?</em><br/>Please call <b>1300 793 341</b>.</p>");
					}else{
						$('#message').html("<h2>Sorry we are<br/>unable to process the quote</h2>")
						.append("<p><strong>Unfortunately </strong>we are unable to provide a quote as you are not a licensed real estate agent.</p>")
						.append("<p><em>Need Help?</em><br/>Please call <b>1300 793 341</b>.</p>");
					}
				}
			});
		}
		return false;
	});
	
	//Support Submit
	$(".supportForm input.submit").click(function() {
		// validate and process form here
		var fields = ["fname","fphonenumber","femail","fstate", "fcomments"];
		
		jQuery.each(fields, function() {
			$("#" + this).removeClass("error");
		});
		var NoErrors="yes";
		jQuery.each(fields, function() {
			if ($("#" + this).val() == "") {
				$("#" + this).addClass("error");
				$("#" + this).focus();
				NoErrors = "no";
			}
		});
		if(NoErrors == "yes") {
			$.ajax({
				type: "POST",
				url: "/wp-content/themes/hubonline/support_quote.php",
				data: $(".supportForm form").serialize(),
				success: function() {
					pageTracker._trackPageview('/getsupport.php');
					$(".supportForm").html("<div id=\"message\" style=\"text-align:center;\"></div>");
					$('#message').html("<h2>Thankyou for your Message</h2>")
					.append("<p>One of our support team members will endeavor to contact you in the next 24hrs.</p><br/>")
					.append("<h3>Have you heard of our CRM product?</h3>")
					.append("<p>Our CRM is designed to improve office processes and increase productivity. <a href=\"/software/\">more info...</a><p>")
					.append("<h3>Have you seen our new web offerings?</h3>")
					.append("<p><a href=\"/web-design/\">Click here to see our latest web offerings.</a></p>");
				}
			});
		}
		return false;
	});
	
	//Guidelines Acceptance Submit
	$(".guidelinesWrap input.submit").click(function() {
		// validate and process form here
		var fields = ["fagencyname","fdesignername","femail"];
		
		jQuery.each(fields, function() {
			$("#" + this).removeClass("error");
		});
		var NoErrors="yes";
		jQuery.each(fields, function() {
			if ($("#" + this).val() == "") {
				$("#" + this).addClass("error");
				$("#" + this).focus();
				NoErrors = "no";
			}
		});
		if(NoErrors == "yes") {
			$.ajax({
				type: "POST",
				url: "/wp-content/themes/hubonline/mail_guidelines.php",
				data: $(".guidelinesWrap form").serialize(),
				success: function() {
					pageTracker._trackPageview('/acceptguidelines.php');
					$(".guidelinesWrap").html("<div id=\"message\" style=\"text-align:center;\"></div>");
					$('#message').html("<h2>Thank you for accepting our guidelines</h2>");
				}
			});
		}
		return false;
	});
	
	//SEO Requirements Submit
	$(".seoWrap input.submit").click(function() {
		// validate and process form here
		var fields = ["fname","femail", "fstate","fcontactphone","fkeywords","fdescription","ftitle"];
		
		jQuery.each(fields, function() {
			$("#" + this).removeClass("error");
		});
		var NoErrors="yes";
		jQuery.each(fields, function() {
			if ($("#" + this).val() == "") {
				$("#" + this).addClass("error");
				$("#" + this).focus();
				NoErrors = "no";
			}
		});
		if(NoErrors == "yes") {
			$.ajax({
				type: "POST",
				url: "/wp-content/themes/hubonline/mail_seo.php",
				data: $(".seoWrap form").serialize(),
				success: function() {
					//pageTracker._trackPageview('/seorequirements.php');
					$(".seoWrap").html("<div id=\"message\" style=\"text-align:center;\"></div>");
					$('#message').html("<h2>Thankyou for your request</h2>")
					.append("<p>One of our support team members will endeavor to contact you in the next 24hrs.</p><br/>")
					.append("<h3>Have you heard of our CRM product?</h3>")
					.append("<p>Our CRM is designed to improve office processes and increase productivity. <a href=\"/software/\">more info...</a><p>")
					.append("<h3>Have you seen our new web offerings?</h3>")
					.append("<p><a href=\"/web-design/\">Click here to see our latest web offerings.</a></p>");
				}
			});
		}
		return false;
	});

});