<!-- // JavaScript Document

var d = document;
var loadingPage = true;

//GET THE SERVER NAME TO USE ABSOLUTE URLS WHERE NEEDED
function serverName() {
	var server; var url = location.href;
	if(url.indexOf("localhost") != -1)		{ server = "../"; }
	else if(url.indexOf("klstudios") != -1)	{ server = "http://www.dobbins.klstudios.ie/"; }
	else									{ server = "http://www.dobbins.ie/"; }
	if(url.indexOf("_office") != -1) { server += "/_office"; } return server;
}

function getSelectedIndex(cellID) { //GET THE SELECTED INDEX VALUE OF A SELECT BOX
	var selectedItem = d.getElementById(cellID).selectedIndex; var selectedvalue = d.getElementById(cellID).options[selectedItem].value; return selectedvalue;
}

function doButton(buttonId,img,action) {
	if(action == 1) { img+="-active"; if(d.getElementById(buttonId+'Slide')) { $('#'+buttonId+'Slide').fadeIn(); } } 
	else 			{ if(d.getElementById(buttonId+'Slide')) { $('#'+buttonId+'Slide').fadeOut(); }	}
	d.getElementById(buttonId).src = serverName()+"_images/nav/"+img+".gif";
}

function doIcon(buttonId,action) {
	var img = buttonId; if(action) { img+="-"+action; } d.getElementById(buttonId).src = serverName()+"_images/icons/"+img+".gif";
}

// START TAG LINE ROTATION FUNCTION
var tagLineTimer, lastTagLine = 1, thisTagLine = 1, tagLineTimerCount = 0;

$(function() {
	$('#tagLine').mouseover(function()	{ clearTimeout(tagLineTimer); tagLineTimerCount = 0; });
	$('#tagLine').mouseleave(function()	{ startTagLineTimer(); });	
	startTagLineTimer();
});

function autoTagLine() {
	runTagLines(); tagLineTimer=setTimeout("autoTagLine()",3000);	
}

function startTagLineTimer() {
	if (tagLineTimerCount == 0) { tagLineTimerCount=1; autoTagLine(); }
}

function manualTagLine() {
	if(tagLineTimerCount == 1) { clearTimeout(tagLineTimer); tagLineTimerCount = 0; } runTagLines();
}

function runTagLines() {
	var totalTagLines = ($('#tagLine').children().size());
	if(thisTagLine == totalTagLines) { lastTagLine = totalTagLines; thisTagLine = 1; } else { thisTagLine += 1; lastTagLine = thisTagLine-1; }
	$('#tagLineA'+lastTagLine).fadeOut(); $('#tagLineA'+thisTagLine).fadeIn();
}

function swapLoader() {
	$('#menuLoader').animate({"opacity": 0, "height": "0px"},1000);	
}

//LOADING STANDARD PAGES
function loadThePage() {
	$('#blowUpContainerBackground').css({"opacity": 0 });
	if(d.getElementById('backgroundImage')) { $('#backgroundImage').fadeIn(); setInterval('loadPage()',500); }
}

function loadPage() {
	if(loadingPage == true) { loadingPage = false; if(d.getElementById("pageRightContainer")) {
		$('#backgroundImage').animate({"opacity": .1},500); $('#pageRightContainer').fadeIn();
		if (window.XMLHttpRequest) { if(d.getElementById('menuNav')) { if (d.getElementById('menuLoader')) { setTimeout('swapLoader()',500); } } // IE 6
	} }	}
}

// FILE STRIP FUUNCTIONS AND GALLRY FUNCTIONS
var  position = 0, rightPosition, thisFileWidth, thisGalleryImage = 1; lastVisibleImage = 1;
function doImage(newSrc) {
	d.getElementById("backgroundImage").src = serverName()+"_fileupload/media/"+newSrc;
}

function slideGallery(direction) {
	var totalImagesWidth = 0; var b = $('#galleryPanel img').size(); var galleryContainer = parseInt($('#galleryContainer').outerWidth());
	for(var a = 1; a <= b; a++) { totalImagesWidth += parseInt($('#imgContainer_'+a).outerWidth()); }
	rightPosition = totalImagesWidth + position;
	if(direction == 'left') { if(rightPosition > galleryContainer) {
		thisFileWidth = parseInt($('#imgContainer_'+thisGalleryImage).outerWidth()); position -= thisFileWidth;
		$('#galleryPanel').animate({ left : '-='+thisFileWidth+'' }); thisGalleryImage +=1; } }
	else { if(position < 0) {
		thisGalleryImage -=1; thisFileWidth = parseInt($('#imgContainer_'+thisGalleryImage).outerWidth());
		position += thisFileWidth; $('#galleryPanel').animate({ left : '+='+thisFileWidth+'' }); } }
}

function moveAlbums() {
	var position, more, moreImg, offset = 210; if(d.getElementById("moreA").innerHTML == "More") { 
	if(!window.innerWidth) {  if(!(document.documentElement.clientWidth == 0)) { offset = 215; } } // IE
	position = ($('#galleryAlbums').height() + offset)+"px"; more = "Close"; moreImg = "moveDown.png"; } else { position = "423px"; more = "More"; moreImg = "moveUp.png"; }
	$('#galleryAlbums').animate({"top":position});
	d.getElementById("moreA").innerHTML = more;
	d.getElementById("moreImg").src = serverName()+"_images/nav/"+moreImg;
} 

function windowSize(type) {
	var w = 0; var h = 0; if(!window.innerWidth) { 
		if(!(document.documentElement.clientWidth == 0)) { w = d.documentElement.clientWidth; h= d.documentElement.clientHeight; } //IE STRICT
		else 											 { w = d.body.clientWidth; h = document.body.clientHeight; }} //QUIRKS MODE
	else 												 { w = window.innerWidth; h = window.innerHeight; } // W3C
	if(type=="width") { return w; } else { return h; }
}

$(document).keypress(function(e) { if(e.keyCode == 27) { doBackground('hide'); } });

function doBackground(action,startLeft,startTop) {
	if(action == "show") {
		scrollTo(0,0); var posLeft = ((windowSize("width"))-800)/2; var panelHeight = windowSize("height")+"px";
		$('#blowUpContainerBackground').show().animate({'opacity':0.8});
		$('#blowUpContainer').css({'left':startLeft+'px','top':startTop+'px','width':'100px'}).fadeIn().animate({'left':posLeft+'px','top':'70px','width':'800px','height':'470px'},500); } 
	else {
		$('#blowUpContainerBackground').css({"opacity": 0 }).hide(); $('#blowUpContainer').animate({'height':'0px'},1000).animate({'width':'800px'}).animate({'top':'70px'}).fadeOut();
		//RESET FORMS
		$('.form').fadeOut();  $('.formButtons').css('display','block'); $('.formResult').css('display','none').html('&nbsp;');
		$('#locationMapContent').val('&nbsp;'); $('.formInput').val(''); $('.formLabel').show(); $('.formInfo').hide(); }
//		$('#blowUpImage').html('<div style="text-align : center; height : 400px;"><img src="'+serverName()+'_images/page/loadingGeneral.png" alt="Dobbins Data Loading" /><img src="'+serverName()+'_images/page/loading.gif" alt="Dobbins Data Loading" /><div>\r'); }
}

function doForm(formName,startLeft,startTop) {
	doBackground("show",startLeft,startTop); setTimeout('callForm(\''+formName+'\')',1000);
}

function callForm(formName,fileID) {
//	if(formName == "blowUpImage") { 
//		var p = $("#blowUpContainer"); var position = p.position(); var p = position.left + 50;
//		$('#blowUpContainer').animate({"top":"20px","height":"570px","width":"675px","left":p+"px"}); }
	$('#'+formName+'Form').fadeIn('slow');
}

function doMap(mapId) {
	doBackground("show",750,600); setTimeout('callMap(\''+mapId+'\')',1000);
}

function callMap(mapId) {
	$('#locationForm').fadeIn('slow'); $.ajax({ url: serverName()+"_lib/ajax.php", type: 'POST', data: 'locationMap='+mapId,
		success: function(result) {  d.getElementById('locationMapContent').innerHTML = result; } });
}

$(function() { 
	$('#viewAgain').click(function() {
	var innerhtml = $('#viewAgain').html();
	if(innerhtml == "View background image again") {
		$('#backgroundImage').animate({"opacity": 1},1000); $('#pageRightContainer').fadeOut(); $('#viewAgain').html('View page again').css({'color':'#fff'}).stop(); }
	else {
		$('#backgroundImage').animate({"opacity": .1},1000);  $('#pageRightContainer').fadeIn(); $('#viewAgain').html('View background image again').css({'color':'#ccc'}).stop(); }
	});

	//CONTACT FORM VALIDATION AND SUBMISSION
	$('#submitForm').click(function() {
		var submitForm	= true; var data = Array(); var arrCells = Array('name','email','phone','message');
		for(var i = 0; i <= 3; i++) {
			data[i] = $('#'+arrCells[i]).val();
			if(data[i] == "")	{	$('#'+arrCells[i]+'Info').show(); $('#'+arrCells[i]+'Label').hide(); submitForm = false; }
			else				{	$('#'+arrCells[i]+'Info').hide(); $('#'+arrCells[i]+'Label').show(); } }
		var spamCode	= $('#spamcode').val();	var confirmCode	= $('#spamcodeconfirm').val();
		if(spamCode != confirmCode)	{	$('#spamcodeInfo').show(); $('#spamcodeLabel').hide(); submitForm = false; }
		else						{	$('#spamcodeInfo').hide(); $('#spamcodeLabel').show(); }
		if(submitForm == true) {
			$.ajax({ url: serverName()+"_lib/ajax.php", type: 'POST',  
			data: 'submitContactForm=true&name='+data[0]+'&email='+data[1]+'&phone='+data[2]+'&message='+data[3],
			success: function(result) {  
				$('#contactFormButtons').hide(); d.getElementById('contactFormResult').innerHTML = result; $('#contactFormResult').show();
				setTimeout('doBackground(\'hide\')',3000); } }); }
		else { d.getElementById('contactFormLoading').style.visibility = 'hidden'; }
		return false;
	});
	
	//RESERVATIONS VALIDATION AND SUBMISSION
	$('#submitEnquiry').click(function() {
		submitForm = true; var data = Array("","","",""); var arrCells = Array('resName','resEmail','resPhone','resDate','resGuests');
		for(var i = 0; i <= 4; i++) {
			data[i] = $('#'+arrCells[i]).val();
			if(data[i] == "")	{	$('#'+arrCells[i]+'Info').show(); $('#'+arrCells[i]+'Label').hide(); submitForm = false; }
			else				{	$('#'+arrCells[i]+'Info').hide(); $('#'+arrCells[i]+'Label').show(); } }
		var spamCode	= $('#resspamcode').val();	
		var confirmCode	= $('#resspamcodeconfirm').val();
		if(spamCode != confirmCode)	{	$('#resspamcodeInfo').show(); $('#resspamcodeLabel').hide(); submitForm = false; }
		else						{	$('#resspamcodeInfo').hide(); $('#resspamcodeLabel').show(); }
		if(submitForm == true) {
			$.ajax({ url: serverName()+"_lib/ajax.php", type: 'POST',  
			data: 'submitReservationForm=true&name='+data[0]+'&email='+data[1]+'&phone='+data[2]+'&date='+data[3]+'&guests='+data[4],
			success: function(result) {  
				$('#reservationFormButtons').hide();
				d.getElementById('reservationFormResult').innerHTML = result;
				$('#reservationFormResult').show();
				setTimeout('doBackground(\'hide\')',5000); } }); }
		else { d.getElementById('reservationFormLoading').style.visibility = 'hidden'; }
		return false;
	});
	
	//REGESTRATION VALIDATION AND SUBMISSION
	$('#submitRegistration').click(function() {
		submitForm = true; var data = Array(); var arrCells = Array('regName','regEmail');
		for(var i = 0; i <= 1; i++) {
			data[i] = $('#'+arrCells[i]).val();
			if(data[i] == "")	{	$('#'+arrCells[i]+'Info').show(); $('#'+arrCells[i]+'Label').hide(); submitForm = false; }
			else				{	$('#'+arrCells[i]+'Info').hide(); $('#'+arrCells[i]+'Label').show(); } }
		var company = $('#regCompany').val(); if(submitForm == true) {
			$.ajax({ url: serverName()+"_lib/ajax.php", type: 'POST',  
			data: 'submitRegestrationForm=true&name='+data[0]+'&email='+data[1]+'&company='+company,
			success: function(result) {  
				$('#registerFormButtons').hide();
				d.getElementById('registerFormResult').innerHTML = result;
				$('#registerFormResult').show();
				setTimeout('doBackground(\'hide\')',5000); } }); }
		else { d.getElementById('registerFormLoading').style.visibility = 'hidden'; }
		return false;
	});
});

function doPrint(type,menuId,restaurantId) {
	var url = serverName()+"print.php?type="+type+"&menu="+menuId+"&restaurant="+restaurantId;
	window.open(url,'','width=740,height=700,location=no,scrollbars=1');
}

function doPdf(menuId,restaurantId) {
	window.location = serverName()+"download.php?menu="+menuId+"&restaurant="+restaurantId;
}

function doUnsubscribe(contactId) {
	$.ajax({ url: serverName()+"_lib/ajax.php", type: 'POST', data: 'unsubscribe='+contactId,
	success: function(result) { d.getElementById('unsubscribeResult').innerHTML = result; } });
}
-->
