//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			
		});
	}
	*/
	
	
	// We only want these styles applied when javascript is enabled
	$('div.navigation').css({'width' : '280px', '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:                 6,
		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:           true,
		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 showMenu(sender)
{
	var mainMenus = $(".divMainMenuItem a");
	var index;
	for (var i = 0; i < mainMenus.length; i++)
	{
		mainMenus[i].className = "";
		if (mainMenus[i] == sender)
		{
			mainMenus[i].className = "selected";
			index = i;
		}
	}
	var subMenus = $(".divHiddenSubMenu");
	if (index != undefined)		
 		document.getElementById("divSubMenu").innerHTML = subMenus[index].innerHTML;
}

/*
function slideshowCallback(Items, Index)
{
	var link = Items[Index][1];
		
	divAdvertDescription.innerHTML = advertRecords[Index][1];
}
*/

sfHover = function() {
	if(document.getElementById("nav")){
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
		this.className+=" sfhover";
		}
			sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
	}
}
sfHovertop = function() {
	if(document.getElementById("navtop")){
	var sfEls = document.getElementById("navtop").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
		this.className+=" sfhovertop";
		}
			sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhovertop\\b"), "");
		}
	}
	}
}
sfHoverleft = function() {
	if(document.getElementById("leftnav")){
	var sfEls = document.getElementById("leftnav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
		this.className+=" sfhoverleft";
		}
			sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhoverleft\\b"), "");
		}
	}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
if (window.attachEvent) window.attachEvent("onload", sfHovertop);
if (window.attachEvent) window.attachEvent("onload", sfHoverleft);
