/*******************************************************************************************/
/* Search Page Functions                                                                   */
/*******************************************************************************************/

//function used to change the help box when the user changes the type of search being performed
function SwitchHelpBox(id, global) {
   if(GetDomElement(global)) {
        //get all of the divs within the global container
        var a = GetDomElement(global).getElementsByTagName('div');

        //cycle the div collection hiding them all
        for(var i=0;i <a.length;i++) {
            a[i].className = "none";
        }

        //now display the selected div
        GetDomElement(id).className = "";
    }
}

//function used to hide the help boxes on mouse out
function HideBoxes(global) {
	if(GetDomElement(global)) {
		//get all of the divs within the global container
		var a = GetDomElement(global).getElementsByTagName('div');

		//cycle the div collection hiding them all
		for(var i=0;i <a.length;i++) {
			a[i].className = "none";
		}
	}
}

//function used to enable and disable certain controls on the page depending on the rdb selected
function SwitchSearchType(id) {
	if(id == 'rdbDealerVehicles') {
		GetDomElement('ddlCentres').disabled = false;
		GetDomElement('txtPostcode').disabled = true;
		GetDomElement('ddlPriceFrom_dropdown').disabled = true;
		GetDomElement('ddlPriceTo_dropdown').disabled = true;
		GetDomElement('lnkSubmit').style.display = 'none';
		GetDomElement('rdbRodeo').disabled = true;
		GetDomElement('rdbTrooper').disabled = true;
		
	}
	else {
		GetDomElement('ddlCentres').disabled = true;
		GetDomElement('txtPostcode').disabled = false;
		GetDomElement('ddlPriceFrom_dropdown').disabled = false;
		GetDomElement('ddlPriceTo_dropdown').disabled = false;
		GetDomElement('lnkSubmit').style.display = '';
		GetDomElement('rdbRodeo').disabled = false;
		GetDomElement('rdbTrooper').disabled = false;
	}
}

//function used to read the QS and enable or disable the search controls as needed
function SearchPageLoad() {
	if(getQueryVariable('SearchType') && (document.referrer.indexOf('search.aspx') == -1)) {
		if(getQueryVariable('SearchType') == 'Local') {
			GetDomElement('rdbDealerVehicles').checked = true;
			GetDomElement('ddlCentres').disabled = false;
			GetDomElement('txtPostcode').disabled = true;
			GetDomElement('ddlPriceFrom').disabled = true;
			GetDomElement('ddlPriceTo').disabled = true;
			GetDomElement('lnkSubmit').style.display = 'none';
			GetDomElement('rdbRodeo').disabled = true;
			GetDomElement('rdbTrooper').disabled = true;
			
		}
		else {
			GetDomElement('ddlCentres').disabled = true;
			GetDomElement('txtPostcode').disabled = false;
			GetDomElement('ddlPriceFrom').disabled = false;
			GetDomElement('ddlPriceTo').disabled = false;
			GetDomElement('lnkSubmit').style.display = '';
			GetDomElement('rdbRodeo').disabled = false;
			GetDomElement('rdbTrooper').disabled = false;
		}
	}
	else {
		GetDomElement('ddlCentres').disabled = true;
		GetDomElement('txtPostcode').disabled = false;
		GetDomElement('ddlPriceFrom').disabled = false;
		GetDomElement('ddlPriceTo').disabled = false;
		GetDomElement('lnkSubmit').style.display = '';
		GetDomElement('rdbRodeo').disabled = false;
		GetDomElement('rdbTrooper').disabled = false;
	}
}

/*******************************************************************************************/
/* Stocklist Page Functions                                                                */
/*******************************************************************************************/

//function used to show the IFrame containing the options page!
function ShowOptionsIFrame(carId) {
    var iFrame = GetDomElement('Options'+carId);
	var imgPlus = GetDomElement('Expander'+carId);
	if (iFrame.style.display != "block") {
		iFrame.src = "options.aspx?carId=" + carId;
		iFrame.style.display = "block";
		imgPlus.src = "assets/images/minus.gif";
	}
	else {
		iFrame.style.display = "none";
		imgPlus.src = "assets/images/plus.gif";
	}
}