var prefsLoaded = false;
var currentFontSize = 12;
var currentFontType = 1;
var currentStyle = "White";
var currentWidth = 990;
function revertStyles(){
	currentFontType = 1;
	setFontFace(1);
	
	currentFontSize = 12;
	changeFontSize(0);
	
	currentStyle = "White";
	setColor("White");
	
	currentWidth = 990;
	setWidth(990);
}
/**
 * DHTML textbox character counter (IE4+) script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function taLimit() {
	var taObj=event.srcElement;
	if (taObj.value.length==taObj.maxLength*1) return false;
}

function taCount(visCnt) { 
	var taObj=event.srcElement;
	if (taObj.value.length>taObj.maxLength*1) taObj.value=taObj.value.substring(0,taObj.maxLength*1);
	if (visCnt) visCnt.innerText=taObj.maxLength-taObj.value.length;
}

function textCounter(field, maxlimit) {
	if (field.value.length > maxlimit) {
		field.value = field.value.substring(0, maxlimit);
		alert("This field cannot contain more than " + maxlimit + " characters");
	}
}
function hideShow(div,icon,swaptext,title)
{ 
	if(document.getElementById(div).style.display == 'none')
	{ 
		document.getElementById(div).style.display = '';
		document.images[icon].src = '/_resources/images/xtree/hide.gif';
		document.getElementById(swaptext).innerText = 'Hide ' + title;	
	}
	else
	{
		document.getElementById(div).style.display = 'none';
		document.images[icon].src = '/_resources/images/xtree/show.gif';
		document.getElementById(swaptext).innerText = 'Show ' + title;	
	}
}  
function saveSettings()
{
  createCookie("fontSize", currentFontSize, 365);
  createCookie("fontFace", currentFontType, 365);
  createCookie("pageWidth", currentWidth, 365);
  createCookie("pageColor", currentStyle, 365);
}

function popupImage(url, x, y, scroll)
{
  ua   = window.navigator.userAgent;
  ns   = (document.layers) ? 1 : 0;
  mz   = (ua.indexOf("zilla") >= 0) ? 1 : 0;
  pcie = (ua.indexOf( "MSIE " ) >= 0 && ua.indexOf("Win") >= 0) ? 1 : 0;

  // Grrr...
  if(ns || pcie || mz) { x += 15; y += 15; }
  if(mz) { x += 10; y += 10; } 

  noise = Math.round((Math.random() * 10000) + 1);

  pictureWindow = open(url, "pictureWindow" + noise, "width=" + x + ",height=" + y + ",scrollbars=" + ((scroll) ? "yes" : "no") + ",status=no,toolbar=no,resizable=yes");

  return false;
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}
function changeImages() {
var preloadFlag = false;
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}
function clickclear(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
		thisfield.value = "";
	}
}
function clickrecall(thisfield, defaulttext) {
	if (thisfield.value == "") {
		thisfield.value = defaulttext;
	}
}
function trim(str)
{
  return str.replace(/^\s+|\s+$/g, '')
};
 
function cancel() {
	 history.go(-1);
}
function gohere(gotoURL) {
	 window.location = gotoURL;	
}
function hov(loc,cls){
   if(loc.className)
      loc.className=cls;
}
 

