var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
try {
	xmlhttp = new XMLHttpRequest();
} catch (e) {
	xmlhttp=false;
}
}
if (!xmlhttp && window.createRequest) {
try {
	xmlhttp = window.createRequest();
} catch (e) {
	xmlhttp=false;
}
}

var swch;

function om(oid,m_id) {
	
	posobj=document.getElementById(oid);
	
	for(var ii=1;ii<=100;ii++) {
		if ((m_id!=('mr' + ii))&&(document.getElementById('mr'+ii))) {
			curobj=document.getElementById('mr'+ii);
			curobj.style.visibility='hidden';
		}
	}
	
	curobj=document.getElementById(m_id);
	curobj.style.left=Left(posobj)-7 + 'px';
	curobj.style.top=Top(posobj)-(-posobj.offsetHeight) + 'px';
	curobj.style.visibility='visible';
}

function cmo() {
	for(var ii=1;ii<=100;ii++) {
		if (document.getElementById('mr'+ii)) {
			curobj=document.getElementById('mr'+ii);
			curobj.style.visibility='hidden';
		}
	}
}

function d_over_n(o_id,p_id,e_id) {
	document.getElementById(e_id+'_1').className='tl_black';
	document.getElementById(e_id+'_2').className='tm_black';
	document.getElementById(e_id+'_3').className='tr_black';
	clearTimeout(swch);
	if (document.getElementById(p_id)) {
		om(o_id,p_id);
	}
	else {
		for(var ii=1;ii<=100;ii++) {
			if (document.getElementById('mr'+ii)) {
				curobj=document.getElementById('mr'+ii);
				curobj.style.visibility='hidden';
			}
		}
	}
}

function d_over_n_test(o_id, p_id, e_id) {
    document.getElementById(e_id + '_1').className = 'tl_black';
    document.getElementById(e_id + '_2').className = 'tm_black';
    document.getElementById(e_id + '_da').className = 'tlda_black';
    document.getElementById(e_id + '_3').className = 'tr_black';
    clearTimeout(swch);
    if (document.getElementById(p_id)) {
        om(o_id, p_id);
    }
    else {
        for (var ii = 1; ii <= 100; ii++) {
            if (document.getElementById('mr' + ii)) {
                curobj = document.getElementById('mr' + ii);
                curobj.style.visibility = 'hidden';
            }
        }
    }
}

function d_out_n(p_id,e) {
	document.getElementById(p_id+'_1').className='tl';
	document.getElementById(p_id+'_2').className='tm';
	document.getElementById(p_id+'_3').className='tr';
	swch=setTimeout('cmo()',500);
}

function d_out_n_test(p_id, e) {
    document.getElementById(p_id + '_1').className = 'tl';
    document.getElementById(p_id + '_2').className = 'tm';
    document.getElementById(p_id + '_da').className = 'tlda';
    document.getElementById(p_id + '_3').className = 'tr';
    swch = setTimeout('cmo()', 500);
}

function Left(obj)
	{
		var curleft = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
			curleft += obj.x;
		return curleft;
	}
   
function Top(obj)
	{
		var curtop = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			curtop += obj.y;
		return curtop;
	}

function ll(tid) {
		o=document.getElementById('sareaaccommodation');
		o.options.length=0;
		o.options[0] = new Option('Loading list...',-1);
		xmlhttp.open("GET", "/suburblist.asp?id="+tid,true);   
		xmlhttp.onreadystatechange=usl;
		xmlhttp.send(null); 
	}

function usl() {
	if (xmlhttp.readyState==4) {
		o=document.getElementById('sareaaccommodation');
		
	  ot=xmlhttp.responseText;
	  var otarr=ot.split('<>');
	  o.options[0] = new Option('Area / All',-1);
	  for(var m=0;m<otarr.length;m++) {
		var lt=otarr[m].split('::');
		if (lt[1]=='')
			o.options[m+1] = new Option(lt[0] + ' (' + lt[2] + ')',lt[0].toLowerCase());
		else
			o.options[m+1] = new Option(lt[0] + ' (' + lt[2] + ')',lt[1]);
	  }
   }		
}

function cfa(kplural) {
	d=document.getElementById('satownid').value;
	eURL='';
	if (d==1)
		URL='http://www.capetown-direct.com';
	if (d==2)
		URL='http://www.johannesburg-direct.com';
	if (d==3)
		URL='http://www.durban-direct.com';
	if (d==7)
		URL='http://www.gardenroute-direct.com';
	if (d==8)
		URL='http://www.northerncape-direct.com';
	if (d==11)
		URL='http://www.krugerpark-direct.com';
	if (d==12)
		URL='http://www.swaziland-direct.com';
	if (d==15)
		URL='http://www.victoriafalls-direct.com';
	if (d==27)
		URL='http://www.kenyasafari-direct.com';
	if (d==29)
		URL='http://www.namibia-direct.com';
	if (d==30)
		URL='http://www.mozambique-direct.com';
	if (d==31)
		URL='http://www.botswana-direct.com';
	if (d==32)
		URL='http://www.mauritiushotels-direct.com';
	if (d==33)
		URL='http://www.madagascarhotels-direct.com';
	if (d==34)
		URL='http://www.seychelles-direct.com';
	if (d==43)
		URL='http://www.benin-direct.com';
	if (d==44)
		URL='http://www.algeriahotels-direct.com';
	if (d==45)
		URL='http://www.tanzania-direct.com';
	if (d==46)
		URL='http://www.nigeria-direct.com';
	if (d==47)
		URL='http://www.moroccohotels-direct.com';
	if (d==48)
		URL='http://www.malawi-direct.com';
	if (d==49)
		URL='http://www.libya-direct.com';
	if (d==50)
		URL='http://www.orlandovacation-direct.com';
	if (d==55)
		URL='http://www.sanfrancisco-direct.com';
	if (d==56)
		URL='http://www.miami-direct.com';
	if (d==60)
		URL='http://www.newyork-direct.com';
	if (d==65)
		URL='http://www.canadavacation-direct.com';
		
	level1raw=document.getElementById('sareaaccommodation').value;
	if (level1raw=='-1') {
		document.getElementById('sf').action=URL + '/' + kplural;
	}
	else {
		level1=level1raw.split(':')[0];
		itemtype=level1raw.split(':')[1];
		
		if (itemtype=='s') {
			if (level1==-1)
				eURL='/' + kplural;
			else
				eURL='/' + level1 + '/' + kplural;
		
			document.getElementById('sf').action = URL + eURL;
		}
		else {
			document.getElementById('sf').action = URL + '/g/' + level1;
		}
	}
	
	return true;
}

function cfadotnet(kplural) {
	d=document.getElementById('ctl00_satownid').value;
	eURL='';
	if (d==1)
		URL='http://www.capetown-direct.com';
	if (d==2)
		URL='http://www.johannesburg-direct.com';
	if (d==3)
		URL='http://www.durban-direct.com';
	if (d==7)
		URL='http://www.gardenroute-direct.com';
	if (d==8)
		URL='http://www.northerncape-direct.com';
	if (d==11)
		URL='http://www.krugerpark-direct.com';
	if (d==12)
		URL='http://www.swaziland-direct.com';
	if (d==15)
		URL='http://www.victoriafalls-direct.com';
	if (d==27)
		URL='http://www.kenyasafari-direct.com';
	if (d==29)
		URL='http://www.namibia-direct.com';
	if (d==30)
		URL='http://www.mozambique-direct.com';
	if (d==31)
		URL='http://www.botswana-direct.com';
	if (d==32)
		URL='http://www.mauritiushotels-direct.com';
	if (d==33)
		URL='http://www.madagascarhotels-direct.com';
	if (d==34)
		URL='http://www.seychelles-direct.com';
	if (d==46)
		URL='http://www.nigeria-direct.com';
	if (d==47)
		URL='http://www.moroccohotels-direct.com';
	if (d==50)
		URL='http://www.orlandovacation-direct.com';
	if (d==55)
		URL='http://www.sanfrancisco-direct.com';
	if (d==56)
		URL='http://www.miami-direct.com';
	if (d==60)
		URL='http://www.newyork-direct.com';
	if (d==65)
		URL='http://www.canadavacation-direct.com';
		
	level1raw=document.getElementById('sareaaccommodation').value;
	if (level1raw=='-1') {
		document.getElementById('sf').action=URL + '/' + kplural;
	}
	else {
		level1=level1raw.split(':')[0];
		itemtype=level1raw.split(':')[1];
		
		if (itemtype=='s') {
			if (level1==-1)
				eURL='/' + kplural;
			else
				eURL='/' + level1 + '/' + kplural;
		
			document.getElementById('sf').action = URL + eURL;
		}
		else {
			document.getElementById('sf').action = URL + '/g/' + level1;
		}
	}
	
	return true;
}
	
function gr() {
		var rs='';
		if (xmlhttp.readyState==4) {
			busyreq=false;
			outputtext=xmlhttp.responseText;
			rs='<div style="padding:10px"><div class=dcb style="margin-bottom:10px"><b>SEARCH RESULTS</b></div>';
			if ((outputtext!='') & (outputtext!=null)) {
				outputtextarr=outputtext.split('//>>');
				for(var pp=0;pp<=outputtextarr.length-1;pp++) {
					m=getFieldValue('m', outputtextarr[pp]);
					t=getFieldValue('t', outputtextarr[pp]);
					_id=getFieldValue('id', outputtextarr[pp]);
					rs+='<div class=sbi>';
					rs+=(t==2)?'<img src="/images/icons/houseicon-blue1.png">':(t==0)?'<img src="/images/icons/suburb-green1.png">':'';
					//rs+='</div><div class=sbl><a href="#" onclick="rc(\'' + q + '\',\'' + getFieldValue('l', outputtextarr[pp]) + '\')">' + getFieldValue('n', outputtextarr[pp]) + '</a></div><div class=sblm>';
					rs+='</div><div class=sbl><a href="' + getFieldValue('l', outputtextarr[pp]) + '">' + getFieldValue('n', outputtextarr[pp]) + '</a></div><div class=sblm>';
					if (m!='') {
						rs+='<form style="margin-top:0px;margin-bottom:0px;padding:0px" action="' + m + '" method="post">';
						rs+=(t==2)?'<input type="hidden" name="propertyid" value="' + _id + '">':'';
						rs+='[<input type="submit" value="map" style="border:none;background:#FFFFFF;font-weight:normal;padding:0px;text-align:left;display:inline" class=lnk>]</form>';
					}
					itxt=(outputtextarr[pp]>1)?'items':'item';
					rs+='</div><div class=sblm>(' + getFieldValue('c', outputtextarr[pp]) + ' ' + itxt + ')</div><br clear=all>';
				}
				rs+='<div class=dvd></div><a href="#" onclick="document.getElementById(\'rdiv\').style.display=\'none\';" style="float:right"><b>Close</b></a></div>';
				//alert(getFieldValue('n', outputtextarr[0]));
			}
			else
				rs+='<div>No results found...</div>';
			document.getElementById('rdiv').innerHTML=rs; 
		}
	}
	
var q;
var busyreq=false;
var lks, ctm;

function dothis(qs) {
	if (qs.value.length >= 3) {
		lks = new Date();
		setTimeout('ct(' + lks.getTime() + ')',550);
		}
	else
		document.getElementById('rdiv').innerHTML='';
}
	
function getFieldValue(fieldName,sourceText) {
	dataArray=sourceText.split("|||");
	for(var i=0; i < dataArray.length; i++) {
	 fieldArray=dataArray[i].split(":<>:");
	 if (fieldArray[0]==fieldName)
		return fieldArray[1];
	}
	return "";
}

function ct(ti) {
	if (ti==lks.getTime()) {
		ctm = new Date();
		if ((ctm.getTime() - ti) > 500) {
			qs=document.getElementById('q_s');
			r_d=document.getElementById('rdiv');
			r_d.style.display=''; 
			r_d.style.left=Left(qs) - r_d.offsetWidth - (-qs.offsetWidth) + 'px';
			r_d.style.top=Top(qs) + qs.offsetHeight + 'px';
			r_d.innerHTML='<div style="padding:10px;heigth:40px"><div style="float:left"><b>Loading</b></div><div id=d1 style="display:none;float:left;width:3px">.</div><div id=d2 style="display:none;float:left;width:3px">.</div><div id=d3 style="display:none;float:left;width:3px">.</div><div id=d4 style="display:none;float:left;width:3px">.</div><div id=d5 style="display:none;float:left;width:3px">.</div></div>';

			setTimeout('if (document.getElementById(\'d1\')) {document.getElementById(\'d1\').style.display=\'\';}',500);
			setTimeout('if (document.getElementById(\'d2\')) {document.getElementById(\'d2\').style.display=\'\';}',1000);
			setTimeout('if (document.getElementById(\'d3\')) {document.getElementById(\'d3\').style.display=\'\';}',1500);
			setTimeout('if (document.getElementById(\'d4\')) {document.getElementById(\'d4\').style.display=\'\';}',2000);
			setTimeout('if (document.getElementById(\'d5\')) {document.getElementById(\'d5\').style.display=\'\';}',2500);
			
			busyreq=true;
			q=qs.value;
			xmlhttp.open("GET",'/searchsuggest.asp?q=' + q);
			xmlhttp.onreadystatechange=gr;
			xmlhttp.send(null);
		}
	}
}

function uc_x(v,cstr) {
	itxtx='';
	for(var ii=1;ii<=v;ii++) {
		itxtx+='&nbsp;<select class=pss name="Children Ages" style="width:75px" id="child_' + ii + '"><option value="--">--</option><option value="1 yrs">1 yrs</option><option value="2 yrs">2 yrs</option><option value="3 yrs">3 yrs</option><option value="4 yrs">4 yrs</option><option value="5 yrs">5 yrs</option><option value="6 yrs">6 yrs</option><option value="7 yrs">7 yrs</option><option value="8 yrs">8 yrs</option><option value="9 yrs">9 yrs</option><option value="10 yrs">10 yrs</option><option value="11 yrs">11 yrs</option><option value="12 yrs">12 yrs</option></select>';
		if ((ii%4)==0) {itxtx+='<br clear=all>';}
	}
	document.getElementById('childrenages').innerHTML=itxtx;
	if (v>=1)
		document.getElementById('childrenagesdiv').style.display='';
	else
		document.getElementById('childrenagesdiv').style.display='none';
	
	if (cstr!='') {
		cstrarr=cstr.split(',');
		for(var ii=0;ii<cstrarr.length;ii++) {
			sindex(document.getElementById('child_' + (ii-(-1))),cstrarr[ii]);
		}
	}
}

function sindex(_o,_v) {
	if (_o) {
		for(var kk=0;kk<_o.options.length;kk++) {
			if (trim(_o.options[kk].value)==trim(_v))
				_o.selectedIndex=kk;
		}
	}
}

function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}

function isChild(s,d) {
	while(s) {
		if (s==d) 
			return true;
		s=s.parentNode;
	}
	return false;
}

