suspendAriSubmit.__ONSUBMIT;

var requiredMajorVersion = 9;
var requiredMinorVersion = 0;
var requiredRevision = 0;

var minMajorVersion = 6;
var minMinorVersion = 0;
var minRevision = 0;

var __BUSYLAYER_ACTIVE__ = false;
var browser = navigator.userAgent.toLowerCase();
var IECheck = ((browser.indexOf("msie") != -1) && (browser.indexOf("opera") == -1));

function CompleteZip() {
	var zipCompleter = new Ajax.Autocompleter(
		'ariChoice_Zip', 
		'autocomplete_zip', 
		'/arijax-search.php', {
			callback: function(element, entry) { return entry + '&cid='+$F('ariChoice_Country');},
			parameters: 'function=GETZIP',
			minChars: 2,
			indicator: 'indicator_load'
		}
	)
}
function SelectAll() {
	for (var i=0;i<document.ariForm.elements.length;i++) {
		var x = document.ariForm.elements[i];
		if(x.type == 'checkbox') {
			x.checked = true;
		}
	}
}
function UnSelectAll() {
	for (var i=0;i<document.ariForm.elements.length;i++) {
		var x = document.ariForm.elements[i];
		if(x.type == 'checkbox') {
			x.checked = false;
		}
	}
}
function ariSubmitForm() {
	self.document.ariForm.ariSubmit.value = 'Submit';
	self.document.ariForm.submit();
}
function ariSubmitDealer() {
	self.document.ariForm.ariDealerSubmit.value = 'Submit';
	self.document.ariForm.submit();
}
function Logout() {
	self.document.ariForm.ariLogin.value = 'Logout';
	self.document.ariForm.submit();
}
function Login() {
	self.document.ariForm.ariLogin.value = 'Login';
	self.document.ariForm.submit();
}
function Search() {
	self.document.ariForm.ariSubmit.value = 'Search';
	self.document.ariForm.submit();
}
function resetSearch() {
	self.document.ariForm.ariSubmit.value = 'resetSearch';
	self.document.ariForm.submit();
}
function BackToList() {
	self.document.ariForm.ariSubmit.value = 'BackToList';
	self.document.ariForm.submit();
}
function ariReloadForm() {
	self.document.ariForm.ariSubmit.value = 'ReloadForm';
	self.document.ariForm.submit();
}
function ariReloadList() {
	self.document.ariForm.ariSubmit.value = 'ReloadList';
	self.document.ariForm.submit();
}
function ariSubmit1(val) {
	self.document.ariForm.ariSubmit.value = val;
	self.document.ariForm.submit();
}
function ariSubmit(val) {
	self.document.ariForm.ariSubmit.value = val;
	self.document.ariForm.submit();
}
function activateInput(val1,val2) {
	if ($(val1).checked==true) {
		$(val2).disable();
	}
	else {
		$(val2).enable();
		$(val2).value = '';
	}
}

function showBusyLayer() {
	var busyLayer = document.getElementById("busy_layer")
	if (busyLayer != null) {
		busyLayer.style.visibility = "visible"; 
		busyLayer.style.height = "2500px";
	}
	if (IECheck) return true;
	if (document.onfocus) {
		busyLayer.onfocus = evthdl_onfocus_busyLayer;
	}
	else {
		busyLayer.addEventListener("focus", evthdl_onfocus_busyLayer, true);
		window.addEventListener("unload", evthdl_onunload_busyLayer, true);
	}
	return true;
}

function evthdl_onfocus_busyLayer (evt) {
	if (document.onfocus) {
		hideBusyLayer();
	}
	else {
		window.setTimeout("hideBusyLayer()", 1000);
	}
	return true;
}

function evthdl_onunload_busyLayer (evt) {
	var busyLayer = document.getElementById("busy_layer")
	if (busyLayer != null) {
		busyLayer.focus();
	}
	return true;
}

function hideBusyLayer() {
	var busyLayer = document.getElementById("busy_layer")
	if (busyLayer != null) {
		busyLayer.style.visibility = "hidden";
		busyLayer.style.height = "0px";
	}
	if (IECheck) return true;
	if (document.onfocus) {
		document.onfocus = null;
	}
	else {
		busyLayer.removeEventListener("focus", evthdl_onfocus_busyLayer, true);
		window.removeEventListener("unload", evthdl_onunload_busyLayer, true);
	}
	return true;
}

function customeridOnChange () {
	ariSubmit("SwitchCustomer");
}

function switchInputType (src) {
	if (src.id != "PasswordFront") {
		document.getElementById("PasswordFront").style.visibility = "hidden";
		self.document.ariForm.ari_PASS.focus();
	}
	else {
		src.style.visibility = "hidden";
		self.document.ariForm.ari_PASS.focus();
	}
}

function fixOverlibPos () {
	// to ensure correct placement of layers in IE7 and Opera-Browsers 
	// when page has been scrolled vertically placeY is not set to scrolloffset 
	// but scrolloffset gets added to placeY
	if (Browser.is(IE7) || Browser.is(OP5UP)) {
		if (o3_vpos < document.body.scrollTop) over.style.top = (o3_vpos+document.body.scrollTop)+"px";
	}
	if (Browser.is(IE6)) {
		var rectDHTMLMask = {x: 0, y: 0, width: 0, height: 0};
		var bubbleOffset = $('bubble').viewportOffset();
		var bubbleDim = $('bubble').getDimensions();
		with (rectDHTMLMask) {
			x = bubbleOffset.left-30;
			y = bubbleOffset.top;
			width = bubbleDim.width+6;
			height = bubbleDim.height+11;
		}
		
		var DHTMLMask = new Element('iframe');
		$(document.body).insert({bottom: DHTMLMask});
		DHTMLMask.setOpacity(0.0);
		DHTMLMask.writeAttribute('id', 'DHTML_MASK');
		DHTMLMask.writeAttribute('allowtransparency', 'true');
		DHTMLMask.writeAttribute('width', rectDHTMLMask.width);
		DHTMLMask.writeAttribute('height', rectDHTMLMask.height);
		DHTMLMask.writeAttribute('src', 'javascript:void(0);');
		DHTMLMask.setStyle(
							{
								position: 'absolute',
								left: ''+(rectDHTMLMask.x)+'px',
								top: ''+(rectDHTMLMask.y)+'px',
								border: '1px solid #cccccc'
							}
						  );
	}
}

function helpboxUnmask () {
	var DHTMLMask = $('DHTML_MASK');
	if (DHTMLMask) {
		DHTMLMask.remove();
	}
	return true;
}

function suspendAriSubmit(ev) {
	ev?ev:ev=window.event;
	if (ev && ev.keyCode == 13) {
		if (ev.type != 'keydown') {
			ev=null;
		}
		if (suspendAriSubmit.__ONSUBMIT == undefined) {
			suspendAriSubmit.__ONSUBMIT = self.document.ariForm.onsubmit;
		}
		if (ev) {
			self.document.ariForm.onsubmit = function () {
				void(0);
				return false;
			}
		}
		else {
			self.document.ariForm.onsubmit = suspendAriSubmit.__ONSUBMIT;
		}
		if (arguments[1] != undefined) {
			if (typeof(arguments[1]) == 'string' && typeof(self[arguments[1]]) == 'function') {
				var action = self[arguments[1]];
			}
			else if (typeof(arguments[1]) == 'function') {
				var action = arguments[1];
			}
			else {
				var action = (function () {void(0);});
			}
		}
		else {
			var action = (function () {void(0);});
		}
		action();
	}
	else {
		return true;
	}
}

function populateModelDropdown() {
	$('indicator_load').style.display = 'inline'; 
	$('ariChoice_model').disable();
	var url = '/arijax-search.php';
	var params = 'function=GETMODELDD&makeid=' + $F('ariChoice_make');
	var ajax = new Ajax.Updater(
		{success: 'ariChoice_model' },
		url,
		{method: 'get', parameters: params}
	);
	$('ariChoice_model').enable();
	$('indicator_load').style.display = 'none';
}

function resetSS() {
	$('ariChoice_make').value = '-1';
	$('ariChoice_priceStart').value = '-1';
	$('ariChoice_priceStop').value = '-1';
	$('ariChoice_model').value = '0';
	$('ariChoice_FirstRegStart').value = '-1';
	$('ariChoice_FirstRegStop').value = '-1';
	$('ariChoice_Country').value = 'XX';
	$('ariChoice_MileageStart').value = '-1';
	$('ariChoice_MileageStop').value = '-1';
	$('ariChoice_PowerStart').value = '-1';
	$('ariChoice_PowerStop').value = '-1';
	$('ariChoice_PowerUnit').value = '0';
	$('ariChoice_Distance').value = '-1';
	$('ariChoice_FUEL').value = '1000';
	checkCountry();
}

function acivatePrice() {
	$('indicator_load').style.display = 'inline'; 
	$('ariChoice_priceStart').disable();
	$('ariChoice_priceStop').disable();
	$('SelectedCurrency').innerHTML = $('ariChoice_Currency').value;
	var url = 'arijax-search.php';
	var params = 'function=UPDATEPRICEDD&curr=' + $('ariChoice_Currency').value + '&name=ariChoice_priceStart&dname=100262';
	var ajax = new Ajax.Updater({success: 'ariChoice_priceStart' },url,{method: 'get', parameters: params});
	var params = 'function=UPDATEPRICEDD&curr=' + $('ariChoice_Currency').value + '&name=ariChoice_priceStop&dname=100263';
	var ajax = new Ajax.Updater({success: 'ariChoice_priceStop' },url,{method: 'get', parameters: params});
	$('SimpleSearchCurrencySelectionText').style.display = 'none';
	$('SimpleSearchCurrencySelectionText2').style.display = 'inline';
	$('SimpleSearchCurrencySelection').style.display =  'none';
	$('SimpleSearchPriceSelectionText').style.display = 'inline'; 
	$('SimpleSearchPriceSelection').style.display = 'inline'; 
	$('ariChoice_priceStart').enable();
	$('ariChoice_priceStop').enable();
	$('indicator_load').style.display = 'none';
}
function acivateCurrency() {
	$('ariChoice_Currency').value = 'X';
	$('SimpleSearchPriceSelectionText').style.display = 'none'; 
	$('SimpleSearchPriceSelection').style.display = 'none'; 
	$('SimpleSearchCurrencySelectionText').style.display = 'inline';
	$('SimpleSearchCurrencySelectionText2').style.display = 'none';
	$('SimpleSearchCurrencySelection').style.display =  'inline';
}


