
//common.js


function AddEventListener(obj, type, action)
{
	if(typeof window.addEventListener != 'undefined')
	{
		//.. gecko, safari, konqueror and standard
		obj.addEventListener(type, action, false);
	}
	else if(typeof document.addEventListener != 'undefined')
	{
		//.. opera 7
		obj.addEventListener(type, action, false);
	}
	else if(typeof window.attachEvent != 'undefined')
	{
		//.. win/ie
		obj.attachEvent('on' + type, action);
	}
}


function GetEventSource(pthis)
{
	if(!document.all)
	{
		//.. moz
		var x = pthis;
	}
	else
	{
		//.. ie
		var x = window.event.srcElement;
	}
	return x;
}



var iRoomCount  = 0;



function hpaccosearchAddUnitInitialise()
{
	var cont;
	if (document.getElementById('hpaccosearch')) 
	{
		cont = document.getElementById('hpaccosearch')
	}
	else if (document.getElementById('roomReqs'))
	{
		cont = document.getElementById('roomReqs').parentElement;	
	}
	if (cont)
	{
		AddRoomLink = cont.getElementsByTagName('a');
		for (var i = 0; i < AddRoomLink.length; i++)
		{
			var x = AddRoomLink.item(i);
			if (x.className.toLowerCase()=='addanotherroom')
			{
				x.href='#';
				AddEventListener(x, 'click', hpaccosearchAddUnit);
				AddEventListener(x, 'keypress', hpaccosearchAddUnit);
				
			}
			
		}
	
	}
	
}


function hpaccosearchAddUnit()
{
	iRoomCount++;
	document.getElementById('NumRoomReqs').value = iRoomCount;
	var theNode = document.getElementById('roomsReqRow2').cloneNode(true);
	theNode.id = theNode.id.replace('roomsReqRow2', 'roomsReqRow' + iRoomCount);
	theNode.innerHTML = theNode.innerHTML.replace(/roomReq_2/g, 'roomReq_' + iRoomCount).replace(/Room 2/g, 'Room ' + iRoomCount);
	document.getElementById('roomReqs').appendChild(theNode);
	return false;
}



// Excursion Javascript - MBirkett 20060830

function ShowId(aId,abVisible)
{
	document.getElementById(aId).style.display= (abVisible?"block":"none");
}

function Excur_CreateNote()
{
	ShowId("ExcursionTxtNotesForm",true);
	ShowId("ExcursionTxtNotesLbl",false);
	return false;
}
function Excur_EmailFr()
{
	ShowId("ExcursionEmailFrForm",true);
	ShowId("ExcursionEmailFrLbl",false);
	return false;
}
function Excur_NoteLimit1(aTextbx)
{
	return (aTextbx.value.length<512);
}

function Excur_NoteLimit2(aTextbx)
{
	aTextbx.style.backgroundColor=(aTextbx.value.length<512?'#fff':"#faa");
}
