

var isIE = false;
var isOther = false;
var isNS4 = false;
var isNS6 = false;
if(document.getElementById)
{
	if(!document.all)
	{
		isNS6=true;
	}
	if(document.all)
	{
		isIE=true;
	}
}
else
{
	if(document.layers)
	{
		isNS4=true;
	}
	else
	{
		isOther=true;
	}
}

function aLs(layerID)
{
var returnLayer;
	if(isIE)
	{
		returnLayer = eval("document.all." + layerID + ".style");
	}
	if(isNS6)
	{
		returnLayer = eval("document.getElementById('" + layerID + "').style");
	}
	if(isNS4)
	{
		returnLayer = eval("document." + layerID);
	}
	if(isOther)
	{
		returnLayer = "null";
		alert("-[Error]-\nDue to your browser you will probably not\nbe able to view all of the following page\nas it was designed to be viewed. We regret\nthis error sincerely.");
	}
return returnLayer;
}
function objectExists(id){
  return document.getElementById(id)!=null ? true : false
} 
function HideShow(ID, ID2)
{	
	var tmp = "admin_" + ID2;
	
	var el;
	if (el = document.getElementById(ID)) {

	
		if((aLs(ID).visibility == "visible") || (aLs(ID).visibility == ""))
		{
			aLs(ID).visibility = "hidden";
			aLs(ID).display = "none";
			document.getElementById(ID2).src = "images/icon_plus.gif";
			setCookie(tmp, "");
		}
		else if(aLs(ID).visibility == "hidden")
		{
			aLs(ID).visibility = "visible";
			aLs(ID).display = "block";
			document.getElementById(ID2).src = "images/icon_minus.gif";
			setCookie(tmp, "t");
		}
			return
		}	
	
}
function Hide(ID)
{
		aLs(ID).visibility = "hidden";
		aLs(ID).display = "none";
}
function Show(ID)
{
		aLs(ID).visibility = "visible";
		aLs(ID).display = "block";
}
var IE4
IE4 == document.all;
function newConfirm(title,mess,icon,defbut,mods) {
   if (IE4) {
      icon = (icon==0) ? 0 : 2;
      defbut = (defbut==0) ? 0 : 1;
      retVal = makeMsgBox(title,mess,icon,4,defbut,mods);
      retVal = (retVal==6);
   }
   else {
      retVal = confirm(mess);
   }
   return retVal;
}
function Left(str, n)
        {
                if (n <= 0)     // Invalid bound, return blank string
                        return "";
                else if (n > String(str).length)   // Invalid bound, return
                        return str;                // entire string
                else // Valid bound, return appropriate substring
                        return String(str).substring(0,n);
        }
function Len(str)
        {  return String(str).length;  }
function ShowMoreImages(obj) {

Imgs = new Array()

	for(i = 0; i < document.images.length; i++) {

		if (Left(document.images[i].id, Len(obj)) == obj) {
			Imgs[i] = new Image();
			Imgs[i].src = 'cars/' + document.images[i].name;
			document.images[i].src = 'cars/' + document.images[i].name;
		}
	}
}
function popup(mylink, windowname, winparam, theWidth, theHeight)
		{
		if (! window.focus)return true;
		var href;
		if (typeof(mylink) == 'string')
		   href=mylink;
		else
		   href=mylink.href;

		var theTop=(screen.height/2)-(theHeight/2)
		var theLeft=(screen.width/2)-(theWidth/2)
		winparam = winparam + ',height='+theHeight+',width='+theWidth+',top='+theTop+',left='+theLeft;
		winparam = winparam + ',resizable=yes'

		window.open(href, windowname, winparam);
		return false;
		}
		
function retrieveCookie( cookieName ) {
	/* retrieved in the format
	cookieName4=value; cookieName3=value; cookieName2=value; cookieName1=value
	only cookies for this domain and path will be retrieved */
	var cookieJar = document.cookie.split( "; " );
	for( var x = 0; x < cookieJar.length; x++ ) {
		var oneCookie = cookieJar[x].split( "=" );
		if( oneCookie[0] == escape( cookieName ) ) { return unescape( oneCookie[1] ); }
	}
	return null;
}

function setCookie( cookieName, cookieValue, lifeTime, path, domain, isSecure ) {
	if( !cookieName ) { return false; }
	if( lifeTime == "delete" ) { lifeTime = -10; } //this is in the past. Expires immediately.
	/* This next line sets the cookie but does not overwrite other cookies.
	syntax: cookieName=cookieValue[;expires=dataAsString[;path=pathAsString[;domain=domainAsString[;secure]]]]
	Because of the way that document.cookie behaves, writing this here is equivalent to writing
	document.cookie = whatIAmWritingNow + "; " + document.cookie; */
	document.cookie = escape( cookieName ) + "=" + escape( cookieValue ) +
		( lifeTime ? ";expires=" + ( new Date( ( new Date() ).getTime() + ( 1000 * lifeTime ) ) ).toGMTString() : "" ) +
		( path ? ";path=" + path : "") + ( domain ? ";domain=" + domain : "") + 
		( isSecure ? ";secure" : "");
	//check if the cookie has been set/deleted as required
	if( lifeTime < 0 ) { if( typeof( retrieveCookie( cookieName ) ) == "string" ) { return false; } return true; }
	if( typeof( retrieveCookie( cookieName ) ) == "string" ) { return true; } return false;

}
		
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

_editor_url = "htmlarea/";                     // URL to htmlarea files
var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
if (navigator.userAgent.indexOf('Mac')        >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Opera')      >= 0) { win_ie_ver = 0; }
if (win_ie_ver >= 5.5) {
 document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
 document.write(' language="Javascript1.2"></scr' + 'ipt>');  
} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }

function xreplace(checkMe,toberep,repwith){

	var temp = checkMe;
	
	var i = temp.indexOf(toberep);
	
	while(i > -1)
	
	{
	
	temp = temp.replace(toberep, repwith);
	
	i = temp.indexOf(toberep, i + repwith.length + 1);
	
	}
	
	return temp;

}

function Chr(CharCode)
{
	return String.fromCharCode(CharCode);
}