﻿var scroller;
//var defaultPreloadImages;


$(function() {

    $("#TheScroller").find("img.TopImage").hover(function() {
        $(this).animate({ marginTop: "0px" }, { duration: 500 });
        $(this).next().animate({ marginTop: "15px" }, { duration: 500 });
        //scroller.hover = true;
    }, function() {
        $(this).animate({ marginTop: "10px" }, { duration: 500 });
        $(this).next().animate({ marginTop: "0px" }, { duration: 500 });
        //scroller.hover = false;
    });

    var defaultPreloadImages = new Array();

    defaultPreloadImages[0] = 'images/button_submit_large-bg-over.png';
    defaultPreloadImages[1] = 'images/menu_active_bg.png';

    //preLoadImages(defaultPreloadImages);

    $("a[rel='external']").click(function() { window.open($(this).attr("href")); return false; });

    $("a.Popup").fancybox();


});

function preLoadImages( imageArray ) {
	var imageLoadCount = 0;
	
	jQuery.each( imageArray, function(i, val) {
		imageLoadCount++;
		$('<img />')
		.attr('src', this)
		.load(function(){
			if ( i + 1 == imageArray.length ) {
				// Callback can go here
			}
		});
	});
}

function validateLiveForm(cForm) {
	
	if ( $("#Name_Full").val() == "" ) {
		alert("Please fill in your name");
		return false;
	} else if ( $("#Question").val() == "" ) {
		alert("Please fill in your problem description as accurately as possible");
		return false;
	}
	
	return true;
	
}

function loadScroller() {
	
	var scrollerPreloadImages = new Array('images/accreditations/cisco_top.png','images/accreditations/cisco_bottom.png', 'images/accreditations/dell_top.png', 'images/accreditations/dell_bottom.png', 'images/accreditations/ibm_top.png', 'images/accreditations/ibm_bottom.png', 'images/accreditations/microsoft_top.png', 'images/accreditations/microsoft_bottom.png', 'images/accreditations/netgear_top.png', 'images/accreditations/netgear_bottom.png', 'images/accreditations/cisco2_top.png','images/accreditations/cisco2_bottom.png', 'images/accreditations/aruba_top.png', 'images/accreditations/aruba_bottom.png', 'images/accreditations/citrix_top.png', 'images/accreditations/citrix_bottom.png', 'images/accreditations/bluecoat_top.png', 'images/accreditations/bluecoat_bottom.png', 'images/accreditations/redmap_top.png', 'images/accreditations/redmap_bottom.png', 'images/accreditations/novell_top.png','images/accreditations/novell_bottom.png', 'images/accreditations/dlink_top.png', 'images/accreditations/dlink_bottom.png', 'images/accreditations/hp_top.png', 'images/accreditations/hp_bottom.png', 'images/accreditations/draytek_top.png', 'images/accreditations/draytek_bottom.png', 'images/accreditations/telstra_top.png', 'images/accreditations/telstra_bottom.png', 'images/accreditations/gfi_top.png','images/accreditations/gfi_bottom.png', 'images/accreditations/novastor_top.png', 'images/accreditations/novastor_bottom.png', 'images/accreditations/vizioncore_top.png', 'images/accreditations/vizioncore_bottom.png', 'images/accreditations/symantec_top.png', 'images/accreditations/symantec_bottom.png', 'images/accreditations/thwate_top.png', 'images/accreditations/thwate_bottom.png', 'images/accreditations/vmware_top.png', 'images/accreditations/vmware_bottom.png', 'images/accreditations/fortinet_top.png','images/accreditations/fortinet_bottom.png');
	
	preLoadImages(scrollerPreloadImages);

	setTimeout( function() {
		scroller = $("#TheScroller").jCarouselLite({
			btnNext: ".next",
			btnPrev: ".prev",
			easing: "easeInOutSine",
			scroll: 5,
			visible: 5,
			speed: 5000,
			auto: 7000
		});
	}, 5000 );
}

function preloadCustomer() {

	var customerPreloadImages = new Array('images/button_help-hover.png', 'images/button_session-hover.png');
	
	preLoadImages(customerPreloadImages);
}

