	var previousFrame;
	
	Array.prototype.CBTSin_array = function(p_val) {
		//in_array prototype
		for(var i = 0, l = this.length; i < l; i++) {
			if(this[i] == p_val) {
				return true;
			}
		}
		return false;
	}
	
	String.prototype.CBTStrim = function() {
		return this.replace(/^\s+|\s+$/g,"");
	}
	
	String.prototype.CBTSURLEncode = function () {
		var output = '';
		var x = 0;
		clearString = this.toString();
		var regex = /(^[a-zA-Z0-9_.]*)/;
		while (x < clearString.length) {
			var match = regex.exec(clearString.substr(x));
			if (match != null && match.length > 1 && match[1] != '') {
				output += match[1];
				x += match[1].length;
			} 
			else {
				if (clearString[x] == ' '){
					output += '+';
				}
				else {
					var charCode = clearString.charCodeAt(x);
					var hexVal = charCode.toString(16);
					output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
				}
				x++;
			}
		}
		return output;
	}
	
	String.prototype.CBTSURLDecode = function () {
		var output = this;
		var binVal, thisString;
		var myregexp = /(%[^%]{2})/;
		while ((match = myregexp.exec(output)) != null && match.length > 1 && match[1] != '') {
			binVal = parseInt(match[1].substr(1),16);
			thisString = String.fromCharCode(binVal);
			output = output.replace(match[1], thisString);
		}
		return output;
	}
	
	function lookup1(host,inputString) {
		$('#suggestions2').hide();
		$('#inputString2').val('');
	   
		if(inputString.length == 0) {
	        // Hide the suggestion box.
			$('#suggestions1').hide();
			alert ("Enter a name in the search box");
	    } 
	    else {
		    $.post(host+"/IAF_includes/ajax-include1.php", {queryString: ""+inputString+""}, function(data){
	            if(data.length >0) {
		            $('#suggestions1').show();
	                $('#autoSuggestionsList1').html(data);
	            }
	        });
	    }
	} // lookup1
	
	function lookup2(host,inputString) {
		$('#suggestions1').hide();
		$('#inputString1').val('');
		
		if(inputString.length == 0) {
	        // Hide the suggestion box.
			$('#suggestions2').hide();
			alert ("Enter a name in the search box");
	    } 
	    else {
		    $.post(host+"/IAF_includes/ajax-include2.php", {queryString: ""+inputString+""}, function(data){
	            if(data.length >0) {
		            $('#suggestions2').show();
	                $('#autoSuggestionsList2').html(data);
	            }
	        });			
	    }
	} // lookup2
	
	function SearchFor1(host, sz){
		if(sz.length==0) {
			alert ("Enter a name in the search box");
		}
		else{
			sz = sz.replace(/&/g,"%26");
			sz = sz.replace(/-/g,"_");
			sz = sz.replace(/%20/g,"-");   
			sz = sz.replace(/ /g,"-");
			sz = sz.replace(/Å/g,"AA");
			sz = sz.replace(/å/g,"aa");
			sz = sz.replace(/Ø/g,"OE");
			sz = sz.replace(/ø/g,"oe");
			sz = sz.replace(/Æ/g,"AE");
			sz = sz.replace(/æ/g,"ae");
			location.href = host+"SEARCHKONTAKT/"+sz;
		}
	}
	
	function SearchFor2(host, sz){
		if(sz.length==0) {
			alert ("Enter a name in the search box");
		}
		else{
			sz = sz.replace(/&/g,"%26");
			sz = sz.replace(/-/g,"_");
			sz = sz.replace(/%20/g,"-");   
			sz = sz.replace(/ /g,"-");
			sz = sz.replace(/Å/g,"AA");
			sz = sz.replace(/å/g,"aa");
			sz = sz.replace(/Ø/g,"OE");
			sz = sz.replace(/ø/g,"oe");
			sz = sz.replace(/Æ/g,"AE");
			sz = sz.replace(/æ/g,"ae");
			location.href = host+"SEARCHFIRMA/"+sz;
		}
	}
	
	function fill1(host,thisCompany,thisValue) {
	   $('#suggestions2').hide();
	   $('#inputString1').val(thisValue);
	   launchContact(host, thisCompany);
	}
	
	function fill2(host,thisValue) {
	   $('#suggestions1').hide();
	   $('#inputString2').val(thisValue);
	   launchCompany(host, thisValue);
	}
	
	function launchCompany(host, thisValue){
		thisValue = thisValue.CBTStrim();
		thisValue = thisValue.replace(/&/g,"%26");
		thisValue = thisValue.replace(/-/g,"_");
		thisValue = thisValue.replace(/%20/g,"-");   
		thisValue = thisValue.replace(/ /g,"-");
		thisValue = thisValue.replace(/Å/g,"AA");
		thisValue = thisValue.replace(/å/g,"aa");
		thisValue = thisValue.replace(/Ø/g,"OE");
		thisValue = thisValue.replace(/ø/g,"oe");
		thisValue = thisValue.replace(/Æ/g,"AE");
		thisValue = thisValue.replace(/æ/g,"ae");
		location.href = host+"Firma/"+thisValue;
	}
	
	function launchContact(host, thisValue){
		thisValue = thisValue.CBTStrim();
		location.href = host+"SEARCHKONTAKT/"+thisValue;
	}
	
	var BrowserDetect = {
		init: function () {
			this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
			this.version = this.searchVersion(navigator.userAgent)
				|| this.searchVersion(navigator.appVersion)
				|| "an unknown version";
			this.OS = this.searchString(this.dataOS) || "an unknown OS";
		},
		searchString: function (data) {
			for (var i=0;i<data.length;i++)	{
				var dataString = data[i].string;
				var dataProp = data[i].prop;
				this.versionSearchString = data[i].versionSearch || data[i].identity;
				if (dataString) {
					if (dataString.indexOf(data[i].subString) != -1)
						return data[i].identity;
				}
				else if (dataProp)
					return data[i].identity;
			}
		},
		searchVersion: function (dataString) {
			var index = dataString.indexOf(this.versionSearchString);
			if (index == -1) return;
			return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
		},
		dataBrowser: [
			{ 	string: navigator.userAgent,
				subString: "OmniWeb",
				versionSearch: "OmniWeb/",
				identity: "OmniWeb"
			},
			{
				string: navigator.vendor,
				subString: "Apple",
				identity: "Safari"
			},
			{
				prop: window.opera,
				identity: "Opera"
			},
			{
				string: navigator.vendor,
				subString: "iCab",
				identity: "iCab"
			},
			{
				string: navigator.vendor,
				subString: "KDE",
				identity: "Konqueror"
			},
			{
				string: navigator.userAgent,
				subString: "Firefox",
				identity: "Firefox"
			},
			{
				string: navigator.vendor,
				subString: "Camino",
				identity: "Camino"
			},
			{		// for newer Netscapes (6+)
				string: navigator.userAgent,
				subString: "Netscape",
				identity: "Netscape"
			},
			{
				string: navigator.userAgent,
				subString: "MSIE",
				identity: "Explorer",
				versionSearch: "MSIE"
			},
			{
				string: navigator.userAgent,
				subString: "Gecko",
				identity: "Mozilla",
				versionSearch: "rv"
			},
			{ 		// for older Netscapes (4-)
				string: navigator.userAgent,
				subString: "Mozilla",
				identity: "Netscape",
				versionSearch: "Mozilla"
			}
		],
		dataOS : [
			{
				string: navigator.platform,
				subString: "Win",
				identity: "Windows"
			},
			{
				string: navigator.platform,
				subString: "Mac",
				identity: "Mac"
			},
			{
				string: navigator.platform,
				subString: "Linux",
				identity: "Linux"
			}
		]
	
	};
	BrowserDetect.init();

	function AjaxLayerGetSelectId(selectBox){
		/***********
		*	ok, this is fairly un-ajaxy but really useful:
		*	it returns the value of whatever is in the (named)
		*	selectbox
		*/
		var value = "";
		if (document.getElementById) {
			// Type 1: IE5,6; NN6; Mozilla
			// if our browser supports DOM and we can get an object according to it's name
			selectedIndex = document.getElementById(selectBox).selectedIndex;
			value = document.getElementById(selectBox).options[selectedIndex].value; //.text = text
		}	
		else if(document.all) {
			// Type 2: For document.all stands IE4-6 and Opera5, but IE5,6 were gone as the 1-st type
			selectedIndex = document.all[selectBox].selectedIndex;
			value = document.all[selectBox].options[selectedIndex].value; //.text = text
		}
		return value;
	}
	
	function AjaxLayerhideFrame(frameName){
		/***********
		*	empties a frame
		*/
		if (document.getElementById) {
			// Type 1: IE5,6; NN6; Mozilla
			// if our browser supports DOM and we can get an object according to it's name
			document.getElementById(frameName).innerHTML = '';
			document.getElementById(frameName).style.visibility = 'hidden';
			document.getElementById(frameName).style.display = 'none';
		}	
		else if(document.all) {
			// Type 2: For document.all stands IE4-6 and Opera5, but IE5,6 were gone as the 1-st type
			document.all[frameName].innerHTML = '';
			document.getElementById(frameName).style.visibility = 'hidden';
			document.getElementById(frameName).style.display = 'none';
		}
	}

	function AjaxLayerframeShow(frameName,Url){
		/***********
		* Fills the desired frame (DIV needs to be there in the calling page somewhere!)
		* EG: 
		*	google: AjaxLayerframeShow('viewpane_layer','http://www.google.com');
		*	<div id='viewpane_layer' style='position:absolute; left:0px; top:164px; width:700px; height:100; z-index:1; visibility: hidden;'></div>
		* or
		*	<div id='viewpane_layer' style="width:428px; height:100px;"></div>
		*/
		
		document.body.style.cursor='wait';
		if (frameName=='viewpane_layer') draw(frameName);
		AjaxLayerhideFrame(frameName);
		AjaxLayerdisplayData(frameName,Url);
		
		if (document.getElementById) { 
			// Type 1: IE5,6; NN6; Mozilla
			document.getElementById(frameName).style.visibility = 'visible';
			document.getElementById(frameName).style.display = 'block';
		} 		
		else if(document.all) { 
			// Type 2: For document.all stands IE4-6 and Opera5, but IE5,6 were gone as the 1-st type 
			document.all[frameName].style.visibility= 'visible'; 
			document.all[frameName].style.display= 'block'; 
		}
		document.body.style.cursor='default';		
	}
	
	function AjaxLayerframePrepare(){
		/***********
		* special one off function
		*/
		AjaxLayerframeShow('lowerpage','ajaxlowerframe_fixed.php?home=true');
		AjaxLayerframeShow('topbox','ajaxframe_grab.php');
		
	}
	
	function AjaxLayerdisplayData(frameName,Url){
		
		var ajaxRequest;  // The variable that makes Ajax possible!
		/*******
		*
		*  make AJAXREQUEST object
		*
		********/
		try{
			// Opera 8.0+, Firefox, Safari
			ajaxRequest = new XMLHttpRequest();
		} catch (e){
			// Internet Explorer Browsers
			try{
				ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try{
					ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e){
				// Something went wrong
					alert("Your browser broke!");
					//return false;
				}				
			}
		}
		
		/********
		*
		*  put a randomiser variable on the file name
		*
		********/
		
		var Random = Math.floor(Math.random()*100000);
		if (Url.indexOf('?') == -1) {
			Url  += '?rnd=' + Random;
		}
		else{
			Url  += '&rnd=' + Random;
		}
		
		/*******
		*
		*  get response text (HTML) from our background php called ajax.php
		*
		********/
		
		ajaxRequest.open("GET", Url, true);
		
		/*******
		*
		*  readystate check
		*
		*******/
		
	
        ajaxRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajaxRequest.onreadystatechange = function(){
				if (ajaxRequest.readyState == 4 && ajaxRequest.status == 200) {
						if (ajaxRequest.responseText){
								/*******
								*
								*  spool the ajax.php response text to the div tag
								*
								********/
								//alert(ajaxRequest.responseText);
								if (parseInt(navigator.appVersion)>=5&&navigator.appName=="Netscape") {
									//NS6, Firefox, Safari
									//alert("NS6 Firefox, Safari" + frameName);
									document.getElementById(frameName).innerHTML = ajaxRequest.responseText; 
								} else if (document.all){ 
									//IE5 IE7 Opera 8.0+
									//alert("E5 IE7 Opera 8.0+" + frameName);
									document.all[frameName].innerHTML = ajaxRequest.responseText;
								}
						}
				}
        }
        ajaxRequest.send(null);
	}
	
	function urlencode(str) {
		str = escape(str);
		str = str.replace('+', '%2B');
		str = str.replace('%20', '+');
		str = str.replace('*', '%2A');
		str = str.replace('/', '%2F');
		str = str.replace('@', '%40');
		return str;
	}
	
	function urldecode(str) {
		str = str.replace('+', ' ');
		str = unescape(str);
		return str;
	}
	
	function draw(frameName){
		if (document.getElementById) { 
			// Type 1: IE5,6; NN6; Mozilla
			// if our browser supports DOM and we can get an object according to it's name
			
			//if((BrowserDetect.browser=="Firefox") || (BrowserDetect.browser=="Safari")){
			//	document.getElementById(frameName).style.left = "30px";
			//}
			//else{
				document.getElementById(frameName).style.left = Math.round((document.body.offsetWidth)/2)-Math.round(930/2) + "px";
			//}
			
			//document.getElementById(frameName).style.left = Math.round((document.body.offsetWidth-201)/2)-Math.round(930/2);
			//document.getElementById(frameName).style.left = 201;
			//document.getElementById(frameName).style.width = Math.round(document.body.offsetWidth)-Math.round(201*2);
			//alert(frameName + " moved to "  + document.getElementById(frameName).style.left);
		} 		
		else if(document.all) { 
			// Type 2: For document.all stands IE4-6 and Opera5, but IE5,6 were gone as the 1-st type 
			document.all[frameName].style.posLeft = Math.round((document.body.offsetWidth)/2)-Math.round(930/2);
			//document.all[frameName].style.posLeft = Math.round((document.body.offsetWidth-201)/2)-Math.round(930/2);
			//document.all[frameName].style.posLeft = 201;
			//document.all[frameName].style.width = Math.round(document.body.offsetWidth)-Math.round(201*2);
		} 		
	}
	
	function minidraw(frameName){
		if (document.getElementById) { 
			// Type 1: IE5,6; NN6; Mozilla
			// if our browser supports DOM and we can get an object according to it's name
			//if((BrowserDetect.browser=="Firefox") || (BrowserDetect.browser=="Safari")){
			//	document.getElementById(frameName).style.left = "230px";
			//}
			//else{
				document.getElementById(frameName).style.left = Math.round((document.body.offsetWidth)/2)-Math.round(500/2) + "px";
			//}
		} 		
		else if(document.all) { 
			// Type 2: For document.all stands IE4-6 and Opera5, but IE5,6 were gone as the 1-st type 
			document.all[frameName].style.posLeft = Math.round((document.body.offsetWidth)/2)-Math.round(500/2);
		} 		
	}
	
	function alterImage(id,newsrc){
		var myImage = new Image();
		myImage.src = newsrc;
		document.getElementById(id).src = myImage.src;
	}