// JavaScript Document
// Copyright 2000-2011, DataCom/OTA, Inc.
        
// 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";
}

// Show/hide
function sh(theItem) {
	if ( document.getElementById(theItem).style.display == "block") {
	  document.getElementById(theItem).style.display = "none";
	} else {
	  document.getElementById(theItem).style.display = "block";
	}
}

// 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>";
}

// /contactUs.shtml form
function em() {
    var form = document.forms['contactUs'];
    var fn = form.Name.value;
    var em = form.Email.value;
	var ph = form.Phone.value;
    var fm = form.Message.value;
    qstr = 'Name=' + escape(fn) + '&Email=' + escape(em) + '&Phone=' + escape(ph) + '&Message=' + escape(fm);
    return qstr;
}


