/*****************************************************************
GENERIC SITE FUNCTIONS
*****************************************************************/
<!--
//	DOM
var IE=false;
var MOZ5=false;
var NS=false;

//	Request vars object
var url = new Object();

var tid = null;
var opentip = null;

// For table-row duplication/removal
var rowsAdded = 0;

//	Detect browser
detectBrowser();
getRequestVars();

/*
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0
*/

//	Determine the current browser
function detectBrowser() 
{
	if (document.all) {
	  IE = true;
	}
	else if (document.layers) {
	  NS = true;
	}
	else if (document.getElementById) {
	  MOZ5 = true;
	}
	else {
	  NS = true;
	  // No known browser support for layers
	}
}

function over(img,ext)
{
	if (ext == null)
		img.src=site_root + 'images/' + img.id + '_f2.jpg';
		
	else
		img.src=site_root + 'images/' + img.id + '_f2.' + ext;
}

function out(img,ext)
{
	if (ext == null)
		img.src=site_root + 'images/' + img.id + '.jpg';
		
	else
		img.src=site_root + 'images/' + img.id + '.' + ext;
}

function togglePanel(objName,imgName)
{
	var p=getObj(objName);
	var img=getObj(imgName);
	
	if (p==null)
		return false;	
		
	if (p.style.display=='none'||p.style.display=='')
	{
		p.style.display='block';
		
		if (img)
			img.src = baseName(img.src) + '/' + img.id + '_hide.png';
	}
	else
	{
		p.style.display='none';
		
		if (img)
			img.src = baseName(img.src) + '/' + img.id + '_show.png';
	}
}

function getRequestVars()
{  
	var qs = location.search.substring(1);
  	var nv = qs.split('&');
  	
	for(i = 0; i < nv.length; i++)
  	{
    	eq = nv[i].indexOf('=');
    	url[nv[i].substring(0,eq).toLowerCase()] = unescape(nv[i].substring(eq + 1));
  	}
}

function baseName(path)
{
	var dirs = path.split("/");
	var path = '';
	
	if (dirs.length > 1)
		dirs.pop();
	
	path = dirs.join("/");
	
	return path;
}

function preloadImages()
{
	if (!document.images)
		return;
		
	for (i = 0; i < document.images.length ; i++)
	{
		img = new Image();
		img_src = site_root + 'images/' + document.images[i].id + '_f2.jpg';
		img.src = img_src;
	}
	
	return true;
}

//	Get document object by string names
function getObj(str,array)
{
	if (IE)
		obj = document.all[str];
		
	else if (MOZ5)
	{
		if (array!=null)
			obj = document.getElementsByName(str);
		else
			obj = document.getElementById(str);
	}
	else 
		obj = document.layers[str];
		
	if (obj == null)
		return false;
		
	return obj;
}

function getMouseXY(e) 
{
	var coords = new Array();
	if (IE) 
	{
		tempX = event.clientX + document.body.scrollLeft
		tempY = event.clientY + document.body.scrollTop
	} 
	else 
	{ 
		tempX = e.pageX
		tempY = e.pageY
	}  
	 
//	Zero coords if outside screen
	if (tempX < 0)
		tempX = 0;
	if (tempY < 0)
		tempY = 0;
		
//	Fill return array
	coords["X"] = tempX;
	coords["Y"] = tempY;
		
	return coords;
}

function viewRoomDesc(key)
{		
	var r=getObj('room_desc_'+key);
	var o=getObj('open_close_'+key);
	var a;
	var i;
	
	if (r==null)
		return;
	if (r.style.display=='none')
	{
		r.style.display='block';
		for (i=0;i < 14;i++)
		{
			a =getObj('room_avail_'+key+"_"+i);
			a.style.display='block';
		}
		o.src=site_root+'images/close.gif';

	}		
	else 
	{
		r.style.display='none';
		for (i=0;i < 14;i++)
		{
			a =getObj('room_avail_'+key+"_"+i);
			a.style.display='none';
		}
		o.src=site_root+'images/open.gif';
	}
}

function insert(obj,str)
{
	if (!obj)
		return false;
		
	if (IE || MOZ5)
		obj.innerHTML = str;
		
	else
		obj.write(str);
	
	return;
}

function setStyle(o,fieldclass)
{   
    if(o){
    	if (IE)
    		return o.setAttribute('className',fieldclass);

    	else
    		return o.setAttribute('class',fieldclass);
    }
}
	
//	Empties a dropdown box
//	Params - object[,object,object...]
function emptyDD()
{
	a=emptyDD.arguments;
	
	for (i=0;i<a.length;i++)
	{
		obj=a[i];
		
		if (!obj || !obj.options)
			continue;

		for(j=0;j<obj.options.length;j++)
			obj.options[j]=null;
	}	
}

function openGallery(h, integrated)
{
	if (h==null)
		return false;
	if(integrated)
		window.open(site_root+'gallery_partner.php?h='+h,'gallery','width=620,height=600,resize=false,scrollbars=auto');
	else
		window.open(site_root+'gallery_yr.php?h='+h,'gallery','width=620,height=800,resize=false,scrollbars=auto');
	
	return;
}

function openLMGallery(h, ids)
{

	if (h==null)
		return false;

	window.open(site_root+'gallery_lm.php?h='+h+'&ids='+ids,'gallery','width=620,height=600,resize=false');
	
	return;
}

function fillTxt(msg,t,e)
{	
	if (t==null)
		return false;
		
	switch (e)
	{
		case 'on':
			if (t.value==msg)
				t.value='';
				
			break;
			
		case 'off':
			if (t.value=='')
				t.value=msg;
				
			break;
	}
	
	return;
}

function disableCurrencyBox() {
	
	var currBox = getObj('sel_currency');
	currBox.disabled = 'disabled';
	return;
}

function showMsg(msg,mode)
{
//	Get object
	m=getObj('msg_layer');
	
	if (!m)
		return;
		
//	Insert message
	insert(m,msg);
	
//	Position layer
	center(m);
	
//	Display Layer
	m.style.display='inline';
	
	window.onscroll=center;
	window.onresize=center;
}

function center(obj)
{			
	if (window.pageYOffset)
	{
		var left=(window.innerWidth/2)-275;
		var top=parseInt(((window.innerHeight/2)-65))+parseInt(window.pageYOffset);
	}
	else
	{
		var left=(document.body.clientWidth/2)-275;
		var top=parseInt(document.body.clientHeight)-parseInt(((screen.width/2)-65));
	}
	
	if (top<=230)
		top=230;
		
	obj.style.left=left+'px';
	obj.style.top=top+'px';
}

function setSlide(src)
{
	var f = getObj('frm_slideshow');
	
	f.src=src;
}

function showTip(mObj,oName)
{
	if (tid != null)
		clearTimeout(tid);
		
	opentip = getObj(oName);
	
	if (!opentip)
		return;
		
	//opentip.style.left 	= tempX+'px';
	//opentip.style.top 	= tempY+'px';
	tid = setTimeout("makeVisibleTip('"+oName+"',"+tid+")",800);
	mObj.onmouseout = hideTip;
}

function hideTip()
{
	if (tid != null)
		clearTimeout(tid);
		
	opentip.style.display='none';
}

function makeVisibleTip(oName)
{
	var obj = getObj(oName);
	obj.style.display='block';
}


// 

/**
* Function::addTableRow()
* 
* Copies a table row and adds a copy of it in the next row
* 
* @param        string  sTableID  The ID of the table
* @param        string  sRowID    The ID of the table row
*/
function addTableRow( sTableID, sRowID )
{
	var table_row = document.getElementById( sRowID );
	var table_object = document.getElementById( sTableID );
	
	new_row = table_object.insertRow( table_row.rowIndex + rowsAdded + 1);
	
	//var row = table_row.cloneNode( true );
	
	for (i=0; i<table_row.cells.length;i++)
	{
		current_cell = document.createElement("td");
		
		current_cell.innerHTML = table_row.cells[i].innerHTML;
			
		new_row.appendChild( current_cell );
	}
	
	rowsAdded++;
}

/**
* Function::removeTableRow()
* 
* Removes the last instance of a table row for the given Table and Row IDs
* 
* @param        string  sTableID  The ID of the table
* @param        string  sRowID    The ID of the table row
*/
function removeTableRow( sTableID, sRowID )
{
	if (rowsAdded == 0)
		return;
		
	var table_row = document.getElementById( sRowID );
	var table_object = document.getElementById( sTableID );
	var lastRow = table_row.rowIndex + rowsAdded;
	table_object.deleteRow(lastRow);
	rowsAdded--;
}

// 
/**
* Function::getSelectedValue()
* 
* Retrieve the selected value of a SELECT form element object
* 
* @param        object  oSelectObj The DOM SELECT object
* @return       mixed   Value of the selected item
*/
function getSelectedValue( oSelectObj )
{
	var index = oSelectObj.selectedIndex;
	return oSelectObj.options[index].value;
}

//if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
//document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
//var tempX = 0
//var tempY = 0
//-->
