// JavaScript Document
<!--

// Fullscreen view new window
var newwindow;
function fullscreen(url)
{
	newwindow=window.open(url,'name','height=500,width=400,left=100,top=100,resizable=yes,scrollbars=no,toolbar=no,status=no');
	if (window.focus) {newwindow.focus()}
}
function smallscreen(url)
{
	newwindow=window.open(url,'name','height=320,width=240,left=100,top=100,resizable=yes,scrollbars=no,toolbar=no,status=no');
	if (window.focus) {newwindow.focus()}
}

function fullscreen(url)
{
	newwindow=window.open(url,'name','height=768,width=1024,left=0,top=0,resizable=yes,scrollbars=no,toolbar=no,status=no');
	if (window.focus) {newwindow.focus()}
}

// We keep here the state of the search box
searchIsDisabled = false;
siteSearchIsDisabled = false;

function searchChange(e) {
    // Update search buttons status according to search box content.
    // Ignore empty or whitespace search term.
    var value = e.value.replace(/\s+/, '');
    if (value == '' || searchIsDisabled) { 
        searchSetDisabled(true);
    } else {
        searchSetDisabled(false);
    }
}

function searchSetDisabled(flag) {
    // Enable or disable search
    document.getElementById('fullsearch').disabled = flag;
}

function searchFocus(e) {
    // Update search input content on focus
    if (e.value == 'Search Section') {
        e.value = '';
        e.style.color = 'black';
        searchIsDisabled = false;
    }
}

function searchBlur(e) {
    // Update search input content on blur
    if (e.value == '') {
        e.value = 'Search Section';
        e.style.color = 'gray';
        searchIsDisabled = true;
    }
}

function siteSearchSetDisabled(flag) {
    // Enable or disable search
    document.getElementById('fullsitesearch').disabled = flag;
}

function siteSearchChange(e) {
    // Update search buttons status according to search box content.
    // Ignore empty or whitespace search term.
    var value = e.value.replace(/\s+/, '');
    if (value == '' || siteSearchIsDisabled) { 
        siteSearchSetDisabled(true);
    } else {
        siteSearchSetDisabled(false);
    }
}

function siteSearchFocus(e) {
    // Update search input content on focus
    if (e.value == 'Search Site') {
        e.value = '';
        e.style.color = 'black';
        siteSearchIsDisabled = false;
    }
}

function siteSearchBlur(e) {
    // Update search input content on blur
    if (e.value == '') {
        e.value = 'Search Site';
        e.style.color = 'gray';
        siteSearchIsDisabled = true;
    }
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


<!-- THIS PART GOES AFTER SEARCH ----

/* <form id="searchform" method="get" action="search.php">
	<label for="searchinput">Search</label>
	<input id="searchinput" type="text" class="search" name="search" size="18"
	onfocus="searchFocus(this)" onblur="searchBlur(this)"
	onkeyup="searchChange(this)" onchange="searchChange(this)" alt="Search">

	<input id="fullsearch" name="submit" type="hidden" value="Go" alt="Search">
</form> */
			

//<script type="text/javascript">
<!--// Initialize search form
//var f = document.getElementById('searchform');
//f.getElementsByTagName('label')[0].style.display = 'none';
//var e = document.getElementById('searchinput');
//searchChange(e);
//searchBlur(e);
//-->
//
--> 




<!-- THIS IS THE DIALOG BOXES 
// ADDED FOR DIALOG POPUP MENU
// NOTE: requires css/screen_styles.css


function toggle_dynamic_dialog_custom(rootEl, innerHTML) {
    if (isIE()) {
        /* because of the way IE renders select boxes, we should put an 
         * an iframe underneath our dynamic dialog so that select boxes
         * don't shine through, yuck. -jared m. 
         * 
         * this lays the iframe_holder, at the end of the function
         * we'll dynamically get the size of the dynamic dialog and
         * then we'll drop in the appropriately sized iframe.
         *
         * booyakasha. 
         */
        var ieHTML;
        ieHTML =  '<div id="ie_iframe_holder"></div>';
        ieHTML += '<div style="position: absolute; z-index: 100;">';
        innerHTML = ieHTML + innerHTML + '</div>';
    }
    var dynamic_dialog = ge('dynamic_dialog');
    if (dynamic_dialog) {
        //reuse it
        if (shown(dynamic_dialog) && same_place(rootEl, dynamic_dialog)) {
            hide(dynamic_dialog);
        } else {
            move_here(rootEl, dynamic_dialog);  
	    dynamic_dialog.innerHTML = unescapeQuotes(innerHTML);
            show('dynamic_dialog');
        }
    } else {
        //create it
        var dynamic_dialog = document.createElement("div");
        dynamic_dialog.id = 'dynamic_dialog';
        dynamic_dialog.innerHTML = unescapeQuotes(innerHTML);
        move_here(rootEl, dynamic_dialog);
        ge('content').appendChild(dynamic_dialog);
    }
    if (isIE()) {
        // now dynamically get the size and drop the iframe in
        var height, width, ieIframeHTML;
        height = ge('dialog').offsetHeight;
        width  = ge('dialog').offsetWidth;
        ieIframeHTML = '<iframe width="' + width + ' "height=' + height + '" ';
        ieIframeHTML += 'style="position: absolute; z-index: 99;"></iframe>';
        ge('ie_iframe_holder').innerHTML = ieIframeHTML;
    }
    return false;
}

function same_place(rootEl, dynamic_dialog) {
    if (rootEl = ge(rootEl)) {
        if (elementY(rootEl) + 20 == elementY(dynamic_dialog))
            return true;
    }
    return false;
}

function move_here(rootEl, el) {
    var x = elementX(rootEl) - 62;
    var y = elementY(rootEl) - 100;
    el.style.left = x + "px";
    el.style.top = y + "px";
}

function toggle_dynamic_dialog(rootEl, headingText, contentText, 
        confirmText, confirmLocation, itemID, projectID,IDname) {
    
    var innerHTML = 
   "<table id=\"dialog\" border=\"0\" cellspacing=\"0\" width=\"360\">" +
   "<tr>\n" + 
   "<td class=\"dialog\">\n" + 
   "<h4>" + headingText + "</h4>\n" + 
   "<p>" + contentText + "</p><br><br>" +
   "<div class=\"buttons\">\n" +
   "<form action=\"" + confirmLocation + "\" method=\"post\">\n" +
   "<input type=\"hidden\" name=\"next\" value=\"" + window.location.pathname.substr(1) + window.location.search + "\"/>\n" +
   "<input type=\"hidden\" name=\""+ IDname + "\" value=\""+ itemID + "\"/>\n" +
   "<input type=\"hidden\" name=\"projectID\" value=\""+ projectID + "\"/>\n" +
   "<input type=\"submit\" id=\"confirm\" name=\"confirm\" class=\"inputsubmit\" value=\"" + confirmText + "\"/>&nbsp;<input type=\"button\" id=\"cancel\" name=\"cancel\" onclick=\"hide('dynamic_dialog');\" class=\"inputbutton\" value=\"cancel\" />\n" + 
   "</form>\n" +
   "</div>\n" + 
   "</td>\n" + 
   "</tr>\n" +
   "</table>\n";
    return toggle_dynamic_dialog_custom(rootEl, innerHTML);
}

function toggle_dynamic_entry(rootEl, headingText, contentText, 
        confirmText, caption, imageID, confirmLocation) {
    
    var innerHTML = 
   "<table id=\"dialog\" border=\"0\" cellspacing=\"0\" width=\"360\">" +
   "<tr>\n" + 
   "<td class=\"dialog\">\n" + 
   "<h4>" + headingText + "</h4>\n" + 
   "<p>" + contentText + "</p><br><br>" +
   "<div class=\"buttons\">\n" +
   "<form action=\"" + confirmLocation + "\" method=\"post\">\n" +
   "<textarea name=\"caption\" cols=\"30\" rows=\"8\">" + caption + "</textarea><br>" +
   "<input type=\"hidden\" name=\"imageID\" value=\"" + imageID + "\"/>\n" +
   "<input type=\"hidden\" name=\"next\" value=\"" + window.location.pathname.substr(1) + window.location.search + "\"/>\n" +
   "<input type=\"submit\" id=\"confirm\" name=\"confirm\" class=\"inputsubmit\" value=\"" + confirmText + "\"/>&nbsp;<input type=\"button\" id=\"cancel\" name=\"cancel\" onclick=\"hide('dynamic_dialog');\" class=\"inputbutton\" value=\"Cancel\" />\n" + 
   "</form>\n" +
   "</div>\n" + 
   "</td>\n" + 
   "</tr>\n" +
   "</table>\n";
    return toggle_dynamic_dialog_custom(rootEl, innerHTML);
}

function toggle_dynamic_image(rootEl, image) {
    
    var innerHTML = 
   "<table id=\"dialog\" border=\"0\" cellspacing=\"0\" >" +
   "<tr>\n" + 
   "<td class=\"dialog\">\n" + 
   "<div class=\"buttons\">\n" +
   "<img src=\"" + image + "\" /><br>\n" +
   "<a href=\"#\" onclick=\"hide('dynamic_dialog')\">x close</a>\n" + 
   "</div>\n" + 
   "</td>\n" + 
   "</tr>\n" +
   "</table>\n";
    return toggle_dynamic_dialog_custom(rootEl, innerHTML);
}

function toggle_dynamic_dialog_js(rootEl, headingText, contentText, 
        confirmText, confirmJS) {
    
    var innerHTML = 
   "<table id=\"dialog\" border=\"0\" cellspacing=\"0\" width=\"360\">" +
   "<tr>\n" + 
   "<td class=\"dialog\">\n" + 
   "<h4>" + headingText + "</h4>\n" + 
   "<p>" + contentText + "</p>" +
   "<div class=\"buttons\">\n" +
   "<input type=\"button\" id=\"confirm\" name=\"confirm\" class=\"inputsubmit\"  value=\"" + confirmText + "\" onclick=\"" + confirmJS + "\"/>&nbsp;<input type=\"button\" id=\"cancel\" name=\"cancel\" onclick=\"hide('dynamic_dialog');\" class=\"inputbutton\" value=\"Cancel\" />\n" + 
   "</form>\n" +
   "</div>\n" + 
   "</td>\n" + 
   "</tr>\n" +
   "</table>\n";
    return toggle_dynamic_dialog_custom(rootEl, innerHTML);
}


// === Get/Hide/Show/Toggle ===

function ge()
{
  var ea;
  for( var i = 0; i < arguments.length; i++ ) {
    var e = arguments[i];
    if( typeof e == 'string' )
      e = document.getElementById(e);
    if( arguments.length == 1 )
      return e;
    if( !ea )
      ea = new Array();
    ea[ea.length] = e;
  }
  return ea;
}

function show()
{
  for( var i = 0; i < arguments.length; i++ ) {
    var element = ge(arguments[i]);
    if (element && element.style) element.style.display = '';
  }
  return false;
}

function hide()
{
  for( var i = 0; i < arguments.length; i++ ) {
    var element = ge(arguments[i]);
    if (element && element.style) element.style.display = 'none';
  }
  return false;
}

function shown(el) {
    el = ge(el);
    return (el.style.display != 'none');
}

function toggle()
{
  for( var i = 0; i < arguments.length; i++ ) {
    var element = ge(arguments[i]);
    element.style.display = (element.style.display == 'block') ? 'none' : 'block';
  }
  return false;
}

// === Event Info Access ===

function mouseX(event)
{
  return event.pageX || (event.clientX +
    (document.documentElement.scrollLeft || document.body.scrollLeft));
}

function mouseY(event)
{
  return event.pageY || (event.clientY +
    (document.documentElement.scrollTop || document.body.scrollTop));
}

function pageScrollX()
{
  return document.body.scrollLeft || document.documentElement.scrollLeft;
}

function pageScrollY()
{
  return document.body.scrollTop || document.documentElement.scrollTop;
}

function elementX(obj)
{
  var curleft = 0;
  if (obj.offsetParent) {
    while (obj.offsetParent) {
      curleft += obj.offsetLeft;
      obj = obj.offsetParent;
    }
  }
  else if (obj.x)
    curleft += obj.x;
  return curleft;
}

function elementY(obj)
{
  var curtop = 0;
  if(obj.offsetParent) {
    while (obj.offsetParent) {
      curtop += obj.offsetTop;
      obj = obj.offsetParent;
    }
  }
  else if (obj.y)
    curtop += obj.y;
  return curtop;
}

// === Onload Registry ===

var onloadRegistry = new Array();

function onloadRegister(handler)
{
  onloadRegistry.push(handler);
}

function onloadRun()
{
  for( var index in onloadRegistry )
    onloadRegistry[index]();
}

window.onload = onloadRun;

// === Placeholder Text ===

function placeholderSetup(id) {
	var el = ge(id);
	if(!el) return;
	if(el.type != 'text') return;
	if(el.type != 'text') return;
	
	var ph = el.getAttribute("placeholder");
	if( ph && ph != "" ) {
		el.value = ph;
		el.style.color = '#777';
		el.is_focused = 0;
		el.onfocus = placeholderFocus;
		el.onblur = placeholderBlur;
	}
}

function placeholderFocus() {
	if(!this.is_focused) {
		this.is_focused = 1;
    this.value = '';
    this.style.color = '#000';
  }
}

function placeholderBlur() {
  var ph = this.getAttribute("placeholder")
  if( this.is_focused && ph && this.value == "" ) {
		this.is_focused = 0;
    this.value = ph;
    this.style.color = '#777';
  }
}

// === Log Stub ===

function Log(){};
Log.prototype.show = function (){alert('log disabled')};
Log.prototype.error = function (){};
Log.prototype.warning = function (){};
Log.prototype.note = function (){};
Log.prototype.time = function (){};
log = new Log();

// === String Utilities ===

function escapeQuotes(word) {

  // jsesq is a key/acronym for javascript escaped single quote
  // jsdsq is a key/acronym for javascript escaped double quote

  escaped = word.replace(/'/g, ":jsesq:"); 
  escaped = escaped.replace(/"/g, ":jsedq:"); 
  escaped = escaped.replace(/\[/g, ":jselb:"); 
  escaped = escaped.replace(/\]/g, ":jserb:"); 

  return escaped;
}

function unescapeQuotes(word) {

  // jsesq is a key/acronym for javascript escaped single quote
  // jsdsq is a key/acronym for javascript escaped double quote

  escaped = word.replace(/:jsesq:/g, "'"); 
  escaped = escaped.replace(/:jsedq:/g, '"'); 
  escaped = escaped.replace(/:jselb:/g, '\['); 
  escaped = escaped.replace(/:jserb:/g, '\]'); 

  return escaped;
}

// === URI Handling ===

function escapeURI(u) {
    if(encodeURIComponent) {
        return encodeURIComponent(u);
    }
    if(escape) {
        return escape(u);
    }
}

function goURI(href) {
  window.location.href = href;
}

//13th parallel
function getViewportWidth() {
  var width = 0;
  if( document.documentElement && document.documentElement.clientWidth ) {
    width = document.documentElement.clientWidth;
  }
  else if( document.body && document.body.clientWidth ) {
    width = document.body.clientWidth;
  }
  else if( window.innerWidth ) {
    width = window.innerWidth - 18;
  }
  return width;
};

function getViewportHeight() {
  var height = 0;
  if( document.documentElement && document.documentElement.clientHeight ) {
    height = document.documentElement.clientHeight;
  }
  else if( document.body && document.body.clientHeight ) {
    height = document.body.clientHeight;
  }
  else if( window.innerHeight ) {
    height = window.innerHeight - 18;
  }
  return height;
};

// === Deprecated ===
// --- Delete checkAgree when user profile picture editing moves to picture widget

function checkAgree() {
  if (document.frm.pic.value) {
    if (document.frm.agree.checked) {
      document.frm.submit();
    } else {
      show("error");
    }
  }
}

function isIE() {
 return (navigator.userAgent.toLowerCase().indexOf("msie") != -1);
}   
    
function getTableRowShownDisplayProperty() {
  if (isIE()) {
    return  'inline';
  } else {
    return 'table-row';
  }
}
  
function showTableRow()
{ 
  for( var i = 0; i < arguments.length; i++ ) {
    var element = ge(arguments[i]);
    if (element && element.style) element.style.display =
        getTableRowShownDisplayProperty();
  }
  return false;
} 
  
function getParentRow(el) {
    el = ge(el);
    while (el.tagName && el.tagName != "TR") {
        el = el.parentNode;
    }
    return el;
} 


//-->
