<!--
		var finalResults=new Array();
		
		var googleResults=new Array();
		var bingResults=new Array();
		var yahooResults=new Array();
				
		var isGoogleSearchComplete = new Boolean();
		var isYahooSearchComplete = new Boolean();
		var isBingSearchComplete = new Boolean();
		
		function result(url, title, description, engine, score, position) {
				this.url=url;
				this.title=title;
				this.description=description;
				this.engine=engine;
				this.score=score;
				this.position=position;
			}

        function doSearch() {
            var query = document.getElementById('txtQuery').value;
            var locale = document.getElementById('txtLocale').value;
			
			
			var content = document.getElementById('allResults');
			content.innerHTML = "";
				
			/*alert( query );
            alert( countryCode );
            alert( languageCode );*/
			finalResults=new Array();
		
			googleResults=new Array();
			bingResults=new Array();
			yahooResults=new Array();
					
			isGoogleSearchComplete = new Boolean();
			isYahooSearchComplete = new Boolean();
			isBingSearchComplete = new Boolean();
				
			isGoogleSearchComplete = false;
			isYahooSearchComplete = false;
			isBingSearchComplete = false;

            if (query != "") {
                doGoogleSearch(query, locale);
                doBingSearch(query, locale);
                doYahooSearch(query, locale);
            }

            $("#resultsImage").slideDown();
            $("#explanation").hide();
            $("#defaultSearchProvider").hide();

        }

        // on page load complete, fire off a jQuery json-p query
        // against Google web search
        function doGoogleSearch(query, locale) {
			
            $("#searchingGoogle").show();
			
			if (locale == "en-GB")
				locale = "en-UK";
			
            var url = "http://ajax.googleapis.com/ajax/services/search/web?rsz=large&q=" + query + 
						"&v=1.0" +
						"&lr=lang_" + locale.substr(0,2) +
						"&gl=" + locale.substring(3) +
						"&callback=?";
            $.getJSON(url, function(data) {
                if (data.responseData.results &&
					data.responseData.results.length > 0 && 
					!isGoogleSearchComplete) {
                    var results = data.responseData.results;
                    var cursor = data.responseData.cursor;
                    var count = document.getElementById('googlecount');
                    var more = document.getElementById('googleMore');

                    for (var i = 0; i < results.length; i++) {
						googleResults[i] = new result(results[i].unescapedUrl, results[i].titleNoFormatting, results[i].content, "Google", 8-i, i+1);
					}

                    more.innerHTML = "<a alt='See all the results from Google' href='" + cursor.moreResultsUrl + "'>" + cursor.estimatedResultCount + " records...</a>";
					
					$("#googleSummary").slideDown();
                }
				
				finishGoogleSearch();				
				
            });
        }
		
		function finishGoogleSearch(){
			isGoogleSearchComplete = true;
			$("#searchingGoogle").fadeOut();
			CompileResults(googleResults);
		}


        function doBingSearch(query, locale) {

            $("#searchingBing").show();
		
            var url = "http://api.search.live.net/json.aspx" +
                            "?AppId=B9B1EF3E1C7FBD63CB74D8D9100396BCFD61D075" +
                             "&Market=" + locale +
							 "&Query=" + query +
                             "&Sources=web" +
                             "&web.Count=8" +
                             "&JsonType=callback&JsonCallback=?";

            $.getJSON(url, function(data) {
				if (data.SearchResponse.Web.Results &&
					data.SearchResponse.Web.Results.length > 0 && 
					!isBingSearchComplete) {
                    var results = data.SearchResponse.Web.Results;
                    var count = document.getElementById('bingcount');
                    var more = document.getElementById('bingMore');

                    for (var i = 0; i < results.length; i++) {						
						bingResults[i] = new result(results[i].Url, results[i].Title, results[i].Description, "Bing", 8-i, i+1);
                    }
					
                    more.innerHTML = "<a alt='See all the results from Bing' href='http://www.bing.com/search?q=" + query + "&go=&form=QBLH&filt=all&qs=n'>" + data.SearchResponse.Web.Total + " records.</a>";

					$("#bingSummary").slideDown();
                }
				
				finishBingSearch();
            });
        }
		
		function finishBingSearch(){
			$("#searchingBing").fadeOut();	
			isBingSearchComplete = true;
			CompileResults(bingResults);
		}
	


        function doYahooSearch(query, locale) {
		
            $("#searchingYahoo").show();
			
            var url = "http://boss.yahooapis.com/ysearch/web/v1/" + query +
                            "?appid=dj0yJmk9cGs1T1JUODZwd096JmQ9WVdrOVZrZG5lVVpETkdNbWNHbzlNVGc1T0RNd01EZ3pNUS0tJnM9Y29uc3VtZXJzZWNyZXQmeD1jNw--" + 
                            "&count=8" +
							"&lang=" + locale.substr(0,2) +
							"&region=" + locale.substring(3) +
                            "&format=json" +
							"&Callback=?";

            $.getJSON(url, function(data) {
                if (data.ysearchresponse.resultset_web &&
					data.ysearchresponse.resultset_web.length > 0 && 
					!isYahooSearchComplete) {
                    var results = data.ysearchresponse.resultset_web;
                    var count = document.getElementById('yahooCount');
                    var more = document.getElementById('yahooMore');

                    for (var i = 0; i < results.length; i++) {
						yahooResults[i] = new result(results[i].url, results[i].title, results[i].abstract, "Yahoo", 8-i, i+1);
                    }

                    more.innerHTML = "<a alt='See all the results from Yahoo!' href='http://search.yahoo.com/search;p=" + query + "'>" + data.ysearchresponse.totalhits + " records...</a>";
					
					$("#yahooSummary").slideDown();
                }
				
				finishYahooSearch();
            });
        }
		
		
		function finishYahooSearch(){	
			isYahooSearchComplete = true;
			$("#searchingYahoo").fadeOut();
			CompileResults(yahooResults);
		}
		
		
		
		function CompileResults(arr)
		{
			for(i in arr)
			{
				AddOrEditFinalResult(arr[i]);
			}
			
			CreateFinalOutPutCompile();
		}
		
		function finalResult(url, title, score, arrResults) {
				this.url=url;
				this.title=title;
				this.score=score;
				this.arrResults=arrResults;
			}
		
		function AddOrEditFinalResult(result){
			var IsEdited = false;
			
			for(i in finalResults)
			{
				if (finalResults[i].url == result.url)
				{
					finalResults[i].score = finalResults[i].score + result.score;
					finalResults[i].arrResults.push(result);
					IsEdited = true;
					break;
				}
			}
			
			if (!IsEdited)
			{
				var newResultArray = new Array();
				newResultArray.push(result);
				
				finalResults.push(new finalResult(result.url, result.title, result.score, newResultArray));
			}
			
			finalResults.sort(sortResults);
		}
		
		function sortResults(resulta, resultb)
			{
				if (resulta.score < resultb.score)
					return 1;
				else if (resulta.score > resultb.score)
					return -1;
				else
					return 0;
			}
		
		
		function CreateFinalOutPutCompile()
		{		
			//alert(	isGoogleSearchComplete);
			//alert(	isBingSearchComplete);
			//alert(	isYahooSearchComplete);
				
			if (isGoogleSearchComplete && isBingSearchComplete && isYahooSearchComplete)
			{
				//alert(finalResults.length);
				var content = document.getElementById('allResults');
				var isOpenInNewWindow = document.getElementById('openInNewWindow');
				
				///alert(isOpenInNewWindow);
				///alert(isOpenInNewWindow.checked);
								
				var string;
				
				string = '';
				string += "<table cellspacing='5' cellpadding='10'>";
				
				for (i in finalResults) {
				
					string += "<tr>";
					string += "<td class='off' onMouseOver=\"this.className='highlight'\" onMouseOut=\"this.className='off'\">";
					
					// Display each result however you wish
					string += "<b><a ";
					
					if (isOpenInNewWindow.checked)
					{
						string += " target='_parent' ";
					}
					
					string += " href='" + finalResults[i].url + "'>" + finalResults[i].title + "</a></b><br>";
					
					for(e in finalResults[i].arrResults)
					{
						string += "<img src='resources/images/" + finalResults[i].arrResults[e].engine + "_icon.jpg' alt='This result was found in " + finalResults[i].arrResults[e].engine + " at position " + finalResults[i].arrResults[e].position + "'>&nbsp;";
						string += "<span class='details'>" + finalResults[i].arrResults[e].description + "</span><br>";
					}					

				    string += "<span class='tiny'>" + finalResults[i].url + "</span>";
					
					string += "</td>";
					string += "</tr>";											
				}

				string += "</table>";

				content.innerHTML = string;
											
			}
			
		}
		
		
		var isOptionsDisplayed = false;
		function showHideOptions()
		{
			$("#options").dialog({modal:true});
			$("#options").dialog('open');
		}

-->
		
