/******************************************************

 rollover,push
 
******************************************************/

$(function (){
	$('a[href] img, input[type="image"]').mouseover(function() {
																													 
		var offimgSrc = $(this).attr("src");
		var onimgSrc = offimgSrc.replace("off", "on");
		var pushimgSrc = offimgSrc.replace("off", "push");
		
		$(this).attr("src", onimgSrc);
		$(this).css("background-image", "url("+offimgSrc+")");

		$(this).mousedown(function() {
			if ( $(this).hasClass("push") ) 
			$(this).attr("src", pushimgSrc);
			$(this).mouseup(function() {
				$(this).attr("src", offimgSrc);
			});
		});
		
		$(this).mouseout(function() {
			$(this).attr("src", offimgSrc);
		});
		
	});
});

/******************************************************

 new window
 
******************************************************/

$.extend($.expr[':'],{
  newWindow: function(a,i,m) {
    if(!a.href) {
      return false;
    }
    return a.hostname && a.hostname !== window.location.hostname;
  }
});
$(function(){
  $('a:newWindow').addClass('newWindow').click(function(){
    window.open(this.href);
    return false;
  });
	
	/* $('a[href^="guidemap.html"]').addClass('newWindow').click(function(){
    window.open(this.href,'guidemapWindow', 'width=700, height=600, menubar=yes, toolbar=yes, scrollbars=yes, resizable=yes, location=yes');
    return false;
  }); */

});



/******************************************************

 current page
 
******************************************************/

function globalNaviCurrent() {
	var url = location.pathname;

	if (url.match("top.html")) {
		$("div#globalNav ul li:nth-child(1) img").attr("style","border-bottom: 2px solid #017f00;");
		$("div#footerGlobalNav ul li:nth-child(1) a").attr("style","border-bottom: 1px solid #017f00;");
	} else if (url.match("forsalenow/")) {
		$("div#globalNav ul li:nth-child(2) img").attr("style","border-bottom: 2px solid #017f00;");
		$("div#footerGlobalNav ul li:nth-child(2) a").attr("style","border-bottom: 1px solid #017f00;");
	} else if (url.match("works/")) {
		$("div#globalNav ul li:nth-child(3) img").attr("style","border-bottom: 2px solid #017f00;");
		$("div#footerGlobalNav ul li:nth-child(3) a").attr("style","border-bottom: 1px solid #017f00;");
	} else if (url.match("ourbusiness/")) {
		$("div#globalNav ul li:nth-child(4) img").attr("style","border-bottom: 2px solid #017f00;");
		$("div#footerGlobalNav ul li:nth-child(4) a").attr("style","border-bottom: 1px solid #017f00;");
	} else if (url.match("aboutus/")) {
		$("div#globalNav ul li:nth-child(5) img").attr("style","border-bottom: 2px solid #017f00;");
		$("div#footerGlobalNav ul li:nth-child(5) a").attr("style","border-bottom: 1px solid #017f00;");
	} else if (url.match("privacypolicy/")) {
		$("div#globalNav ul li:nth-child(6) img").attr("style","border-bottom: 2px solid #5e5e5e;");
	}
};
$(document).ready(globalNaviCurrent);
