var request;var _field;var html = "";function createRequest() {  try {    request = new XMLHttpRequest();  } catch (trymicrosoft) {    try {      request = new ActiveXObject("Msxml2.XMLHTTP");    } catch (othermicrosoft) {      try {        request = new ActiveXObject("Microsoft.XMLHTTP");      } catch (failed) {        request = false;      }    }  }  if (!request)    alert("Error initializing XMLHttpRequest!");}function DBlookup(view, key, fieldName, callbackFunction, listField){	_field = eval ("document.forms[0]." + listField);	//_field.options[0] = new Option("Please Wait");	createRequest();	 var url = "/" + document.forms[0].DbName.value + "/doAjaxLookup?openAgent&" + view + ";" + key + ";" + fieldName;     request.open("GET", url, true);     request.onreadystatechange = callbackFunction;     request.send(null);}function DbColumn(view, columnNum, callbackFunction, listField){	_field = eval ("document.forms[0]." + listField);	//_field.options[0] = new Option("Please Wait");	createRequest();	 var url = "/" + document.forms[0].DbName.value + "/doAjaxDBColumnLookup?openAgent&" + view + ";" + columnNum;     request.open("GET", url, true);     request.onreadystatechange = callbackFunction;     request.send(null);}function setListbox(){	if (request.readyState == 4)	{		if (request.status == 200)		{			var responseTxt = "~" + request.responseText;//			alert(responseTxt);			var response = responseTxt.split("~");			_field.length = 1;						for (var x = 0;x <response.length; x++)			{				var parser = document.getElementById("Parser")				parser.innerHTML = response[x];//				window.prompt("",parser.innerHTML);				var opt = new String(TrimSpaces(parser.innerHTML));				opt = opt.replace("&amp;","&");				_field.options[x] = new Option(opt);			}		}		else if (request.status == 404)		{			alert("Request URL does not exist");		}		else		{			alert("Error: status code is " + request.status);		}	}}function setOption(field, option){	for (i=0;i<field.options.length;i++)	{		if (field.options[i].text.toUpperCase() == option.toUpperCase())		{			field.options[i].selected = true		}	}}function addEvent( obj, type, fn ){	if (obj.addEventListener)		obj.addEventListener( type, fn, false );	else if (obj.attachEvent)	{		obj["e"+type+fn] = fn;		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }		obj.attachEvent( "on"+type, obj[type+fn] );	}}function removeEvent( obj, type, fn ){	if (obj.removeEventListener)		obj.removeEventListener( type, fn, false );	else if (obj.detachEvent)	{		obj.detachEvent( "on"+type, obj[type+fn] );		obj[type+fn] = null;		obj["e"+type+fn] = null;	}}/*Create the new window*/function openInNewWindow() {	// Change "_blank" to something like "newWindow" to load all links in the same new window	var newWindow = window.open(this.getAttribute('href'), '_blank');	newWindow.focus();	return false;}/*Add the openInNewWindow function to the onclick event of links with a class name of "new-window"*/function getNewWindowLinks() {	// Check that the browser is DOM compliant	if (document.getElementById && document.createElement && document.appendChild) {		// Change this to the text you want to use to alert the user that a new window will be opened		var strNewWindowAlert = " (opens in a new window)";		// Find all links		var links = document.getElementsByTagName('a');		var objWarningText;		var strWarningText;		var link;		for (var i = 0; i < links.length; i++) {			link = links[i];			// Find all links with a class name of "non-html"			if (/\bnon\-html\b/.exec(link.className)) {				// Create an em element containing the new window warning text and insert it after the link text				objWarningText = document.createElement("em");				strWarningText = document.createTextNode(strNewWindowAlert);				//objWarningText.appendChild(strWarningText);				link.appendChild(objWarningText);				link.onclick = openInNewWindow;			}		}		objWarningText = null;	}}function getCheckboxValue(field1){	var j;	for ( j = 0; j <= field1.length; j++)	{		alert(j);		if (field1[j].checked == true)		{			return field1[j].value;		}	}	return "";}function AdvancedSettings(id){	if(document.getElementById(id).style.display == "none")	{		document.getElementById(id).style.display = "block";	}	else	{		document.getElementById(id).style.display = "none";	}}function keypress(e) {     if({ 13:1 }[e.which||e.keyCode])     {		siteSearch()		e.preventDefault? e.preventDefault() : e.returnValue = false;	}}function getRadioValue(field){	var i;	for (i=0;i<field.length;i++)	{		if (field[i].checked)		{			return(field[i].value);		}	}	return "";}function Right(str , rightof)	{if(!isNaN(rightof)) {return String(str).slice((str.length - rightof),str.length)}	if(String(str).indexOf(rightof) == -1) {return str}	return String(str).slice(String(str).indexOf(rightof)+1 , str.length)}function Left(str , leftof)	{if(!isNaN(leftof)) {return String(str).slice(0,leftof)}	if(String(str).indexOf(leftof) == -1) {return str}	return String(str).slice(0,String(str).indexOf(leftof))}function convertJsonToHtmlTable(jsonString){	html = "<table>";	var row = "";	var json = eval('(' + jsonString + ')');//	var json = Object.toJSON(jsonString);//	alert("past convert");//	var json = jsonString	if (json.resultstotal != null)	{		for(x = new Number(0); x < json.resultstotal.length; x++)		{			html = html + "<tr><td colspan=4 style='text-align:center'><b>Your search has returned " + json.resultstotal[x].total + " results.</b><br><br></td></tr>";		}	}	if (json.Photos != null)	{		for(x = new Number(0); x < json.Photos.length; x++)		{			html = html + "<tr><td><img src = 'camera.gif'; title ='Campsite with photo's'></td><td>";			html = html + "<a href = './0/" + json.Photos[x].id + "!openDocument' target=_blank>" + json.Photos[x].campname + "</a></td>";			if (json.Photos[x].location != null)			{				html = html + "<td width='10'></td><td>" + json.Photos[x].location + "</td>";			}			html = html + "</tr>";		}	}	if (json.Complete_info != null)	{		for(x = new Number(0); x < json.Complete_info.length; x++)		{			html = html + "<tr><td><img src = 'Complete info'; title ='Campsite with complete information'></td><td>"			html = html + "<a href = './0/" + json.Complete_info[x].id + "!openDocument' target=_blank>" + json.Complete_info[x].campname + "</a></td>";			if (json.Complete_info[x].location != null)			{				html = html + "<td width='10'></td><td>" + json.Complete_info[x].location + "</td>";			}			html = html + "</tr>";		}	}	if (json.Web_Info != null)	{		for(x = new Number(0); x < json.Web_Info.length; x++)		{			html = html + "<tr><td><img src = 'Web info'; title = 'Campsite with web information only'></td><td>";			html = html + "<a href = './0/" + json.Web_Info[x].id + "!openDocument' target=_blank>" + json.Web_Info[x].campname + "</a></td>";			if (json.Web_Info[x].location != null)			{				html = html + "<td width='10'></td><td>" + json.Web_Info[x].location + "</td>";			}			html = html + "</tr>";		}	}	if (json.Contact_Info_Only != null)	{		for(x = new Number(0); x < json.Contact_Info_Only.length; x++)		{			html = html + "<tr><td><img src = 'Contact info only'; title = 'Campsite with contact information only'></td><td>";			html = html + "<a href = './0/" + json.Contact_Info_Only[x].id + "!openDocument' target=_blank>" + json.Contact_Info_Only[x].campname + "</a></td>";			if (json.Contact_Info_Only[x].location != null)			{				html = html + "<td width='10'></td><td>" + json.Contact_Info_Only[x].location + "</td>";			}			html = html + "</tr>";		}	}		if (json.Tourism_Office != null)	{		for(x = new Number(0); x < json.Tourism_Office.length; x++)		{			html = html + "<tr><td><img src = 'Tourism_Office'; title = 'Tourism Office'></td><td>";			html = html + "<a href = './0/" + json.Tourism_Office[x].id + "!openDocument' target=_blank>" + json.Tourism_Office[x].campname + "</a></td>";			if (json.Tourism_Office[x].location != null)			{				html = html + "<td width='10'></td><td>" + json.Tourism_Office[x].location + "</td>";			}			html = html + "</tr>";		}	}		html = html + "</table>"	return html;}function viewCampPhoto(url){	window.open(url , "" , 'toolbar=no, directories=no, location=no, status=yes,top=145, left=145, menubar=no, resizable=yes, scrollbars=no,width=700,height=550');}function TrimSpaces(value){	var str = String(value);	var str1= new String("");	var str2 = new String("");	var str3 = String(str);	for (i=0;i<str.length;i++)	{		if (Left(str3,1) != ' ')		{			str1 = str1 + str.charAt(i);		}		else		{			str3 = Right( str3 , str3.length - 1 );		}	}	for (i=str1.length;i>-1;i--)	{		if (Right(str1,1) != ' ')		{			str2 = str1.charAt(i) + str2;		}		else		{			str1 = Left( str1 , str1.length - 1 );		}	}	return str2;}function rates(){	alert("A		0 - 50\nB		51 - 100\nC		101 - 150\nD		151+\n		All rates are in local currency");}function tariewe(){	alert("A		0 - 50\nB		51 - 100\nC		101 - 150\nD		151+\n		Alle tariewe is in plaaslike valuta");}function arrayUnique( array ){    var uniqueArray = [];         var item;    for( var i = 0, len=array.length ; i < len ; i++ ){        item = array[i];        if( uniqueArray.indexOf( item ) == -1 ){            uniqueArray.push( item );        }    }    return uniqueArray;}
