function add_accsearch()
{
	if (document.getElementById('alterunit'))
	{
		var browserName=navigator.appName
		var noprior=true
		var tobedestroyed=false
		homediv=document.getElementsByTagName('div');
		for (x=0;x<homediv.length;x++)
		{
			if (homediv[x].id=='alterunit')
			{
				//This is a row with data in it
				thisrow=homediv[x]
				/*
				if (noprior==true)
				{
					filterbox_home=thisrow
					noprior=false
				}
				*/
				productlink=thisrow.getElementsByTagName('a')
				if (productlink[0].href==location.href)
				{
					//This is the same as the current page URL, so we can remove this alterunit
					container=homediv[x].parentNode
					tobedestroyed=homediv[x]
				}
				else
				{
					productname=productlink[0].href
					para=thisrow.getElementsByTagName('p')
					para[0].style.paddingRight='140px'
					accresult=document.createElement('p')
					accresult.setAttribute('id','acc'+x)
					accresult.style.width='140px'
					accresult.style.textAlign='right'
					if(browserName=="Microsoft Internet Explorer")
					{
						accresult.style.styleFloat="right";
					}
					else
					{ 
						accresult.style.cssFloat="right";
					}
					thisrow.appendChild(accresult)
					thisrow.insertBefore(accresult,para[0])
					add_details(productname,'acc'+x)
				}
			}
		}
		if (tobedestroyed!=false)
			container.removeChild(tobedestroyed)
		/*
		if (noprior==false)
		{
			filterbox=document.createElement('div')
			filterbox.innerHTML="<center><a href='#' onclick='toggle_filterbox(); return false;' style='background-color: #d7d9b8; border: 1px solid #cec991; padding: 0pt 10px; color: #BF6D5C;'>Show/Hide Accommodation Advanced Search</a><form id='filterbox' style='overflow: hidden;height: 0px; border:1px solid #cec991; background-color: #d7d9b8;'><h3>Filters would go here</h3><input type='checkbox'>Like this</form></center>"
			homediv.appendChild(filterbox)
			homediv.insertBefore(filterbox,filterbox_home)
		}
		*/
	}
	return
}

function add_details(pname,dest)
{
	div=document.getElementById(dest)
	div.innerHTML="<center>Retrieving Details<br><img src='http://www.namibian.org/images/page-elements/waiting.gif' style='float: none;height:20px; width:20px;'><br>Please Wait</center>";
	jsinsert = document.createElement('SCRIPT')
	jsinsert.type = 'text/javascript'
	jsinsert.src = "http://www.namibian.org/php/accsearch.php?dest="+dest+"&prod="+encodeURI(pname)
	document.body.appendChild(jsinsert)
}


function toggle_filterbox()
{
	if (document.getElementById('filterbox'))
	{
		div=document.getElementById('filterbox')
		if (div.offsetHeight<130)
		{
			scale_filterbox(140)
		}
		else
		{
			scale_filterbox(0)
		}
	}
}

function scale_filterbox(newheight)
{
	div=document.getElementById('filterbox')
	y_size=parseInt(div.offsetHeight)
	y_finished=false
	if (y_size<=newheight)
	{
		newy_size=y_size+3
		div.style.height=newy_size+"px"
		if (newy_size>=newheight)
			y_finished=true
	}
	else
	{
		newy_size=y_size-8
		div.style.height=newy_size+"px"
		if (newy_size<=0)
		{
			div.style.height="0px"
			y_finished=true
		}
	}
	if (y_finished==false)
		setTimeout(function(){scale_filterbox(newheight);},25)
}
