// JavaScript Document
var album = new Array();
var directory = "main-images/slideimages/";

function determineAlbum(currentPage) {
	switch (currentPage) {
		case "home":
			album[0] = "general002.jpg";
			album[1] = "private001.jpg";
			album[2] = "locations001.jpg";
			album[3] = "general001.jpg";
			album[4] = "private003.jpg";
			album[5] = "general004.jpg";
			album[6] = "menu4.jpg";
			album[7] = "menu6.jpg";
			album[8] = "menu7.jpg";
			album[9] = "menu9.jpg";
			album[10] = "menu17.jpg";
			album[11] = "menu21.jpg";
		break;
		case "about_us":
			album[0] = "private001.jpg";
			album[1] = "locations001.jpg";
		break;
		case "menus":
			album[0] ="menu1.jpg";
			for(i=2;i<=21;i++){
				album.push ("menu"+i+".jpg");
			}
		break;
		case "private_dining":
			album[0] = "private001.jpg";
			album[1] = "private002.jpg";
			album[2] = "private003.jpg";
			album[3] = "private004.jpg";
			album[4] = "private005.jpg";
			album[5] = "private006.jpg";
			album[6] = "private007.jpg";
		break;
		case "locations":
			album[0] ="locations003.jpg";
		break;
		case "reservations":
			album[0] ="reserv001.jpg";
		break;
	}
}

/******************************** Cross Fade FX ********************************/
var currentSlide = 0;
var totalSlides = 0;
var fading = false;
var fadeTimer = setInterval("nextslide()", 7000);

function randOrd(){
	return (Math.round(Math.random())-0.5);
}

function $(id) {
	var $ = document.getElementById(id);
	
	$.fadeIn = function(delay,callbk,out) {
		var _this = this;
		for (i = 1; i <= 100; i++) {
		  (function(j) {
				setTimeout(function() {  
					  if (out==true) j=100-j;
					  _this.style.opacity = j/100;
					  _this.style.MozOpacity = j/100;
					  _this.style.KhtmlOpacity = j/100;
					  _this.style.zoom = 1; // for ie, set haslayout
					  _this.style.display="block"; 
					   if (j==100&&callbk!=undefined) {callbk.call(_this);}
					   else if (out==true&&callbk!=undefined&&j==0) {callbk.call(_this);}
					  _this.style.filter = "alpha(opacity=" + j + ");";},j*delay/100);
					 
			})(i);     
		}
	};
	
	$.fadeOut = function(delay,callbk) {
		$.fadeIn(delay,callbk,true);
	};
	
	return $;
}

function nextslide() {
	if (totalSlides != 0) {
		if (fading != true){
			if (currentSlide == totalSlides) {
				fading = true;
				currentSlide = 0;
				loadimage(currentSlide);
			} else {
				fading = true;
				currentSlide++;
				loadimage(currentSlide);
			}
		}
	}
}
	
	
function slideleft() {
	clearInterval(fadeTimer);
	if(totalSlides != 0) {
		if(fading != true){
			if (currentSlide == 0) {
				fading = true;
				currentSlide = totalSlides;
				loadimage(currentSlide);
			}else{
				fading = true;
				currentSlide--;
				loadimage(currentSlide);
			}
		}
	}
}

function slideright() {
	clearInterval(fadeTimer);
	if(totalSlides != 0) {
		if(fading != true){
			
			if (currentSlide == totalSlides) {
			fading = true;
			currentSlide = 0;
			loadimage(currentSlide);
			}else{
			fading = true;
			currentSlide++;
			loadimage(currentSlide);
			}
			
		}
	}
}
/*******************************************************************************/
/********************************** Ticker FX **********************************/
//Scrolling Slide FX variables
var imgPlaces	= 2; // number of images visible
var imgWidth	= 365; // width of the images
var imgHeight	= 320; // height of the images
var imgSpacer	= 2; // space between the images
var dir			= 0; // 0 = left, 1 = right
var newWindow	= 1; // 0 = Open a new window for links 0 = no  1 = yes
var step		= 1;
var tickerTimer	= "";
var speed		= 50;
var nextPic		= 0;
var initPos		= new Array();
var nowDivPos	= new Array();
var moz			= document.getElementById && !document.all

function initHIS3(currentPage) {
	determineAlbum(currentPage);
	
	for (var i = 0; i <= imgPlaces; i++) {// create image holders
		newImg = document.createElement("IMG")
		newImg.setAttribute("id","pic_"+i)
		newImg.setAttribute("src","")
		newImg.style.position	= "absolute";
		newImg.style.width		= imgWidth+"px";
		newImg.style.height		= imgHeight+"px";
		newImg.style.border		= 0;
		newImg.alt		= "";
		newImg.i		= i;
		document.getElementById("display_area").appendChild(newImg)
	}

	containerEL = document.getElementById("his3container");
	displayArea = document.getElementById("display_area");
	pic0 = document.getElementById("pic_0");
	
	containerBorder =(document.compatMode=="CSS1Compat"?0:parseInt(containerEL.style.borderWidth)*2)
	containerWidth = (imgPlaces*imgWidth)+((imgPlaces - 1)*imgSpacer);
	
	containerEL.style.width		= containerWidth+(!moz ? containerBorder : "")+"px"
	containerEL.style.height	= imgHeight+(!moz ? containerBorder : "")+"px"
	
	displayArea.style.width	= containerWidth+"px"
	displayArea.style.clip	= "rect(0,"+(containerWidth+"px")+","+(imgHeight+"px")+",0)"
//	displayArea.onmouseover	= function(){ stopHIS3() }
//	displayArea.onmouseout	= function(){ scrollHIS3() }
	
	imgPos = -imgWidth;
	
	for (var i = 0; i < imgPlaces + 1 ; i++) {
		currentImage = document.getElementById("pic_"+i);
		
		if (dir == 0) { imgPos += imgWidth + imgSpacer; } // if left
		
		initPos[i] = imgPos;
		if (dir == 0) { currentImage.style.left = initPos[i]+"px"; } // if left
		
		if (dir == 1) { // if right
			document.getElementById("pic_"+[(imgPlaces - i)]).style.left = initPos[i]+"px";
			imgPos += (pic0.width + imgSpacer);
		}
	
		if (nextPic == album.length) { nextPic = 0; }
		
		currentImage.src = directory+album[nextPic];
		currentImage.i = nextPic
		nextPic++
	}

	scrollHIS3()
}

function scrollHIS3(){
	clearTimeout(tickerTimer);
	for (var i = 0; i < imgPlaces + 1; i++) {
		currentImage = document.getElementById("pic_"+i)
		
		nowDivPos[i] = parseInt(currentImage.style.left)
		
		if (dir == 0) { nowDivPos[i] -= step }
		if (dir == 1) { nowDivPos[i] += step }
		
		if (dir == 0 && nowDivPos[i] <= -(imgWidth + imgSpacer) || dir == 1 && nowDivPos[i] > containerWidth) {
			
			if (dir == 0) { currentImage.style.left = (containerWidth + imgSpacer)+"px"; }
			if (dir == 1) { currentImage.style.left = (-imgWidth - (imgSpacer*2))+"px"; }
			
			if (nextPic > album.length - 1) { nextPic = 0; }
			
			currentImage.src = directory+album[nextPic];
			currentImage.i = nextPic;
			
			nextPic++
		} else {
			currentImage.style.left = nowDivPos[i]+"px"
		}
	}
	tickerTimer = setTimeout("scrollHIS3()", speed);
	
}
	
function stopHIS3(){
	clearTimeout(tickerTimer)
}
/**********************************************************************************/

function loadbig(currentPage) {
	determineAlbum(currentPage);
	
	if (currentPage == "gift_cards" || currentPage == "rewards_program" || currentPage == "contact_us" || currentPage == "keep_in_touch" || currentPage == "whats_happening" || currentPage == "careers" || currentPage == "media_and_awards" || currentPage == "facebook" || currentPage == "twitter") {
		album[0] = "general001.jpg";
	}
	
	for (i=0; i < album.length; i++) {
		window["pic"+i] = new Image(100,25);
		window["pic"+i].src = directory+album[i];
	}
	
	totalSlides = album.length - 1;
	if (currentPage != "home") {
		album.sort( randOrd );
	}
	loadimage(0);
}


function loadimage(imagenum) {
	$("thebigimage").fadeOut(1000, function() { loadcontent(imagenum); });
}


function loadcontent(imagenum) {
	document.getElementById('thebigimage').innerHTML = '<img src="'+directory+album[imagenum]+'" width="773" height="599" border="0">';
   	$("thebigimage").fadeIn(1000, function() { fading = false; });
}
