/* =========================================================

// home.js
// Autor: Lane B
// CONTROLS IMAGE LOAD AND ANIMATION PARAMETERS

// ========================================================= */

$(document).ready(function() {
    $('.slideshow').cycle({
		fx: 'fade',
		autostop: 6,
		autostopCount: 6
	});
});

// Create an image elementvar 
b1 = $('<img src="images/home_banner_main.jpg"/>').attr('src', 'images/home_banner_main.jpg');
b2 = $('<img src="images/home_banner_distributors.jpg"/>').attr('src', 'images/home_banner_distributors.jpg');
b3 = $('<img src="images/home_banner_manufacturers.jpg"/>').attr('src', 'images/home_banner_manufacturers.jpg');
b4 = $('<img src="images/home_banner_operators.jpg"/>').attr('src', 'images/home_banner_operators.jpg');
b5 = $('<img src="images/home_banner_retailers.jpg"/>').attr('src', 'images/home_banner_retailers.jpg');

$(document).ready(function(){
	var minHeight = 600;
	var actualHeight = $('#main').height();
	if (actualHeight < minHeight){
		$('#main').css({'height' : minHeight});
	};			
});

Image1 = new Image(602,542)
Image1.src = "images/home_banner_main.jpg"

Image2 = new Image(602,542)
Image2.src = "images/home_banner_distributors.jpg"

Image3 = new Image(602,542)
Image3.src = "images/home_banner_manufacturers.jpg"

Image4 = new Image(602,542)
Image4.src = "images/home_banner_operators.jpg"

Image5 = new Image(602,542)
Image5.src = "images/home_banner_retailers.jpg"

function region(nu) {
 document.getElementById('b1').src = window['Image'+nu].src; return true;
}

$(document).ready(function() {
    $('.slideshow2').cycle({
		fx: 'fadeZoom',
    	sync:   0, 
    	delay: 1500,
		height: 'auto',
		speed:  1000,
		timeout: 10000,
		before: onBefore
	});
});
$(document).ready(function() {
    $('.slideshow3').cycle({
		fx: 'fadeZoom',
    	sync:   0, 
    	delay: 1500,
		height: 'auto',
		speed:  1000,
		timeout: 10000,
		before: onBefore
	});
});


function onBefore(curr,next,opts) {
	
	//center the image
    var $slide = $(next);
    var w = $slide.outerWidth();
    var h = $slide.outerHeight();
    $slide.css({
        marginTop: (80 - h) / 2,
        marginLeft: (355 - w) / 2
    });
}
