// JavaScript Document

function focusFirstField() {
	var bFound = false;
  	for (f=0; f < document.forms.length; f++) {
    	for(i=0; i < document.forms[f].length; i++) {
      		if (document.forms[f][i].type != "hidden") {
        		if (document.forms[f][i].disabled != true) {
		            document.forms[f][i].focus();
            		bFound = true;
        		}
      		}
			if (bFound) {
        		break;
			}
    	}
    	if (bFound) {
      		break;
		}
  	}
}

var scriptCache = new Array();
function isInArray(arrayList,key) {
	for ( var i=0; i<scriptCache.length; i++ ) {
		if ( scriptCache[i] == key ) {
			return true;
		}
	}
	return false;
}

function loadscriptfile(filename,funct) {
	var inArray = isInArray(scriptCache,filename);
	if ( !inArray ) {
		scriptCache[scriptCache.length] = filename;
		$.getScript(filename,function() {
			eval(funct+"()");
		});
	} else {
		eval(funct+"()");
	}
}

function loadjscssfile(filename, filetype) {
	var fileref;
	if (filetype=="js") { //if filename is a external JavaScript file
		fileref=document.createElement('script');
		fileref.setAttribute("type","text/javascript");
		fileref.setAttribute("src", filename);
	} else if (filetype=="css") { //if filename is an external CSS file
		fileref=document.createElement("link");
		fileref.setAttribute("rel", "stylesheet");
		fileref.setAttribute("type", "text/css");
		fileref.setAttribute("href", filename);
	}
	if (typeof fileref!="undefined") {
		document.getElementsByTagName("head")[0].appendChild(fileref);
	}
}

function preloadIntroScripts() {
	loadjscssfile("/js/jquery.lightbox-0.5.min.js","js");
	loadjscssfile("/js/jquery.master.min.js","js");
	loadjscssfile("/js/jquery-impromptu.1.5.js","js");
	loadjscssfile("/js/jtip.js","js");
	loadjscssfile("/js/swfupload/swfupload.master.js","js");
}

function restoreStyles() {
	if (event.srcElement.style.backgroundColor != "") {
  		event.srcElement.style.backgroundColor = "";
	}
}

function setGoogleListeners() {
	var inputList = document.getElementsByTagName("INPUT");
	for (i=0;i<inputList.length;i++) {
		inputList[i].attachEvent("onpropertychange",restoreStyles);
		inputList[i].style.backgroundColor = "";
	}
	var selectList = document.getElementsByTagName("SELECT");
	for (i=0;i<selectList.length;i++) {
	  	selectList[i].attachEvent("onpropertychange",restoreStyles);
	  	selectList[i].style.backgroundColor = "";
	}
}
function clearGoogleHighlight() {
	if(window.attachEvent) {
    	window.attachEvent("onload",setGoogleListeners);
	}
}

function setupCurrentRealm() {
	try {
		eval(realm+"Setup()");
	} catch (err) {
		//
	}
}

var menu_items = new Array();
menu_items[0] = "home";
menu_items[1] = "concept";
menu_items[2] = "membership";
menu_items[3] = "menu";
menu_items[4] = "register";
menu_items[5] = "events";
menu_items[6] = "reserve";
menu_items[7] = "gallery";
menu_items[8] = "future";
menu_items[9] = "press";
menu_items[10] = "company";
menu_items[11] = "account";
menu_items[12] = "login";
menu_items[13] = "logoff";
menu_items[14] = "maps";
menu_items[15] = "customize";
menu_items[16] = "venue";

function clearMenu() {
	for (var i=0; i<menu_items.length; i++) {
		eval("$('#menu_"+menu_items[i]+"').attr({src:'/images/menu/menu_"+menu_items[i]+"_off.gif'});");
	}
}

function setMenu() {
	$.clickOrEnter("#logo_home",
		function() {
			realm = "home";
			menuCurrent = "menu_home";
			clearMenu();
			$("#page").fadeOut("medium",
				function() {
					window.location.href="";
				}
			);
		}
	);

	for (var i=0; i<menu_items.length; i++) {
		eval("setupMenu('"+menu_items[i]+"')");
	}
}

function unblockPage() {
	$("#container").unblock();
}

function playFx(soundName,volume){
	var playerpath	= '/flash/singlemp3player.swf';
	var path		= '/sound/';
	var filename	= path + soundName + '.mp3';
	var mp3html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
	mp3html += 'width="1" height="1" ';
	mp3html += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">';
	mp3html += '<param name="movie" value="'+playerpath+'?';
	mp3html += 'showDownload=false&file=' + filename + '&autoStart=true';
	mp3html += '&backColor=ffffff&frontColor=ffffff';
	mp3html += '&repeatPlay=false&songVolume='+volume+'" />';
	mp3html += '<param name="wmode" value="transparent" />';
	mp3html += '<embed wmode="transparent" width="1" height="1" ';
	mp3html += 'src="' + playerpath + '?';
	mp3html += 'showDownload=false&file=' + filename + '&autoStart=true';
	mp3html += '&backColor=ffffff&frontColor=ffffff';
	mp3html += '&repeatPlay=false&songVolume='+volume+'" ';
	mp3html += 'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	mp3html += '</object>';
	return mp3html;
}

function fxSlideVert() {
	//$("#fxPlayer").prepend(playFx('woom',15));
}

function fxWelcome() {
	//$("#fxPlayer").prepend(playFx('welcome',50));
}

function loadPage() {
	unblockPage();
	if ( $("#pageHeader").is(":hidden") ) {
		ajaxpage('inc_menu.cfm?realm='+realm, 'pageMenu');
		$("#pageHeader").fadeIn(500,
			function() {
				if ( $("#pageMenu").is(":hidden") ) {
					$("#pageMenu").fadeIn(500,
						function() {
							setMenu();
						}
					);
				}
			}
		);
	}
	if ( $("#page").is(":hidden") ) {
		fxSlideVert();
		$("#page").slideDown(1000,
			function() {
				$("#pageBody").show();
				if ( $("#bodyHeader").is(":hidden") ) {
					$("#bodyHeader").fadeIn(800,
						function() {
							if ( $("#bodyContent").is(":hidden") ) {
								$("#bodyContent").fadeIn(300,setupCurrentRealm);
							}
						}
					);
				}
				if ( $("#pageFooter").is(":hidden") ) {
					$("#pageFooter").fadeIn("slow");
				}
				if ( $("#xspfPlayer").is(":hidden") ) {
					ajaxpage('inc_xspf.cfm', 'xspfPlayer');
					$("#xspfPlayer").fadeIn("slow");
				}
			}
		);
	}
}

function gotoMenuCurrentRealm() {
	try {
		var firstchar = realm.substring(0,1);
		var remainder = realm.substring(1,realm.length);
		eval("gotoMenu"+firstchar.toUpperCase()+remainder+"()");
	} catch (err) {
		//
	}
}

function fxMenu() {
	//$("#fxPlayer").prepend(playFx('ting',60));
}

function setupMenu(name) {
	var firstchar = name.substring(0,1);
	var remainder = name.substring(1,name.length);
	var fullname = "menu_"+name;
	//$("#"+fullname).click(fxMenu);
	$.clickOrEnter("#"+fullname,eval("gotoMenu"+firstchar.toUpperCase()+remainder));
	$("#"+fullname).hover(
		function() {
			$("#"+fullname).attr( { src: "/images/menu/"+fullname+"_on.gif" } );
		},
		function() {
			if ( menuCurrent != fullname ) {
				$("#"+fullname).attr( { src: "/images/menu/"+fullname+"_off.gif" } );
			}
		}
	);
}

function resetMenu() {
	$("#pageMenu").fadeOut(500,
		function() {
			ajaxpage('inc_menu.cfm?realm='+realm, 'pageMenu');
			$("#pageMenu").fadeIn(1000,
				function() {
					setMenu();
				}
			);
		}
	);
}

function blockMenu() {
	$("#pageMenu").block('<img src="/images/spacer_clear.gif" />');
}

function unblockMenu() {
	$("#pageMenu").unblock();
}

function gotoMenu(name,file,setup,newRealm) {
	location.hash=1;
	$("ul.menu2").hide();
	blockMenu();
	if(newRealm) {
		realm=newRealm;
	} else {
		realm = name;
	}
	menuCurrent = "menu_"+name;
	clearMenu();
	$("#"+menuCurrent).attr({src:"/images/menu/"+menuCurrent+"_on.gif"});
	$("#bodyContent").hide(100,
		function() {
			$("#page").fadeOut(1300,
				function() {
					ajaxpage(file,'pageBody',
						function() {
							clearGoogleHighlight();
							$("#pageBody").hide(300,
								function() {
									fxSlideVert();
									$("#page").slideDown(1000,
										function() {
											$("#pageBody").show();
											if ( $("#bodyHeader").is(":hidden") ) {
												$("#bodyHeader").fadeIn(800,
													function() {
														if ( $("#bodyContent").is(":hidden") ) {
															$("#bodyContent").fadeIn(300,
																function() {
																	unblockMenu();
																	eval(setup+"()");
																	//focusFirstField();
																}
															);
														}
													}
												);
											}
										}
									);
								}
							);
						}
					);
				}
			);
		}
	);
}

function gotoMenuHome() {
	gotoMenu('home','home_default.cfm','homeSetup');
}

function gotoMenuConcept() {
	gotoMenu('concept','concept_default.cfm','conceptSetup');
}
function gotoMenuConceptMobile() {
	gotoMenu('concept','concept_mobile_order.cfm','conceptMobileSetup');
}
function gotoMenuConceptNteract() {
	gotoMenu('concept','concept_nteract.cfm','conceptNteractSetup');
}
function gotoMenuConceptTech() {
	gotoMenu('concept','concept_tech.cfm','conceptTechSetup');
}
function gotoMenuConceptReservation() {
	gotoMenu('concept','concept_table_reserve.cfm','conceptTableReserveSetup');
}

function gotoMenuMembership() {
	gotoMenu('membership','membership_default.cfm','membershipSetup');
}

function gotoMenuMenu() {
	gotoMenu('menu','menu_default.cfm','menuSetup');
}

function gotoMenuRegister() {
	gotoMenu('register','register_default.cfm','registerSetup');
}

function gotoMenuEvents() {
	gotoMenu('events','events_default.cfm','eventsSetup');
}

function gotoMenuReserve() {
	gotoMenu('reserve','reserve_default.cfm','reserveSetup');
}
function gotoMenuReserveProcess(table_num,res_date) {
	gotoMenu('reserve','reserve_process.cfm?table_num='+table_num+'&res_date='+res_date,'reserveProcessSetup');
}

function gotoMenuGallery() {
	gotoMenu('gallery','gallery_default.cfm','gallerySetup');
}

function gotoMenuVenue() {
	gotoMenu('venue','venue_default.cfm','venueSetup');
}

function gotoMenuFuture() {
	gotoMenu('future','future_default.cfm','futureSetup');
}

function gotoMenuPress() {
	gotoMenu('press','press_default.cfm','pressSetup');
}

function gotoMenuCompany() {
	gotoMenu('company','company_default.cfm','companySetup');
}

function gotoMenuAccount() {
	gotoMenu('account','account_default.cfm','accountSetup');
}
function gotoMenuAccountReserveCustomizeByTxn(txn_id) {
	gotoMenu('reserve','account_reservation_customize.cfm?txn_id='+txn_id,'accountReserveCustomizeSetup');
}
function gotoMenuAccountReserveCustomize(usr_id,tbl_num,res_date) {
	gotoMenu('reserve','account_reservation_customize.cfm?usr_id='+usr_id+'&tbl_num='+tbl_num+'&res_date='+res_date,'accountReserveCustomizeSetup');
}
function gotoMenuCustomize() {
	gotoMenu('reserve','account_reservation_customize.cfm','customizeSetup');
}

function gotoMenuLogin() {
	gotoMenu('login','login_default.cfm','loginSetup',realm);
}

function gotoMenuLogoff() {
	gotoMenu('logoff','logoff_default.cfm','logoffSetup',realm);
}

function gotoMenuMaps() {
	gotoMenu('maps','maps_default.cfm','mapsSetup');
}

jQuery.preloadImages = function() {
	for(var i = 0; i<arguments.length; i++) {
    	jQuery("<img>").attr("src", arguments[i]);
  	}
};

function preloadIntroImages() {	
	$.preloadImages(
		"/images/divider_menu.gif",
		"/images/footer_a.gif",
		"/images/footer_b.gif");
	for (var i=0; i<menu_items.length; i++) {
		$.preloadImages("/images/menu/menu_"+menu_items[i]+"_off.gif","/images/menu/menu_"+menu_items[i]+"_on.gif");
	}
}

function createMarker(point, index, baseIcon) {
	// Create a lettered icon for this point using our icon class
	var letter = String.fromCharCode("A".charCodeAt(0) + index);
	var letteredIcon = new GIcon(baseIcon);
	letteredIcon.image = "../images/map_marker.png";

	// Set up our GMarkerOptions object
	markerOptions = { icon:letteredIcon };
	var marker = new GMarker(point, markerOptions);

	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml("<b>Shadow Room</b><br>2131 K St NW<br>Washington, D.C. 20037<br>202.887.1200");
	});
	return marker;
}

function buildMap() {
	$("#gmap").show(100,
		function() {
			if (GBrowserIsCompatible()) {
				var map = new GMap2(document.getElementById("gmap"));
				map.setCenter(new GLatLng(38.902870,-77.047700), 17);
				map.addControl(new GLargeMapControl());
				map.addControl(new GMapTypeControl());
				map.addControl(new GScaleControl());
				map.setMapType(G_NORMAL_MAP);
				map.enableContinuousZoom();
				map.enableDoubleClickZoom();
				map.enableScrollWheelZoom();
		
				//map.addControl(new google.maps.LocalSearch(), new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,20)));
				
				var baseIcon = new GIcon();
				baseIcon.shadow = "";
				baseIcon.iconSize = new GSize(200, 30);
				baseIcon.shadowSize = new GSize(200, 30);
				baseIcon.iconAnchor = new GPoint(90, 20);
				baseIcon.infoWindowAnchor = new GPoint(100, 20);
				baseIcon.infoShadowAnchor = new GPoint(150, 20);
		
				var bounds = map.getBounds();
				var southWest = bounds.getSouthWest();
				var northEast = bounds.getNorthEast();
				var lngSpan = northEast.lng() - southWest.lng();
				var latSpan = northEast.lat() - southWest.lat();
				var point = new GLatLng(38.902814,-77.047820);
				map.addOverlay(createMarker(point, 18, baseIcon));
			}

		}
	);
}

function homeSetup() {
	$(".media").media( { width: 800, height: 400, autorun: true } );
}

function conceptSetup() {
	jQuery("div#slider1").codaSlider();
	$("div.panelContainer").fadeTo(1000,1.00);
	$('#gallery a').lightBox();
}
function conceptMobileSetup() {
	jQuery("div#slider1").codaSlider();
	$("div.panelContainer").fadeTo(1000,1.00);
}
function conceptNteractSetup() {
	jQuery("div#slider1").codaSlider();
	$("div.panelContainer").fadeTo(1000,1.00);
}
function conceptTechSetup() {
	jQuery("div#slider1").codaSlider();
	$("div.panelContainer").fadeTo(1000,1.00);
}
function conceptTableReserveSetup() {
	jQuery("div#slider1").codaSlider();
	$("div.panelContainer").fadeTo(1000,1.00);
}

function menuSetup() {
	jQuery("div#slider1").codaSlider();
	$("div.panelContainer").fadeTo(1000,1.00);
	showBottleMenuFlow(1500);
}
function bottleMenuSetup() {
	$("#bottleMenuflow").hide();
}
function drinkMenuSetup() {
	$("#drinkMenuflow").hide();
}

function registerSetup() {
	jQuery("div#slider1").codaSlider();
	$("div.panelContainer").fadeTo(1000,1.00);
	loadscriptfile("/js/proc_register_register.js","registerRegisterSetup");
}

function eventsSetup() {
	jQuery("div#slider1").codaSlider();
	$("div.panelContainer").fadeTo(1000,1.00);
	loadscriptfile("/js/proc_events_custom.js","eventsCustomSetup");
}

function reserveSetup() {
	tableResTipInit = false;
	$.preloadImages(
		"/images/content/reserve_splash.jpg",
		"/images/content/reserve_splash_1.jpg",
		"/images/content/reserve_splash_2.jpg",
		"/images/content/reserve_splash_3.jpg");
	jQuery("div#slider1").codaSlider();
	$("div.panelContainer").fadeTo(1000,1.00,
		function() {
			//var start = new Date("06/27/2008").zeroTime();
			var start = (new Date()).zeroTime();
			var end = (new Date()).zeroTime().addMonths(2);
			$("#resCal").datePicker({
				inline: true,
				startDate: start.asString(),
				endDate: end.asString(),
				renderCallback: filterOpenDays
			});
			if($("#resInitDateSel").val()!='') {
				$("#resCal").dpSetSelected($("#resInitDateSel").val(),true,true);
			}
			$("#resCal").dpClearCalendar();
			$("#resCal").dpRenderCalendar();
			$(".tableIcon").show();
			window.setTimeout(loadReserveData,1);
		}
	);
}
function reserveProcessSetup() {
	jQuery("div#slider1").codaSlider();
	$("div.panelContainer").fadeTo(1000,1.00);
	loadscriptfile("/js/proc_reserve_client.js","reserveClientSetup");
}

function gallerySetup() {
	$(".media").media( { width: 800, height: 400, autorun: true } );
}

function venueSetup() {
	$(".media").media( { width: 800, height: 400, autorun: true } );
}

function membershipSetup() {
	jQuery("div#slider1").codaSlider();
	$("div.panelContainer").fadeTo(1000,1.00);
	loadscriptfile("/js/proc_membership_apply.js","membershipApplySetup");
}

function futureSetup() {
	jQuery("div#slider1").codaSlider();
	$("div.panelContainer").fadeTo(1000,1.00);
}

function pressSetup() {
	jQuery("div#slider1").codaSlider();
	$("div.panelContainer").fadeTo(1000,1.00);
	pressClipSetup();
	$(".media").media( { width: 740, height: 320, autorun: false } );
}

var currentThumb1 = 1;
var currentThumb2 = 1;
function pressClipSetup() {
	$("#press-thumb1").jScrollPane({animateTo:true,scrollbarWidth:0,scrollbarMargin:0,animateInterval:150,animateStep:2});
	$("#press-thumb2").jScrollPane({animateTo:true,scrollbarWidth:0,scrollbarMargin:0,animateInterval:150,animateStep:2});
	$("div.scroll-to-thumb-up-1").click(
		function()
		{
			var targetElementSelectorString = "#t"+(($(this).attr('id')*1)+currentThumb1*1);
			if ( currentThumb1 > 1 ) {
				currentThumb1--;
			}
			$("#press-thumb1")[0].scrollTo(targetElementSelectorString);
			return false;
		}
	);
	$("#thumb-up-1").hover(
		function() {
			$("#thumb-up-1").attr( { src: "/images/press/scrollup_on.gif" } );
		},
		function() {
			$("#thumb-up-1").attr( { src: "/images/press/scrollup.gif" } );
		}
	);
	$("div.scroll-to-thumb-down-1").click(
		function()
		{
			var targetElementSelectorString = "#t"+(($(this).attr('id')*1)+currentThumb1*1);
			if ( currentThumb1 < 3 ) {
				currentThumb1++;
			}
			$("#press-thumb1")[0].scrollTo(targetElementSelectorString);
			return false;
		}
	);
	$("#thumb-down-1").hover(
		function() {
			$("#thumb-down-1").attr( { src: "/images/press/scrolldown_on.gif" } );
		},
		function() {
			$("#thumb-down-1").attr( { src: "/images/press/scrolldown.gif" } );
		}
	);
	$("div.scroll-to-thumb-up-2").click(
		function()
		{
			var targetElementSelectorString = "#t"+(($(this).attr('id')*1)+currentThumb2*1);
			if ( currentThumb2 > 1 ) {
				currentThumb2--;
			}
			$("#press-thumb2")[0].scrollTo(targetElementSelectorString);
			return false;
		}
	);
	$("#thumb-up-2").hover(
		function() {
			$("#thumb-up-2").attr( { src: "/images/press/scrollup_on.gif" } );
		},
		function() {
			$("#thumb-up-2").attr( { src: "/images/press/scrollup.gif" } );
		}
	);
	$("div.scroll-to-thumb-down-2").click(
		function()
		{
			var targetElementSelectorString = "#t"+(($(this).attr('id')*1)+currentThumb2*1);
			if ( currentThumb2 < 3 ) {
				currentThumb2++;
			}
			$("#press-thumb2")[0].scrollTo(targetElementSelectorString);
			return false;
		}
	);
	$("#thumb-down-2").hover(
		function() {
			$("#thumb-down-2").attr( { src: "/images/press/scrolldown_on.gif" } );
		},
		function() {
			$("#thumb-down-2").attr( { src: "/images/press/scrolldown.gif" } );
		}
	);
	//window.setTimeout(flipFirstPage, 2000);
}

function jsGotoPage(movieName,page) {
  	getFlashMovie(movieName).jsGotoPage(page);
}

function flipFirstPage() {
	jsGotoPage('pressBook',2);
}

function jobsSetup() {
	loadscriptfile("/js/proc_company_jobs.js","companyJobsSetup");
}
function contactSetup() {
	loadscriptfile("/js/proc_contact_comment.js","contactCommentSetup");
}
function teamSetup() {
	$.preloadImages(
		"/images/content/team_splash_swaptak_on.jpg",
		"/images/content/team_splash_steve_on.jpg",
		"/images/content/team_splash_panutat_on.jpg");
	$("#team_swaptak").hover(
		function() {
			$("#team_swaptak").attr( { src: "/images/content/team_splash_swaptak_on.jpg" } );
		},
		function() {
			$("#team_swaptak").attr( { src: "/images/content/team_splash_swaptak_off.jpg" } );
		}
	);
	$("#team_steve").hover(
		function() {
			$("#team_steve").attr( { src: "/images/content/team_splash_steve_on.jpg" } );
		},
		function() {
			$("#team_steve").attr( { src: "/images/content/team_splash_steve_off.jpg" } );
		}
	);
	$("#team_panutat").hover(
		function() {
			$("#team_panutat").attr( { src: "/images/content/team_splash_panutat_on.jpg" } );
		},
		function() {
			$("#team_panutat").attr( { src: "/images/content/team_splash_panutat_off.jpg" } );
		}
	);
	$("#team_ezra").hover(
		function() {
			$("#team_ezra").attr( { src: "/images/content/team_splash_ezra_on.jpg" } );
		},
		function() {
			$("#team_ezra").attr( { src: "/images/content/team_splash_ezra_off.jpg" } );
		}
	);
}

function companySetup() {
	jQuery("div#slider1").codaSlider();
	$("div.panelContainer").fadeTo(1000,1.00);
	
	contactSetup();
	jobsSetup();
	teamSetup();
}

function accountSetup() {
	jQuery("div#slider1").codaSlider();
	$("div.panelContainer").fadeTo(1000,1.00);
	loadscriptfile("/js/proc_account_profile.js","accountProfileSetup");
	$(".media").media( { width: 800, height: 400, autorun: true } );
}

var swfu;
function initSWFUpload() {
	var settings = {
		flash_url : "/js/swfupload/swfupload_f9.swf",
		upload_url: "../../upload.cfm",	// Relative to the SWF file
		post_params: {"PHPSESSID" : ""},
		file_size_limit : "25 MB",
		file_types : "*.zip",
		file_types_description : "Zip Files",
		file_upload_limit : 1,
		file_queue_limit : 1,
		custom_settings : {
			progressTarget : "fsUploadProgress",
			cancelButtonId : "btnCancel"
		},
		debug: false,

		// The event handler functions are defined in handlers.js
		file_queued_handler : fileQueued,
		file_queue_error_handler : fileQueueError,
		file_dialog_complete_handler : fileDialogComplete,
		upload_start_handler : uploadStart,
		upload_progress_handler : uploadProgress,
		upload_error_handler : uploadError,
		upload_success_handler : uploadSuccess,
		upload_complete_handler : uploadComplete,
		queue_complete_handler : queueComplete	// Queue plugin event
	};
	swfu = new SWFUpload(settings);
}
function accountReserveCustomizeSetup() {
	jQuery("div#slider1").codaSlider();
	$("div.panelContainer").fadeTo(1000,1.00);
	
	loadscriptfile("/js/proc_customize_auto.js","customizeAutoSetup");
	loadscriptfile("/js/proc_customize_list.js","customizeListSetup");
	loadscriptfile("/js/proc_customize_preo.js","customizePreoSetup");
	loadscriptfile("/js/proc_customize_ocsn.js","customizeOcsnSetup");
	loadscriptfile("/js/proc_customize_foto.js","customizeFotoSetup");
	loadscriptfile("/js/proc_customize_vdeo.js","customizeVdeoSetup");
	loadscriptfile("/js/proc_customize_iden.js","customizeIdenSetup");
	loadscriptfile("/js/autoDB.js","updateMakeList");
	initSWFUpload();
}
function customizeSetup() {
	jQuery("div#slider1").codaSlider();
	$("div.panelContainer").fadeTo(1000,1.00);
	
	loadscriptfile("/js/proc_customize_auto.js","customizeAutoSetup");
	loadscriptfile("/js/proc_customize_list.js","customizeListSetup");
	loadscriptfile("/js/proc_customize_preo.js","customizePreoSetup");
	loadscriptfile("/js/proc_customize_ocsn.js","customizeOcsnSetup");
	loadscriptfile("/js/proc_customize_foto.js","customizeFotoSetup");
	loadscriptfile("/js/proc_customize_vdeo.js","customizeVdeoSetup");
	loadscriptfile("/js/proc_customize_iden.js","customizeIdenSetup");
	loadscriptfile("/js/autoDB.js","updateMakeList");
	initSWFUpload();
}

function loginSetup() {
	$("#formArea").fadeTo(100,1.00);
	loadscriptfile("/js/proc_login_login.js","loginLoginSetup");
}

function logoffSetup() {
	$("#formArea").fadeTo(100,1.00);
	$.clickOrEnter("#buttonCancel",gotoMenuCurrentRealm);
	loadscriptfile("/js/proc_logoff_logoff.js","logoffLogoffSetup");
}

function mapsSetup() {
	buildMap();
}

function blockPage(addImage,blockWidth) {
	if (addImage) {
		$("#container").block('<img src="'+addImage+'"><br><img src="/images/anim_busy.gif" vspace="20" />',{ width: blockWidth+'px' } );
	} else {
		$("#container").block('<img src="/images/anim_busy.gif" vspace="20" />');
	}
}

function blockPane() {
	$("#bodyContent").block('<img src="/images/anim_busy.gif" vspace="20" />');
}

function delayUnblockPane() {
	$("#bodyContent").unblock();
}
function unblockPane(delay) {
	if(delay) {
		window.setTimeout(delayUnblockPane,delay);
	} else {
		delayUnblockPane();
	}
}

function fxSlideHorz() {
	//$("#fxPlayer").prepend(playFx('woom',15));
}

function fxError() {
	//$("#fxPlayer").prepend(playFx('notice',40));
}

function fxConfirm() {
	//$("#fxPlayer").prepend(playFx('twinkle',40));
}

function mycarousel_initCallback(carousel) {
    $('.jcarousel-control a').bind('click', function() {
		var pagenum = $(this).attr('id').split('_');
        carousel.scroll(jQuery.jcarousel.intval(pagenum[1]));
        return false;
    });
	/*
    $('.jcarousel-scroll select').bind('change', function() {
        carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
        return false;
    });
    $('#mycarousel-next').bind('click', function() {
        carousel.next();
        return false;
    });
    $('#mycarousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
	*/
}

function loadConcept(name) {
	ajaxpage(name+".cfm",'conceptContainer',
		function () {
			$("#mycarousel").jcarousel({
				scroll: 1,
				animation: 3300,
				initCallback: mycarousel_initCallback,
				// This tells jCarousel NOT to autobuild prev/next buttons
				buttonNextHTML: null,
				buttonPrevHTML: null
			});
		}
	);
}


function getFlashMovie(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}

function hideBottleMenuFlow(delay) {
	window.setTimeout(hideBottleMenuFlowAction, delay);
}
function hideBottleMenuFlowAction() {
	$("#bottleMenuflow").fadeOut(300,
		function() {
			$("#bottleMenuPlaceholder").fadeIn(1000);
		}
	);
}
function showBottleMenuFlow(delay) {
	window.setTimeout(showBottleMenuFlowAction, delay);
}
function showBottleMenuFlowAction() {
	$("#bottleMenuPlaceholder").fadeOut(2000,
		function() {
			$("#bottleMenuflow").fadeIn(2000);
		}
	);
}
function hideDrinkMenuFlow(delay) {
	window.setTimeout(hideDrinkMenuFlowAction, delay);
}
function hideDrinkMenuFlowAction() {
	$("#drinkMenuflow").fadeOut(300,
		function() {
			$("#drinkMenuPlaceholder").fadeIn(1000);
		}
	);
}
function showDrinkMenuFlow(delay) {
	window.setTimeout(showDrinkMenuFlowAction, delay);
}
function showDrinkMenuFlowAction() {
	$("#drinkMenuPlaceholder").fadeOut(2000,
		function() {
			$("#drinkMenuflow").fadeIn(2000);
		}
	);
}


function setVenueHighlight(roomnum) {
	if (roomnum>0) {
		var imgsrc = "/images/content/reserve_splash_"+roomnum+".jpg";
		$("#venue3d").attr( { src: imgsrc } );
	} else {
		$("#venue3d").attr( { src: "/images/content/reserve_splash.jpg" } );
	}
}

function enableMyReservation(tableObj,usr_id,table_num,res_date) {
	tableObj.unbind("click");
	tableObj.click(
		function() {
			gotoMenuAccountReserveCustomize(usr_id,table_num,res_date);
		}
	);
}
function checkLogin(v,m) {
	if ( v ) {
		gotoMenuLogin();
	}
}
function enableReservation(tableObj,table_num,res_date) {
	tableObj.unbind("click");
	tableObj.click(
		function() {
			if ($("#resLoggedIn").val()==1) {
				gotoMenuReserveProcess(table_num,res_date);
			} else {
				$.prompt('YOU MUST BE LOGGED IN TO RESERVE A TABLE',{ buttons: { LOGIN: true, CANCEL: false }, callback: checkLogin });
			}
		}
	);
}
function disableReservation(tableObj) {
	tableObj.unbind("click");
	tableObj.click(
		function() {
			return false;
		}
	);
}
function reserveTipsInit() {
	if ($("#tipsInitialized")&&$("#tipsInitialized").val()==0) {
		$("a.jTip")
			.hover(function(){JT_show(this.href,this.id,this.name);},function(){$('#JT').remove();})
			.click(function(){return false;});
		$("#tipsInitialized").val(1);
	}
}
function zeroPad(num) {
	var s = '0'+num;
	return s.substring(s.length-2);
}
function loadReserveData() {
	blockPane();
	
	var myUsrID = 0;
	var queryUsrID = "reserve_ajax_usrid.cfm";
	$.getJSON(queryUsrID,
		function(data){
			$.each(data.items, function(i,item){
				myUsrID = item.usr_id;
			});
		}
	);
	
	var dateformat = 'yyyy-mm-dd';
	var seldate = new Date();
	seldate.setTime($("#resCal").dpGetSelected());
	var formatteddate = dateformat
		.split('yyyy').join(seldate.getFullYear())
		.split('mm').join(zeroPad(seldate.getMonth()+1))
		.split('dd').join(zeroPad(seldate.getDate()));
	var query = "reserve_ajax_search.cfm?reserve_date="+formatteddate;
	$.getJSON(query,
		function(data){
			var dump = "";
			$.each(data.items, function(i,item){
				var table_id = item.table_id;
				var table_num = item.table_num;
				var capacity = item.capacity;
				var table_type = item.table_type;

				var min_array = item.minimum_list.split(",");
				var minimum = min_array[seldate.getDay()];
				
				var res_id = item.res_id;
				var usr_id = item.usr_id;
				if (minimum==9999||(res_id>0&&$("#tblIcon_"+table_num))) {
					$("#tblIcon_"+table_num).attr({src:"/images/reserve/status_reserved_"+table_type+".gif"});
					if (myUsrID!=usr_id) {
						disableReservation($("#tblIcon_"+table_num));
					} else {
						enableMyReservation($("#tblIcon_"+table_num),myUsrID,table_num,formatteddate);
					}
				} else {
					$("#tblIcon_"+table_num).attr({src:"/images/reserve/table_"+table_num+".gif"});
					enableReservation($("#tblIcon_"+table_num),table_num,formatteddate);
				}
				updatePopupLink($("#fpStatus_"+table_num),table_num,formatteddate);
			});
			reserveTipsInit();
			unblockPane(1500);
		}
	);
}
function filterOpenDays($td, thisDate, month, year)
{
	//var today = new Date("06/27/2008").zeroTime();
	var today = (new Date()).zeroTime();
	var end = (new Date()).zeroTime().addMonths(1);

	if ( thisDate.getDate() == 25 && month == 10 && year == 2009 ) {
		$td.bind('click',
			function() {
				loadReserveData();
			}
		);
	} else if ( thisDate.getDay() != 0 && thisDate.getDay() != 4 && thisDate.getDay() != 5 && thisDate.getDay() != 6 ) {
		$td.addClass('disabled');
	} else if (thisDate>end) {
		$td.addClass('disabled');
	} else if	(
				 	(
						thisDate.getYear() == today.getYear() &&
						(
							(
							 	thisDate.getMonth() == today.getMonth() &&
								thisDate.getDate() >= today.getDate()
							) ||
							thisDate.getMonth() > today.getMonth()
						)
					) ||
					thisDate.getYear() > today.getYear()
				) {
		if($("#resInitDateSel")&&$("#resInitDateSel").val()=='') {
			$("#resInitDateSel").val(thisDate.asString());
		}
		$td.bind('click',
			function() {
				loadReserveData();
			}
		);
	}
}

function updatePopupLink(linkObj,table_num,res_date) {
	if(linkObj.attr("id")!="undefined") {
		var baseurl = "reserve_popup.cfm?tbl_num="+table_num+"&width=110&res_date="+res_date;
		$("#"+linkObj.attr("id")+" > a").attr({href:baseurl});
	}
}

function strip(fieldValue) {
	return fieldValue.replace(/\(|\)|\-|\ /gi, '');
}

function showReservePayDepositAction() {
	$("#reserveDepositPlaceholder").fadeOut(1000,
		function() {
			var form_table_num = $("#form_table_num").val();
			var form_res_date = $("#form_res_date").val();
			var form_security = $("#form_security").val();
			ajaxpage('reserve_paydeposit_load.cfm?table_num='+form_table_num+'&res_date='+form_res_date+'&security='+form_security, 'reserveDepositPane',
				function() {
					$("#reserveDepositPane").fadeIn(1000);
				}
			);
		}
	);
}

function payDeposit(formName,venue_id,res_date,table_num) {
	var formObj = $("#"+formName);
	var query = "reserve_ajax_avail.cfm?venue_id="+venue_id+"&res_date="+res_date+"&table_num="+table_num;
	$.getJSON(query,
		function(data){
			if(data.status==1){
				formObj.submit();
			} else {
				$.prompt('SORRY, THIS TABLE HAS RECENTLY BEEN RESERVED. PLEASE SELECT ANOTHER TABLE.',{ buttons: { OK: true }, callback: gotoMenuReserve });
			}
		}
	);
}
function showReservePayDeposit(delay) {
	window.setTimeout(showReservePayDepositAction, delay);
}
function hideReservePayDepositAction() {
	$("#reserveDepositPane").fadeOut(1000,
		function() {
			$("#reserveDepositPlaceholder").fadeIn(1000);
		}
	);
}
function hideReservePayDeposit(delay) {
	window.setTimeout(hideReservePayDepositAction, delay);
}
function reserveVerifyClient() {
	if($("#clientVerified").val()==1) {
		showReservePayDeposit(0);
	} else {
		hideReservePayDeposit(0);
	}
}
function processCustomStripNavAction(navObj) {
	if (navObj.html()!='Bottle Menu') {
		hideBottleMenuFlow(0);
	} else {
		showBottleMenuFlow(3200);
	}
	if (navObj.html()!='Drink Menu') {
		hideDrinkMenuFlow(0);
	} else {
		showDrinkMenuFlow(3200);
	}
	if (navObj.html()=='Reserve Table') {
		//window.setTimeout(loadReserveData,3000);
	}
	if (navObj.html()=='Step 2: Pay Deposit') {
		reserveVerifyClient();
	}
}

function gal(img) {
	NewWindow=window.open('slideshow/gallery/'+img,'myWindow','width=835,height=400');NewWindow.focus();void(0);
}

var mobileWindow = null;
function wopen(url, name, w, h, opt) {
	w += 32;
  	h += 96;
  	wleft = (screen.width - w) / 2;
  	wtop = (screen.height - h) / 2;
  	if (wleft < 0) {
    	w = screen.width;
    	wleft = 0;
  	}
  	if (wtop < 0) {
    	h = screen.height;
    	wtop = 0;
  	}
  	var optionlist =
  		'width=' + w + ', height=' + h + ', ' +
    	'left=' + wleft + ', top=' + wtop + ', ' +
    	'location=no, menubar=no, ' +
    	'status=no, toolbar=no, scrollbars=yes, resizable=no';
  	if (opt)
  	{
	  	optionlist =
	  		'width=' + w + ', height=' + h + ', ' +
	  		'left=' + wleft + ', top=' + wtop + ', ' + opt;
  	}
  	var win = window.open(url,name,optionlist);
  	win.resizeTo(w,h);
  	win.moveTo(wleft,wtop);
  	win.focus();
}
function openMobile() {
	mobileWindow = wopen("iphone.cfm","mobileWindow",388,736,'location=no,menubar=no,status=no,toolbar=no,scrollbars=no,resizable=no');
}

function clickIE4() {
	if (event.button==2){
		return false;
	}
}
function clickNS4(e) {
	if (document.layers||document.getElementById&&!document.all) {
		if (e.which==2||e.which==3) {
			return false;
		}
	}
}
if (document.layers) {
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown=clickNS4;
} else if (document.all&&!document.getElementById) {
	document.onmousedown=clickIE4;
}
document.oncontextmenu=new Function("return false");

$(document).ready(function() {
	$.preloadImages("/images/logo_load.gif","/images/anim_busy.gif");
	window.setTimeout(loadPage,3000);
	blockPage("/images/logo_load.gif",393);
	preloadIntroImages();
	preloadIntroScripts();
	$.gaTracker('UA-3134677-1');
	
	$("#menu_mobile").hover(
		function() {
			$("#menu_mobile").attr( { src: "/images/menu/menu_mobile_on.gif" } );
		},
		function() {
			$("#menu_mobile").attr( { src: "/images/menu/menu_mobile_off.gif" } );
		}
	);
});