
///////////////////
//  open window utils
///////////////////

// general window, there can be only one but contents and size can change
var genWin='';
function openWindow (url,name,width,height,options) {
	if (!genWin.closed && genWin.location) genWin.location.href = url;
	else genWin=window.open(url,name,'width='+width+',height='+height+','+options);
	//genWin.resizeTo(width,height);
	if (window.focus) genWin.focus();
}

// Open the help popup window
var helpWin='';
function openHelpWin(helpurl) 
{
	if (!helpWin.closed && helpWin.location) helpWin.location.href = helpurl;
	else helpWin = window.open(helpurl,'helpPopup','width=320,height=480,status=1,menubar=0,scrollbars=1,resizable=1');
	if (window.focus) helpWin.focus();
}


// Open the map popup window
var mapWin='';
function openMapWin(url,width,height) 
{
	// if not closed the window supports the focus method call focus
	// else open the window, resize and focus it if supported by browser
	// we must resize to ensure windows that are already open are resized
	if (!mapWin.closed && mapWin.focus) mapWin.focus();
	else 
	{
		width = width+15;
		height = height+70;
		mapWin=window.open(url,'mapPopup','width='+(width+15)+',height='+(height+70)+',status=1,menubar=0,scrollbars=1,resizable=1');
		mapWin.resizeTo(width,height);
		if (window.focus) mapWin.focus(); 
	}
}


// Open the OS map popup window
var OSMapWin='';
function openOSMapWin(url,width,height)
{
	// if not closed the window supports the focus method call focus
	// else open the window, resize and focus it if supported by browser
	// we must resize to ensure windows that are already open are resized
	if (!OSMapWin.closed && OSMapWin.focus) OSMapWin.focus();
	else 
	{
		OSMapWin=window.open(url,'osmapPop','width='+width+',height='+height+',status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no');
		OSMapWin.resizeTo(width,height);
		if (window.focus) OSMapWin.focus(); 
	}
}

// Open the card popup window
var cardWin='';
function openCardWin(url)
{
	if (!cardWin.closed && cardWin.focus) cardWin.focus();
	else 
	{
		cardWin=window.open(url,'routeCardPopup','resizable=yes');
		if (window.focus) cardWin.focus();
	}
}

// Open the location popup window
var locWin='';
function openLocWin(url)
{
	if (!locWin.closed && locWin.focus) locWin.focus();
	else 
	{
		locWin=window.open(url,'locPopup','width=455,height=635,status=no,toolbar=no,menubar=no,location=no')
		if (window.focus) locWin.focus();
	}
}

// Open the gradient popup window
var gradWin='';
function openGradWin(url,width,height)
{
	// if not closed and supports focus, focus
	// else open the window and resize
	// set focus if supporte by browser
	if (!gradWin.closed && gradWin.focus) gradWin.focus();
	else 
	{
		width = width+15;
		height = height+70;
		gradWin=window.open(url,'gradPop','width='+width+',height='+height+',status=no,toolbar=no,menubar=no,location=no');
		gradWin.resizeTo(width,height);
		if (window.focus) gradWin.focus(); 
	}
}

// Open the accomodation popup window
var accomWin='';
function openAccom (who) {
	// if not closed and supports location property close the location
	// else open the window
	// set focus if supporte by browser
	url = 'accommodationDetail.asp?a=' + who;
	if (!accomWin.closed && accomWin.location) accomWin.location.href = url;
	else accomWin=window.open(url,'accomDetails','width=540, height=320,scrollbars=yes',false)
	if (window.focus) accomWin.focus();
}

// Open the accomodation popup window 2
var accomHowtoWin='';
function openAccomHowto() {
	// if not closed and supports location property close the location
	// else open the window
	// set focus if supporte by browser
	if (!accomHowtoWin.closed && accomHowtoWin.focus) accomHowtoWin.focus();
	else
	{
		accomHowtoWin=window.open('accommodationAdd.asp','accomHowTo','width=320, height=200',false)
		if (window.focus) accomHowtoWin.focus();
	}
}


function windowWidth () {
	var tmp = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		tmp = window.innerWidth;
	} 
	else {
	  if( document.documentElement && document.documentElement.clientWidth  ) {
	    //IE 6+ in 'standards compliant mode'
	    tmp = document.documentElement.clientWidth;
	  } 
	  else {
	    if( document.body && document.body.clientWidth ) {
	      //IE 4 compatible
	      tmp = document.body.clientWidth;
	    }
	  }
	}
	return tmp;
}

function windowHeight () {
	var tmp = 0;
	if( typeof( window.innerHeight ) == 'number' ) {
		tmp = window.innerHeight;
	} 
	else {
	  if( document.documentElement && document.documentElement.clientHeight ) {
	    //IE 6+ in 'standards compliant mode'
	    tmp = document.documentElement.clientHeight;
	  } 
	  else {
	    if( document.body && document.body.clientHeight  ) {
	      //IE 4 compatible
	      tmp = document.body.clientHeight;
	    }
	  }
	}
	return tmp;
}



// ----------------------------------------------------------- 
// Utility code from get2dom.com
// -----------------------------------------------------------

 /* getRef
 *   Return an object reference, first DOM, then UA specific
 *   Warning: object must exist
 *   Dominic Winsor, www.get2dom.com
 */
function getRef( element ) {

	if ( document.getElementById( element ) )
		return document.getElementById( element );
		
	if ( document.all )
		return document.all[element];
	
	if ( document.layers )
		return document.layers[element];

}


/* 
 * CHANGE THE CLASS OF AN ELEMENT
 * Dominic Winsor, www.get2dom.com
 * Usage: index=layer id, if not supplied then it will return to
 *        previous class. class=stylesheet class to apply
 */

lastChange = new String();
lastClass = new String();

function swapClass(index,className) {
	if( index ) {
		lastChange = index;
		lastClass = getRef(index).className;
		getRef(index).className = className;
	} else {
		getRef(lastChange).className = lastClass;
	}
}

