// JavaScript Document

// Copyright 2000-2009, DataCom/OTA, Inc.
        
// Setup

// 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 "";
}

function setPage(currentPage) {
	setCookie('cPage', currentPage);
}

// 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 postFile(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>Sending . . . </h1>";
}

//  /contact.shtml form
function em() {
    var form = document.forms['ContactUs'];
    var fn = form.Name.value;
    var em = form.Email.value;
    var cm = form.Message.value;
    qstr = 'Name=' + escape(fn) + '&Email=' + escape(em) + '&Message=' + escape(cm);
    return qstr;
}