// SN loader
// Copyright exorbyte GmbH, 2011. All rights reserved.

var jQuery_old;
var protocol = document.location.protocol + "//";
var p = document.location.protocol + "//";

function gup(name) {
  name =  name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS  =  "[\\?&]"+name+"=([^&#]*)";
  var regex  =  new  RegExp(regexS);
  var results  =  regex.exec(window.location.href);
  if(results  ==  null)
    return  "";
  else
    return results[1];
}

function suppressExo() {
	return isUrlTrigger && !gup("exo-search");
}

document.writeln(unescape("%3Cscript src='" + protocol + "www.thesolarcentre.co.uk/exorbyte/sncustom/sntemplate.js' type='text/javascript'%3E%3C/script%3E"));
document.writeln(unescape("%3Clink href='" + protocol + "www.thesolarcentre.co.uk/exorbyte/sn/lib/sn.css' type='text/css' rel='stylesheet'/%3E"));
document.writeln(unescape("%3Cscript src='" + protocol + "www.thesolarcentre.co.uk/exorbyte/sn/lib/sn-ajaxQueue-bgiframe-cookie.min.js' type='text/javascript'%3E%3C/script%3E"));

$exoJ = jQuery.noConflict();
if (jQuery_old) {
	$ = jQuery_old;
}
$exoJ(document).ready(function($) {
	if (!suppressExo()) {
		// remove current submit event(s)
		$("#searchbar form").unbind();
		$("#searchbar form div.search_button a").remove();
		$("#searchbar form div.search_button").first().append("<input type='image' alt='Search' value='Search' src='images/search-button.jpg' id='Submit' name='Submit'>");
		
		exoProxyUrl = protocol+"www.thesolarcentre.co.uk/exorbyte/suggest.php";
		exoSuggestParams.dataType="jsonp";
		$(searchFieldSel).autocomplete(exoProxyUrl, exoSuggestParams).focus();
		$(searchFieldSel).result(exoSuggRedirect);
	}
});

document.writeln(unescape("%3Clink href='" + protocol + "www.thesolarcentre.co.uk/exorbyte/css/smoothness/jquery-ui-1.7.2.custom.css' type='text/css' rel='stylesheet'/%3E"));
document.writeln(unescape("%3Clink href='" + protocol + "www.thesolarcentre.co.uk/exorbyte/lib/exorbyte-search.css' type='text/css' rel='stylesheet'/%3E"));

document.writeln(unescape("%3Cscript src='" + protocol + "www.thesolarcentre.co.uk/exorbyte/lib/jquery-ui-1.7.2.custom.min.js' type='text/javascript'%3E%3C/script%3E"));
document.writeln(unescape("%3Cscript src='" + protocol + "www.thesolarcentre.co.uk/exorbyte/lib/jquery.history.js' type='text/javascript'%3E%3C/script%3E"));
document.writeln(unescape("%3Cscript src='" + protocol + "www.thesolarcentre.co.uk/exorbyte/lib/exorbyte-search.min.js' type='text/javascript'%3E%3C/script%3E"));

if ($exoJ.browser.msie && document.documentMode < 7) {
	document.writeln(unescape("%3Clink href='" + protocol + "www.thesolarcentre.co.uk/exorbyte/lib/exorbyte-search-quirks.css' type='text/css' rel='stylesheet' /%3E") );
}

function solarcentreSubmit() {
	 $exoJ('div.pagecontent').html('<div class="myBox" style="width: 638px;"><div id="exo-results" style="width: 638px;">Search Results</div></div>');
};

$exoJ(document).ready(function($) {
	if (!suppressExo()) {
		exoProxyUrl = protocol+"www.thesolarcentre.co.uk/exorbyte/suggest.php";
		if (containerDivSel!="") exoSearchParams.resultsContainerDiv=containerDivSel;
		if (facetDivSel!="") exoSearchParams.facetDivId=facetDivSel;
		exoSearchParams.dataType="jsonp";
		exoSearchParams.onFormSubmit = solarcentreSubmit;
		$(searchFieldSel).mainsearch && $(searchFieldSel).mainsearch(exoProxyUrl, exoSearchParams);
	}
});

document.writeln(unescape("%3Clink href='" + protocol + "www.thesolarcentre.co.uk/exorbyte/sncustom/sntemplate.css' type='text/css' rel='stylesheet'/%3E"));

$exoJ(document).ready(function() {
	if (jQuery_old) {
		jQuery.noConflict(true);
		jQuery = $ = jQuery_old;
	}
});

