var domain ='';
var domainRef ='';
var usesFlyouts = true;
function init(d, dr, usesFlyouts_) {
	domain = d;
	domainRef = dr;
//	if((usesFlyouts_=='false')||(usesFlyouts_ = 0)||(usesFlyouts_ = '0')||(usesFlyouts_ = 'False')){usesFlyouts = false}
	usesFlyouts = usesFlyouts_;

	//jCarousel
	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();
	    });
	};

$(document).ready(function(){
														 
		//jCarousel
		jQuery(document).ready(function() {
		    jQuery('#mycarousel').jcarousel({
		        auto: 2,
						scroll: 1,
						animation: 'slow',
		        wrap: 'circular',
		        initCallback: mycarousel_initCallback
		    });
		});
												 
														 
		// fix breadcrumbs
		$("#breadcrumbs li:last").removeAttr('class');
		$("#breadcrumbs li").each(function(){
			if ($(this).attr('class')) {
				$(this).find(".breadcrumb-title").wrapInner('<a href="'+$(this).attr('class')+'"></a>');
			}
		});
		
		if(usesFlyouts_){
			$("ul.sf-menu").supersubs({ 
				minWidth:    12,   // minimum width of sub-menus in em units 
				maxWidth:    40,   // maximum width of sub-menus in em units 
				extraWidth:  1     // extra width can ensure lines don't sometimes turn over 
								   // due to slight rounding differences and font-family 
			});
		
			$("ul.sf-menu").superfish();
		} 
		
		// fix forms
		$(".siteForm").attr("name", d+$(".siteForm").attr("name"));
		
		stripeTable();
		
		
	});
}
jQuery.preloadImages = function() {
  for(var i = 0; i<arguments.length; i++) {
    jQuery("<img>").attr("src", domainRef+arguments[i]);
  }
}
function stripeTable() {
	// works backwards because the index of the first row is 0. :) nice
	$("table.stripe tr:even").addClass("odd");
	$("table.stripe tr:odd").addClass("even");
}

// Not only when the DOM is ready, but when the images have finished loading,
// important, but subtle difference to $(document).ready();
$(window).bind('load', function () {
	$('.fade').hover(
		function () {
			$(this).stop().animate({opacity: .5}, 250);
		},
		function () {
			$(this).stop().animate({opacity: 1}, 500);
		}
	);
	
});

