<!--
var vistop=0,visbot=14;
var seltip=0;
var distips = new Array();
var disvals = new Array();

function tipkeyup(e)
{
	var keynum = e.keyCode || e.which;
	var val = getElm('coursetxt').value;

	// only search on words greater than 2 chars long
	if(val.length<3)
	{
		popd();
		return;
	}
		
	if (e.shiftKey&&(keynum>48 && keynum<57))
		return;

	if(keynum < 32 || (keynum>48 && keynum<57)||(keynum >= 33 && keynum < 46) || (keynum >= 112 && keynum <= 123)||keynum>126)
		return;

	switch(keynum)
	{

		default:		// if none of the above are pressed, reload the list
			seltip=-1;

			if(val!='')
				loadtips(e,val);
			else
				popd();
			break;
	}
}

function tipkeydown(e)
{
	var keynum = e.keyCode || e.which;
	var val = getElm('coursetxt').value;

	// only search on words greater than 2 chars long
	if(val.length<3)
	{
		popd();
		return;
	}
		
	switch(keynum)
	{
		case 8: case 46: // backspace key
			seltip=-1;
			val = val.substr(0,val.length-1);
			
			if(val!='')
				loadtips(e,val);
			else
				popd();
			break;

		case 9: //tab key
			if(seltip!=-1)
				selecttip(seltip);
			else
				popd();
			break;
		case 13:		// enter key
			selecttip(seltip);
			break;
		case 38:		// up key
			changeselectedtip(e,seltip-1);
			break;
		case 40:		// down key
			changeselectedtip(e,seltip+1);
			break;
	}

}

function changeselectedtip(e,val)
{
	// clear any previous setting
	if(seltip!=-1)
		getElm('row-'+seltip).style.backgroundColor = '';

	seltip = val;
	seltip = (seltip<0)?0:seltip;

	if(seltip>visbot)
	{
		getElm('ofbox').scrollTop = getElm('ofbox').scrollTop+14;
		visbot++;
		vistop++;
	}
	else if(seltip<vistop)
	{
		getElm('ofbox').scrollTop = getElm('ofbox').scrollTop-14;
		vistop--;
		visbot--;
	}

	getElm('row-'+seltip).style.backgroundColor = '#F1F4CA';

}

function loadtips(e,val)
{
	callServ(siteurl+'/golfcourses/golfcoursesjax.php?op=loadtips&val='+val,loadtipsresult,true);
}

function loadtipsresult(xml)
{
	var airp,out="",found=-1,counter=0;
	vistop=0;visbot=14;
	out="<div style=\"cursor:pointer;\" align=\"left\">";
	distips = new Array();
	disvals = new Array();
	
	var re = new RegExp(getTag(xml,'value')[0].firstChild.data,"gi");
	
	for(var i=0;i<getTag(xml,'noresults')[0].firstChild.data;i++)
	{
		var tag = getTagAttr(xml,i,'tag');
		distips.push(tag[0]);
		disvals.push(tag[1].replace(/ /g,'-'));
		out += "<div style=\"padding:2px 0 2px 0;\" onclick=\"selecttip("+counter+");\" id=\"row-"+counter+"\" name=\"row-"+counter+"\"  onmouseover=\"changeselectedtip(event,"+counter+");\">"+distips[i].replace(re,function(m){return highlighttext(m)})+"</div>";
		counter++;		
	}
	out +="</div>";
	
	pop(getLeft(getElm('coursetxt'))-10,getTop(getElm('coursetxt'))+18,out,false,440,true);
}




function highlighttext(match)
{
	return("<b>"+match+"</b>");
}

function selecttip(sel)
{
	popd();
	if(sel==-1) return;
	var tmp = disvals[sel];
	tmp = tmp.split(' - ');
	getElm('coursetxt').value=tmp[0];
	seltip = sel;
	if(getElm('courseform')!=null)
		getElm('courseform').submit();
}

function getLeft(elm)
{

    var oNode = elm;
    var iLeft = 0;

    while(oNode!=null && oNode.tagName != "body") 
    {
        iLeft += oNode.offsetLeft;
        oNode = oNode.offsetParent;
    }

    return iLeft;
}

function getTop(elm)
{

    var oNode = elm;
    var iTop = 0;

    while(oNode!=null && oNode.tagName != "body") {
        iTop += oNode.offsetTop;
        oNode = oNode.offsetParent;
    }

    return iTop;
}

function addcomment()
{
	getElm('addcommentdiv').style.display = '';
}

function submitcomment(tip,comments,rating)
{
	if(empty(rating)||rating<1)
	{
		alert('Please select a rating');
		return false;
	}
	
	if(empty(comments))
	{
		alert('Please enter some comments before proceeding.');
		return false;
	}
	// show adding tip aninimation	
	getElm('addcommentstatus').innerHTML = '';
	getElm('comlayer').style.display='none';
	getElm('anilayer').style.display='';
	
	// make call to add the tip
	callServ(siteurl+'/golfcourses/golfcoursesjax.php',submitcommentresult,'','POST','op=addcomment&t='+tip+'&c='+escape(comments)+'&r='+rating);
}

function submitcommentresult(xml)
{
	var passed = getTag(xml,'passed')[0].firstChild.data;
	var reason = getTag(xml,'reason')[0].firstChild.data;
	
	if(passed=='true')
	{
		// show tip as temporarily added
		getElm('anistatus').innerHTML = '<div class=\"msgblock\"><h4>'+reason+'</h4></div><br />Success IMAGE';
	}
	else
	{
		getElm('comlayer').style.display='';
		getElm('anilayer').style.display='none';
		
		getElm('addcommentstatus').innerHTML = '<div class=\"msgblock\"><h4>'+reason+'</h4></div>';
		
	}
}

-->