
if(typeof Object.create !== 'function'){ //work around for creating objects laymbda
	Object.create = function(o){
		function F(){}
		F.prototype = o;
		return new F();
	}
}


lgfl ={}; //filter namespace

lgfl.loadObject = null; //default is running on all DOM content
lgfl.ajax = (window.XMLHttpRequest || window.ActiveXObject)? true:false;
lgfl.init = function(){
	
}

lgfl.getClass = function(object) { //see http://juhukinners.com/tag/instanceof/ - better way to detecting type of value
    return Object.prototype.toString.call(object).slice(8, -1);
}

lgfl.$ = function() { //same principle as the prototype function as a shortcut to finding the elemnet on the page.  
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}


/**
*   Add an event listener to an object
*   @param      object
*   @param      evt  / event
*   @param      func            function
*   @param      capture
*   @return     boolean
*/

lgfl.addEvent = function(object, evt, func, capture){
	if(typeof func != 'function'){
		return false;
	}
	if(object.addEventListener){
		object.addEventListener(evt, func, capture);
		return true;
	}else if(object.attachEvent){
		object.attachEvent('on'+evt, func);
		return true;
	}
	return false;
}

/**
*   Find all elements by class name
*   @param      c = class name
*   @param      p = parent element (optional)
*   @param      t = tag name (optional)
*   @param      f = Callback function
*   @return     boolean
*/
lgfl.getElementsByClassName = function(c,p,t,f){
  var found = new Array();
  var re = new RegExp('\\b'+c+'\\b', 'i');
  var p = p || document;
  var list = lgfl.getElementsByTagName(t,p);
  if(list.length==0) list[0] = p; //not matches so maybe it's the parent element itself
  
  for (var i = 0; i < list.length; ++i) {
    if (list[i].className && list[i].className.search(re) != -1) {
      found[found.length] = list[i];
      if (f) f(list[i]);
    }
  }
  return found;
}

// rework of xGetElementsByTagName, Copyright 2001-2005 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL
lgfl.getElementsByTagName = function(t,p){
  if(typeof(p) === "string"){
	p = document.getElementById(p);
  }
  var list = null;
  t = t || '*';
  p = p || document;

  if (document.all) {
    if (t == '*') list = p.all;
    else list = p.all.tags(t);
  }else if(p.getElementsByTagName){
	  list = p.getElementsByTagName(t);
  }  
  return list || new Array();
}

/**
*   change an object to an array so that array methods can be used - useful when using getElementsByTagName which returns a nodelist instead of an array
*   @param      obj = the Object to be converted to an array
*/
lgfl.convertToArray = function(obj) {
   if (!obj.length) {return [];} // length must be set on the object, or it is not iterable
   var a = [];
   var x = 0;
   for(var i in obj){
		a[x++] = obj[i];
   }
   return a;
};

/*
*   cms.addClassName
*   Description : adds a class to the class attribute of a DOM element
*   @param      objElement = page element 
*   @param      strClass = class name to add 
*/
lgfl.addClassName = function(objElement, strClass){
	
   var classExists = false;
   if(objElement.className){ // if there is already a class
     var arrList = objElement.className.split(' ');
	 var strClassUpper = strClass.toUpperCase();
	 for(var i = 0; i < arrList.length; i++ ){ // find all instances and remove them
		if(arrList[i].toUpperCase()==strClassUpper){ // if class found
		   classExists = true;
		   break;
		}
	 }
	 if(!classExists){
       arrList[arrList.length] = strClass; // add the new class to end of list
       objElement.className = arrList.join(' ');
	 }
   }else{ //no existing class  
      objElement.className = strClass;
   }
}


/*
*   cms.removeClassName
*   Description : removes a class to the class attribute of a DOM element
*   @param      objElement = page element 
*   @param      strClass = class name to add 
*/
lgfl.removeClassName = function(objElement, strClass){

   // if there is a class
   if (objElement.className){
      var arrList = objElement.className.split(' ');
      var strClassUpper = strClass.toUpperCase();
      for ( var i = 0; i < arrList.length; i++ ){
         if( arrList[i].toUpperCase() == strClassUpper){
            arrList.splice(i, 1); // remove array item
            i--; // decrement loop counter as we have adjusted the array's contents
         }
      }
      objElement.className = arrList.join(' ');
   }
}

/*
*   cms.containsClass
*   Description : checks to see if the className attribute contains the class name being searched for
*   @param      objElement = page element 
*   @param      strClass = class name to search for 
*/
lgfl.containsClass = function(objElement, strClass){

   // if there is a class
   if(objElement.className){
      var arrList = objElement.className.split(' ');
      var strClassUpper = strClass.toUpperCase();
      for ( var i = 0; i < arrList.length; i++ ){
         if( arrList[i].toUpperCase() == strClassUpper){
				return true;
         }
	  }
   }
   return false;
}


/**
*   Removes an event listener
*   @param      object
*   @param      evt         event
*   @param      func            function
*   @param      capture
*   @return     boolean
*/

lgfl.removeEvent = function(object, evt, func, capture){
	if(typeof func != 'function'){
		return false;
	}
	if(object.removeEventListener){
		object.removeEventListener(evt, func, capture);
		return true;
	}else if(object.detachEvent){
		object.detachEvent('on' + evt, func);
		return true;
	}
	return false;
}


/*
cms.onContentLoad is designed to run all unobtrusive scripts when a new bit of content is loaded to the page using AJAX
This function sets the variable 'cms.loadedObject' which all functions within 'lgfl.loadInit()' can access. This allows the functions within loadInit() to just apply to new content instead of the whole page    
*/
lgfl.onContentLoad = function(element){
	if(typeof lgfl.loadInit == 'function'){
		if(typeof(element) === "string"){
			element = document.getElementById(element);
		}
		lgfl.loadObject = element || window.document;
		lgfl.loadInit();
		lgfl.loadObject = null; //after completed reset object to null
	}	
}

/*
*   lgfl.addDomLoad
*   Description : lgfl.init is run on the first page load & lgfl.loadInit stack can optionally be run when content is subsequently loaded using AJAX
*   @param      func = function to be called  
*   @param      argument[1] = if set then add function passed to lgfl.loadInit stack which is called each time ajax content is loaded  
*/
lgfl.addDomLoad = function(func){
  		
	if (!document.getElementById | !document.getElementsByTagName) return;
	if (typeof lgfl.init != 'function'){
		lgfl.init=func;
	}else{
		var oldInit=lgfl.init;
		lgfl.init=function(){
			oldInit();
			func();
		}
	}
	if(arguments[1]==true){
		if (typeof lgfl.loadInit != 'function'){
			lgfl.loadInit=func;
		}else{
			var oldLoadInit=lgfl.loadInit;
			lgfl.loadInit=function(){
				oldLoadInit();
				func();
			}
		}
	}	
}

/**
*   load content using ajax
*   @param      url = path to the script
*   @param      targetPath  = parent layer into which to load the content
*   @param      boolean init = (optional) if 'true' runs cms.onContentLoad which runs init() on the ajax loaded content 
*/
lgfl.ajaxLoadContent = function(url,target,init){
	var target = target || cms.conf.loadContainer //detault container where content can be loaded
	var init = init || true;
	lgfl.ajaxLoad(url,target,init); //true: make sure cms.onContentLoad is run on new loaded content 
}

/**
*   load ajax - simple script that performs most ajax tasks
*   @param      string url = path to the script
*   @param      function | htmlElement | string target = (optional) if id or htmlElement then load content directly or if function then the function manipulates the response text
*   @param      boolean init = (optional) if 'true' runs cms.onContentLoad which runs init() on the ajax loaded content 
*/
lgfl.ajaxLoad = function(url,target,init) {
	
	if(typeof(target) === "string"){
		target = document.getElementById(target);
	}
	
	(function(){ //closure - added this to allow multiple ajax loads to run symultaneously without any risk of 'target' changing
		
		var initSet = init || false;
		var http = null;
		var xmlDoc = null;
		var value = null;
		if(window.XMLHttpRequest) { // branch for native XMLHttpRequest object
			http = new XMLHttpRequest();
		} else if(window.ActiveXObject) { // branch for IE/Windows ActiveX version
			try{
				http = new ActiveXObject("Msxml2.XMLHTTP");
			}catch(e) {
				http = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		if(http) {
			
			http.onreadystatechange = function(){
				xmlDoc = null;

				if (http.readyState == 4){	
					if(http.status == 200){ // only if "OK"
						
						if(http.responseText=='reloadpage'){ //session timed out so reload parent page incase login is required
							document.location.reload(true);
						}else{
							
							if(lgfl.getClass(target)==='Function'){ //if a function passed then execute callback function 
								target(http.responseText);
							}else if(target){
								target.innerHTML = http.responseText;
								if(initSet) lgfl.onContentLoad(target); //run unobrusive script to set onload events for new content
							}
						}						
					}else{
						//had to check for http.status to stop an exception being thrown in firfox when the clipboard was cleared - very odd behaviour
						if(http.status !==0) alert("There was a problem retrieving the XML data:\n" + http.statusText);
					}
				}	
			}
			http.open("POST", url, true); //true means asynchronous
			http.send("");
		}
	})();
}

// DF1.1 :: domFunction 
// *****************************************************
// DOM scripting by brothercake -- http://www.brothercake.com/
// GNU Lesser General Public License -- http://www.gnu.org/licenses/lgpl.html
//******************************************************

//DOM-ready watcher
lgfl.domFunction = function(f, a){

	var n = 0;
	var test = "hello";
	var t = setInterval(function(){
		var c = true;
		n++;
		if(typeof document.getElementsByTagName != 'undefined' && (document.getElementsByTagName('body')[0] != null || document.body != null)){
			c = false;
			if(typeof a == 'object'){
				for(var i in a){
					if(
						(a[i] == 'id' && document.getElementById(i) == null)
						||
						(a[i] == 'tag' && document.getElementsByTagName(i).length < 1)
					){ 
						c = true; 
						break; 
					}
				}
			}
			if(!c) { 
				//alert('test')
				f();
				clearInterval(t);
			}


		}
		if(n >= 60){
			//clear the timer
			clearInterval(t);
		}
	}, 250);
};
var foobar = new lgfl.domFunction(function(){ lgfl.init(); });

//http://www.json.org/json2.js - size reduced using http://fmarcia.info/jsmin/test.html
//JSON.parse(text, reviver) - This method parses a JSON text to produce an object or array.
//JSON.stringify(value, replacer, space) - used to convert to string ready for sending as a get
if(!this.JSON){this.JSON={};}(function(){function f(n){return n<10?'0'+n:n;}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+f(this.getUTCMonth()+1)+'-'+f(this.getUTCDate())+'T'+f(this.getUTCHours())+':'+f(this.getUTCMinutes())+':'+f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}if(typeof rep==='function'){value=rep.call(holder,key,value);}switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}v=partial.length===0?'[]':gap?'[\n'+gap+partial.join(',\n'+gap)+'\n'+mind+']':'['+partial.join(',')+']';gap=mind;return v;}if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}return str('',{'':value});};}if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}return reviver.call(holder,key,value);}cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}throw new SyntaxError('JSON.parse');};}}());



/**
 * DOM
 */
var isDOM1 = (document.getElementById) ? true : false;
var isDOM2 = (document.addEventListener && document.removeEventListener) ? true : false;

/**
 * UserAgent
 */
var theNavUA = navigator.userAgent.toLowerCase();
if (theNavUA.indexOf('windows') > -1 || theNavUA.indexOf('win') > -1) {
	var os = 'Microsoft Windows';
	if (theNavUA.indexOf('windows xp') > -1 || theNavUA.indexOf('win xp') > -1 || theNavUA.indexOf('nt 5.1') > -1) {
		var osVer = 'XP';
	} else if (theNavUA.indexOf('windows 2000') > -1 || theNavUA.indexOf('win 2000') > -1 || theNavUA.indexOf('nt 5.0') > -1) {
		var osVer = '2000';
	} else if (theNavUA.indexOf('windows me') > -1 || theNavUA.indexOf('win 9x 4.90') > -1) {
		var osVer = 'ME';
	} else if (theNavUA.indexOf('windows 98') > -1 || theNavUA.indexOf('win 98') > -1) {
		var osVer = '98';
	} else if (theNavUA.indexOf('windows 95') > -1 || theNavUA.indexOf('win 95') > -1) {
		var osVer = '95';
	} else if (theNavUA.indexOf('windows ce') > -1 || theNavUA.indexOf('win ce') > -1 || theNavUA.indexOf('windowsce') > -1 || theNavUA.indexOf('wince') > -1) {
		var osVer = 'CE';
	}
} else if (theNavUA.indexOf('linux') > -1) {
	var os = 'Linux';
} else if (theNavUA.indexOf('mac os x') > -1) {
	var os = 'Mac OS X';
} else if (theNavUA.indexOf('free bsd') > -1) {
	var os = 'Free BSD';
} else if (theNavUA.indexOf('sun os') > -1) {
	var os = 'Sun OS';
} else if (theNavUA.indexOf('irix') > -1) {
	var os = 'Irix';
} else if (theNavUA.indexOf('open bsd') > -1) {
	var os = 'Open BSD';
} else if (theNavUA.indexOf('macintosh') > -1 || theNavUA.indexOf('powerpc') > -1) {
	var os = 'Mac Classic';
} else if (theNavUA.indexOf('openvms') > -1) {
	var os = 'Open VMS';
} else if (theNavUA.indexOf('amigaos') > -1) {
	var os = 'Amiga';
} else if (theNavUA.indexOf('hurd') > -1) {
	var os = 'Hurd';
} else if (theNavUA.indexOf('hp-ux') > -1) {
	var os = 'HP-UX';
} else if (theNavUA.indexOf('unix') > -1 || theNavUA.indexOf('x11') > -1) {
	var os = 'UNIX';
} else if (theNavUA.indexOf('cygwin') > -1) {
	var os = 'Cygwin';
} else if (theNavUA.indexOf('java') > -1) {
	var os = 'Java';
} else if (theNavUA.indexOf('palmos') > -1) {
	var os = 'Palm OS';
} else if (theNavUA.indexOf('symbian') > -1) {
	var os = 'Symbian';
}

var isWin = (os == 'Microsoft Windows') ? true : false;
var isMac = (os == 'Mac OS X' || os == 'Mac Classic') ? true : false;
var isLinux = (os == 'Linux') ? true : false;
var isUNIX = (os == 'UNIX') ? true : false;

var isOp = (theNavUA.indexOf("opera") > -1) ? true : false;
var isOp5 = (theNavUA.indexOf("opera 5") > -1 || theNavUA.indexOf("opera/5") > -1) ? true : false;
var isOp6 = (theNavUA.indexOf("opera 6") > -1 || theNavUA.indexOf("opera/6") > -1) ? true : false;
var isOp7 = (theNavUA.indexOf("opera 7") > -1 || theNavUA.indexOf("opera/7") > -1) ? true : false;
var isIE = (theNavUA.indexOf("msie") > -1 && !isOp) ? true : false;
var isIE5 = (theNavUA.indexOf("msie 5") > -1 && !isOp) ? true : false;
var isIE50 = (theNavUA.indexOf("msie 5.0") > -1 && !isOp) ? true : false;
var isIE52 = (theNavUA.indexOf("msie 5.2") > -1 && !isOp) ? true : false;
var isIE6 = (theNavUA.indexOf("msie 6" && !isOp) > -1) ? true : false;
var isFFox = (theNavUA.indexOf("firefox") > -1) ? true : false;
var isNN6 = (theNavUA.indexOf("Netscape6") > -1) ? true : false;
var isNN7 = (theNavUA.indexOf("Netscape7") > -1) ? true : false;


/**
 * Multiple onload event handler
 * Mark Robinson 08 Feb 2005
 */
var lgflOnloadFunctions = new Array();
function lgflAddOnload(f) {
	if (window.onload) {
		if (window.onload != lgflOnload) {
			lgflOnloadFunctions[0] = window.onload;
			window.onload = lgflOnload;
		}
		lgflOnloadFunctions[lgflOnloadFunctions.length] = f;
	} else {
		lgflOnloadFunctions[0] = f;
		window.onload = lgflOnload;
	}
}
function lgflOnload() {
	for (var i = 0; i < lgflOnloadFunctions.length; i++) {
		eval(lgflOnloadFunctions[i])
	}
}

/**
 * Multiple onunload event handler
 * Mark Robinson 08 Feb 2005
 */
var lgflOnunloadFunctions = new Array();
function lgflAddOnunload(f) {
	if (window.onunload) {
		if (window.onunload != lgflOnunload) {
			lgflOnunloadFunctions[0] = window.onunload;
			window.onunload = lgflOnunload;
		}
		lgflOnunloadFunctions[lgflOnunloadFunctions.length] = f;
	} else {
		lgflOnunloadFunctions[0] = f;
		window.onunload = lgflOnunload;
	}
}
function lgflOnunload() {
	for (var i = 0; i < lgflOnunloadFunctions.length; i++) {
		eval(lgflOnunloadFunctions[i])
	}
}

/**
 * Find object
 */
function findObj(n, d) {
	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 = findObj(n, d.layers[i].document);
	}
	if (!x && d.getElementById) {
		x = d.getElementById(n);
	}
	return x;
}

/**
 * Regular expression test
 * Mark Robinson
 */
function regExpTest(pat, str) {
	var regExpSupported = false;
	if (window.RegExp) {
		var tmpStr = 'a';
		var tmpReg = new RegExp(tmpStr);
		if (tmpReg.test(tmpStr)) {
			regExpSupported = true;
		}
	}
	if (regExpSupported) {
		var ret = new RegExp(pat);
		return (!ret.test(str));
	}
}

/**
 * Read cookie
 * Mark Robinson
 */
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;
}

/**
 * Write cookie
 * Mark Robinson
 */
function writeCookie(name, value, days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
		var expires = '; expires=' + date.toGMTString();
	}
	else {
		expires = '';
	}
	document.cookie = name + '=' + value + expires + '; path=/';
}



/**
 * Style sheet switcher functions
 * Mark Robinson
 * Needs work...
 */
function getActiveStyleSheet() {
	if (document.getElementsByTagName) {
		var i, a;
		for(i = 0; (a = document.getElementsByTagName('link')[i]); i++) {
			if(a.getAttribute('rel').indexOf('style') != -1 && a.getAttribute('title') && !a.disabled) {
				return a.getAttribute("title");
			}
		}
		return null;
	}
}
function setActiveStyleSheet(title) {
	if (document.getElementsByTagName) {
		var i, a, main;
		for(i=0; (a = document.getElementsByTagName('link')[i]); i++) {
			if(a.getAttribute('rel').indexOf('style') != -1 && a.getAttribute('title')) {
				a.disabled = true;
				if(a.getAttribute('title') == title) {
					a.disabled = false;
				}
			}
		}
	}
}
function getPreferredStyleSheet() {
	if (document.getElementsByTagName) {
		var i, a;
		for(i=0; (a = document.getElementsByTagName('link')[i]); i++) {
			if(a.getAttribute('rel').indexOf('style') != -1 && a.getAttribute('rel').indexOf('alt') == -1 && a.getAttribute('title')) {
				return a.getAttribute("title");
			}
		}
		return null;
	}
}

/**
 * Detect plugins
 * Mark Robinson
 */
function detectPlugin(pluginName, pluginMimeType, pluginActiveXName) {
	var r = new Array(false, false);
	if (!isIE) {
		if (navigator.plugins && navigator.plugins.length > 0) {
			for (i = 0; i < navigator.plugins.length; i++) {
				var x = navigator.plugins[i];
				if (x.name.indexOf(pluginName) > -1) {
					r[0] = true;
					if (x.description) {
						y = x.description;
						try {
							r[1] = y.match(/(\d+(\.?\d*)*)/)[1];
						} catch (e) { }
						try {
							r[1] = x.name.match(/(\w?\d+(\.?\d*)*)/)[1];
						} catch (e) { }
						return r;
					}
				}
			}
		} else if (navigator.mimeTypes) {
			var x = navigator.mimeTypes[pluginMimeType];
			if (x && x.enabledPlugin) {
				r[0] = true;
				return r;
			}
		}
	} else {
		for (var i = 10; i > 0; i--) {
			try {
				var x = new ActiveXObject(pluginActiveXName+'.'+i);
				r[1] = i;
				break;
			} catch (e) { }
		}
		if (r[1] > 0) {
			r[0] = true;
			return r;
		}
	}
	return false;
}

/**
 * Set external links in open in new window (standards compliant)
 * Mark Robinson
 * Makes use of "rel" attribute.
 * e.g. <a href="" title="" rel="external"></a>
 */
function setExtLinkTarget() {
	if (document.getElementsByTagName) {
		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';
				anchor.className = 'link-external';
				anchor.title = (anchor.title.indexOf('(New window)') > -1) ? anchor.title : anchor.title + ' (New window)';
			}
		}
	}
}

function setLinks() { //function taken from steven's own functions
	if (document.getElementsByTagName) {
		var anchors = document.getElementsByTagName('a');
		for (var i = 0; i < anchors.length; i++) {
			var anchor = anchors[i];
			//setExtLinkTarget(anchor);
			//setLinkTab(anchor);
			setDeleteConfirm(anchor);
		}
	}
}

function setDeleteConfirm(obj){
	var arrList = obj.className.split(' ');
	for(var i = 0; i < arrList.length; i++ ){
		if (arrList[i].toUpperCase() == 'DELETE') {
			obj.onclick = function(){
				if(confirm("Are you sure you want to delete this")){
					return true;
				}else{
					return false;
				}
			}
		}
	}
}

lgflAddOnload('setLinks()');


/**
* Wrap element using DOM compliant methods
* Mark Robinson 22 Feb 2005
*/
function lgflWrapElementById(id)
{
	if (document.getElementById)
	{
		var newParentElement = arguments[1] ? arguments[1] : 'span';
		var newParentId = arguments[2] ? arguments[2] : id+'_wrapper';
		var toBeWrapped = document.getElementById(id);
		var newparent = document.createElement(newParentElement);
		var parent = toBeWrapped.parentNode;
		parent.replaceChild(newparent, toBeWrapped);
		newparent.setAttribute('id', newParentId);
		newparent.appendChild(toBeWrapped);
		return true;
	}
	return false;
}

/**
* Set field focus
* Mark Robinson 07 Apr 2005
*/
function setFocusById(id)
{
	if (document.getElementById)
	{
		document.getElementById(id).focus();
	}
}


/**
* Load (preload-hide) stylesheet
* SHOLT
*/
function lgflPreloadHide()
{
	var tags = document.getElementsByTagName('head');
	var headtag = tags.item(0);
	newlink = document.createElement('link');
	newlink.setAttribute('id', 'preload-hide');
	newlink.setAttribute('rel', 'stylesheet');
	newlink.setAttribute('type', 'text/css');
	newlink.setAttribute('href', '/lgfl_shared/css/preload-hide.css');
	headtag.appendChild(newlink);
	return true;
}
//document.write('<link rel="stylesheet" type="text/css" href="/lgfl_shared/css/preload-hide.css" title="Normal" />');
lgflPreloadHide();

/*
* All the variables and functions have been defined,
* now lets do some work...
*/

/*
* Link targets
*/
lgflAddOnload('setExtLinkTarget()');


/*
* Style sheet selection
*/
var cookie = readCookie('lgfl_stylesheet');
var stylesheet = (cookie != 'null' ? cookie : getPreferredStyleSheet());
if (stylesheet) {
	setActiveStyleSheet(stylesheet);
}
function lgflLoadStyle() {
	var cookie = readCookie('lgfl_stylesheet');
	var title = (cookie != 'null' ? cookie : getPreferredStyleSheet());
	if (title) {
		setActiveStyleSheet(title);
	}
}
lgflAddOnload('lgflLoadStyle()');
function lgflSaveStyle() {
	var title = getActiveStyleSheet();
	if (title) {
		writeCookie('lgfl_stylesheet', title, 0);
	}
}
lgflAddOnunload('lgflSaveStyle()');








/* Still to be completed MR */

/* this function is needed to work around 
   a bug in IE related to element attributes */
function hasClass(obj) {
	var result = false;
	if (obj.getAttributeNode('class') != null) {
		result = obj.getAttributeNode('class').value;
	}
	return result;
} /* function hasClass ends */

/* this function adds 'Zebra' effect to table */
function stripeTable(id) {
	if (document.getElementById) {
		var even = false;
		var evenColor = arguments[1] ? arguments[1] : '#fff';
		var oddColor = arguments[2] ? arguments[2] : '#eee';
		var table = document.getElementById(id);
		if (!table)	{
			return;
		}
		var tbodies = table.getElementsByTagName('tbody');
		for (var h = 0; h < tbodies.length; h++) {
			var trs = tbodies[h].getElementsByTagName('tr');
			for (var i = 0; i < trs.length; i++) {
				if (!hasClass(trs[i]) && !trs[i].style.backgroundColor) {
					var tds = trs[i].getElementsByTagName('td');
					for (var j = 0; j < tds.length; j++) {
						var mytd = tds[j];
						if (!hasClass(mytd) && !mytd.style.backgroundColor) {
							mytd.style.backgroundColor = even ? evenColor : oddColor;
						}
					}
				}
				even =  !even;
			}
		}
	}
}


function lgfl_openFolder(obj){ //used by class LGfL_displayFiles 
	var parent = obj.parentNode;
	if(parent.lastChild.className=="show"){
		parent.lastChild.className="hide";
	}else{
		parent.lastChild.className="show";
	}	
	return false;
}









