// JavaScript Document


// FOR EMAIL /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */

function writeEmail(ad,dom) {
	document.write('<a href="mailto:'+ad+'@'+dom+'.com">'+ad+'@'+dom+'.com</a>');

}

// FOR TOUR /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
var tourPics=new Array();

	tourPics["bararea"]=new Array();
		tourPics["bararea"][0]="bararea0.jpg";
		tourPics["bararea"][1]="bararea1.jpg";
	
	tourPics["tablesinbar"]=new Array();
		tourPics["tablesinbar"][0]="tablesinbar0.jpg";
	
	tourPics["tatami4"]=new Array();
		tourPics["tatami4"][0]="tatamirm4-0.jpg";
	
	tourPics["tatami6"]=new Array();
		tourPics["tatami6"][0]="tatamirm6-0.jpg";
	
	tourPics["tatami8"]=new Array();
		tourPics["tatami8"][0]="tatamirm8-0.jpg";
	
	tourPics["pond"]=new Array();
		tourPics["pond"][0]="pond0.jpg";
	
	tourPics["bridge"]=new Array();
		tourPics["bridge"][0]="bridge0.jpg";
	
	tourPics["outside"]=new Array();
		tourPics["outside"][0]="outside0.jpg";
	
	tourPics["dining"]=new Array();	
		tourPics["dining"][0]="dining0.jpg";
	
	tourPics["fireside"]=new Array();
		tourPics["fireside"][0]="fireside0.jpg";
		tourPics["fireside"][1]="fireside1.jpg";
	
	tourPics["hibachi"]=new Array();
		tourPics["hibachi"][0]="hibachi0.jpg";
		tourPics["hibachi"][1]="hibachi1.jpg";
		tourPics["hibachi"][2]="hibachi2.jpg";
		tourPics["hibachi"][3]="hibachi3.jpg";
	
	tourPics["sushibar"]=new Array();
		tourPics["sushibar"][0]="sushibar0.jpg";
		tourPics["sushibar"][1]="sushibar1.jpg";
		tourPics["sushibar"][2]="sushibar2.jpg";
		tourPics["sushibar"][3]="sushibar3.jpg";
	
	tourPics["entrance"]=new Array();
		tourPics["entrance"][0]="entrance0.jpg";
	
	tourPics["case"]=new Array();
		tourPics["case"][0]="case0.jpg";

function closeWin()
{
	tourWin.document.close();
 }	

var ii=0;
function nextPic(aArray) {
	var maxArray=tourPics[aArray].length;
	if(ii < maxArray) {
		ii++;
	}
	if(ii == maxArray) {
		ii=0;
	}
	document.getElementById('vImage').src='tour/'+tourPics[aArray][ii];
}
function prevPic(aArray) {
	var maxArray=tourPics[aArray].length;
	if(ii >= 0) {
		ii--;
	}
	if(ii < 0 ) {
		ii=maxArray-1;
	}
	document.getElementById('vImage').src='tour/'+tourPics[aArray][ii];
}

function tour(array) {
	var nav = navigator.appName;
	var w=650;
	var h=650;
		if(nav == 'Microsoft Internet Explorer') {
			tourWin = window.open('','','menubar=0,toolbar=0,resizable=1,width='+w+',height='+h);
		}
		if(nav == 'Netscape' || nav == 'Opera') {
			tourWin = window.open('','','menubar=no,toolbar=no,resizable=yes,width='+w+',height='+h);
		}


	tourWin.document.write('<html><head><title>Sakura Tour<\/title>');
	tourWin.document.write('<scr' + 'ipt language="javaScript" type="text/javascript" src="index.js"><\/scr' + 'ipt>');
	tourWin.document.write('<link type="text/css" rel="stylesheet" href="popup.css">');
	tourWin.document.write('<\/head><body><table cellspacing=0 cellpadding=0 border=0>');
	tourWin.document.write('<tr><td height=104 colspan=3 align=center><img border=0 width=650 height=104 src="tour/images/header.jpg" /><\/td><\/tr>')
	tourWin.document.write('<tr>');

		if(tourPics[array].length > 1) {
			tourWin.document.write('<td align=left><a href="javascript:prevPic(\x27'+array+'\x27)">')
			tourWin.document.write('<img src="tour/images/previous.jpg" border=0 width=26 height=219 />')
			tourWin.document.write('<\/a><\/td>')
		}

	tourWin.document.write('<td valign=middle align=center><img id="vImage" src="tour/'+tourPics[array][0]+'" /><\/td>')

		if(tourPics[array].length > 1) {
			tourWin.document.write('<td align=right><a href="javascript:nextPic(\x27'+array+'\x27)">')
			tourWin.document.write('<img src=tour/images/next.jpg border=0 width=26 height=219 />')
			tourWin.document.write('</a><\/td>')
		}

	tourWin.document.write('<\/tr><\/table>')

	/*
	if(tourPics[array].length > 1) {
		var i=0;
		tourWin.document.write('<tr><td id=prev align=left><a href=javascript:prevPic(\x27'+array+'\x27)>Previous</a></td>')
		tourWin.document.write('<td align=right><a href=javascript:nextPic(\x27'+array+'\x27)>Next</a></td></tr>');
	}
	*/
	tourWin.document.write('<\/body><\/html>');
	setTimeout("closeWin()",250);
//	closeWin()

	userWidth = ((screen.availWidth) / 2) - (w / 2);
	userHeight = ((screen.availHeight) / 2) - (h / 2);
	tourWin.focus();
	tourWin.moveTo(userWidth,userHeight);
}


// FOR DROP DOWN MENUS // /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */

var aAbout = new Array();
	aAbout[0] = {choice:"Directions",links:"directions_new.htm"};
	aAbout[1] = {choice:"Tour",links:"tour_new.htm"};
	aAbout[2] = {choice:"Contact Us",links:"contactus.htm"};

var aMenus = new Array();
	aMenus[0] = {choice:"Traditional Lunch",links:"menus/trad_lunch.htm"};
	aMenus[1] = {choice:"Traditional Dinner",links:"menus/trad_dinner.htm"};
	aMenus[2] = {choice:"Hibachi Lunch",links:"menus/hibachi_lunch.htm"};
	aMenus[3] = {choice:"Hibachi Dinner",links:"menus/hibachi_dinner.htm"};
	aMenus[4] = {choice:"Dessert",links:"menus/dessert.htm"};

	/*[0] = 'home'
	[1] = 'about'
	[2] = 'menus'
	[3] = 'sushi'
	[4] = 'drinks'
	[5] = 'tour'
	[6] = 'gift certificates'
	[7] = 'directions'
	[8] = 'contact us'*/
function writeMenus() {
	writeMenu('menus');
}

function writeMenu(mm) {
	var length;
	var id="t"+mm;
	var ourDiv=document.getElementById(mm);
	var t=document.createElement('table');  	// - start by creating the table element
	var tb=document.createElement('tbody');  
		t.id=id;
		t.className='ddmenu';
		t.align='left';
		t.setAttribute('cellSpacing','0');
		//var tr=document.createElement('tr');  
		//var td=document.createElement('td');
		//var tdText=document.createTextNode('This is the text node');  // - create the text that will go in the table cell
		//var tdText=document.createTextNode('This is the text node');  // - create the text that will go in the table cell

	switch(mm) {
		case "menus":
		length=aMenus.length;
		break
		case "about":
		length=aAbout.length;
		break
	}	

	for(i=0; i<length; i++) {
		var tr=document.createElement('tr');
		var td=document.createElement('td');
		var aLink=document.createElement('a');
		td.onmouseover=function over() {this.style.backgroundColor='#FFCCCC'};
		td.onmouseout=function out() {this.style.backgroundColor='#FFFFFF'};
			switch(mm) {
				case "menus":
				var tdText=document.createTextNode(aMenus[i].choice);
				aLink.href=aMenus[i].links;
				aLink.target="_blank"
				break
				case "about":
				var tdText=document.createTextNode(aAbout[i].choice);
				aLink.href=aAbout[i].links;
				break
			}
		aLink.appendChild(tdText);
		td.appendChild(aLink);
		tr.appendChild(td);
		tb.appendChild(tr);	
	}

	t.appendChild(tb);						// - put the tbody into the table	
	ourDiv.appendChild(t); 					// - put the table into the div
}
function showTable(mm) {
	var id='t'+mm;
	document.getElementById(id).style.visibility='visible';
	}

function clearTable(mm) {
	var id='t'+mm;
		//	var ourDiv = document.getElementById('menus');
		//	var output1 = ourDiv.firstChild.nodeValue;
		//	ourDiv.removeChild(ourDiv.firstChild);
	document.getElementById(id).style.visibility='hidden';
}

$(document).ready( function() {
	$('.submenu').hide();						
							
	$('.active-trail').hover( 
	  function() {
		  $(this).find('.submenu').show();
		  $(this).addClass('over');
	  },
	  function() {
		  $(this).find('.submenu').hide();
		  $(this).removeClass('over');
	  }
	);
});
						
						
						