// user req code
function initSite() {
	var aDays = "Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday".split("|");
	var aMonths = "January|February|March|April|May|June|July|August|September|October|November|December".split("|");
	roll.init();
	var oItem = document.getElementById("clock");
	var dNow = new Date();
	var curHour = dNow.getHours()
	var curMin = dNow.getMinutes()
	var curSec = dNow.getSeconds()
	var curTime = ((curHour < 10) ? "0" : "") + curHour + ":" 
		+ ((curMin < 10) ? "0" : "") + curMin + ":" 
		+ ((curSec < 10) ? "0" : "") + curSec;
	oItem.innerHTML = curTime + " GMT" + (-(dNow.getTimezoneOffset() / 60)) + "<br>" +
		aDays[dNow.getDay()] + "<br>" +
		aMonths[dNow.getMonth()] + " " + dNow.getDate() + ", " + dNow.getFullYear();
}

// User rollMap

iLastMapID = 0;
function rollMap(sRollID) {
	var oItem;
	if (iLastMapID > 0) {
		oItem = document.getElementById("ur_url_" + iLastMapID);
		oItem.className = "out";
		oItem = document.getElementById("ur_mapdiv_" + iLastMapID);
		oItem.style.display = "none";
	}
	oItem = document.getElementById("ur_url_" + sRollID);
	oItem.className = "textdown";
	oItem = document.getElementById("ur_mapdiv_" + sRollID);
	oItem.style.display = "block";
	iLastMapID = sRollID;
}
iLastSelectID = 0;
function selMap(sRollID) {
	var oItem;
	if (iLastSelectID > 0) {
		oItem = document.getElementById("ur_txtdiv_" + iLastSelectID);
		oItem.style.display = "none";
	}
	oItem = document.getElementById("ur_txtdiv_" + sRollID);
	oItem.style.display = "block";
	iLastSelectID = sRollID;
}

// Tech Integration rollMap

iLastMapID = 0;
function rollMapTech(sRollID) {
	var oItem;
	if (iLastMapID > 0) {
		oItem = document.getElementById("tech_url_" + iLastMapID);
		oItem.className = "out";
		oItem = document.getElementById("tech_mapdiv_" + iLastMapID);
		oItem.style.display = "none";
	}
	oItem = document.getElementById("tech_url_" + sRollID);
	oItem.className = "textdown";
	oItem = document.getElementById("tech_mapdiv_" + sRollID);
	oItem.style.display = "block";
	iLastMapID = sRollID;
}
iLastSelectID = 0;
function selMapTech(sRollID) {
	var oItem;
	if (iLastSelectID > 0) {
		oItem = document.getElementById("tech_txtdiv_" + iLastSelectID);
		oItem.style.display = "none";
	}
	oItem = document.getElementById("tech_txtdiv_" + sRollID);
	oItem.style.display = "block";
	iLastSelectID = sRollID;
}

// newsitem code
iLastNewsItem = 0;
function showNews(sNewsID) {
	var oItem;
    if (iLastNewsItem > 0) {
    	oItem = document.getElementById("news_div_" + iLastNewsItem);
		oItem.style.display = "none";
		oItem = document.getElementById("newslink_" + iLastNewsItem);
		oItem.className = "";
	}
    oItem = document.getElementById("news_div_" + sNewsID);
    oItem.style.display = "block";
    oItem = document.getElementById("newslink_" + sNewsID);
    oItem.className = "textdown";
    iLastNewsItem = sNewsID;
}

// teamitem code
iLastTeamID = 0;
function showTeam(sTeamID) {
	var oItem;
    if (iLastTeamID > 0) {
    	oItem = document.getElementById("team_div_" + iLastTeamID);
		oItem.style.display = "none";
		oItem = document.getElementById("teamlink_" + iLastTeamID);
		oItem.className = "";
	}
    oItem = document.getElementById("team_div_" + sTeamID);
    oItem.style.display = "block";
    oItem = document.getElementById("teamlink_" + sTeamID);
    oItem.className = "textdown";
    iLastTeamID = sTeamID;
}

// rollover code
roll = new csRoll();
function csRoll(overSuffix, outSuffix){
	this.overSuffix = "_over";
	this.outSuffix = "_out";
	this.images = new Object()
	this.initialized = false;
}
csRoll.prototype.over = function csRollOver(imgName) { if (this.initialized) this.images[imgName].over(); }
csRoll.prototype.out = function csRollOut(imgName) { if (this.initialized) this.images[imgName].out(); }
csRoll.prototype.init = csRollInit;
function csRollInit(){
	var imgs = document.getElementsByTagName("img");
	for(var i = 0; i < imgs.length; i++) this.mapImage(imgs[i]);
	this.initialized = true;
}
csRoll.prototype.mapImage = csRollMapImage;
function csRollMapImage(img){
	if(img.name.indexOf("_ROLL") != -1)
		this.images[img.name.substr(0,img.name.lastIndexOf("_"))] = new csRollImage(img, this.overSuffix, this.outSuffix);
}
function csRollImage(img, overSuffix, outSuffix){
	this.img = img;
	this.baseSuffix = this.img.src.substr(this.img.src.lastIndexOf("."));
	var baseSrc = this.img.src.substr(0,this.img.src.lastIndexOf("_"));
	this.overSrc = baseSrc + overSuffix + this.baseSuffix;
	this.outSrc = baseSrc + outSuffix + this.baseSuffix;
	this.preloadOver = new Image(); 
	this.preloadOver.src = this.overSrc; 
	this.preloadOut = new Image();
	this.preloadOut.src = this.outSrc;
}
csRollImage.prototype.over = function csRollImageOver() { this.img.src = this.preloadOver.src; }
csRollImage.prototype.out = function csRollImageOut() {	this.img.src = this.preloadOut.src; }

//popup
function popLargeImage(sImage) {
	wLargeImage = new csWin("pop_image.asp?img=" + sImage, "Zocalo", 550, 450);
}
function csWin(popUrl,popName,w,h,scrollbars,x,y,toolbar,menubar,resizable,status,directories){
	this.popUrl = popUrl;
	this.popName = popName;
	this.w = w ? w : screen.width;
	this.h = h ? h : screen.height;
	this.scrollbars = scrollbars ? scrollbars : 0;
	this.toolbar = toolbar ? toolbar : 0;
	this.menubar = menubar ? menubar : 0;
	this.resizable = resizable ? resizable : 0;
	this.status = status ? status : 0;
	this.directories = directories ? directories : 0;
	var winl = x ? x : ((screen.width - this.w) / 2);
	var wint = y ? y : ((screen.height - this.h) / 2);
	if (wint < 0) wint = 1;
	if (winl < 0) winl = 0;
	this.popWin = window.open(
		this.popUrl,
		this.popName,
		"top=" + wint + "," +
		"left=" + winl + "," +
		"toolbar=" + this.toolbar.toString() + "," +
		"directories=" + this.directories.toString() + "," +
		"status=" + this.status.toString() + "," +
		"menubar=" + this.menubar.toString() + "," +
		"scrollbars=" + this.scrollbars.toString() + "," +
		"resizable=" + this.resizable.toString() + "," +
		"width=" + this.w.toString() + "," +
		"height=" + this.h.toString()
	);
}
// form validation
function validateForm() {
	var bFormOK = true;
	if (checkString("Name", "fldName", bFormOK)) bFormOK = false;
	if (checkString("Email", "fldEmail", bFormOK, true)) bFormOK = false;
	if (checkString("Phone", "fldPhone", bFormOK)) bFormOK = false;
	if (checkString("Evening Phone", "fldEvePhone", bFormOK, true)) bFormOK = false;
	if (checkString("Fax", "fldFax", bFormOK, true)) bFormOK = false;
	if (checkString("Address 1", "fldAddress1", bFormOK)) bFormOK = false;
	if (checkString("Address 2", "fldAddress2", bFormOK, true)) bFormOK = false;
	if (checkString("City", "fldCity", bFormOK)) bFormOK = false;
	if (checkString("State", "fldState", bFormOK)) bFormOK = false;
	if (checkString("Zip", "fldZip", bFormOK)) bFormOK = false;
	if (checkString("Country", "fldCountry", bFormOK, true)) bFormOK = false;
	if (checkString("Message", "fldMessage", bFormOK, true)) bFormOK = false;
	if (document.frmThis.fldBestTime.value == "0" && bFormOK) {
		alert("Please select best time to call");
		bFormOK = false;
	}
	if (bFormOK)
		document.frmThis.submit();
}
// form validation functions
function checkString(sFieldText, sFieldName, bFormOK, bBlankOK) {
	if (bFormOK) {
		if (hasScript(eval("document.frmThis." + sFieldName).value)) {
			alert(sFieldText + " contains illegal script text\nthat can cause problems with your information");
			eval("document.frmThis." + sFieldName).focus();
			return true;
		} else {
			if (!bBlankOK && isWhitespace(eval("document.frmThis." + sFieldName).value)) {
				alert(sFieldText + " is required");
				eval("document.frmThis." + sFieldName).focus();
				return true;
			} else {
				return false;
			}
		}
	}
	return false;
}
var sWhitespace = " \t\n\r";

function isEmpty(s){
	return ((s == null) || (s.length == 0))
}

function isWhitespace (s) {
	var i;
	if (isEmpty(s)) return true;
	for (i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if (sWhitespace.indexOf(c) == -1) return false;
	}
	return true;
}
function hasScript (inString) {
	var tmpString = stripWhitespace(inString).toUpperCase();
	if (tmpString.indexOf("<" + "SCRIPT") != -1) return true;
	if (tmpString.indexOf("<" + "/" + "SCRIPT") != -1) return true;
	if (tmpString.indexOf("<" + "%") != -1) return true;
	if (tmpString.indexOf("%" + ">") != -1) return true;
	if (tmpString.indexOf("<" + "?") != -1) return true;
	if (tmpString.indexOf("php" + ">") != -1) return true;
	if (tmpString.indexOf("language=") != -1) return true;
	return false;
}
function stripWhitespace (s) {
	return stripCharsInBag (s, sWhitespace);
}
function stripCharsInBag (s, bag){
	var i;
	var returnString = "";
	for (i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if (bag.indexOf(c) == -1) returnString += c;
	}
	return returnString;
}
function isInteger (s){
	var i;
	if (isEmpty(s))
		if (isInteger.arguments.length == 1) return defaultEmptyOK;
		else return (isInteger.arguments[1] == true);
	for (i = 0; i < s.length; i++){
		var c = s.charAt(i);
		if (!isDigit(c)) return false;
	}
	return true;
}
function isDigit (c){
	return (((c >= "0") && (c <= "9")) || c == ".");
}

function displayFAQAnswer(id) {

	if (document.getElementById("faqQuestion_"+id).innerHTML == "[+]")
	{
		document.getElementById("faqAnswer_"+id).style.display = "block";
		document.getElementById("faqQuestion_"+id).innerHTML = "[-]";
	}
    else if (document.getElementById("faqQuestion_"+id).innerHTML == "[-]")
	{
		document.getElementById("faqAnswer_"+id).style.display = "none";
		document.getElementById("faqQuestion_"+id).innerHTML = "[+]";
	}
		
}

function displayComment(id) {

	if (document.getElementById("commentID_"+id).innerHTML == "[+]")
	{
		document.getElementById("comment_"+id).style.display = "block";
		document.getElementById("commentID_"+id).innerHTML = "[-]";
	}
    else if (document.getElementById("commentID_"+id).innerHTML == "[-]")
	{
		document.getElementById("comment_"+id).style.display = "none";
		document.getElementById("commentID_"+id).innerHTML = "[+]";
	}
		
}

