﻿/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!					
/***************************/

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.7",
			"filter": "alpha(opacity=70)",
			"width": document.documentElement.clientWidth,
			"height": document.documentElement.clientHeight
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popUp").fadeIn("slow");
		popupStatus = 1;
	}
}

//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popUp").fadeOut("slow");
		popupStatus = 0;
	}
}

//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popUp").height();
	var popupWidth = $("#popUp").width();
	//centering
	$("#popUp").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}


//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	$("#button").click(function(){
		//centering with css
		centerPopup();
		//load popup
		loadPopup();
	});
				
	//CLOSING POPUP
	//Click the x event!
	$("#popUpClose").click(function(){
		disablePopup();
	});
	//Click out event!
	$("#backgroundPopup").click(function(){
		disablePopup();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if((e.keyCode==27 || e.which == 27) && popupStatus==1){
			disablePopup();
		}
	});

});

function popUp(id)
{
	//centering with css
	document.getElementById("popUpClose").innerHTML = "x";
	if(id == "hrs")
	{
		document.getElementById("popUp").style.height = "200px";
		document.getElementById("popUp").style.width = "400px";
		document.getElementById("popUpTitle").innerHTML = "Hours of Operation";
		document.getElementById("popUpText").innerHTML = "OPEN ALL SEVEN DAYS<br><br> Lunch: 11:00am - 2:30 pm <br><br>Happy Hour: 3:30 pm- 7:00 pm <br><br>Dinner: 5:00 pm - 10:00 pm <br><br>Late Night: Open for drinks till 2:00 am <br>(Last Order for dinner at 9:30 pm)";
	}
	else if(id == "map")
	{
		document.getElementById("popUp").style.height = "420px";
		document.getElementById("popUp").style.width = "450px";
		document.getElementById("popUpTitle").innerHTML = "Map and Directions";
		document.getElementById("popUpText").innerHTML = "<iframe width='425' height='350' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=1333++5th++Avenue+++++Seattle,+WA&amp;sll=37.0625,-95.677068&amp;sspn=40.460237,70.400391&amp;ie=UTF8&amp;s=AARTsJoZT_jyGmGWnCYsL_uaU1cvblhwUg&amp;ll=47.608716,-122.334427&amp;spn=0.010127,0.018239&amp;z=15&amp;output=embed'></iframe><br /><small><a href='http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=1333++5th++Avenue+++++Seattle,+WA&amp;sll=37.0625,-95.677068&amp;sspn=40.460237,70.400391&amp;ie=UTF8&amp;ll=47.608716,-122.334427&amp;spn=0.010127,0.018239&amp;z=15' style='color:#0000FF;text-align:left'>View Larger Map</a></small>";
	}
	else if(id == "contact")
	{
		document.getElementById("popUp").style.height = "200px";
		document.getElementById("popUp").style.width = "400px";
		document.getElementById("popUpTitle").innerHTML = "Contact Us";
		document.getElementById("popUpText").innerHTML = "1333 5th AVENUE, SEATTLE WA 98101<br><br> (Second level in Rainier Plaza at<br>the corner of 5th and Union in downtown Seattle)<br><br> TEL : (206) 623 4111 <br><br>  FAX: (206) 623 4114  <br><br> EMAIL: navyalounge@gmail.com";
	}
	else if(id.match("jpg"))
	{
 	}
	centerPopup();
	//load popup
	loadPopup();
	
}

function loadImg()
{
	if(popupStatus==0){
		$("#showImg").fadeIn("slow");
		document.getElementById("index").style.zIndex = "1";
		popupStatus = 1;
	}
}

function closeImg()
{
	if(popupStatus==1){
		$("#showImg").fadeOut("slow");
		popupStatus = 0;
	}
}
function resizeImg(x,y) {
	var target = 500;
	var percent = target / y;
//gets the new value and applies the percentage, then rounds the value
var width = Math.round(x*percent);
var height = Math.round(y*percent);
//returns the new sizes in html image tag format...this is so you
//can plug this function inside an image tag and just get the
var dims = "width='"+width+"' height='"+height+"'";
return dims;
}
function showPic(id,x,y)
{
	if( y > 500) {
		var dimensions = resizeImg(x,y);
	} else {
		var dimensions = '';
	}
	var str = "<img src='"+id+"' "+dimensions+">"; 	
	document.getElementById("showImg").innerHTML = str;
	loadImg();
}

function resolution()
{
	var winW = 0, winH = 0;

	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
	  winW = window.innerWidth-16;
	  winH = window.innerHeight-16;
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  winW = document.body.offsetWidth;
	  winH = document.body.offsetHeight;
	 }
	}
	if (winW <= 1024) {
		document.getElementById("index").style.width = "600px";
	}
	if (winW <= 800) {
		document.getElementById("index").style.left = "50px";
		document.getElementById("index").style.width = "440px";
		if(document.getElementById("show")){
		document.getElementById("show").style.width = "440px";}
	}
	if (winW <= 640) {
		document.getElementById("index").style.width = "300px";
	}
}

function menuShow()
{
	var winW = 0, winH = 0;

	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
	  winW = window.innerWidth-16;
	  winH = window.innerHeight-16;
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  winW = document.body.offsetWidth;
	  winH = document.body.offsetHeight;
	 }
	}
	if (winW <= 800) {
		if(document.getElementById("show")){
			if(document.getElementById("animatedtabs1")){
			document.getElementById("animatedtabs1").style.width = "440px";
			document.getElementById("animatedtabs2").style.width = "440px";
			document.getElementById("animatedtabs3").style.width = "440px";}
			document.getElementById("show").style.width = "440px";
			document.getElementById("show").style.height = "450px";
		if(document.getElementById("menutitle")){
		document.getElementById("menutitle").style.width = "440px";}
		if(document.getElementById("merchandise")){
		document.getElementById("merchandise").style.width = "440px";}}
	}
	else{
		if(document.getElementById("show")){
		//document.getElementById("show").style.marginRight = "200px";}
		document.getElementById("index").align = "";}
	}
}

// function play() {
   // emb = document.createElement("embed");
   // emb.setAttribute("src", "test.wav");
   // emb.setAttribute("hidden", true);
   // emb.setAttribute("autostart", true);
   // document.body.appendChild(emb);
// }
 
function brsr()
{
	var chk = navigator.userAgent;
	//play();
	if(document.URL.match("event") || document.URL.match("album"))
	{
		if(document.login)
		{
			if(document.login.uname)
			{
				document.login.uname.focus();
			}
		}
	}
	if(document.URL.match("register"))
	{
		document.getElementById("name").focus();
	}
/*	if(chk.match("IE"))
	{
		document.getElementById("navbar").style.left = "10px";
		document.getElementById("index").style.left = "50px";
		document.getElementById("index").style.top = "15px";
		if(document.body.offsetWidth > 1000){
			document.getElementById("index").style.width = "750px";}
		document.getElementById("index").style.left = "-20px";
		if(document.getElementById("show")){
			document.getElementById("show").style.marginRight = "200px";
			document.getElementById("show").style.marginTop = "5px";
		}
	}*/
	if(document.body.offsetWidth > 800){
	if(document.URL.match("menu")){
		document.getElementById("menutitle").style.marginRight = "200px";}
	if(document.URL.match("merchandise")){
	document.getElementById("merchandise").style.marginRight = "200px";}}
}

function ajaxmain()
{
	var request;
	try
	{
		request = new XMLHttpRequest();
	}
	catch(ms)
	{
		try
		{
			request = new ActiveXObject("MSxml2.XMLHTTP");
		}
		catch(ms2)
		{
			try
			{
				request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(unsupported)
			{
				alert("Your browser does not support the xmlHttpRequest object");
			}
		}
	}
	return request;
}

var xmlreq;

function disp(url)
{
	var arr = url.split('=');	
	var liarr = document.getElementsByTagName('li');
	for(var i=0;i<liarr.length;i++) {
		if(liarr[i].id != '') {
			if(liarr[i].id  == arr[1]) {	
				document.getElementById(liarr[i].id).className = "selected";
			} else {
				document.getElementById(liarr[i].id).className = "";
			}
		}
	}
	xmlreq = ajaxmain();
	xmlreq.open("GET",url,true);
	xmlreq.onreadystatechange = updatePage;
	xmlreq.send(null);
}

function updatePage() {
  if (xmlreq.readyState == 4 && xmlreq.status == 200) {
    var response = xmlreq.responseText;
	document.getElementById("show").innerHTML = response;
  }
}