//var divAdvertisement;
//var divAdvertDescription;

$(document).ready(function() {
	/*
	divAdvertisement = document.getElementById("slideshow");
	divAdvertDescription = document.getElementById("divAdvertDescription");
		
	if (divAdvertisement)
	{
		$("#slideshow a[rel='slide']").crossf4de({
			callBack: slideshowCallback,
			fadeDuration: 2000,
			pauseDuration: 5000			
		});
	}
	*/
	
	$('#advert_slide').innerfade({ animationtype: 'fade', speed: 1000, timeout: 7000, type: 'sequence', containerheight: '220px' });
	
	$tabs = $("#featured > ul").tabs({ fx: { opacity: 'toggle' }}).tabs('rotate', 5000);
		
	$('.divContactFormButton').css("background-image", "url(/site/view/images/contact_form_button_"+board_culture+".png)");  
	$('.divContactFormButton').hover( function(){ 
	    $(this).css("background-image", "url(/site/view/images/contact_form_button_hover_"+board_culture+".png)"); 
	 },
	 function(){ 
	    $(this).css("background-image", "url(/site/view/images/contact_form_button_"+board_culture+".png)"); 
	 }
	);
	 
	// We only want these styles applied when javascript is enabled
	$('div.navigation').css({'width' : '850px', 'float' : 'left'});
	$('div.content').css('display', 'block');

	// Initially set opacity on thumbs and add
	// additional styling for hover effect on thumbs
	var onMouseOutOpacity = 0.67;
	$('#thumbs ul.thumbs li').opacityrollover({
		mouseOutOpacity:   onMouseOutOpacity,
		mouseOverOpacity:  1.0,
		fadeSpeed:         'fast',
		exemptionSelector: '.selected'
	});
	
	// Initialize Advanced Galleriffic Gallery
	var gallery = $('#thumbs').galleriffic({
		delay:                     2500,
		numThumbs:                 40,
		preloadAhead:              10,
		enableTopPager:            true,
		enableBottomPager:         false,
		maxPagesToShow:            7,
		imageContainerSel:         '#slideshow',
		controlsContainerSel:      '#controls',
		captionContainerSel:       '#caption',
		loadingContainerSel:       '#loading',
		renderSSControls:          true,
		renderNavControls:         true,
		playLinkText:              'Play Slideshow',
		pauseLinkText:             'Pause Slideshow',
		prevLinkText:              '&lsaquo; Previous Photo',
		nextLinkText:              'Next Photo &rsaquo;',
		nextPageLinkText:          SBPhrases["SLIDE_NEXT"],
		prevPageLinkText:          SBPhrases["SLIDE_PREVIOUS"],
		enableHistory:             false,
		autoStart:                 false,
		syncTransitions:           false,
		defaultTransitionDuration: 900,
		onSlideChange:             function(prevIndex, nextIndex) {
			// 'this' refers to the gallery, which is an extension of $('#thumbs')
			this.find('ul.thumbs').children()
				.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
				.eq(nextIndex).fadeTo('fast', 1.0);
		},
		onPageTransitionOut:       function(callback) {
			this.fadeTo('fast', 0.0, callback);
		},
		onPageTransitionIn:        function() {
			this.fadeTo('fast', 1.0);
		}
	});
	 
	
});

/*
function slideshowCallback(Items, Index)
{
	var link = Items[Index][1];
		
	divAdvertDescription.innerHTML = advertRecords[Index][1];
}
*/


/*
	PRELOAD IMAGES
*/
if (document.images)
{    
  	preload_image_object = new Image();
  	// set image url
	image_url = new Array();
	image_url[0] = "/site/view/images/contact_form_button_en-CA.png";
	image_url[1] = "/site/view/images/contact_form_button_fr-CA.png";
	image_url[2] = "/site/view/images/contact_form_button_hover_en-CA.png";
	image_url[3] = "/site/view/images/contact_form_button_hover_fr-CA.png";

	var i = 0;
	for(i=0; i<=3; i++) 
	    preload_image_object.src = image_url[i];
}
    
  
