
//<![CDATA[


var HeaderImages = new Array('http://www.allfourseasons.co.uk/wp-content/themes/atahualpa/images/header/high-wall-office.jpg','http://www.allfourseasons.co.uk/wp-content/themes/atahualpa/images/header/ducted-residential.jpg','http://www.allfourseasons.co.uk/wp-content/themes/atahualpa/images/header/chassis-hidden.jpg','http://www.allfourseasons.co.uk/wp-content/themes/atahualpa/images/header/high-wall-residential3.jpg','http://www.allfourseasons.co.uk/wp-content/themes/atahualpa/images/header/low-wall-mounted-residentia.jpg','http://www.allfourseasons.co.uk/wp-content/themes/atahualpa/images/header/high-wall-office-large.jpg','http://www.allfourseasons.co.uk/wp-content/themes/atahualpa/images/header/under-ceiling-1-way-residential.jpg','http://www.allfourseasons.co.uk/wp-content/themes/atahualpa/images/header/ducted-round-grille.jpg','http://www.allfourseasons.co.uk/wp-content/themes/atahualpa/images/header/4-way-cassette-single.jpg','http://www.allfourseasons.co.uk/wp-content/themes/atahualpa/images/header/high-wall-residential.jpg','http://www.allfourseasons.co.uk/wp-content/themes/atahualpa/images/header/high-wall-residential2.jpg');
var t; var j = 0
var p = HeaderImages.length
var PreLoadImages = new Array()
for (i = 0; i < p; i++){
	PreLoadImages[i] = new Image()
	PreLoadImages[i].src = HeaderImages[i]
}
function RotateHeaderImages(){
	if (document.body){
		HeaderImageContainer = document.getElementById('imagecontainer');
		HeaderImageContainer.style.background = 'url(' + HeaderImages[j] + ') top center no-repeat';
		j = j + 1
		if (j > (p-1)) j=0
		t = setTimeout('RotateHeaderImages()', 10000)
	}
}
// Smooth fading code starts here
var fadeInSpeed=4000; // ms
var fadeOutSpeed=3000; // ms

function PrepareRotatingImages() {
	if (document.body){
        if(HeaderImages.length < 2) 
            return; 
		imageContainer = jQuery('#imagecontainer');
        imageContainer.css("background","none"); 
        for(i=0; i < HeaderImages.length; i++) {
            imageContainer.append("<div id=\"himage" + i + "\" style=\"overflow:hidden;display:none;position:absolute;top=0;left=0;width:100%;height:220px\"><img src=\""+HeaderImages[i]+"\"/></div>");
        }
        jQuery("#himage"+j).fadeIn(fadeInSpeed);
        SmoothRotateHeaderImages();
    }
}

function SmoothRotateHeaderImages() {
    fadeOutImage=jQuery("#himage"+j);
    j+=1; if(j>(HeaderImages.length-1)) j=0;
    fadeInImage=jQuery("#himage"+j);
    fadeInImage.fadeIn(fadeInSpeed);
    fadeOutImage.fadeOut(fadeOutSpeed);
    t = setTimeout('SmoothRotateHeaderImages()', 10000);
}

window.onload = PrepareRotatingImages;
// end smooth fading

//window.onload = RotateHeaderImages;



/* JQUERY */

jQuery(document).ready(function(){  
  
	/* For IE6 */
	if (jQuery.browser.msie && /MSIE 6\.0/i.test(window.navigator.userAgent) && !/MSIE 7\.0/i.test(window.navigator.userAgent) && !/MSIE 8\.0/i.test(window.navigator.userAgent)) {

		/* Max-width for images in IE6 */		
		var centerwidth = jQuery("td#middle").width(); 
		
		/* Images without caption */
		jQuery(".post img").each(function() { 
			var maxwidth = centerwidth - 10 + 'px';
			var imgwidth = jQuery(this).width(); 
			var imgheight = jQuery(this).height(); 
			var newimgheight = (centerwidth / imgwidth * imgheight) + 'px';	
			if (imgwidth > centerwidth) { 
				jQuery(this).css({width: maxwidth}); 
				jQuery(this).css({height: newimgheight}); 
			}
		});
		
		/* Images with caption */
		jQuery("div.wp-caption").each(function() { 
			var captionwidth = jQuery(this).width(); 
			var maxcaptionwidth = centerwidth + 'px';
			var captionheight = jQuery(this).height();
			var captionimgwidth =  jQuery("div.wp-caption img").width();
			var captionimgheight =  jQuery("div.wp-caption img").height();
			if (captionwidth > centerwidth) { 
				jQuery(this).css({width: maxcaptionwidth}); 
				var newcaptionheight = (centerwidth / captionwidth * captionheight) + 'px';
				var newcaptionimgheight = (centerwidth / captionimgwidth * captionimgheight) + 'px';
				jQuery(this).css({height: newcaptionheight}); 
				jQuery("div.wp-caption img").css({height: newcaptionimgheight}); 
				}
		});
		
		/* sfhover for LI:HOVER support in IE6: */
		jQuery("ul li").
			hover( function() {
					jQuery(this).addClass("sfhover")
				}, 
				function() {
					jQuery(this).removeClass("sfhover")
				} 
			); 

	/* End IE6 */
	}
	
	jQuery(".post table tr").
		mouseover(function() {
			jQuery(this).addClass("over");
		}).
		mouseout(function() {
			jQuery(this).removeClass("over");
		});

	
	jQuery(".post table tr:even").
		addClass("alt");

	
	jQuery("input.text, input.TextField, input.file, input.password, textarea").
		focus(function () {  
			jQuery(this).addClass("highlight"); 
		}).
		blur(function () { 
			jQuery(this).removeClass("highlight"); 
		})
	
	jQuery("input.inputblur").
		focus(function () {  
			jQuery(this).addClass("inputfocus"); 
		}).
		blur(function () { 
			jQuery(this).removeClass("inputfocus"); 
		})

		

	
	jQuery("input.button, input.Button").
		mouseover(function() {
			jQuery(this).addClass("buttonhover");
		}).
		mouseout(function() {
			jQuery(this).removeClass("buttonhover");
		});

	/* toggle "you can use these xhtml tags" */
	jQuery("a.xhtmltags").
		click(function(){ 
			jQuery("div.xhtml-tags").slideToggle(300); 
		});

	/* For the Tabbed Widgets plugin: */
	jQuery("ul.tw-nav-list").
		addClass("clearfix");

		
	/* Strech short pages to full height, keep footer at bottom. */
	
	/* Set a compensation value to fix browser differences and an overall 
	misalignment with this method */
	if (jQuery.browser.msie || jQuery.browser.safari) { 
		var bfacompensate = 41; 
	} else { 
		var bfacompensate = 21; 
	}
	
	/* Fix a jQuery/Opera 9.5+ bug with determining the window height */
	var windowheight = jQuery.browser.opera && jQuery.browser.version > "9.5" &&
    jQuery.fn.jquery <= "1.2.6" ? document.documentElement["clientHeight"] : jQuery(window).height();
	
	/* Top and bottom padding may have been set on the BODY */
	var paddingtop = parseInt(jQuery("body").css("padding-top"));
	var paddingbottom = parseInt(jQuery("body").css("padding-bottom"));
	
	/* Get the height of the header, footer, and the layout as a whole */
	var headerheight = jQuery("td#header").height();
	var footerheight = jQuery("td#footer").height();
	var layoutheight = jQuery("div#wrapper").height();
	
	/* Adjust height of middle column if (layout height + body padding-top + body padding-bottom) is smaller than 
	height of browser viewport */
	if ( windowheight > (layoutheight + paddingtop + paddingbottom) ) {
		var newmiddleheight = windowheight - paddingtop - headerheight - footerheight - paddingbottom - bfacompensate;
		jQuery("td#middle").css({height: newmiddleheight + "px"});
	}  
	
});

//]]>
