(function($) {

$.ajaxSetup({cache: false});

function readmore(){
	$("#readmorelink").hide();
	$("#readmoretext").show();
	$("#brighton_three-column").css("margin-top","0px");
}
function readless(){
	$("#readmoretext").hide();
	$("#readmorelink").show();
	$("#brighton_three-column").css("margin-top","-90px");
}

function SplitPhoneNum(stringToSplit, charToSplit) {
    var myArray = stringToSplit.split(charToSplit);
    return myArray;
}

$(document).ready(function() {

//show read more text on homepage
$("#readmorelink a.readmore").click(function(){
	$("#readmorelink").hide();
	$("#readmoretext").show();
	$("#brighton_three-column").css("margin-top","0px");
});
//hide read more text on homepage
$("#readmoretext a.readless").click(function(){
	$("#readmoretext").hide();
	$("#readmorelink").show();
	$("#brighton_three-column").css("margin-top","-90px");
});

//move footerStuff to footer
if ( location.href.match('http://www.johnmooreservices.com/pest-control/')) {
	$.get('/Portals/77655/footerPestControl.html', function(data) {
		$('#footer').prepend(data);
	});
}
else if ( location.href.match('http://www.johnmooreservices.com/john-moore-renovation/')) {
	$.get('/Portals/77655/footerRenovations.html', function(data) {
		$('#footer').prepend(data);
	});
}
else {
	$.get('/Portals/77655/footerStuff1.html', function(data) {
		$('#footer').append(data);
	});
}



//google search box
$("#googlesearchbox").prependTo("#topnav");

// SHOW BLOG NAVIGATION OPTIONS IF LOGGED IN
if( $("#hsnavigation").length) {
    $("p.hk_menu").show();
}

// replace <!--zipcode--> with zip code request form html
$.get('/Portals/77655/zipCodeRequestForm.html', function(data) {
 	$('.zipcode').replaceWith(data);
});

// zip request input field
$(".ziprequest").live("keyup", function() {
	var theZip = $(this).val();
	$(".ziprequest").val(theZip);
});

// zip code request form submit
$(".zipsubmit").live("click", function() {
window.location.href='/schedule-service/?zip=' + $(this).prev("input").val();
return false;
});

// populate Online Service Request Form with zip from url
if(location.href.match('schedule-service')) {
var theUrl = location.href.split("=");
var theZip = theUrl[1];
$("label").each(function() {
if ($(this).text() == "Zip") {
$(this).next("input").val(theZip);
}
});
}

//form defaults for zip code form
$("div.zipform .ziprequest").val("enter zip code");
$(".ziprequest").live("click", function() {
	if($(this).val() == "enter zip code") $(this).val("");
});
$(".ziprequest").live("blur", function() {
	if($(this).val() == "") $(this).val("enter zip code");
});

//coupon subscribe block
$(".IngeniMailSubscribeContainer").closest(".block").addClass("couponsub");
$("div.couponsub .IngeniMailSubscribeButton").val("");
$("div.couponsub .IngeniMailSubscribeEmailInput").val("e-mail address");
$("div.couponsub .IngeniMailSubscribeEmailInput").click(function() {
	if($(this).val() == "e-mail address") $(this).val("");
});
$("div.couponsub .IngeniMailSubscribeEmailInput").blur(function() {
	if($(this).val() == "") $(this).val("e-mail address");
});

//blog feed block for homepage
$(".feedreader_box").closest(".block").addClass("maintenance");
$(".maintenance .pad").append('<a href="/blog/" class="readmore">READ MORE</a>');


// jquery for blog feed icons for different inner pages
//if(location.href.match('a-c-heating')) {
//	$(".maintenance h3").css("background-image", "url(hello.png)");
//}


//move map to right of address on contact page. only moves if not logged in
if( $("div.location-map").length && !$("#hsnavigation").length) {
	$("#map").prependTo("div.location-map");
}


});

})(jQuery);
