/*
newquay-selfcatering.co.uk
Written by Ian Collier, of lidd Consulting on behalf of Atonic Internet Limited
This work copyright Xperian Recruitment Limited
Please do not copy or modified this work without seeking the express permission of
the copyright holder beforehand.
Thank you
*/

/* main menu script */

// variables
var timeout=500;
var closetimer=0;
var ddmenuitem=0;

// open hidden layer
function mopen(id) {	
	// cancel close timer
	mcancelclosetime();
	// close old layer
	if(ddmenuitem) {
		ddmenuitem.style.visibility='hidden';
	}
	// get new layer and show it
	ddmenuitem=document.getElementById(id);
	if(ddmenuitem!=null) {
		ddmenuitem.style.visibility='visible';
	}
}

// close showed layer
function mclose() {
	if(ddmenuitem) {
		ddmenuitem.style.visibility='hidden';
	}
}

// function to draw the main menu
function domenu() {
	// initialise html string
	var html='';
	// construct the menu
	html+='<!-- build menu -->';
	html+='<!-- unordered list -->';
	html+='<ul id="sddm">';
		html+='<!-- home  -->';
		html+='<li><a href="index.html" onmouseover="javascript:mopen(\'m1\');" onmouseout="javascript:mclosetime();">Home</a>';
		html+='</li>';
   	html+='<!-- bredon court -->';
   	html+='<li><a href="bredon_court.html" onmouseover="javascript:mopen(\'m2\');" onmouseout="javascript:mclosetime();">Bredon Court</a>';
			html+='<div id="m2" onmouseover="javascript:mopen(\'m2\');" onmouseout="javascript:mclosetime();">';
				html+='<!-- drop down options -->';
				html+='<a href="tariff.asp?m=2">Tariff</a>';				
			html+='</div>';
		html+='</li>';
		html+='<!-- beachside -->';
		html+='<li><a href="beachside.html" onmouseover="javascript:mopen(\'m3\');" onmouseout="javascript:mclosetime();">Beachside</a>';
			html+='<div id="m3" onmouseover="javascript:mopen(\'m3\');" onmouseout="javascript:mclosetime();">';
				html+='<!-- drop down options -->';
				html+='<a href="tariff.asp?m=3">Tarrif</a>';
			html+='</div>';
		html+='</li>';
  		html+='<!-- testimonials -->';
		html+='<li><a href="testimonials.html" onmouseover="javascript:mopen(\'m4\');" onmouseout="javascript:mclosetime();">Testimonials</a>';
  		html+='</li>';
		html+='<!-- links -->';
		html+='<li><a href="links.html" onmouseover="javascript:mopen(\'m5\');" onmouseout="javascript:mclosetime();">Links</a>';
		html+='</li>';
  		html+='<!-- contact us -->';
		html+='<li><a href="contact_newquay.html" onmouseover="javascript:mopen(\'m6\');" onmouseout="javascript:mclosetime();">Contact Us</a>';
		html+='</li>';
  		html+='<span class="phonetext" style="float : right;">0207 724 4445</span>';
	html+='</ul>';
	// write the html string
	document.write(html);
}

// go close timer
function mclosetime() {
	closetimer=window.setTimeout(mclose,timeout);
}

// cancel close timer
function mcancelclosetime() {
	if(closetimer) {
		window.clearTimeout(closetimer);
		closetimer=null;
	}
}

// close layer when click-out
document.onclick=mclose;

