function resizeBox(){
	$(".solarEstimator").colorbox.resize();
}
//jQuery
$(document).ready(function() {

	//$( "#datepicker" ).datepicker({ dateFormat: 'dd/mm/yy' });
	$(".solarEstimator").colorbox({
			width:"970px",
			height:"880px",
			overlayClose: false,
			scrolling: false,
			iframe:true,
			fastIframe:false,
			onLoad:function(){ $('.content object').css('visibility','hidden').addClass('autoHide'); },
			onClosed:function(){ $('.autoHide').css('visibility','visible'); }
		});

	var maxModuleHeight = 0;
	$('.greyBoxes .greyBox').each(function(){
		if ($(this).height() > maxModuleHeight )
			maxModuleHeight = $(this).height();

	}).css('height',maxModuleHeight);

	$('.picture-slides-thumbnails li a').each(function() {
		var $el = $(this);
		$el.attr('href', $el.attr('rel'));
	});

	jQuery.PictureSlides.set({
		// Switches to decide what features to use
		useFadingIn : true,
		useFadingOut : true,
		useFadeWhenNotSlideshow : true,
		useFadeForSlideshow : true,
		useDimBackgroundForSlideshow : true,
		loopSlideshow : false,
		usePreloading : true,
		useAltAsTooltip : true,
		useTextAsTooltip : false,

		// Fading settings
		fadeTime : 500, // Milliseconds
		timeForSlideInSlideshow : 2000, // Milliseconds

		// At page load
		startIndex : 1,
		startSlideShowFromBeginning : true,
		startSlideshowAtLoad : false,
		dimBackgroundAtLoad : false,

		thumbnailActivationEvent : "click",

		// Classes of HTML elements to use
		mainImageClass : "picture-slides-image", // Mandatory
		imageLinkClass : "picture-slides-image-link",
		fadeContainerClass : "picture-slides-fade-container",
		imageTextContainerClass : "picture-slides-image-text",
		previousLinkClass : "picture-slides-previous-image",
		nextLinkClass : "picture-slides-next-image",
		imageCounterClass : "picture-slides-image-counter",
		startSlideShowClass : "picture-slides-start-slideshow",
		stopSlideShowClass : "picture-slides-stop-slideshow",
		thumbnailContainerClass: "picture-slides-thumbnails",
		dimBackgroundOverlayClass : "picture-slides-dim-overlay"
	});

	
	jQuery.PictureSlides.init();

	$.fn.dCF=function(settings){
		var config={
			'index':0,
			'showTime':5000,
			'transitionTime':1000,
			'doHoverPause':true,
			'maxZIndex':100
		};var timeOut=null;var itemArray=[];function cancelXFade(){
			if(timeOut!==null){
				window.clearTimeout(timeOut);timeOut=null;
			}
			}
		function doXFade(){
			timeOut=window.setTimeout(function(){
				var currentIndex=config.index;var nextIndex=(config.index>=itemArray.length-1)?0:config.index+1;itemArray[currentIndex].css('z-index',(config.maxZIndex-1)+'');itemArray[nextIndex].css('z-index',config.maxZIndex+'');itemArray[nextIndex].fadeIn(config.transitionTime,function(){
					itemArray[currentIndex].hide();
				});config.index=nextIndex;doXFade();
			},config.showTime);
		}
		if(settings)$.extend(config,settings);this.each(function(){
			(itemArray.length===config.index)?$(this).show():$(this).hide();if(config.doHoverPause){
				$(this).hover(function(){
					cancelXFade();
				},function(){
					cancelXFade();doXFade();
				});
			}
			itemArray[itemArray.length]=$(this);
		});doXFade();return this;
	};

	$('.content table tr:even').addClass('evenRow');

// make the boiler size dropdown only show when needed
	$('#boilerField').css('display','none');
	$('#boilerSize').attr('disabled', true);

	$('#enquiryType').change(function(){
			var selId = $(this).val();
			boilerSel = false;
			for(var i=0;i<globalBoilerFieldIds.length;i++)
				if(selId == globalBoilerFieldIds[i]) boilerSel = true;

			if(boilerSel){
				$('#boilerField').slideDown();
				$('#boilerSize').removeAttr("disabled");
			}else{
				$('#boilerField').slideUp();
				$('#boilerSize').attr('disabled', true);
			}

		});

	// Bind up the lightbox links
	$('.lightboxIframe').colorbox({width:"940px", height:"780px", scrolling:false, iframe:true});
	
});
