function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function ReloadModel(index) {
	if(index==-1){
		location.href= "agent.php" + window.location.search;
	}
}

function ReloadWebcam(timeout) {
	window.setTimeout("window.location.reload()", timeout*1000);
}

function ReloadBrand(index) {
	start = window.location.search.indexOf("brand=");
	sub="";
	end = "";
	if(start > 0)
	{
		sub = window.location.search.substr(1, start-1);
		next = window.location.search.indexOf("&", start);
		if(next > 0)
		{
			end = window.location.search.substr(next+1, window.location.search.length);
		}
	}else{
		sub = window.location.search.substr(1, window.location.search.length);
	}
	
	if(index==-1){
		part="";
		success = window.location.search.indexOf("success=true");
		if(success > 0)
		{
			part = window.location.search.substr(0, success) + window.location.search.substr(success+12, window.location.search.length);
			location.href= "agent.php" + part;
			return;
		}
		success = window.location.search.indexOf("success=false");
		if(success > 0)
		{
			part = window.location.search.substr(0, success) + window.location.search.substr(success+13, window.location.search.length);
			location.href= "agent.php" + part;
			return;
		}
		location.href="agent.php" + window.location.search;
	}else{
		if(window.location.href.indexOf("search_detail.php")<0){
    		location.href= "search.php?brand=" + index + "&" + sub + end;
    	}else{
    		location.href= "search_detail.php?brand=" + index + "&" + sub + end;
    	}
    }
}

function ReloadBrandResult(index) {
	start = window.location.search.indexOf("brand=");
	sub="";
	end = "";
	if(start > 0)
	{
		sub = window.location.search.substr(1, start-1);
		next = window.location.search.indexOf("&", start);
		if(next > 0)
		{
			end = window.location.search.substr(next+1, window.location.search.length);
		}
	}else{
		sub = window.location.search.substr(1, window.location.search.length);
	}
	
	if(index==-1){
		part="";
		success = window.location.search.indexOf("success=true");
		if(success >= 0)
		{
			part = window.location.search.substr(0, success) + window.location.search.substr(success+12, window.location.search.length);
			location.href= "agent.php" + part;
			return;
		}
		success = window.location.search.indexOf("success=false");
		if(success >= 0)
		{
			part = window.location.search.substr(0, success) + window.location.search.substr(success+13, window.location.search.length);
			location.href= "agent.php" + part;
			return;
		}
		location.href="agent.php" + window.location.search;
	}else{
		location.href= "cars.php?brand=" + index + "&" + sub + end + "&page=0";
    }
}

function disableSubmit(whichButton)
{
    if (document.getElementById)
    {
        // this is the way the standards work
        document.getElementById(whichButton).disabled = true;
    }
    else if (document.all)
    {
        // this is the way old msie versions work
        document.all[whichButton].disabled = true;
    }
    else if (document.layers)
    {
        // this is the way nn4 works
        document.layers[whichButton].disabled = true;
    }
}