var images = new Array();

function preload(width,height,src)
{
	imgNo = images.length;
	images[imgNo] = new Image(width,height);
	images[imgNo].src = src;
}

function swapClass(id,newClass)
{
	document.getElementById(id).className=newClass;
}

function swapbg(id,newBg,newCol)
{
	var item = document.getElementById(id);
	item.style.backgroundImage = "url('"+newBg+"')";
	item.style.color = newCol;
}

function swapImage(obj,src)
{
	document.getElementById(obj).src = src;
}

var showHide = new Array();

function showDiv(num)
{
	if(showHide[num] == 0)
	{
		document.getElementById('hid'+num).style.visibility = 'visible';
		document.getElementById('iecov'+num).style.visibility = 'visible';
		document.getElementById('hid'+num).style.zIndex = document.getElementById('iecov'+num).style.zIndex+1;
		showHide[num] = 1;
	}
}

function hideDiv(num)
{
	if(showHide[num] == 1)
	{
		showHide[num] = 0;
		setTimeout('actuallyHide('+num+')', 30);
	}
}

function actuallyHide(num)
{
	if(showHide[num] == 0)
	{
		document.getElementById('hid'+num).style.visibility = 'hidden';
		document.getElementById('iecov'+num).style.visibility = 'hidden';
	}
}

var hotels = new Array();

function addHotel(name, address, bookID, offer, id, info, special)
{
	hotels[hotels.length] = new Array(name, address, bookID, offer, id, info, special);
}

function printHotelsSearch()
{
	for(i = 0; i < hotels.length; i++)
	{
		document.write("<option>"+hotels[i][0]+"</option>");
	}
}

function makeHotelsMenu(relativePath,imagePath)
{
	document.write("<div id='hid0' class='popup_menu' style='left:96px;' onmouseover='swapClass(\"tab1\",\"menu_tab_over\"); showDiv(0)' onmouseout='swapClass(\"tab1\",\"menu_tab\"); hideDiv(0)'>");
	for(i = 0; i < hotels.length; i++)
	{
		if(hotels[i][4] != 0)
			document.write("<a id='hmi"+i+"' href='"+relativePath+hotels[i][4]+".htm'");
		else
			document.write("<a id='hmi"+i+"' href='"+hotels[i][5]+"'");
		document.write(" style='color:#555555;' onmouseover='document.getElementById(\"hmi"+i+"\").style.color=\"#3838A8\"' onmouseout='document.getElementById(\"hmi"+i+"\").style.color=\"#555555\"'>"+hotels[i][0]+" ("+hotels[i][1]+")</a><br />");
	}
	document.write("</div>");
	document.write("<iframe id='iecov0' src='javascript:false;' scrolling='no' frameborder='0' style='position:absolute; top:88px; left:96px; width:300px; height:114px; visibility:hidden;'></iframe>");
}

function makeBookMenu()
{
	document.write("<div id='hid2' class='popup_menu' style='left:268px;' onmouseover='swapClass(\"tab3\",\"menu_tab_over\"); showDiv(2)' onmouseout='swapClass(\"tab3\",\"menu_tab\"); hideDiv(2)'>");
	for(i = 0; i < hotels.length; i++)
		document.write("<a id='kmi"+i+"' href='http://www.bookin1.com/portal/in1.jsp?id="+hotels[i][2]+"&src=web&ref=web' style='color:#555555;font-weight:normal;' onmouseover='document.getElementById(\"kmi"+i+"\").style.color=\"#3838A8\"' onmouseout='document.getElementById(\"kmi"+i+"\").style.color=\"#555555\"'>"+hotels[i][0]+" ("+hotels[i][1]+")</a><br />");
	document.write("</div>");
	document.write("<iframe id='iecov2' src='javascript:false;' scrolling='no' frameborder='0' style='position:absolute; top:88px; left:268px; width:180px; height:114px; visibility:hidden;'></iframe>");
}

//name, address, bookID, offer, info, special
addHotel("<span style='font-weight:normal;'>Great Northern Hotel </span>","Bundoran, Co. Donegal","GNH","&euro;55<span style='font-size:7pt;'>pps</span>","great_northern");
addHotel("<span style='font-weight:normal;'>Holyrood  Hotel</span>","Bundoran Co. Donegal","HOL","&euro;49<span style='font-size:7pt;'>pps</span>","holyrood");
addHotel("<span style='font-weight:normal;'>Dublin Skylon  Hotel</span>","Drumcondra Co. Dublin","SKY","&euro;35<span style='font-size:7pt;'>pps</span>","skylon");
addHotel("<span style='font-weight:normal;'>Sligo Southern  Hotel</span>","Sligo Town Co. Sligo","SSH","&euro;50<span style='font-size:7pt;'>pps</span>","sligo_southern");
addHotel("<span style='font-weight:normal;'>Westport Woods  Hotel</span>","Westport Co. Mayo","WWH","&euro;55<span style='font-size:7pt;'>pps</span>",0,"http://www.westportwoodshotel.com","http://www.westportwoodshotel.com/sh747x5493.html");
addHotel("<span style='font-weight:normal;'>Yeats Country  Hotel</span>","Rosses Point Co. Sligo","YCH","&euro;55<span style='font-size:7pt;'>pps</span>",0,"yeats_country.htm","http://www.yeatscountryhotel.com/special_offers.php");


function makeBreaksMenu(relativePath)
{
	document.write("<div id='hid1' class='popup_menu' style='left:182px; height:52px;' onmouseover='swapClass(\"tab2\",\"menu_tab_over\"); showDiv(1)' onmouseout='swapClass(\"tab2\",\"menu_tab\"); hideDiv(1)'>");
	document.write("<a id='bmi0' href='"+relativePath+"theme.htm' style='color:#555555;' onmouseover='document.getElementById(\"bmi0\").style.color=\"#3838A8\"' onmouseout='document.getElementById(\"bmi0\").style.color=\"#555555\"'>Themed Breaks</a><br />");
	document.write("<a id='bmi1' href='"+relativePath+"family.htm' style='color:#555555;' onmouseover='document.getElementById(\"bmi1\").style.color=\"#3838A8\"' onmouseout='document.getElementById(\"bmi1\").style.color=\"#555555\"'>Family Breaks</a><br />");
	document.write("<a id='bmi2' href='"+relativePath+"corporate_occasions.htm' style='color:#555555;' onmouseover='document.getElementById(\"bmi2\").style.color=\"#3838A8\"' onmouseout='document.getElementById(\"bmi2\").style.color=\"#555555\"'>Corporate Events</a><br />");
	document.write("</div>");
	document.write("<iframe id='iecov1' src='javascript:false;' scrolling='no' frameborder='0' style='position:absolute; top:88px; left:182px; width:180px; height:52px; visibility:hidden;'></iframe>");
}

function makeSpecialsMenu(relativePath)
{
	document.write("<div id='hid3' class='popup_menu' style='left:354px;' onmouseover='swapClass(\"tab4\",\"menu_tab_over\"); showDiv(3)' onmouseout='swapClass(\"tab4\",\"menu_tab\"); hideDiv(3)'>");
	for(i = 0; i < hotels.length; i++)
	{
		if(hotels[i][4] != 0)
			document.write("<a id='omi"+i+"' href='"+relativePath+hotels[i][4]+"_special.htm'");
		else
			document.write("<a id='omi"+i+"' href='"+hotels[i][6]+"'");
		document.write(" style='color:#555555;' onmouseover='document.getElementById(\"omi"+i+"\").style.color=\"#3838A8\"' onmouseout='document.getElementById(\"omi"+i+"\").style.color=\"#555555\"'>"+hotels[i][0]+" ("+hotels[i][1]+")</a><br />");
	}
	document.write("</div>");
	document.write("<iframe id='iecov3' src='javascript:false;' scrolling='no' frameborder='0' style='position:absolute; top:88px; left:354px; width:180px; height:20px; visibility:hidden;'></iframe>");
}

var infos = new Array()

function info(name,link)
{
	infos[infos.length] = new Array(name,link);
}

info("Introduction","index.htm");
info("History &amp; Tradition","tradition.htm");
info("Family Breaks","family.htm");
info("Corporate Events","corporate_occasions.htm");
info("Maps/Location","maps.htm");

function create(relativePath)
{
	document.write("<div style='position:absolute; top:190px; height:13px;'>");
	document.write("	<table cellpadding='0' cellspacing='0' width='100%' style='border:1px solid #333399;'>");
	document.write("		<tr><td class='js' colspan='2'><h1>Rates From...</h1></td></tr>");
	for(i = 0; i < hotels.length; i++)
	{	
		document.write("		<tr><td class='js'><a href='http://www.bookin1.com/portal/in1.jsp?id="+hotels[i][2]+"&src=web&ref=web'>&nbsp;<img src='http://www.bmceniffhotels.com/images/left/purple_triangle.gif' /> "+hotels[i][0]+"</a></td><td class='js right'><a href='http://www.bookin1.com/portal/in1.jsp?id="+hotels[i][2]+"&src=web&ref=web'>"+hotels[i][3]+"</a></td></tr>")
	}
	document.write("	</table><br />")
	document.write("	<table cellpadding='0' cellspacing='0' style='border:1px solid #333399;' width='100%'>")
	document.write("		<tr><td class='js'><h1>Information</h1></td></tr>");
	for(i = 0; i < infos.length; i++)
	{
		document.write("		<tr><td class='js'><a href='/"+infos[i][1]+"'>&nbsp;<img src='http://www.bmceniffhotels.com/images/left/purple_triangle.gif' /> "+infos[i][0]+"</a></td></tr>");
	}
	document.write("	</table>");
	document.write("</div>");
}

function searchChange(element, relativePath)
{	
	var sdd = document.getElementById("searchdd");
	if(hotels[sdd.selectedIndex-1][4]==0)
		window.location = hotels[sdd.selectedIndex-1][5]
	else
		window.location = relativePath+hotels[sdd.selectedIndex-1][4]+".htm";
}

function validate()
{
	msg = "";
	email = document.signupform.email.value;

	if(email.length==0)
	{
		msg = "Please enter your email address";
		document.signupform.email.focus();
   }

	else if(!check_email(email))
	{
		msg = "Please enter a valid email address";
		document.signupform.email.select();
   }

	if (msg.length==0)
	{
		document.signupform.submit();
	}

	else
	{
		alert(msg);
	}
}

function check_email(e){
  ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
  for(i=0; i < e.length ;i++){
	  if(ok.indexOf(e.charAt(i))<0){
		  return (false);
		}	
	}	 

  if (document.images){
	  re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
	 re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;

	 if (!e.match(re) && e.match(re_two)){
		 return (-1);		
		} 
	}
}