function hbxRecSearch(keys,res,at1,at2,at3,at4)
{
    /* add a search event to the data sent to hitbox
    that contains details about the search result set */

    var ev1;
    hbx.pn = keys;
    ev1 = _hbEvent("search");
    ev1.keywords = keys;
    ev1.results = res;

    if(at1 != null && at1.length > 0) {ev1.attr1=at1;}
    if(at2 != null && at2.length > 0) {ev1.attr2=at2;}
    if(at3 != null && at3.length > 0) {ev1.attr3=at3;}
    if(at4 != null && at4.length > 0) {ev1.attr4=at4;}
}

function submitGoogleSearch(lid,lpos,form_object){
	var search_form = form_object;
	var searchTerm = search_form.q.value;
	searchTerm = searchTerm.replace(/[\'\"]/g, "");
		//lid += "/search." + searchTerm;
	linkTrack(lid, lpos);
	search_form.submit();
	return true;
}



// 	set in content tool
//	var collection = "";
//  var site = "dodge";
//  var client = "prod_dodge";
var count = 10;


// ======================================================
// set_search_query(query) -- sets the query string
// ======================================================
function set_search_query(query) {

	// set clean query string
	var queryString = "/en/search_results/?&q=" + escape(query);
	queryString += "&start=0";
	
	window.location.replace(queryString);
 
}

// ======================================================
// get_search_results(query) -- called on load
// ======================================================
function get_search_results() {
	
	// check if we have a query string
	if(getParameter("q") != "") {
		
		//Removed by SIMKO page track override in head
		//pageTrack(getParameter("q") + "/" + getParameter("start"), getParameter("q") + "/" + getParameter("start"));
		
		// poulate the form if there was a value called
		document.forms.mainsearch.q.value = unescape(getParameter("q"));
		
		// send the query to the search appliance
		var requestString = "/search";
		requestString += location.href.substr(location.href.indexOf("?"));
		requestString += "&site=" + escape(collection);
		requestString += "&client=" + client;
		requestString += "&output=xml_no_dtd";
		requestString += "&num="  + escape(count);
		requestString += "&proxystylesheet=" + client;
		requestString += "&filter=0";
		
		// call the xml load
		var xmlAjax = new Ajax(requestString, {method: 'get', onComplete:function(text, xml){returnHTMLOutput(text)} }).request();
	
	} else {
		
		$('default_copy').setStyle('display', 'block');
		
	}
 
}


// ======================================================
// checkRequets have been complete
// ======================================================
function returnHTMLOutput(returnHTML) {
    
    //This is to check for zero results and to then fire off additional tracking.
    var zeroResultIndex = returnHTML.indexOf('<strong>0</strong>');
	var thisMLC = "/en/search/no_results";
	
	if(zeroResultIndex != -1){
	    _hbPageView(hbx.pn, thisMLC);
	}

	$('results_container').setHTML(returnHTML);
	var mc_height = $('main_content').getSize().size.y;
	var sa_height = $('search_area').getSize().size.y + $('search_area').getStyle('padding-top').toInt();
	if(sa_height > mc_height){
		$('main_content').setStyle('height', sa_height);
	}
}

// ======================================================
// get_search_results(query) -- called on load
// ======================================================
function sendSearchQuery(url) {
	var search_folder = "";
	search_folder = url.indexOf("chryslerllc") >= 0 ? "search" : language + "/search_results";
	
	if(getParameter("q") != "") {
		window.location = "http://" + env + "." + url + "/"+search_folder +"/?&q=" + getParameter("q") + "&start=0";
	} 
	
	else {
		window.location = "http://" + env + "." + url + "/"+search_folder;
	}
	
}
