// JavaScript Functions

// Function to open links in new window
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
window.onload = externalLinks;

// Function to bust frames
<!--
if (window!= top)
top.location.href=location.href
// -->

<!-- //reloads the window if Nav4 resized
function MM_reloadPage(init) {  
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->

// Functions for toggle layer
function toggleBox(szDivID) {
  if (document.layers) { // NN4+
    if (document.layers[szDivID].visibility == 'visible') {
      document.layers[szDivID].visibility = "hide";
      document.layers[szDivID].display = "none";
    } else {
      document.layers[szDivID].visibility = "show";
      document.layers[szDivID].display = "inline";
    }
  } else if (document.getElementById) { // gecko(NN6) + IE 5+
    var obj = document.getElementById(szDivID);

    if (obj.style.visibility == 'visible') {
      obj.style.visibility = "hidden";
      obj.style.display = "none";
    } else {
      obj.style.visibility = "visible";
      obj.style.display = "inline";
    }
  } else if (document.all) { // IE 4
    if (document.all[szDivID].style.visibility == 'visible') {
      document.all[szDivID].style.visibility = "hidden";
      document.all[szDivID].style.display = "none";
    } else {
      document.all[szDivID].style.visibility = "visible";
      document.all[szDivID].style.display = "inline";
    }
  }
}


function maximizeWin() {
  if (window.screen) {
    var aw = screen.availWidth;
    var ah = screen.availHeight;
    //window.moveTo(0, 0);
    window.resizeTo(aw, ah);
  }
}

window.onload = maximizeWin();
//window.resizeTo(screen.availWidth,screen.availHeight);

// Hide Javascript Errors
function hideerrors() {
return true;}
window.onerror = hideerrors;

// Functions for Admin Menu
function showit(which){
	clear_delayhide()
	thecontent=(which==-1)? "" : submenu[which]
	if (document.getElementById||document.all)
		menuobj.innerHTML=thecontent
	else if (document.layers){
	menuobj.document.write(thecontent)
	menuobj.document.close()
	}
}

function resetit(e){
	if (document.all&&!menuobj.contains(e.toElement))
		delayhide=setTimeout("showit(-1)",delay_hide)
	else if (document.getElementById&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
	delayhide=setTimeout("showit(-1)",delay_hide)
}

function clear_delayhide(){
	if (window.delayhide)
	clearTimeout(delayhide)
}

function contains_ns6(a, b) {
	while (b.parentNode)
	if ((b = b.parentNode) == a)
	return true;
	return false;
}

function Get(id)
{
	return document.getElementById(id);
}

function SetHelpContent(divName, content, ObjPos)
{
	var smilieBox = document.getElementById('emoticons')
	smilieBox.style.display = "none"
	
	div = Get(divName)
	divContent = Get(divName+"_Content")
	
	var t=0;
	var l=0;
	var dt=0;
	var dl=0;
	var dNode = null;
	
	if(div)
	{
		div.className = "visible";
		
		if(divContent)
		{
			divContent.innerHTML = content;
		}
	}
}

function SetLoginPrompt(divName, content, ObjPos)
{
	
	div = Get(divName)
	divContent = Get(divName+"_Content")
	
	var t=0;
	var l=0;
	var dt=0;
	var dl=0;
	var dNode = null;
	
	if(div)
	{
		div.className = "visible";
		
		if(divContent)
		{
			divContent.innerHTML = content;
		}
	}
}

// Function to limit guestbook message to 200 characters
<!--
function getObject(obj) {
  var theObj;
  if(document.all) {
    if(typeof obj=="string") {
      return document.all(obj);
    } else {
      return obj.style;
    }
  }
  if(document.getElementById) {
    if(typeof obj=="string") {
      return document.getElementById(obj);
    } else {
      return obj.style;
    }
  }
  return null;
}

// Function to count characters in message
function CountMessage(field,divMsg,displayTxt,numChars) {
  var fieldObj = getObject(field);
  var divMsgObj = getObject(divMsg);
  var objLength = numChars - fieldObj.value.length;
  if(objLength <= 0) {
    objLength = 0;
    displayTxt = displayTxt;
    fieldObj.value = fieldObj.value.substr(0,numChars);
  }
  divMsgObj.innerHTML = displayTxt.replace("{CHAR}",objLength);
}
//-->

//Function to add the code to the message for the smileys
function AddSmileyIcon(iconCode) {	
	var messageBox = document.getElementById('txtMessage');
	messageBox.value = messageBox.value += iconCode + " ";
	messageBox.focus;
}


/* Togles Hidden Boxs */
function toggleSmilies(objDiv) {
	var objBox = document.getElementById(objDiv);

	if (objBox.style.display == "none")
		objBox.style.display = "";
	else
		objBox.style.display = "none";
}

