function isValid() {

    var valid = true;

    if ( document.callbackform.contactname.value == '' )
    {
        alert ( "Please enter a contact name" );
        valid = false;
    }
    
    if ( valid == true && document.callbackform.telephone.value == '' )
    {
        alert ( "Please enter a telephone number" );
        valid = false;
    }

    return valid;
}

function agentisValid() {


    var valid = true;


    if ( valid == true && document.agentform.contactname.value == '' )
    {
        alert ( "Please enter a contact name" );
        valid = false;
    }

    if ( valid == true && document.agentform.telephone.value == '' )
    {
        alert ( "Please enter a telephone number" );
        valid = false;
    }

    return valid;
}

function initialise()
{

	var spans = document.getElementsByTagName("span");

	var numspans = spans.length;
	
	for (i=0;i<numspans;i++)
		{

		if (spans[i].className == "back")
			{

			spans[i].style.visibility = "visible";	
			}
		}
}

function resize()
{

  if( typeof window.innerWidth  == 'number' ) {
    browser_width = window.innerWidth;
    browser_height = window.innerHeight;
    var adjustment = -1;
  } 
  else if(document.documentElement && 
             document.documentElement.clientWidth ) {
    browser_width = document.documentElement.clientWidth;
    browser_height = document.documentElement.clientHeight;
    var adjustment = 7;
  } 
  else{
    browser_width = document.body.clientWidth;
    browser_height = document.body.clientHeight;
    var adjustment = -1;    
  }

//alert("bheight=" + browser_height);

if (browser_height < 430)
	{
	browser_height = 430;
	}  
var scrollwindow = document.getElementById("scrollcontent");

//alert("scrollwindow = " + scrollwindow.style.height);

var footer = document.getElementById("footerpanel");
var postfooter = document.getElementById("postfooterpanel");
var header = document.getElementById("headerpanel");
var restriction = postfooter.offsetHeight + footer.offsetHeight + header.offsetHeight -adjustment;

//alert("postfoot=" + postfooter.offsetHeight);
//alert("foot=" + footer.offsetHeight);
//alert("head=" + header.offsetHeight);

//alert("rest=" + restriction);

var fixed = document.getElementById("fixedcontent");

if (!fixed)
	{
//alert("not fixed");
	var leftfixed = document.getElementById("fixedleft");
	var rightfixed = document.getElementById("fixedright");
	var leftheight = leftfixed.offsetHeight;
	var rightheight = rightfixed.offsetHeight;
	
	if (rightheight > leftheight)
		{
		var fixedheight = rightheight;
//alert("right");
		}
	else
		{
		var fixedheight = leftheight;
//alert("left");
		}
	}
else
	{
	var fixedheight = fixed.offsetHeight + 15;
//alert("fixed=" + fixedheight);	
	}
//alert("fixed=" + fixedheight);

var maxscrollheight = (browser_height - restriction);
//alert("maxscrollheight=" + maxscrollheight);
if (fixedheight > (430 - restriction))
	{
	if (fixedheight < maxscrollheight)
		{
		maxscrollheight = fixedheight;
		}
	}		
	else
	{
	maxscrollheight = 430 - restriction;
	}

scrollwindow.style.height = maxscrollheight + "px";

// new code

var menufooter = document.getElementById("menufooter");

//menufooter.style.top = "200px";

var footerpos = maxscrollheight - menufooter.style.height - restriction -4;

menufooter.style.top = footerpos + "px";

//alert("restriction=" + restriction);

}
//alert("scroll=" + scrollwindow.style.height);

function displaymenu(menustring,idclicked)
{

//  alert("menustring=" + menustring + " idclicked=" + idclicked);

	initialise();
	resize();

	var currentclass = '';

	var optionclicked = document.getElementById(idclicked);
	
	if (optionclicked)
		{
		var currentclass = optionclicked.className;
		}

	if (currentclass == "menupicked")
		{
		menustring = 'main!';
		}
		
	var leftmenu = document.getElementById("menupanel");

	var options = leftmenu.getElementsByTagName("input");

	var numoptions = options.length;

	
	var showoption = new Array(numoptions);
	
	document.getElementById("menustring").value = menustring;
	
	searchword = menustring.split(",");


	
	var numwords = searchword.length;
	
	for (i=0;i<numoptions;i++)
		{

		if (options[i].parentNode.parentNode.parentNode.className == "optionpicked")
			{
			options[i].parentNode.parentNode.parentNode.className = "menuoption";	
			}
			
		if (options[i].parentNode.parentNode.parentNode.className == "menupicked")
			{
			options[i].parentNode.parentNode.parentNode.className = "menuheader";	
			}
		
		if (options[i].className == "menufilter")
			{

			var optioncriteria = options[i].value;
			
			showoption[i] = "none";

			for (x=0;x<numwords;x++)
				{


				var matched = optioncriteria.match("(" + searchword[x] + ")");
	
				if (matched)
					{

					showoption[i] = "block";
					}
				}
			options[i].parentNode.parentNode.parentNode.style.display=showoption[i];
			}
		}
		
	if (currentclass == "menuheader")
		{
//		alert("menupicked");
		optionclicked.className = "menupicked";	
		swapbutton(optionclicked.id,2);		
		}
	if (currentclass == "menuoption")
		{
//		alert("optionpicked");
		optionclicked.className = "optionpicked";
		swapbutton(optionclicked.id,3);		

//		alert(optionclicked.parentNode.id);

//		var menugroup = document.getElementById(optionclicked.parentNode.id);
//		alert(menugroup.id);
		menuid = "productsid";
//		alert(menuid);

		var menuheader = document.getElementById(menuid);
//		alert("here");

//		alert(menuheader.className);
		menuheader.className = "menupicked";	
		swapbutton(menuheader.id,2);	
		}

		
}
function showimage(element)
{
	var mainimage = document.getElementById("mainimage");
	mainimage.src = element.src;
}
function resetsearch(target)
{
if (target == "hotelsearch")
	{
	var idsearch = document.getElementById("resort_id_query");
	var hotelsearch = document.getElementById("mixed_query");
	idsearch.id.value = "any";
	hotelsearch.location.value = "any";
	hotelsearch.rating.value = "any";	
	hotelsearch.resorttype.value = "any";		
	hotelsearch.minprice.value = "0";	
	hotelsearch.maxprice.value = "999";	
	}
}
function focusmap(element,name)
{
	element.src = "content/images/" + name + "_focus.gif";
}
function blurmap(element,name)
{

	element.src = "content/images/" + name + "_blur.gif";

}

function showmenu(menuid)
{
	var menu = document.getElementById(menuid);
	menu.style.display="block";
}
function hidemenu(menuid)
{
	var menu = document.getElementById(menuid);
	menu.style.display="none";
}

function swapbutton(menuid,image){
 // array of images

// alert("menuid="+menuid+" image="+image);

var buttonid = document.getElementById(menuid);

var currentclass = buttonid.className;

if (currentclass == "menupicked")
{
image=2;
}

if (currentclass == "optionpicked")
{
image=3;
}

var bottomid = menuid + "bottom";
var topid = menuid + "top";

var bottomimg = document.getElementById(bottomid);
var topimg = document.getElementById(topid);

var bottomclass = "bottombutton" + image;
var topclass = "topbutton" + image;

bottomimg.className = bottomclass;
topimg.className = topclass;

}