// Copyright 2000-2008, DataCom of Duluth
	
// Setup
aboutUs_off=new Image(201,131);
aboutUs_off.src="/images/aboutUs_off.gif";
aboutUs_on=new Image(201,131);
aboutUs_on.src="/images/aboutUs_on.gif";

extras_off=new Image(201,131);
extras_off.src="/images/extras_off.gif";
extras_on=new Image(201,131);
extras_on.src="/images/extras_on.gif";

menu_off=new Image(201,129);
menu_off.src="/images/menu_off.gif";
menu_on=new Image(201,129);
menu_on.src="/images/menu_on.gif";

map_off=new Image(201,137);
map_off.src="/images/map_off.gif";
map_on=new Image(201,137);
map_on.src="/images/map_on.gif";


//Set Cookie for Current Page
function scPage(cName) {
	setCookie('cPage', cName);
	grayOut(cName);
}

//Gray Out Current Page
function grayOut(imgName) {
	var ptest = getCookie('cPage');
	if (ptest == imgName) {
		try {
			document[imgName].src=eval(imgName + "_on.src");
		}
		catch(e) { }
	}
}

// Roll Over Buttons
function turnOn(imgName) {
	var ptest = getCookie('cPage');
	if (ptest != imgName) {
		try {
			document[imgName].src=eval(imgName + "_on.src");
		}
		catch(e) { }
	}
}

function turnOff(imgName) {
	var ptest = getCookie('cPage');
	if (ptest != imgName) {
		try {
			document[imgName].src=eval(imgName + "_off.src");
		}
		catch(e) { }
	}
}

// Set cookies
function setCookie(theName, theValue) {
	var expDate = new Date;
	expDate.setMonth(expDate.getMonth()+6);
	document.cookie = theName + "=" + theValue +";path=/;expires=" + expDate.toGMTString() +";"
}

// Read cookies
function getCookie(cookieName) {
  var cookieData = document.cookie;
  var i = 0;
  var cEnd;
  while (i < cookieData.length) {
    var j = i + cookieName.length;
    if (cookieData.substring(i, j) == cookieName) {
      cEnd = cookieData.indexOf(";", j);
      if (cEnd == -1)
        cEnd = cookieData.length;
      return decodeURIComponent(cookieData.substring(j + 1, cEnd));
    }
    i++;
  }
  return "";
}

// Delete Cookie
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";
}

// Open Files
function openFile(theFile) {
    window.open (theFile);
}

function openFileA(theFile, theWindow, theBar, theSize, theWidth, theHeight) {
    window.open (theFile, theWindow,"status=no,location=no,toolbars="+theBar+",menubar="+theBar+",directories=no,scrollbars=yes,resizable="+theSize+",width="+theWidth+",height="+theHeight);
}


// AJAX File Request
function getFile(theFile, theDiv) {
	var pageReq = false;
	
    if (window.XMLHttpRequest) {
        pageReq = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
		try {
			pageReq = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				pageReq = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				pageReq = false;
			}
		}
	}
	
    pageReq.open('GET', theFile, true);
    pageReq.onreadystatechange = function() {
        if (pageReq.readyState == 4) {
			document.getElementById(theDiv).innerHTML = pageReq.responseText;
		}
    }
    pageReq.send(null);
}

//Process Forms
function sendForm(theCGI, theQuery, theDiv) {
	var pageReq = false;
	
    if (window.XMLHttpRequest) {
        pageReq = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
		try {
			pageReq = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				pageReq = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				pageReq = false;
			}
		}
	}
	
    pageReq.open('POST', theCGI, true);
    pageReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    pageReq.onreadystatechange = function() {
        if (pageReq.readyState == 4) {
			document.getElementById(theDiv).innerHTML = pageReq.responseText;
            //updatepage(pageReq.responseText);
        }
    }
    pageReq.send(eval(theQuery)());
	document.getElementById(theDiv).innerHTML = "<h1 id=\"bfm\">Sending . . . </h1>";
}

// /Contact-Us/index.shtml (contact us) form
function em() {
    var form = document.forms['ContactUs'];
    var fn = form.Name.value;
    var em = form.Email.value;
    var fm = form.Message.value;
    qstr = 'Name=' + escape(fn) + '&Email=' + escape(em) + '&Message=' + escape(fm);
    return qstr;
}
