var NS4 = (document.layers) ? 1 : 0;
var IE = (document.all) ? 1 : 0;
var DOM = (document.getElementById) ? 1 : 0;
function setCookie(name, value, expires, path, domain, secure) {
	deleteCookie(name, value,path)
  var curCookie = name + "=" + escape(value) +
	 ((expires) ? "; expires=" + expires.toGMTString() : "") +
	 ((path) ? "; path=" + path : "") +
	 ((domain) ? "; domain=" + domain : "") +
	 ((secure) ? "; secure" : "")
  if ((name + "=" + escape(value)).length <= 4000)
	 document.cookie = curCookie
  else
	 if (confirm("Cookie exceeds 4KB and will be cut!"))
		document.cookie = curCookie
}
function getCookie(name) {
  var prefix = name + "="
  var cookieStartIndex = document.cookie.indexOf(prefix)
  if (cookieStartIndex == -1)
	 return null
  var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex +
	 prefix.length)
  if (cookieEndIndex == -1)
	 cookieEndIndex = document.cookie.length
  return unescape(document.cookie.substring(cookieStartIndex +
	 prefix.length,
cookieEndIndex))
}
function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
	 document.cookie = name + "=" +
	 ((path) ? "; path=" + path : "") +
	 ((domain) ? "; domain=" + domain : "") +
	 "; expires=Thu, 01-Jan-70 00:00:01 GMT"
  }
}
function changeDiv(DivID,Vis)
{
    if (IE) {
        if (Vis == "h") {
        document.all[DivID].style.display='none';
        }
        else if (Vis == "s") {
        document.all[DivID].style.display = '';
        }
        return false;
    }
    if (DOM) {
        if (Vis == "h") {
            var flipOff = document.getElementById(DivID);
            flipOff.style.display="none";
        }
        else if (Vis == "s") {
            var flipOn = document.getElementById(DivID);
            flipOn.style.display="";
        }
        return false;
    }
    if (NS4) {
        if (Vis == "h") {
            document.layers[DivID].visibility='hide';
        }
        else if (Vis == "s") {
            document.layers[DivID].visibility = 'show';
        }
        return false;
    }
    return false;
}
function getPDF(pdfdoc,option)
{
	if(option!='' && option!=null)
	{
		openwindow("http://" + document.location.hostname + "/controllers/protected/pdfdocument.asp?pdfdoc="+pdfdoc+"&option="+option, "PDFPage", "toolbar=no,scrollbars=yes,menubar=no,directories=no,location=no,status=no,width=750,height=550")
	} else {
		openwindow("http://" + document.location.hostname + "/controllers/protected/pdfdocument.asp?pdfdoc="+pdfdoc, "PDFPage", "toolbar=no,scrollbars=yes,menubar=no,directories=no,location=no,status=no,width=750,height=550")
	}
}
function openwindowgethandle(pg, ttl, opts)
	{
	var w;
	//turn missing parms into empty strings
	if (!pg ) pg = "";
	if (!ttl) ttl = "";
	if (!opts) opts = "";
	w = window.open (pg, ttl, opts);
	w.focus();
	return w;
	}
function openwindow(pg, ttl, opts)
{
var w;
if (!pg ) pg = "";
if (!ttl) ttl = "";
if (!opts) opts = "";
w = window.open (pg, ttl, opts);
w.focus();
}
function openfixedwindow(pg, ttl)
{
if (!pg ) pg = ""; 
if (!ttl) ttl = "";
var w = openwindow(pg, ttl, "toolbar=no,scrollbars=yes,menubar=no,directories=no,location=no,status=no,width=600,height=400")
}
function openfixedwindowgethandle(pg, ttl)
{
if (!pg ) pg = ""; 
if (!ttl) ttl = "";
var w = openwindowgethandle(pg, ttl, "toolbar=no,scrollbars=yes,menubar=no,directories=no,location=no,status=no,width=600,height=400")
return w
}
function openPassword()
{
	popupWin = window.open('password.asp', 'remote', 'scrollbars,width=400,height=400')
}
function retrieveCounties(statefield, countyfield)
{
	
	try {
			var statecode, aspObj, countyObj, countypairs, onepair, itm, x;

			statecode = statefield[statefield.selectedIndex].value;
			aspObj = RSGetASPObject("/_ScriptLibrary/JMFCPRemoteScripts.asp")
			countyObj = aspObj.getCountyList(statecode)
			countypairs = countyObj.return_value.split("|");
			for (x = 0; x < countyfield.options.length; x++)
				countyfield.options[x] = null;
			itm = new Option("Select..............",-1);
			countyfield.options[0]=itm;
			for (x = 0; x < countypairs.length; x++)
				{
				onepair = countypairs[x].split("*");
				itm = new Option(onepair[1],onepair[1]);
				countyfield.options[x+1]=itm;
				}
			countyfield.selectedIndex = 0;
		}
	catch(e){
			document.frmDialog.action.value= "refresh";
			document.frmDialog.mode.value= "get";
			document.frmDialog.submit();
		}
}
function OpenDealerCoupon()
{
	cp = openwindowgethandle('/controllers/protected/garage/vehicle/coupon.asp', 'Coupons','toolbar=no,scrollbars=yes,menubar=no,directories=no,location=no,status=no,width=470,height=550');
}


function popUp(url) 
{
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');
	self.name = "mainWin";
}

function privacywindow(pg, ttl)
{
if (!pg ) pg = ""; 
if (!ttl) ttl = "";
var w = openwindow(pg, ttl, "toolbar=no,scrollbars=yes,menubar=no,directories=no,location=no,status=no,width=640,height=400")
}

