var $j = jQuery.noConflict();

$j(document).ready(function() {
		MM_preloadImages(
			'/images/but-homeowners-o.png',
			'/images/but-professionals-o.png',
			'/images/but-about-o.png',
			'/images/but-news-o.png',
			'/images/but-contact-o.png',
			'/images/teaser-ho-top-o.png',
			'/images/teaser-prof-top-o.png',
			'/images/home-nav-ho-o.png',
			'/images/home-nav-prof-o.png',
			'/images/home-nav-about-o.png',
			'/images/home-nav-news-o.png',
			'/images/home-nav-contact-o.png',
			'/images/teaser-store-o.png',
			'/images/teaser-news-o.png',
			'/images/calc-images/calc-bg-middle.jpg',
			'/images/calc-images/calc-but-rec-o.png',
			'/images/calc-images/calc-but-tri-o.png',
			'/images/calc-images/calc-but-cir-o.png',
			'/images/store-images/store-add-to-cart-o.png'
		);
		
		$j('.fancybox').fancybox({'width':800, 'height':612, 'autoDimensions':false, 'padding':0, 'scrolling':'no', 'overlayOpacity':0.6, 'overlayColor':'#333'});
		
		$j('.fancybox-shipping').fancybox({'width':300, 'height':280, 'autoDimensions':false,'padding':0,'scrolling':'no'});
		
		$j('.fieldfill').example(function(){
			return $j(this).attr('title');
		});
		if($j('#grand-total-bsd')){
			var ttl = parseFloat($j('#grand-total-bsd').html());
			if (ttl < 180){
				$j('ul.checkout-types li a').each(function(){
					$j(this).click(function(){
						belowMinOrder();
						return false;
					});
				});
			}
		}
		
		/*$j('#facebook-link img').hover(
			function(){
				this.src = this.src.replace("icon-16x16","lg");
			},function(){
				this.src = this.src.replace("lg","icon-16x16");
			}
		);*/
		
		$j('#facebook-link').tooltip({
			relative: true,
			offset: [-20,0]
		});
});
function grandTotalOverMin(loc){
	var ttl = parseFloat($j('#grand-total-bsd').html());
	if (ttl < 180){
		belowMinOrder();
		return false;
	} else {
		setLocation(loc);
		return true;
	}
}
function belowMinOrder(){
	$j.fancybox('<div class="popup fl cl"><div style="margin:40px;font-size:14px;line-height:20px;">Your order is below our $180 minimum. However, we are happy to custom cut your order.<br /><br />Please call us at <b>602.271.4266</b> to speak to a customer service representative and arrange the details.</div></div>');
}
function triggerPopUp(){
	$j.fancybox('<div class="popup fl cl"><div style="margin:40px;font-size:14px;line-height:20px;font-weight:bold;">We do not currently provide free shipping to your zip code!</div><div>To get a quote for shipping costs, please contact our office at:<br /><b>(602) 271-4266</b><br />41166 W. Steen Road<br />Maricopa, Arizona 85138</div></div>');
}
function hideInstallationGraphic(){
	$j("#block-installation-product-page").css('display','none');	
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

