/*   NEWS TICKER JQUERY IMAGE ROTATOR  */	

function mycarousel_initCallback(carousel)
{
	// Pause autoscrolling if the user moves with the cursor over the clip.
	carousel.clip.hover(function() {
	carousel.stopAuto();
},
function() {
	carousel.startAuto();
});
};

jQuery(document).ready(function() {
jQuery('#mycarousel').jcarousel({
	auto: 2,
	wrap: 'last',
	initCallback: mycarousel_initCallback
});
});


/*  END NEWS TICKER JQUERY IMAGE ROTATOR  */	


/*  PRE LOAD IMAGES FOR HOMEPAGE MAP  */	

function preLoadImages()
{
	imgAll = new Image(208,140);
	imgAll.src = "images/hp_map_all.gif";
	imgSouthAmerica = new Image(208,140);
	imgSouthAmerica.src = "images/hp_map_south_america.gif";
	imgNorthAmerica = new Image(208,140);
	imgNorthAmerica.src = "images/hp_map_north_america.gif";
	imgEurope = new Image(208,140);
	imgEurope.src = "images/hp_map_europe.gif";
	imgAfrica = new Image(208,140);
	imgAfrica.src = "images/hp_map_africa.gif";
	imgAsia = new Image(208,140);
	imgAsia.src = "images/hp_map_asia.gif";
	imgAustralia = new Image(208,140);
	imgAustralia.src = "images/hp_map_australia.gif";
}
/*  END PRE LOAD IMAGES FOR HOMEPAGE MAP  */						
					
/*   HOMEPAGE JQUERY IMAGE ROTATOR  */					
var rotateSpeed = 5000; // Milliseconds to wait until switching tabs.
var currentTab = 0; // Set to a different number to start on a different tab.
var numTabs; // These two variables are set on document ready.
var autoRotate;
var onLoadOfJScript = 'Y';


$(document).ready(function() 
{
   
	numTabs = $(".tabbed-box .tabs li a").length;
	$(".tabbed-box .tabs li a").click(function() { 
		openTab($(this),"YES"); return false; 
	});

	$(".tabbed-box").mouseover(function(){clearInterval(autoRotate)})
	.mouseout(function(){autoRotate = setInterval("rotateTabs()", rotateSpeed)});
	$(".tabbed-box .tabs li a:eq("+currentTab+")").click()
	$(".tabbed-box").mouseout();
	//randomhomepagebanner();
	
});


function openTab(clickedTab, isClicked) 
{

    if(onLoadOfJScript == 'N' && isClicked == 'YES')
    {
        var thisTab = $(".tabbed-box .tabs a").index(clickedTab);
               
        window.location = $(".tabbed-box .tabs li a:eq("+thisTab+")").attr("href");
        
        $(".tabbed-box .tabs li a").removeClass("active");
        $(".tabbed-box .tabs li a:eq("+thisTab+")").addClass("active");
        $(".tabbed-box .tabbed-content").hide();
        //$(".tabbed-box .tabbed-content:eq("+thisTab+")").show();
        $(".tabbed-box .tabbed-content:eq("+thisTab+")").fadeIn("3000");
        currentTab = thisTab;
    }
    else if(onLoadOfJScript == 'N' && isClicked == 'NO')
    {
        var thisTab = $(".tabbed-box .tabs a").index(clickedTab);
        $(".tabbed-box .tabs li a").removeClass("active");
        $(".tabbed-box .tabs li a:eq("+thisTab+")").addClass("active");
        $(".tabbed-box .tabbed-content").hide();
        //$(".tabbed-box .tabbed-content:eq("+thisTab+")").show();
        $(".tabbed-box .tabbed-content:eq("+thisTab+")").fadeIn("3000");
        currentTab = thisTab;
    }
    else if(onLoadOfJScript == 'Y' && isClicked == 'YES')
    {
        onLoadOfJScript = 'N'
        var thisTab = $(".tabbed-box .tabs a").index(clickedTab);
        $(".tabbed-box .tabs li a").removeClass("active");
        $(".tabbed-box .tabs li a:eq("+thisTab+")").addClass("active");
        $(".tabbed-box .tabbed-content").hide();
        //$(".tabbed-box .tabbed-content:eq("+thisTab+")").show();
        $(".tabbed-box .tabbed-content:eq("+thisTab+")").fadeIn("3000");
        currentTab = thisTab;
    }
    else if(onLoadOfJScript == 'Y' && isClicked == 'NO')
    {
        onLoadOfJScript = 'N'
        var thisTab = $(".tabbed-box .tabs a").index(clickedTab);
        $(".tabbed-box .tabs li a").removeClass("active");
        $(".tabbed-box .tabs li a:eq("+thisTab+")").addClass("active");
        $(".tabbed-box .tabbed-content").hide();
        //$(".tabbed-box .tabbed-content:eq("+thisTab+")").show();
        $(".tabbed-box .tabbed-content:eq("+thisTab+")").fadeIn("3000");
        currentTab = thisTab;
    }

    
}

function rotateTabs() 
{
	var nextTab = (currentTab == (numTabs - 1)) ? 0 : currentTab + 1;
	openTab($(".tabbed-box .tabs li a:eq("+nextTab+")"),"NO");
}


/*
this.randomhomepagebanner = function()
{
    var length = $("#homepage_banner_image li").length;
    //alert(length);
    var ran = Math.floor(Math.random()*length) + 1;	
//    alert(ran);
    $("#homepage_banner_image li:nth-child(" + ran + ")").show();

}
*/

/* END   HOMEPAGE JQUERY IMAGE ROTATOR  */	






