String.prototype.toTitleCase = function() {
var words = this.toLowerCase().split(" ");
for(var i=0;i<words.length;i++)
words[i] = words[i].charAt(0).toUpperCase() + words[i].substring(1);
return words.join(" ");
}

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function getInnerText(node,ignorewhitespace)
{
 var text = "";
 // if the node has children, loop through them
 if(node.hasChildNodes())
 {
  var children = node.childNodes;
  for(var i=0; i<children.length; i++)
  {
   // if node is a text node append it
   if(children[i].nodeName == "#text")
   {
    if(ignorewhitespace)
    {
     if(!/^\s+$/.test(children[i].nodeValue))
     {
      text = text.concat(children[i].nodeValue);
     }
    }
    else
    {
     text = text.concat(children[i].nodeValue);
    }
   }
   // if node is a line break append \n
   else if(children[i].nodeName == "BR")
   {
    text = text.concat("\n");
   }
   // otherwise call this function again to get the text
   else
   {
    text = text.concat(getInnerText(children[i]));
   }
  }
 }
 // it has no children, so get the text
 else
 {
  // if node is a text node append it
  if(node.nodeName == "#text")
  {
   text = text.concat(node.nodeValue);
  }
  // if node is a line break append \n
  else if(node.nodeName == "BR")
  {
   text = text.concat("\n");
  }
 }
 return text;
}

function popupWindow(whatURL) {
	poppedWindow=window.open(whatURL,"poppedWindow","toolbar=no,width=440,height=300,directories=no,status=no,scrollbars=yes,resize=no,menubar=no");
}

function popupMapWindow(whatURL) {
	poppedMapWindow=window.open(whatURL,"poppedMapWindow","toolbar=no,width=500,height=300,directories=no,status=no,scrollbars=yes,resize=no,menubar=no");
}

// Disable submit when clicked.
function disableSubmit(buttonName,formName) {
	var whichForm=eval('document.' + formName);
	var whichButton=eval('document.' + formName + '.' + buttonName);
	whichButton.disabled=true;
	whichButton.className='greybutton';
	whichForm.submit();
}

// Generic rollover functions

function overImage(imgName) {
	if (document.images) {
		imgOn = eval(imgName + "on.src");
		document [imgName].src = imgOn;	
	}
}

function offImage(imgName) {
	if (document.images) {
		imgOff = eval(imgName + "off.src");
		document [imgName].src = imgOff;	
	}
}

function loadImages() {
	hb=new Image();
	hb.src="/images/home-background.gif";
	hp=new Image();
	hp.src="/images/home-photo.gif";
	hy=new Image();
	hy.src="/images/home-box.gif";
	hs=new Image();
	hs.src="/images/ssia.gif";
	whaton = new Image();
	whaton.src = "/images/what1.gif";
	whatoff = new Image();
	whatoff.src = "/images/what0.gif";
	whyon = new Image();
	whyon.src = "/images/why1.gif";
	whyoff = new Image();
	whyoff.src = "/images/why0.gif";
	whoon = new Image();
	whoon.src = "/images/who1.gif";
	whooff = new Image();
	whooff.src = "/images/who0.gif";
	actionon = new Image();
	actionon.src = "/images/action1.gif";
	actionoff = new Image();
	actionoff.src = "/images/action0.gif";
	abouton = new Image();
	abouton.src = "/images/about1.gif";
	aboutoff = new Image();
	aboutoff.src = "/images/about0.gif";
	contacton = new Image();
	contacton.src = "/images/contact1.gif";
	contactoff = new Image();
	contactoff.src = "/images/contact0.gif";
	/*
	on = new Image();
	on.src = "/images/1.gif";
	off = new Image();
	off.src = "/images/0.gif";
	*/
}


if (document.images) {
	loadImages();
}

// Returns a handle to the named layer.

function getLayer(name) {

	if (document.layers) {
		return(document.layers[name]);
	}
	else {
		layer = document.getElementById(name);
		if (layer) {
			return(layer);
		} else {
			return(null);
		}
	}
}

// Hides the named layer

function hideLayer(name) {

	var layer = getLayer(name);

	if (layer.style) {
		layer.style.visibility="hidden";	
	} else {
		layer.visibility="hide";
	}

}

// Shows the named layer

function showLayer(name) {

	var layer = getLayer(name);

	if (layer.style) {
		layer.style.visibility="visible";	
	} else {
		layer.visibility="show";
	}

}

