

var da = (document.all) ? 1 : 0;
var pr = (window.print) ? 1 : 0;
var mac = (navigator.userAgent.indexOf("Mac") != -1); 
var dialogWindow;
var debugWindow;
var cselrow = null;
var cselrowNumber = null;

var isMozilla = !(document.all);
if(isMozilla){
	HTMLElement.prototype.__defineGetter__("innerText", function () {
	   var r = this.ownerDocument.createRange();
	   r.selectNodeContents(this);
	   return r.toString();
	});
	
	HTMLElement.prototype.__defineSetter__("innerText", function (sText) {
   this.innerHTML = sText.replace(/\&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
	});

}





fxBUTTON_ON = 0;
fxBUTTON_OFF = 1;

/* Browser Detection 'fxBrowser'
--------------------------------------- */
function fxBrowserDetect() {
	doc=window.document;
	navVersion=navigator.appVersion.toLowerCase();
	this.ie4=(!doc.getElementById&&doc.all)?true:false;
	this.ie5=(navVersion.indexOf("msie 5.0")!=-1)?true:false;
	this.ie55=(navVersion.indexOf("msie 5.5")!=-1)?true:false;
	this.ie6=(navVersion.indexOf("msie 6.0")!=-1)?true:false;
	this.ie7=(navVersion.indexOf("msie 7.0")!=-1)?true:false;
	this.isIE=(this.ie5||this.ie55||this.ie6||this.ie7)?true:false;
	this.isGecko=!this.isIE;
}
fxBrowser = new fxBrowserDetect();


function fxOpenApp(url){
			var features = "menubar=no,resizable=yes,scrollbars=no,status=yes;location=no"
			window.open(location,"mainWindow",features);
			window.close()
}


function fxButton(id, commandIdentifier, customAction, customStateQuery, htmlModeEnabled, customEnabled) {
	this.state = fxBUTTON_OFF;
	this.id = id;
	this.ftb = null;
	this.commandIdentifier = commandIdentifier;
	this.customAction = customAction;
	this.customStateQuery = customStateQuery;	
	
	this.disabled = false;
	this.htmlModeEnabled = htmlModeEnabled	;
	this.customEnabled = customEnabled;
	
	this.td = document.getElementById(id);
	this.td.button = this;
	
	if (fxBrowser.isIE) {		
		this.buttonImage = this.td.childNodes[0];
	} else {
		this.buttonImage = this.td.childNodes[1];
	}

	fxAddEvent(this.td,"click",function() { if(fxBrowser.isIE) document.getElementById(id).button.Click(); else this.button.Click(); } );
	fxAddEvent(this.td,"mouseover",function() { if(fxBrowser.isIE) document.getElementById(id).button.MouseOver(); else this.button.MouseOver(); } );
	fxAddEvent(this.td,"mouseout",function() { if(fxBrowser.isIE) document.getElementById(id).button.MouseOut(); else this.button.MouseOut(); } );
}


fxButton.prototype.Click = function() {
	if (!this.disabled) {
		
		if (this.customAction){ 			
			this.customAction();
		}	
		else if (this.commandIdentifier != null && this.commandIdentifier != '') 
			this.ftb.ExecuteCommand(this.commandIdentifier);

		//this.ftb.Event();
		
	}
}
fxButton.prototype.MouseOver = function() {
	if (!this.disabled) this.SetButtonBackground("Over");
}
fxButton.prototype.MouseOut = function() {
	if (!this.disabled) this.SetButtonBackground("Out");
}
fxButton.prototype.SetButtonBackground = function(mouseState) {
		this.SetButtonStyle(mouseState);
}
fxButton.prototype.SetButtonStyle = function(mouseState) {
	this.td.className =  "fxToolbar_Button_" + ((this.state == fxBUTTON_ON) ? "On" : "Off") + "_" + mouseState;
}


/*  Add events to objects
--------------------------------------- */
function fxAddEvents(obj, evTypes, fn) {
	for (i=0; i<evTypes.length; i++) fxAddEvent(obj, evTypes[i], fn);
}

function fxAddEvent(obj, evType, fn) {
/*alert('Adding ' + evType + ' Event to ' + obj.id);*/
	if (obj.addEventListener) {
		obj.addEventListener(evType, fn, true);
		return true;
	} else if (obj.attachEvent) {
		var r = obj.attachEvent('on'+evType, fn);
		return r;
	} else {
		return false;
	}
}


function writeWhosOn(sGateway,sDomain,sDepartment,sResponse,sChatstart,sBackground,sOnMouseOver,sOnMouseOut){
	var sSession;
	var sUrl;
	var dt=new Date();
	var sCookie=document.cookie.toString();
	
	if(sCookie.indexOf("whoson")==-1){
	    sSession=parseInt(Math.random()*1000)+"-"+dt.getTime();
	    document.cookie="whoson="+sSession+";expires=Fri, 31-Dec-2010 00:00:00 GMT;";}
	sCookie=document.cookie.toString();
	if(sCookie.indexOf('whoson')==-1){sSession="";}
	else{
	    var s=sCookie.indexOf("whoson=")+7;
	    var e=sCookie.indexOf(";",s);
	    if(e==-1)e=sCookie.length;
	    sSession=sCookie.substring(s,e);}
	sUrl=sGateway+"?u="+sSession+"&d="+sDomain;
	if(sDepartment.length>0)sUrl+="&t="+sDepartment;
	sUrl+="&p="+window.location+"&r="+escape(document.referrer);
	if(sResponse==""){
	    if(document.layers){document.write("<layer name=\"WhosOn\" visibility=hide><img src=\""+sUrl+"\" height=1 width=1></layer>");}
	    else{document.write("<div id=\"WhosOn\" STYLE=\"position:absolute;visibility:hidden;\"><img src=\""+sUrl+"\" height=1 width=1 /></div>");}}
	else {
	    sUrl+="&response=g";sChatstart+="?domain="+sDomain;
	    if(sDepartment.length>0)sChatstart+="&department="+sDepartment;
	    document.write("<a target=\"_blank\" href=\""+sChatstart+sBackground+"\" onclick=\"javascript:window.open('"+sChatstart+sBackground+"','new_win','width=484,height=361');return false;\" onmouseover=\""+sOnMouseOver+"\" onmouseout=\""+sOnMouseOut+"\"><img border=\"0\" src=\""+sUrl+"\" /></a>");}
}



function makeArray() {
    for (i = 0; i<makeArray.arguments.length; i++)
        this[i + 1] = makeArray.arguments[i];
}

function makeArray0() {
    for (i = 0; i<makeArray0.arguments.length; i++)
        this[i] = makeArray0.arguments[i];
}

function y2k(number) { return (number < 1000) ? number + 1900 : number; }

function writeDate() {
var months = new makeArray('January','February','March','April','May','June','July','August','September','October','November','December');
var days = new makeArray0('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
var today = new Date();
var day   = days[today.getDay()];
var date  = today.getDate();
var month = today.getMonth() + 1;
var year  = y2k(today.getYear());
document.write(day + ', ' + date + ' ' + months[month] + ' ' + year);
}


function FilterInterlock(name, value){
	var item = document.getElementById(name + value);
	var target = document.getElementById(name);
	var targetplaceholder = document.getElementById(name + '_placeholder');
	
	item.value = "" ;
	myString = new String(target.outerHTML)
	myString = myString.replace(target.innerHTML, "");
	mystring = myString.replace('><', '>' + item.innerHTML + '<');
	targetplaceholder.innerHTML = mystring;
}

function zzzFilterInterlock(name, value){
	
	var item = document.getElementById(name + value);
	var target = document.getElementById(name);
	var targetplaceholder = document.getElementById(name + '_placeholder');

	myString = new String(target.outerHTML)
	myString = myString.replace(target.innerHTML, "");
	mystring = myString.replace('><', '>' + item.innerHTML + '<');
	targetplaceholder.innerHTML = mystring;
	//for(var i=0; i<target.options.length; i++){
	//	target.options[i] = null;
	//}
	//if(item.options.length > 0){
	//	for(var i=0; i<item.options.length; i++){
	//		var sela = false;
	//		if(i==0){sela = true;}
	//		var option = new Option(item.options[i].text, item.options[i].value, false, sela);
	//		target.options[i] = option;
	//	}
	//}
}

function openDebug(path){
	var margin = 100;
	var height = 300;
	var width = screen.width - margin;
	var winl = (screen.width - width) / 2;
	var wint = (screen.height - height) / 2;
	var options = 'width=' + width + 'px,height=' + height + 'px,toolbar=no,location=no,scrollbars,left=' + winl + ',top=' + wint;
	try{debugWindow.close();}catch(e){}
	debugWindow = window.open(path + 'debug.html', 'debug', options);
}

function writeDebug(){
	try{debugWindow.debugdiv.innerHTML = window.debugdiv.innerHTML;}catch(e){}
}

function openDialog(path, mode, height, width){
	var winl = (screen.width - width) / 2;
	var wint = (screen.height - height) / 2;
	var options = 'width=' + width + 'px,height=' + height + 'px,toolbar=no,location=no,left=' + winl + ',top=' + wint;
	try{dialogWindow.close();}catch(e){}
	dialogWindow = window.open(path + 'siteadmin/dialog.aspx?mode=' + mode, 'dialog', options);
}

function openXopus(path,site,page,scheme,theme){
                var features = "menubar=no,resizable=yes,scrollbars=yes,status=yes,location=no"
                window.open(getXopusURL(path,site,page,scheme,theme) ,"mainWindow",features);
}

function getXopusURL(path,site,page,scheme,theme){
	return path + "utilities/xopus.aspx?site=" + site + "&page=" + page + "&scheme=" + scheme + "&theme=" + theme;
}

function openVisualEditor(path, mode){
	var margin = 100;
	var height = screen.height - margin;
	var width = screen.width - margin;
	var winl = (screen.width - width) / 2;
	var wint = ((screen.height - height) - 80) / 2;
	var options = 'width=' + width + 'px,height=' + height + 'px,toolbar=no,scrollbars,resizable,left=' + winl + ',top=' + wint;
	try{dialogWindow.close();}catch(e){}
	dialogWindow = window.open(path + '/siteadmin/dialog.aspx?mode=' + mode, 'dialog', options);
}


function FxWebselectRowChangeClass(row){
	for(var z=0; z<row.childNodes.length; z++){
		if(row.childNodes[z].className != undefined){
				row.childNodes[z].className = 'selected ' + row.childNodes[z].className;
		}
		//FxWebselectRowChangeClass(row.childNodes[z]);
	}
}

function FxWebselectRowChangeClassUnselect(row){
	for(var z=0; z<row.childNodes.length; z++){
		if(row.childNodes[z].className != undefined){
			if(row.childNodes[z].className.substring(0,9) == 'selected '){
				row.childNodes[z].className = row.childNodes[z].className.substring(9,99);
				//alert(row.childNodes[z].className);
			}
		}
		//FxWebselectRowChangeClassUnselect(row.childNodes[z]);
	}
}

function FxWebselectRow(row, db, position){
	if(cselrow != null){
		FxWebselectRowChangeClassUnselect(cselrow);
	}
	if(row != cselrow){
		FxWebselectRowChangeClass(row);
		var colList = eval(db + '_columnlist');
		var colArray = colList.split(',');
		for(var i=0; i<colArray.length-1; i++){
			var currentItem = document.getElementById(db + '.' + colArray[i]);
			var selectedItem = document.getElementById(db + '.' + colArray[i] + '.' + position + '.value');
			currentItem.innerText = GetChildValue(selectedItem);
			//alert(currentItem.innerText);
		}
		
		cselrow = row;
		cselrowNumber = position;
	}else{
		var colList = eval(db + '_columnlist');
		var colArray = colList.split(',');
		for(var i=0; i<colArray.length-1; i++){
			var currentItem = document.getElementById(db + '.' + colArray[i]);
			var selectedItem = document.getElementById(db + '.' + colArray[i] + '.' + position);
			currentItem.innerText = null;
		}
		cselrow = null;
	}
}

function GetChildValue(item){
	var value = "";
			if(item.alt != undefined){
				value = item.alt;
			}else{
				value = item.innerText;
			}
	return value;
}


function paste(){
	var rng = document.selection.createRange();
	rng.execCommand('Paste');
}
function copy(){
	var rng = document.selection.createRange();
	rng.execCommand('Copy');
}
function cut(){
	var rng = document.selection.createRange();
	rng.execCommand('Cut');
}
function GetFileOverHTTP(file, xmlhttp){
	xmlhttp.open("GET", file, true);
	xmlhttp.send(null);
}
function SendFileOverHTTP(file, xmlhttp, contents){
	xmlhttp.open("POST", file, false);
	xmlhttp.send(contents);
}

function printFrame(frame) {
	if (pr && da) { // IE5
		parent.frames[frame].focus();
		parent.frames[frame].print();
	}else if (pr){ // NS4
		parent.frames[frame].print();
	}else if (da && !mac){ // IE4 (Windows)
		parent.frames[frame].focus();
		parent.frames[frame].print();
	} else { // other browsers
		alert("Sorry, your browser doesn't support this feature.");
	}
}

function togglemenu(){
	try{
		var item = document.getElementById('editormenubody');
		var img = document.getElementById('editormenuimage');
		if(item.style.display == 'none'){
			item.style.display = '';
			img.src = img.path + "toggle_up.gif";
		}else{
			item.style.display = 'none';
			img.src = img.path + "toggle_down.gif";
		}
	}catch(e){}
}

function moveeditormenu() {
	try{
		if (document.layers) {
	       	document.layers['editormenu'].pageX = window.pageXOffset + 10;
	        document.layers['editormenu'].pageY = window.pageYOffset + 10;
	    }
	    else if (document.all) {
	        document.all['editormenu'].style.position = 'absolute';
	        
	        if(document.all['editormenu'].style.posLeft <= document.body.scrollLeft){
	        	document.all['editormenu'].style.posLeft = document.body.scrollLeft + 10;
	        }
	        if(document.all['editormenu'].style.posTop <= document.body.scrollTop){
	        	document.all['editormenu'].style.posTop = document.body.scrollTop + 10;
	        }
	
			if(document.all['editormenu'].style.posTop > document.body.clientHeight + document.body.scrollTop){
				document.all['editormenu'].style.posTop = document.body.scrollTop + 10
			}
			
			if(document.all['editormenu'].style.posLeft > document.body.clientWidth + document.body.scrollLeft){
				document.all['editormenu'].style.posLeft = document.body.scrollLeft + 10
			}
	    }
	}catch(e){}
    setTimeout('moveeditormenu()',100);
}

var popupwindow;
var popup_width = '650px';
var popup_height = '400px';

function Popup(target, height, width){
	try{popupwindow.close();
	}catch(e){}
	
	var pHeight = popup_height;
	var pWidth = popup_width;
	var winl = (screen.width - width) / 2;
	var wint = ((screen.height - height) - 80) / 2;
	
	if(height != ''){pHeight = height;}
	if(width != ''){pWidth = width;}
	
	var settings = "scroll=no,toolbar=no,resizable=yes,status=no,location=no,width=" + pWidth + ",height=" + pHeight + ",left=" + winl + ",top=" + wint;
	popupwindow = window.open(fxAppPath + "fxpopup.aspx?target=" + target , 'link', settings);
}

function SetPopupLocation(target){
	var a = null;
	while(a == null){
		try{
			a = popupwindow.document.getElementById('popup_body');
			a.src = appPath + target;
		}catch(e){}
	}
}
			
function CheckTab(el){
	if ((document.all) && (9==event.keyCode)) {
	    el.selection=document.selection.createRange(); 
	    setTimeout("ProcessTab('" + el.id + "')",0);
  	}
}

function ProcessTab(id) {
	document.all[id].selection.text=String.fromCharCode(9);
	document.all[id].focus();
}

function CheckForm(formitems){
	var req = true;	
	var fields = "";
	for(i=0; i<formitems.length; i++){
		var aa = document.getElementById(formitems[i]);
		if(aa.value == ''){
			req = false;
		}
	}
	if(!req){
		alert('All required must be completed.');
	}
	return req;
}


//Macromedia Javascript Functions
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



function colourband() {
sr=128;sg=0;sb=128;fr=255;fg=140;fb=255;s=50;m=255;
os='<table width="100%" cellpadding=0 cellspacing=0 border=0><tr>';
rd=Math.round((fr-sr)/s);gd=Math.round((fg-sg)/s);bd=Math.round((fb-sb)/s);for(i=0;i<s;i++){sr+=rd;sg+=gd;sb+=bd;if(sr>m)sr=m;if(sg>m)sg=m;if(sb>m)sb=m;os+='<td style="background:rgb('+sr+','+sg+','+sb+');" height=20>&nbsp;<\/td>';}
os+='<\/tr><\/table>';
document.write(os);
}

/* fxCurve */

function fxCurveCheck(){
if(!document.getElementById || !document.createElement)
    return(false);
var b=navigator.userAgent.toLowerCase();
if(b.indexOf("msie 5")>0 && b.indexOf("opera")==-1)
    return(false);
return(true);
}

function fxCurve(selector,bk,color,size){
var i;
var v=fxCurveGetElementsBySelector(selector);
var l=v.length;
for(i=0;i<l;i++){
    fxCurveAddTop(v[i],bk,color,size);
    fxCurveAddBottom(v[i],bk,color,size);
    }
}

function fxCurveTop(selector,bk,color,size){
var i;
var v=fxCurveGetElementsBySelector(selector);
for(i=0;i<v.length;i++)
    fxCurveAddTop(v[i],bk,color,size);
}

function fxCurveBottom(selector,bk,color,size){
var i;
var v=fxCurveGetElementsBySelector(selector);
for(i=0;i<v.length;i++)
    fxCurveAddBottom(v[i],bk,color,size);
}

function fxCurveAddTop(el,bk,color,size){
var i;
var d=document.createElement("b");
var cn="r";
var lim=4;
if(size && size=="small"){ cn="rs"; lim=2}
d.className="rtop";
d.style.backgroundColor=bk;
for(i=1;i<=lim;i++){
    var x=document.createElement("b");
    x.className=cn + i;
    x.style.backgroundColor=color;
    d.appendChild(x);
    }
el.insertBefore(d,el.firstChild);
}

function fxCurveAddBottom(el,bk,color,size){
var i;
var d=document.createElement("b");
var cn="r";
var lim=4;
if(size && size=="small"){ cn="rs"; lim=2}
d.className="rbottom";
d.style.backgroundColor=bk;
for(i=lim;i>0;i--){
    var x=document.createElement("b");
    x.className=cn + i;
    x.style.backgroundColor=color;
    d.appendChild(x);
    }
el.appendChild(d,el.firstChild);
}

function fxCurveGetElementsBySelector(selector){
var i;
var s=[];
var selid="";
var selclass="";
var tag=selector;
var objlist=[];
if(selector.indexOf(" ")>0){  //descendant selector like "tag#id tag"
    s=selector.split(" ");
    var fs=s[0].split("#");
    if(fs.length==1) return(objlist);
    return(document.getElementById(fs[1]).getElementsByTagName(s[1]));
    }
if(selector.indexOf("#")>0){ //id selector like "tag#id"
    s=selector.split("#");
    tag=s[0];
    selid=s[1];
    }
if(selid!=""){
    objlist.push(document.getElementById(selid));
    return(objlist);
    }
if(selector.indexOf(".")>0){  //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
    }
var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass=="")
    return(v);
for(i=0;i<v.length;i++){
    if(v[i].className==selclass){
        objlist.push(v[i]);
        }
    }
return(objlist);
}

function keespAlive(){
  var pUrl=document.getElementById("keepaliveiframe");
  pUrl.location = fxSystemUrl + 'keepalive.htm';
  setTimeout("keepAlive()",60000);
}


// Fade interval in milliseconds
// Make this larger if you experience performance issues
fxFade.INTERVAL_MILLIS = 50;

// Creates a fader
// element - The element to fade
// speed - The speed to fade at, from 0.0 to 100.0
// initialOpacity (optional, default 100) - element's starting opacity, 0 to 100
// minOpacity (optional, default 0) - element's minimum opacity, 0 to 100
// maxOpacity (optional, default 0) - element's minimum opacity, 0 to 100
function fxFade (element, rate, initialOpacity, minOpacity, maxOpacity) {
  this._element = element;
  this._intervalId = null;
  this._rate = rate;
  this._isFadeOut = true;

  // Set initial opacity and bounds
  // NB use 99 instead of 100 to avoid flicker at start of fade
  this._minOpacity = 0;
  this._maxOpacity = 99;
  this._opacity = 99;

  if (typeof minOpacity != 'undefined') {
    if (minOpacity < 0) {
      this._minOpacity = 0;
    } else if (minOpacity > 99) {
      this._minOpacity = 99;
    } else {
      this._minOpacity = minOpacity;
    }
  }

  if (typeof maxOpacity != 'undefined') {
    if (maxOpacity < 0) {
      this._maxOpacity = 0;
    } else if (maxOpacity > 99) {
      this._maxOpacity = 99;
    } else {
      this._maxOpacity = maxOpacity;
    }

    if (this._maxOpacity < this._minOpacity) {
      this._maxOpacity = this._minOpacity;
    }
  }
  
  if (typeof initialOpacity != 'undefined') {
    if (initialOpacity > this._maxOpacity) {
      this._opacity = this._maxOpacity;
    } else if (initialOpacity < this._minOpacity) {
      this._opacity = this._minOpacity;
    } else {
      this._opacity = initialOpacity;
    }
  }

  // See if we're using W3C opacity, MSIE filter, or just
  // toggling visiblity
  if(typeof element.style.opacity != 'undefined') {

    this._updateOpacity = this._updateOpacityW3c;

  } else if(typeof element.style.filter != 'undefined') {

    // If there's not an alpha filter on the element already,
    // add one
    if (element.style.filter.indexOf("alpha") == -1) {

      // Attempt to preserve existing filters
      var existingFilters="";
      if (element.style.filter) {
        existingFilters = element.style.filter+" ";
      }
      element.style.filter = existingFilters+"alpha(opacity="+this._opacity+")";
    }

    this._updateOpacity = this._updateOpacityMSIE;
    
  } else {

    this._updateOpacity = this._updateVisibility;
  }

  this._updateOpacity();
}

// Initiates a fade out
fxFade.prototype.fadeOut = function () {
  this._isFadeOut = true;
  this._beginFade();
}

// Initiates a fade in
fxFade.prototype.fadeIn = function () {
  this._isFadeOut = false;
  this._beginFade();
}

// Makes the element completely opaque, stops any fade in progress
fxFade.prototype.show = function () {
  this.haltFade();
  this._opacity = this._maxOpacity;
  this._updateOpacity();
}

// Makes the element completely transparent, stops any fade in progress
fxFade.prototype.hide = function () {
  this.haltFade();
  this._opacity = 0;
  this._updateOpacity();
}

// Halts any fade in progress
fxFade.prototype.haltFade = function () {

  clearInterval(this._intervalId);
}

// Resumes a fade where it was halted
fxFade.prototype.resumeFade = function () {

  this._beginFade();
}

// Pseudo-private members

fxFade.prototype._beginFade = function () {

  this.haltFade();
  var objref = this;
  this._intervalId = setInterval(function() { objref._tickFade(); },fxFade.INTERVAL_MILLIS);
}

fxFade.prototype._tickFade = function () {

  if (this._isFadeOut) {
    this._opacity -= this._rate;
    if (this._opacity < this._minOpacity) {
      this._opacity = this._minOpacity;
      this.haltFade();
    }
  } else {
    this._opacity += this._rate;
    if (this._opacity > this._maxOpacity ) {
      this._opacity = this._maxOpacity;
      this.haltFade();
    }
  }

  this._updateOpacity();
}

fxFade.prototype._updateVisibility = function () {
  
  if (this._opacity > 0) {
    this._element.style.visibility = 'visible';
  } else {
    this._element.style.visibility = 'hidden';
  }
}

fxFade.prototype._updateOpacityW3c = function () {
  
  this._element.style.opacity = this._opacity/100;
  this._updateVisibility();
}

fxFade.prototype._updateOpacityMSIE = function () {
  
  this._element.filters.alpha.opacity = this._opacity;
  this._updateVisibility();
}

fxFade.prototype._updateOpacity = null;



function fxFormSubmit(formname) {
	
	if(document.getElementById(formname).onsubmit()) {
		//this check triggers the validations
    document.getElementById(formname).submit();
	}
}


// Column Help
function showColumnHelp(sourceId, mode) {
	var sourceobj = document.getElementById(sourceId);
	
	
	if (mode == 'popup') {
		var screenWidthCenter = self.screen.width / 2;
		var screenHeightCenter = self.screen.height / 2;
		var helpwindowLeft = screenWidthCenter - 200;
		var helpwindowTop = screenHeightCenter - 200;
	
		helpWindow = null;
		helpwindow = window.open('', 'Help', 'scrollbars=no,toolbar=no,status=no,location=no,modal=yes,titlebar=no,resizable=no,width=400px,height=400px,left=' + helpwindowLeft + 'px,top=' + helpwindowTop);
		helpwindow.document.write('<html><head><title>Help</title><link href="' + fxThemeUrl + 'fxForms.css" rel="stylesheet" type="text/css" /></head><body class="columnhelppopup"><div id="columnhelppopup"><div class="columnhelptitle">Help</div><div class="columnhelpbody">' + sourceobj.innerHTML + '</div><div class="columnhelpclose"><input type="button" onClick="javascript:window.close();" value="Close Window" /></div></div></body></html>');
	}
	
	if (mode == 'slide') {
		var helpobj = document.getElementById("columnhelpslide");
		var sourceobj = document.getElementById(sourceId);
		var windowCenter = document.body.clientWidth / 2;
		var helpobjLeft = windowCenter - 200;
	
		helpobj.innerHTML = '<div class="columnhelptitle">Help</div><div class="columnhelpbody">' + sourceobj.innerHTML + '</div><div class="columnhelpclose"><input type="button" onClick="javascript:hideColumnHelp(' + "'" + 'slide' + "'" + ');" value="Close Window" /></div>';
	
		helpobj.style.width = 400;
		helpobj.style.Height = 400;

		helpobj.style.left = helpobjLeft;
		currentColumnHelpTop = -450;
	
		helpobj.style.display = '';
	
		scrollDownColumnHelp(100);
	}
	
	if (mode == 'tooltip') {
		
	}
}

function hideColumnHelp(mode) {
	if (mode == 'popup') {
		helpwindow.document.close;
	}

	if (mode == 'slide') {
		var helpobj = document.getElementById("columnhelp");
		currentColumnHelpTop = 100;
		scrollUpColumnHelp(-450);
	}
}

function scrollDownColumnHelp(loc) {
	var helpobj = document.getElementById("columnhelp");

	if (currentColumnHelpTop != loc) {
		currentColumnHelpTop = currentColumnHelpTop + 50;
		helpobj.style.top = currentColumnHelpTop;
		setTimeout("scrollDownColumnHelp(" + loc + ");",1);
	}
}

function scrollUpColumnHelp(loc) {
	var helpobj = document.getElementById("columnhelp");

	if (currentColumnHelpTop != loc) {
		currentColumnHelpTop = currentColumnHelpTop - 50;
		helpobj.style.top = currentColumnHelpTop;
		setTimeout("scrollUpColumnHelp(" + loc + ");",1);
	}
}

/* fxModal */
function fxModalShow(loc)
{
	document.getElementById("fxmodalinner").innerHTML = '<iframe src="' + loc + '" id="fxmodaliframe"></iframe><div id="fxmodalfooter"><input type="button" value="Cancel" onclick="fxModalCancel();" /></div>';
	document.getElementById("fxmodalmask").style.display = '';
	document.getElementById("fxmodalouter").style.display = '';
}

function fxModalCancel()
{
	document.getElementById("fxmodalmask").style.display = 'none';
	document.getElementById("fxmodalouter").style.display = 'none';
}



function isElementChanged(oElement) 
{
	switch (oElement.type.toLowerCase()) { 
	case 'text':
	case 'textarea':
	case 'password':
	if (oElement.value != oElement.defaultValue) {
		return true;
	}
	break;
	
	case 'radio':
	case 'checkbox':
	if (oElement.checked != oElement.defaultChecked) {
		return true;
	}
	break;
	
	case 'select-one': 
	case 'select-multiple':
	var i;
	var bDefaultValueSpecified = false;
	
	for (i = 0; i < oElement.options.length; i++) {
		if (oElement.options[i].defaultSelected) {
			bDefaultValueSpecified = true;
			i = oElement.options.length;
		}
	}
	
	for (i = 0; i < oElement.options.length; i++) {
		if (bDefaultValueSpecified) {
			if (oElement.options[i].selected != oElement.options[i].defaultSelected) {
				return true;
			}
		}
	
		else if (oElement.options[i].selected && i != 0) {
			return true;
		}
	}
	break;
	}
	
	// If we make it here, the oElement has not changed, so return false
	return false;
}

function isFormChanged(formname) 
{
	var rtnVal = false; 
	var frm = document.forms[formname];
	var ele = frm.elements;
	//alert(ele.length);

	for ( i=0; i < ele.length; i++ ) {
	//alert(i + ':' + ele[i].id + ':' + ele[i].type);
		if ( ele[i].type.length > 0 ) {
			if ( isElementChanged( ele, i ) ) {
				rtnVal = true;
				break;
			}
		}
	}
	return rtnVal;
}



function getSelectedValues(selObj){
	
	var selectedArray = new Array();
	
	var arrayIdx = 0	
	for (i=0; i<selObj.options.length; i++) {
	if (selObj.options[i].selected) {
	selectedArray[arrayIdx] = selObj.options[i].value;
	arrayIdx++;
	}
	}
	return selectedArray;	
	
}
	
function launchMailTo(){
	
	var strTo = document.getElementById('sendmail.sendTo').value;
	
	var strCC = document.getElementById('sendmail.sendCC').value;
	var strSubject = document.getElementById('sendmail.sendsubject').value;

	
	strUrl = 'mailto:' + strTo + '?cc=' + strCC + '&Subject=' + strSubject;
	alert(strUrl);
	window.location = strUrl
}
				
function ajaxList(fxsite,fxservice,fxid,generatedid,id)
{
	if (event.keyCode == 40) {
		document.getElementById('select' + generatedid).focus();
		document.getElementById('select' + generatedid).selectedIndex = 0;
		ajaxListSelect(generatedid,id);
	} else {
	var searchstring = document.getElementById('input' + generatedid).value;
	document.getElementById('div' + generatedid).style.display = '';
	var sUrl = fxBase + fxSiteUrl + "DataService" + fxExtension + "?fxsite=" + fxsite + "&fxservice=" + fxservice + "&fxid=" + fxid + "&searchstring=" + searchstring;
	var sEncodedUrl = encodeURI(sUrl);
	var oXmlHttp = fxXmlHttp.createRequest();
  oXmlHttp.open("get", sEncodedUrl, true);
  oXmlHttp.onreadystatechange = function () {
      if (oXmlHttp.readyState == 4) {
          if (oXmlHttp.status == 200) {
              var oXmlDom = fxXmlDom.createDocument();
					    oXmlDom.async = false;
					    oXmlDom.setProperty("SelectionLanguage", "XPath");  //GB - Ensures MSXML3 users XPATH and not XSLPatterns 
					    oXmlDom.loadXML(oXmlHttp.responseText);
	
					  	oXslDom = fxXmlDom.createDocument();
					    oXslDom.async = false;
					    oXslDom.load(fxSystemUrl + "ajax.xslt");
					    
					    var str = zXslt.transformToText(oXmlDom,oXslDom);

						var selectobj = document.getElementById('select' + generatedid);
						selectobj.innerHTML = '';
						var sTempTag = selectobj.outerHTML.substring(0,selectobj.outerHTML.length - 9);
						selectobj.outerHTML = sTempTag + str + '</select>';
          } else {
              alert("An error occurred: " + oXmlHttp.statusText); //statusText is not always accurate
          }
      } 
  }
  oXmlHttp.send(null);
  }
}

function ajaxListInputKeydown(generatedid,id)
{
	if (event.keyCode == 09) {
		document.getElementById('select' + generatedid).selectedIndex = 0;
		ajaxListSelect(generatedid,id);
	}
}

function ajaxListSelectKeydown(generatedid,id)
{
	if ((event.keyCode == 09) || (event.keyCode == 13)) {
		ajaxListSelect(generatedid,id);
		document.getElementById('div' + generatedid).style.display = 'none';
	}
}

function ajaxListSelectKeyup(generatedid,id)
{
	if (event.keyCode == 13) {
		document.getElementById('input' + generatedid).focus();
		//document.getElementById('div' + generatedid).style.display = 'none';
	}
}

function ajaxListSelectClick(generatedid,id)
{
	ajaxListSelect(generatedid,id);
	document.getElementById('div' + generatedid).style.display = 'none';
}

function ajaxListSelect(generatedid,id)
{
	selectobj = document.getElementById('select' + generatedid);
	inputobj = document.getElementById('input' + generatedid);
	resolvedobj = document.getElementById(id);

	resolvedobj.value = selectobj.options[selectobj.selectedIndex].value;
	inputobj.value = selectobj.options[selectobj.selectedIndex].text;
}

var fxXml /*:Object*/ = {
    useActiveX: (typeof ActiveXObject != "undefined"),
    useDom: document.implementation && document.implementation.createDocument,
    useXmlHttp: (typeof XMLHttpRequest != "undefined")
};


/*
fxXml.ARR_XMLHTTP_VERS  = ["MSXML2.XmlHttp.6.0","MSXML2.XmlHttp.3.0"];
fxXml.ARR_DOM_VERS  = ["MSXML2.DOMDocument.6.0","MSXML2.DOMDocument.3.0"];
*/


fxXml.ARR_XMLHTTP_VERS  = ["MSXML2.XmlHttp.3.0"];
fxXml.ARR_DOM_VERS = ["MSXML2.DOMDocument.3.0"];

/**
 * Static class for handling XMLHttp creation.
 * @class
 */                     
function fxXmlHttp() {
}



/**
 * Creates an XMLHttp object.
 * @return An XMLHttp object.
 */
fxXmlHttp.createRequest = function ()/*:XMLHttp*/ {

    //if it natively supports XMLHttpRequest object
//    if (fxXml.useXmlHttp) {
//        return new XMLHttpRequest();
//    } else if (fxXml.useActiveX) { //IE < 7.0 = use ActiveX
  
        if (!fxXml.XMLHTTP_VER) {
            for (var i=0; i < fxXml.ARR_XMLHTTP_VERS.length; i++) {
                try {
                    new ActiveXObject(fxXml.ARR_XMLHTTP_VERS[i]);
                    fxXml.XMLHTTP_VER = fxXml.ARR_XMLHTTP_VERS[i];
                    break;
                } catch (oError) {                
                }
            }
        }
        
        if (fxXml.XMLHTTP_VER) {
            return new ActiveXObject(fxXml.XMLHTTP_VER);
        } else {
            throw new Error("Could not create XML HTTP Request.");
        }
//    } else {
//        throw new Error("Your browser doesn't support an XML HTTP Request.");
//    }

};

/**
 * Static class for handling XML DOM creation.
 * @class
 */
function fxXmlDom() {

}

/**
 * Creates an XML DOM document.
 * @return An XML DOM document.
 */
fxXmlDom.createDocument = function () /*:XMLDocument*/{

    if (fxXml.useDom) {

        var oXmlDom = document.implementation.createDocument("","",null);

        oXmlDom.parseError = {
            valueOf: function () { return this.errorCode; },
            toString: function () { return this.errorCode.toString() }
        };
        
        oXmlDom.__initError__();
                
        oXmlDom.addEventListener("load", function () {
            this.__checkForErrors__();
            this.__changeReadyState__(4);
        }, false);

        return oXmlDom;        
        
    } else if (fxXml.useActiveX) {
        if (!fxXml.DOM_VER) {
            for (var i=0; i < fxXml.ARR_DOM_VERS.length; i++) {
                try {
                    new ActiveXObject(fxXml.ARR_DOM_VERS[i]);
                    fxXml.DOM_VER = fxXml.ARR_DOM_VERS[i];
                    break;
                } catch (oError) {                
                }
            }
        }
        
        if (fxXml.DOM_VER) {
            return new ActiveXObject(fxXml.DOM_VER);
        } else {
            throw new Error("Could not create XML DOM document.");
        }
    } else {
        throw new Error("Your browser doesn't support an XML DOM document.");
    }

};

/**
 * Indicates if an XML DOM is available.
 * @return True if XML DOM is available, false if not.
 */
fxXmlDom.isSupported = function ()/*:Boolean*/ {
    return fxXml.useDom || fxXml.useActiveX;
};

//Code to make Mozilla DOM documents act more like MS DOM documents.
var oMozDocument = null;
if (typeof XMLDocument != "undefined") {
    oMozDocument = XMLDocument;
} else if (typeof Document != "undefined") {
    oMozDocument = Document;
}

if (oMozDocument && !window.opera) {

    oMozDocument.prototype.readyState = 0;
    oMozDocument.prototype.onreadystatechange = null;

    oMozDocument.prototype.__changeReadyState__ = function (iReadyState) {
        this.readyState = iReadyState;

        if (typeof this.onreadystatechange == "function") {
            this.onreadystatechange();
        }
    };

    oMozDocument.prototype.__initError__ = function () {
        this.parseError.errorCode = 0;
        this.parseError.filepos = -1;
        this.parseError.line = -1;
        this.parseError.linepos = -1;
        this.parseError.reason = null;
        this.parseError.srcText = null;
        this.parseError.url = null;
    };
    
    oMozDocument.prototype.__checkForErrors__ = function () {

        if (this.documentElement.tagName == "parsererror") {

            var reError = />([\s\S]*?)Location:([\s\S]*?)Line Number (\d+), Column (\d+):<sourcetext>([\s\S]*?)(?:\-*\^)/;

            reError.test(this.xml);
            
            this.parseError.errorCode = -999999;
            this.parseError.reason = RegExp.$1;
            this.parseError.url = RegExp.$2;
            this.parseError.line = parseInt(RegExp.$3);
            this.parseError.linepos = parseInt(RegExp.$4);
            this.parseError.srcText = RegExp.$5;
        }
    };
            
    oMozDocument.prototype.loadXML = function (sXml) {
    
        this.__initError__();
    
        this.__changeReadyState__(1);
    
        var oParser = new DOMParser();
        var oXmlDom = oParser.parseFromString(sXml, "text/xml");
 
        while (this.firstChild) {
            this.removeChild(this.firstChild);
        }

        for (var i=0; i < oXmlDom.childNodes.length; i++) {
            var oNewNode = this.importNode(oXmlDom.childNodes[i], true);
            this.appendChild(oNewNode);
        }
        
        this.__checkForErrors__();
        
        this.__changeReadyState__(4);

    };
    
    oMozDocument.prototype.__load__ = oMozDocument.prototype.load;

    oMozDocument.prototype.load = function (sURL) {
        this.__initError__();
        this.__changeReadyState__(1);
        this.__load__(sURL);
    };
    
    Node.prototype.__defineGetter__("xml", function () {
        var oSerializer = new XMLSerializer();
        return oSerializer.serializeToString(this, "text/xml");
    });

    Node.prototype.__defineGetter__("text", function () {
        var sText = "";
        for (var i = 0; i < this.childNodes.length; i++) {
            if (this.childNodes[i].hasChildNodes()) {
                sText += this.childNodes[i].text;
            } else {
                sText += this.childNodes[i].nodeValue;
            }
        }
        return sText;

    });

}


/**
 * Static class for handling XSLT transformations.
 * @class
 */
function zXslt() {
}

/**
 * Transforms an XML DOM to text using an XSLT DOM.
 * @param oXml The XML DOM to transform.
 * @param oXslt The XSLT DOM to use for the transformation.
 * @return The transformed version of the string.
 */
zXslt.transformToText = function (oXml /*:XMLDocument*/, oXslt /*:XMLDocument*/)/*:String*/ {
    if (typeof XSLTProcessor != "undefined") {
        var oProcessor = new XSLTProcessor();
        oProcessor.importStylesheet(oXslt);
    
        var oResultDom = oProcessor.transformToDocument(oXml);
        var sResult = oResultDom.xml;
    
        if (sResult.indexOf("<transformiix:result") > -1) {
            sResult = sResult.substring(sResult.indexOf(">") + 1, 
                                        sResult.lastIndexOf("<"));
        }
    
        return sResult;     
    } else if (fxXml.useActiveX) {
        return oXml.transformNode(oXslt);
    } else {
        throw new Error("No XSLT engine found.");
    }
}

function setInitialFontSize()
{
  document.body.style.fontSize = readCookie("fontsize");
}

function setFontSize(size)
{
	eraseCookie("fontsize");
  createCookie("fontsize",size,365);
  document.body.style.fontSize = size;
}

function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	document.cookie = name+"=;expires=Thu, 01-Jan-1970 00:00:01 GMT;";
}


function fxformatnumericinput(input){
var num = input.value.replace(/\,/g,'');
   if(!isNaN(num)){
     if(num.indexOf('.') > -1){ 
        num = num.split('.');
        num[0] = num[0].toString().split('').reverse().join('').replace(/(?=\d*\.?)(\d{3})/g,'$1,').split('').reverse().join('').replace(/^[\,]/,'');
       if(num[1].length > 2){ 
          alert('You may only enter two decimals!');
          num[1] = num[1].substring(0,num[1].length-1);
       }  input.value = num[0]+'.'+num[1];        
     } else{ input.value = num.toString().split('').reverse().join('').replace(/(?=\d*\.?)(\d{3})/g,'$1,').split('').reverse().join('').replace(/^[\,]/,'') };
   }
   else{ alert('You may enter only numbers in this field!');
         input.value = input.value.substring(0,input.value.length-1);
   }
 }
 
