function centerWindow(whichPage) {
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 640, yMax=480;

    var xOffset = (xMax - 200)/2, yOffset = (yMax - 200)/2;

    window.open(whichPage,'coupons','toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=375,height=500,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
}

function autoDollarWindow() {
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 640, yMax=480;

    var xOffset = (xMax - 200)/2, yOffset = (yMax - 200)/2;

    var whichPage2 ='http://www.autodollars.com/gm/gm.asp?dealer=3'; window.open(whichPage2,'autodollar','toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=740,height=700,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
}

//Find out if it is okay to run this script
var runScript = false;
var browserName = navigator.appName;
var browserVersion = parseInt(navigator.appVersion);
if ((browserName == "Netscape" && browserVersion >=3) || (browserName == "Microsoft Internet Explorer" && browserVersion >= 4)) {
	runScript = true;
}
else {
	runScript = false;
}

function isFilled(myfield) {
	return( ( (myfield == "") || (myfield == null) ) ? false : true );
}

// check if fields are valid
function checkit() {
	if (runScript == "1") {
		// Check for name
		if ((!isFilled(document.myform.fullname.value)) || (document.myform.fullname.value == 0)) {
			alert("Please enter your name.");
			document.myform.fullname.focus();
			return(false);
		}
		// Check for email
		if ((!isFilled(document.myform.email.value)) || (document.myform.email.value == 0)) {
			alert("Please enter your eMail Address.");
			document.myform.email.focus();
			return(false);
		}
		if ( (document.myform.email.value.indexOf("@") < 0) || (document.myform.email.value.indexOf(".") < 0) ) {
			alert("Please enter a valid email address.\n(ex. name@domain.com).");
			document.myform.email.focus();
			return(false);
		}
		// Check for Phone
		if ((!isFilled(document.myform.phone.value)) || (document.myform.phone.value == 0)) {
			alert("Please enter your telephone number.");
			document.myform.phone.focus();
			return(false);
		}
	}
	return(true);
}
function do_date() {
	currentDate = new Date();
	with (currentDate) {
		mytemp = "" + (getMonth()+1);
		if (mytemp.length < 2) {
			mytemp = "0" + mytemp;
		}
		ckrdate = mytemp;
		mytemp = "" + (getDate()+1);
		if (mytemp.length < 2) {
			mytemp = "0" + mytemp;
		}
		ckrdate = ckrdate + "/" + mytemp;
		if (browserName == "Microsoft Internet Explorer") {
			ckrdate = ckrdate + "/" + getYear();
		} else {
			ckrdate = ckrdate + "/" + (getYear()+1900);
		}
		document.myform.listingdate.value = ckrdate;
	}
}
