


$(document).ready
(
	
	function()
	{
		
		
		preloadImages("/z_assets/logos/nhbc_logo_off.gif", "/z_assets/logos/nhbc_logo_on.gif");
		$('a[href^="http://"]').attr("target", "_blank");
		
		
		var testimonials_count = $('.right_col h3.quote').length;
		if(testimonials_count > 0)
		{
			//alert(testimonials_count);	
			$('.right_col h3.quote').each(
			function(index)
			{
				if(index==0 && !$(this).hasClass('q_first') )
				{
					$(this).addClass('q_first');//ensure first quote hasn't got top border in CSS
				}
				$(this).find('span').after('<span class="jq_close">&nbsp;</span>');
				
				var h3_left = $(this).position().left;
				var h3_width = $(this).width();
				
				var el = $(this).find('span.jq_close');
				var pos = el.position();
				if(typeof(pos) != 'undefined')
				{
					var x = pos.left;
					var adjust_x = h3_width -h3_left - x;
					if(adjust_x < 0){x = x + adjust_x;}//if x strays outside h3 right edge pull it back
					var y = pos.top;
					var margin_top = 10;
					y = y + margin_top;
					
					el.css({'position' : 'absolute', 'left' : x,'top' : y});
					el.html('<img src="/z_images/close_quote.jpg" style="display:inline;" />');
				}
				
				//alert(' span x: '+pos.left,)
			}//function
		);//each
			
		}//testimonials
		$("img.img_swap").hover( 
			function() {
				$(this).attr('src','/z_assets/logos/nhbc_logo_on.gif');				
			},
			function() {
				$(this).attr('src','/z_assets/logos/nhbc_logo_off.gif');		
			}
		);//hover
		$("img.thumb_swap").hover( 
			function() {
				var src = $(this).attr('src');
				var swp = src.replace(/bw_/, "col_")
				$(this).attr('src',swp);				
			},
			function() {
				var src = $(this).attr('src');
				var swp = src.replace(/col_/, "bw_")
				$(this).attr('src',swp);					
			}
		);//hover
		
		var gallery_count = $('a[rel="gallerybox"]').length;
		if(gallery_count > 0)
		{
			//alert(testimonials_count);	
			$('a[rel="gallerybox"]').each(
			function(index)
			{
				var href = $(this).attr('href');
				href += '&jsv=true';
				$(this).attr('href',href);
			}//function
		);//each
			
		}//gallery_count
		$("img.thumbnail").hover( 
			function() {
				var thid = $(this).attr('id');
				var index = thid.replace(/th_/, "");//alert(thid);
				var swp = thumbs_on[index];
				$(this).attr('src',swp);				
			},
			function() {
				var thid = $(this).attr('id');
				var index = thid.replace(/th_/, "");
				var swp = thumbs_off[index];
				$(this).attr('src',swp);					
			}
		);//hover
		
	}//ready func
	
);



if(!Array.indexOf){//index of breaks ie
	Array.prototype.indexOf = function(obj){
		for(var i=0; i<this.length; i++){
			if(this[i]==obj){
				return i;
			}
		}
		return -1;
	}
}

try {//ie6 image swap cache problem
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

function isset( variable )
{

	return( typeof( variable ) != 'undefined' );

}
if(isset(window.preload) )
{
	for(var i=0; i<preload.length; i++){preload_obj.src =preload[i];}
}
function eml_snd(part2,part1)
{
	mail_str = 'mailto: '+part1+'@'+part2;
	return mail_str;
}

