var isNS4=document.layers?true:false;
var isIE=document.all?true:false;
var isIE6=isIE&&document.getElementById?true:false;
var isIE4=isIE&&!isIE6?true:false;
var isNS6=!isIE6&&document.getElementById?true:false;
var isNS=isNS4||isNS6;

function conf(verb, ob, loc) {
	if (confirm('Are you sure you want to ' + verb + ' this ' + ob + "?")) {location.href=loc;}
}
function openWin(loc) {
aWindow = window.open("","thewindow","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=450,height=500");
aWindow.location.href = loc;
if(aWindow == null) aWindow = window;
}
function openWin2(loc) {
aWindow2 = window.open("","thewindow2","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=350,height=400");
aWindow2.location.href = loc;
if(aWindow2 == null) aWindow2 = window;
}
function jspopup(myurl, w, h, tb, sb, st){
var wnd = window.open(myurl,"popup","toolbar=" + tb + ",location=0,directories=0,status=" + st + ",menubar=0,scrollbars=" + sb + ",resizable=0,width=" + w + ",height=" + h);
if (wnd.opener == null) wnd.opener = self;
}
function selectState(stateVar) {
	document.getElementById("oSearchCity").value = document.getElementById("ooSearchCity").value + ", " + stateVar;
	document.resubmitForm.submit();
}
function selectState2(stateVar) {
	document.getElementById("oAnalCity").value = document.getElementById("ooAnalCity").value + ", " + stateVar;
	document.resubmitForm.submit();
}
function showlayer(vid) {
	if (document.getElementById) {eval("document.getElementById(vid).style.display = \"\"");}
	else {
		if (document.layers) {document.layers[vid].style.display = "";}
		else {if (document.all) {eval("document.all." + vid + ".style.display = \"\"");}}
	}
}
function hidelayer(id) {
	if (document.getElementById) {eval("document.getElementById(id).style.display = \"none\"");}
	else {
		if (document.layers) {document.layers[id].display = "none";}
		else {if (document.all) {eval("document.all." + id + ".style.display = \"none\"");}}
	}
}
function togglelayer(id) {
	if (document.getElementById) {
		if (document.getElementById(id).style.display == 'none')
			showlayer(id);
		else
			hidelayer(id);
	}
}
function displayGoogleMap(clat,clon,sid,bid) {
	if (GBrowserIsCompatible()) {
	var map = new GMap2(document.getElementById("map"));
	map.setCenter(new GLatLng(clat, clon), 10);
	map.addControl(new GSmallMapControl());
	GDownloadUrl("/submarketMap.asp?sid=" + sid + "&bid=" + bid + "&xml=1", function(data, responseCode) {
		var xml = GXml.parse(data);
		var markers = xml.documentElement.getElementsByTagName("marker");
		for (var i = 0; i < markers.length; i++) {
			var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng")));
			map.addOverlay(new GMarker(point));
		}
	})
	}
}
function isValidDate(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
}
function getDateObj(dateStr) {
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
	var matchArray = dateStr.match(datePat); // is the format ok?
	month = matchArray[1]; // p@rse date into variables
	day = matchArray[3];
	year = matchArray[5];
	var dateObj = new Date(year,month-1,day);
	return dateObj;
}

function demoPopup(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=625,height=475,left = 647.5,top = 362.5');");
}
