function changeStatus(id) {
	var sc = document.getElementById(id);
	
	if (sc.style.display == "none") {
		sc.style.display = "inline";
	} else {
		sc.style.display = "none";
	}
}


function popit(url,name,w,h) {
	popwin = window.open(url,name,"width=" + w + ",height=" + h + ",toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1");
	popwin.focus();
}


function isemail(email) {

	if (window.RegExp) {
	
    	var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
    	var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
    	var reg1 = new RegExp(reg1str);
    	var reg2 = new RegExp(reg2str);
		
    	if (!reg1.test(email) && reg2.test(email)) {
      		return true;
    	}
		
    	return false;
		
  	} else {
	
    	if(email.indexOf("@") >= 0) {
      		return true;
		}
			
    	return false;
		
  	}
	
}


function trackhit(poo, stain, pageid, subid) {

	if (window.XMLHttpRequest) {
		xmlHttp=new XMLHttpRequest()
	} else if (window.ActiveXObject) {
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
			
	var dt = new Date();
	var ms = dt.getMilliseconds();
	var dtms = dt + ":" + ms;
	var openpage = "hits.aspx?z97@eu92p=" + poo + "&mb38cf=" + stain + "&pageid=" + pageid + "&subid=" + subid + "&dt=" + dtms;
	xmlHttp.open('http://www.foxmotors.com/GET',openpage);
	xmlHttp.send(null);
	
}

function contactit(poo, stain, name, email, phone, comments) {

	if (window.XMLHttpRequest) {
		xmlHttp=new XMLHttpRequest()
	} else if (window.ActiveXObject) {
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
			
	var dt = new Date();
	var ms = dt.getMilliseconds();
	var dtms = dt + ":" + ms;
	var openpage = "contactit.aspx?z97@eu92p=" + poo + "&mb38cf=" + stain + "&name=" + name + "&email=" + email + "&phone=" + phone + "&comments=" + escape(comments) + "&dt=" + dtms;
	xmlHttp.open('http://www.foxmotors.com/GET',openpage);
	xmlHttp.send(null);    

}


function isDate(dateStr) {

	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
	var matchArray = dateStr.match(datePat); // is the format ok?
	
	if (matchArray == null) {
		alert("Please enter date as either mm/dd/yyyy or mm-dd-yyyy.");
		return false;
	}
	
	month = matchArray[1]; // p@rse date into variables
	day = matchArray[3];
	year = matchArray[5];
	
	if (month < 1 || month > 12) { // check month range
		alert("Month must be between 1 and 12.");
		return false;
	}
	
	if (day < 1 || day > 31) {
		alert("Day must be between 1 and 31.");
		return false;
	}
	
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {
		alert("Month "+month+" doesn`t have 31 days!");
		return false;
	}
	
	if (month == 2) { // check for february 29th
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day > 29 || (day==29 && !isleap)) {
			alert("February " + year + " doesn`t have " + day + " days!");
			return false;
		}
	}
	
	return true; // date is valid
	
}

