Lib = {};

// error reporting


Lib.Error = {};
Lib.Error._errorEventsArray = 		[];
Lib.Error.callOnError = 		function(func){
							Lib.Error._errorEventsArray.push(func);
};
Lib.Error.throwError = 			function (e){
						for (var i=0; i<Lib.Error._errorEventsArray.length; i++){
						   Lib.Error._errorEventsArray[i](e);
						}
};
Lib.Error.getErrorDetails = 		function (e){
						var arr = [];
						for (params in e){
							arr.push(params+': '+e[params]);
						}
						return arr;
};
Lib.Error.Report = 			function (e){
						e.userAgent = navigator.userAgent;
						var errordetails = Lib.Error.getErrorDetails(e);
						
						var occdateobj= new Date()
						var theyear=occdateobj.getFullYear();
						var themonth=occdateobj.getMonth()+1;
						var thetoday=occdateobj.getDate();
						var thehours=occdateobj.getHours();
						var theminutes=occdateobj.getMinutes();
						
						var occdate = themonth+'/'+thetoday+'/'+theyear+' '+thehours+':'+theminutes;
						
						
						var poststr = 'siteUrl='+escape(window.location.href);
						poststr += '&errorUrl='+escape((e.fileName?e.fileName:window.location.href));
						poststr += '&errorName='+escape(e.name);
						poststr += '&errorMessage='+escape(errordetails.join(",\n"));
						poststr += '&occurenceTime='+escape(occdate);
						// ajax post error details
						
						//console.log(e);
					
}
Lib.Error.callOnError(Lib.Error.Report);

Lib.Ajax = {}; 
Lib.Ajax.HttpXML = Base.extend({
	constructor :			function (sendpage){
							this.httpxml_prefix = false;
							this.httpxml = false;
							this.create();
							this.data = null;
							this.method = "get";
							this.sendpage = sendpage;
	},
	create	:			function (){
							if (this.httpxml){
							  return this.httpxml;
							}
							try {
							  if (window.XMLHttpRequest) {
							    var req = new XMLHttpRequest();
							    // some older versions of Moz did not support the readyState property
							    // and the onreadystate event so we patch it!
							    if (req.readyState == null) {
							        req.readyState = 1;
							        req.addEventListener("load", function () {
							          req.readyState = 4;
							          if (typeof req.onreadystatechange == "function")
							             req.onreadystatechange();
							        }, false);
							    }
							    this.httpxml = req;
							  }
							  if (window.ActiveXObject) {
							    this.httpxml = new ActiveXObject(this.getControlPrefix() + ".XmlHttp");
							  }
							  
							  return this.httpxml;
							}catch (ex) {}
	},
	getControlPrefix:		function(){
	
							if (this.httpxml_prefix){
								 return this.httpxml_prefix;
							}
							
							var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
							var o, o2;
							for (var i = 0; i < prefixes.length; i++) {
							  try {
								o = new ActiveXObject(prefixes[i] + ".XmlHttp");
								o2 = new ActiveXObject(prefixes[i] + ".XmlDom");
								return  this.httpxml_prefix = prefixes[i];
							  } catch (ex) {};
							}
							
	},
	send : 				function (data, method){
						  
						  if (this.locked)return false;
							if (data) this.data = data;
							if (method) {
							 this.method = method;
							}else if (this.data){
							 this.method = "post";
							}
							
							
							if (this.sendpage){
							
							 this.httpxml.onreadystatechange = Lib.delegate(this, this.recieve);
							 
							 this.httpxml.open(this.method, this.sendpage);
							 this.httpxml.send(this.data);
							 
							 return true;
							}else {
							  throw "No sendpage specified";
							  return false;
							}
	},
	recieve : 			function (){
	
							if(this.httpxml.readyState == 4){
							   data = this.httpxml.responseXML;
						  	   this.onrecieve(data);
							   this.httpxml.onreadystatechange = null;
							}
	},
	onrecieve : 			function (data){
	}
});
Lib.Ajax.HttpText = Lib.Ajax.HttpXML.extend({
	recieve : 			function (){
	
							if(this.httpxml.readyState == 4){
							   data = this.httpxml.responseText;
						  	   this.onrecieve(data);
							   this.httpxml.onreadystatechange = null;
							}
	}
});


Lib.Browser = {};
Lib.Browser._get = 			null;
Lib.Browser.get	=			function () {
						
							if (Lib.Browser._get != null){
							 return Lib.Browser._get;
							}

							var ua, s, i;

							var isMSIE = /*@cc_on!@*/false;
							isNS    = false;
							version = null;

							ua = navigator.userAgent;

							s = "Netscape6/";
							if ((i = ua.indexOf(s)) >= 0) {
							 isNS = true;
							 version = parseFloat(ua.substr(i + s.length));
							}

							s = "Gecko";
							if ((i = ua.indexOf(s)) >= 0) {
							 isNS = true;
							 version = 6.1;
							}
							return Lib.Browser._get = {isIE:isMSIE, isNS:isNS, version:version};
}
Lib.Browser.dim =					function (){
								var bd = {};

								if (window.innerHeight && window.scrollMaxY) {	
									bd.xfull = document.body.scrollWidth;
									bd.yfull = window.innerHeight + window.scrollMaxY;
								} else if (document.body.scrollHeight > document.body.offsetHeight){

									bd.xfull = document.body.scrollWidth;
									bd.yfull = document.body.scrollHeight;
								} else {
									bd.xfull = document.body.offsetWidth;
									bd.yfull = document.body.offsetHeight;
								}
								
								if (self.innerHeight) {	// all except Explorer
									bd.xview = self.innerWidth;
									bd.yview = self.innerHeight;
								} else if (document.documentElement && document.documentElement.clientHeight) {
									bd.xview = document.documentElement.clientWidth;
									bd.yview = document.documentElement.clientHeight;
								} else if (document.body) { // other Explorers
									bd.xview = document.body.clientWidth;
									bd.yview = document.body.clientHeight;
								}	
								

								if(bd.yfull < bd.yview){
									bd.yfull = bd.yview;
								}

								
								if (self.pageYOffset) {
									bd.yscroll = self.pageYOffset;
								} else if (document.documentElement && document.documentElement.scrollTop){
									bd.yscroll = document.documentElement.scrollTop;
								} else if (document.body) {
									bd.yscroll = document.body.scrollTop;
								}
								return bd;
};

Lib.Collections = {};
Lib.Collections.Array = {};
Lib.Collections.Array.inArray = 	function (arr, value){
							var i;
							for (i=0; i < arr.length; i++) {
								if (arr[i] === value) {
									return true;
								}
							}
							return false;
}
Lib.Collections.Hashtable = Base.extend({
	constructor :			function (){
						  	this.hashtable = new Array();
	},
	clear : 			function (){
						  	this.hashtable = new Array();
	},
	containsKey :			function (key){
							  var exists = false;
							  for (var i in this.hashtable) {
								if (i == key && this.hashtable[i] != null) {
									exists = true;
									break;
								}
							  }
							  return exists;
	},
	containsValue : 		function (value){
						  	var contains = false;
						  	if (value != null) {
							  for (var i in this.hashtable) {
								if (this.hashtable[i] == value) {
									contains = true;
									break;
								}
							  }
						  	}
							return contains;
	},
	get : 				function (key){
   						  	return this.hashtable[key];
	},
	isEmpty :			function (){
						  	return (parseInt(this.size()) == 0) ? true : false;
	},
	keys :				function (){
							var keys = new Array();
							for (var i in this.hashtable) {
								if (this.hashtable[i] != null)
									keys.push(i);
							}
							return keys;
	},
	put :				function (key, value){
						  	if (key == null || value == null) {
							  throw "NullPointerException {" + key + "},{" + value + "}";
						  	}else{
							   this.hashtable[key] = value;
     					  		}
	},
	remove : 			function (key){
							var rtn = this.hashtable[key];
							this.hashtable[key] = null;
							return rtn;
	},
	size : 				function (){
						  	var size = 0;
						  	for (var i in this.hashtable) {
							  if (this.hashtable[i] != null)
								size ++;
						  	}
						  	return size;
	},
	toString : 			function (){
						  	var result = "";
						  	for (var i in this.hashtable)
						  	{
							  if (this.hashtable[i] != null)
								result += "{" + i + "},{" + this.hashtable[i] + "}\n";
						  	}
							return result;
	},
	values : 			function (){
						  	var values = new Array();
						  	for (var i in this.hashtable) {
							  if (this.hashtable[i] != null)
								values.push(this.hashtable[i]);
						  	}
						  	return values;
	}
});
Lib.Cookies = {};
Lib.Cookies.get =			function( name ) {
 
							var start = document.cookie.indexOf( name + "=" );
							var len = start + name.length + 1;
							if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
								return null;
							}
							if ( start == -1 ) return null;
							var end = document.cookie.indexOf( ';', len );
							if ( end == -1 ) end = document.cookie.length;
							return unescape( document.cookie.substring( len, end ) );
};
Lib.Cookies.set = 			function ( name, value, expires, path, domain, secure ) {
							var today = new Date();
							today.setTime( today.getTime() );
							if ( expires ) {
								expires = expires * 1000 * 60 * 60 * 24;
							}
							var expires_date = new Date( today.getTime() + (expires) );
							document.cookie = name+'='+escape( value ) +
								( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
								( ( path ) ? ';path=' + path : '' ) +
								( ( domain ) ? ';domain=' + domain : '' ) +
								( ( secure ) ? ';secure' : '' );
};
Lib.Cookies.del =			function( name, path, domain ) {
							if ( getCookie( name ) ) document.cookie = name + '=' +
									( ( path ) ? ';path=' + path : '') +
									( ( domain ) ? ';domain=' + domain : '' ) +
									';expires=Thu, 01-Jan-1970 00:00:01 GMT';
};
Lib.delegate =				function(that, thatMethod){
							var _params = [];
							for(var n = 2; n < arguments.length; n++) _params.push(arguments[n]);
							return function() {
						         var paramsToUse = [];
						         for(var n = 0; n < arguments.length; n++) {
						         	paramsToUse.push(arguments[n]);
						         }
						         for(var n = 0; n < _params.length; n++) {
						         	paramsToUse.push(_params[n]);
						         }
						         
							 try {
							  if (paramsToUse.length > 0){
							    return thatMethod.apply(that, paramsToUse)
							  }else {
							    return thatMethod.call(that)
							  }
							 }catch(e){
							  e.func = thatMethod;
							  e.params = _params.join(",");
							  Lib.Error.throwError(e);
							 };
							}
};
Lib.setTimeoutDelegate =		function(that, thatMethod){	
							var _params = [];
							for(var n = 2; n < arguments.length; n++) _params.push(arguments[n]);
							return function() {
							 try {
							  if (_params.length > 0){
							    return thatMethod.apply(that, _params)
							  }else {
							    return thatMethod.call(that)
							  }
							 }catch(e){
							  e.func = thatMethod;
							  e.params = _params.join(",");
							  
							 };
							}							
};
Lib.Dom = {};
Lib.Dom.Elm = {};	
Lib.Dom.Elm.find = 			function(elm){
							if (typeof elm == "object"){
							 if (source = Lib.Dom.getEventSrc(elm)){
							  return source;
							 }else {
							  return elm;
							 }
							}else {
							  return document.getElementById(elm);
							}
};
Lib.Dom.Elm.first = 			function (elm, type){
							return elm.getElementsByTagName(type)[0];
}
Lib.Dom.Elm.create = 			function(type, styles){
							var elm = document.createElement(type);
							if (styles){
							  Lib.Dom.Elm.Style.add(elm, styles);
							}
							return elm;
};
Lib.Dom.Elm.Style = {};
Lib.Dom.Elm.Style.add = 		function(elm, styles){
							elm = $(elm);
							for (sty in styles){
							  elm.style[sty] = styles[sty];
							}
};

Lib.Dom.Elm.Style.changeStyle =		function (element, newStyleSuffix){
							if(null != element){
							  if (element.originalClass==null || element.originalClass.length==0){
							  
							    if (element.className && element.className.length>0){
							      element.originalClass=element.className;
							    }else {
							      element.originalClass=" ";
							    }
							  }
							  if(element.originalClass.length>0 && element.originalClass != " "){
							    element.className = element.originalClass+" "+element.originalClass+newStyleSuffix;
							  }else {
							    element.className = newStyleSuffix;
							  }
							}
};
Lib.Dom.Elm.Style.revertToOriginalStyle = function (element){
							if(element != null && null != element.originalClass && element.originalClass.length>0){
								element.className =element.originalClass;
							}
};
Lib.Dom.Elm.Style.addClass = 		function (element, newStyleSuffix){

							if(null != element)
							{
							  element.originalClass = element.className;
							  if(element.className == null){
							    element.className = newStyleSuffix;
							  }else{
							    element.className += ' ' + newStyleSuffix;
							  }
							}
};
Lib.Dom.Elm.Style.removeClass = 	function (element, newStyleSuffix){
							if(element != null && element.className!=null){
							  if(element.className.indexOf(newStyleSuffix) != -1){
							    var n = element.className.indexOf(newStyleSuffix);
							    element.className = element.className.substr(0, n) + element.className.substr(n + newStyleSuffix.length);
							  }
							}
};

Lib.Dom.Elm.Opacity = {};
Lib.Dom.Elm.Opacity._tid = {};
Lib.Dom.Elm.Opacity.opacity = 		function(id, opacStart, opacEnd, millisec) {
							var speed = Math.round(millisec / 100);
							var timer = 0;
							if (!opacStart){
							  opacStart = $(id).thisOpacity;
							}
							if (Lib.Dom.Elm.Opacity._tid[id] != null){
							 for (var a = 0; a<Lib.Dom.Elm.Opacity._tid[id].length; a++){
							   clearTimeout(Lib.Dom.Elm.Opacity._tid[id][a]);
							 }
							}
							Lib.Dom.Elm.Opacity._tid[id] = [];;
							if(opacStart > opacEnd) {
								for(i = opacStart; i >= opacEnd; i--) {
									Lib.Dom.Elm.Opacity._tid[id].push(setTimeout("Lib.Dom.Elm.Opacity.changeOpac(" + i + ",'" + id + "')",(timer * speed)));
									timer++;
								}
							} else if(opacStart < opacEnd) {
								for(i = opacStart; i <= opacEnd; i++)
									{
									Lib.Dom.Elm.Opacity._tid[id].push(setTimeout("Lib.Dom.Elm.Opacity.changeOpac(" + i + ",'" + id + "')",(timer * speed)));
									timer++;
								}
							}
};
Lib.Dom.Elm.Opacity.changeOpac = 	function(opacity, id) {
							var object = $(id); 

							Lib.Dom.Elm.Style.add (object, {
								opacity : (opacity / 100),
								MozOpacity : (opacity / 100),
								KhtmlOpacity : (opacity / 100),
								filter : "alpha(opacity=" + opacity + ")"
							});

							object.thisOpacity = opacity;
};
Lib.Dom.getEventSrc = 			function (e){
							if (typeof e == 'undefined') {
							 if (window.event){
							  var e = window.event;
							 }else {
							  return false;
							 }
							}
							return (typeof e.target != 'undefined'?source = e.target:source = e.srcElement);
};
Lib.Dom.getElementsByClassName = 	function (elm, tag, myclass, exact){

 							tags = tag.split("|");
 							
 							var allelms = [];
 							
 							for (var i=0; i<tags.length; i++){
 							 var tmp = (tags[i] == "*" && elm.all)? elm.all : elm.getElementsByTagName(tags[i]);
							 for (var a=0; a<tmp.length; a++){
							  allelms.push(tmp[a])
							 }
							}
							
							var returnelms = new Array();
							myclass = myclass.replace(/-/g, "\-");
							var regexp = new RegExp("(^|\s)" + myclass + "(\s|$)");
							var oElement;
							var classes;
							
							for(var i=0; i<allelms.length; i++){
								oElement = allelms[i];
								if (exact){
								 
								 if(regexp.test(oElement.className)){
								 
								  returnelms.push(oElement);
								 }
								}else {
								 classes = oElement.className.split(" ");
								 
								 var flag = false;
								 
								 for (var a=0; a<classes.length; a++){
								  if(regexp.test(classes[a])){
								   flag = true;	
								  }
								 }
								 if (flag){
								  returnelms.push(oElement);
								 }
								}
								
							}
							
							return returnelms;
};
/* events */

Lib.Dom.addEvent = 			function ( obj, type, fn ) { 
							if ( obj.attachEvent ) { 
							  obj['e'+type+fn] = fn; 
							  obj[type+fn] = function(){obj['e'+type+fn]( window.event );} 
							  
							  obj.attachEvent( 'on'+type, obj[type+fn] ); 
							} else {
							  obj.addEventListener( type, fn, false ); 
							}
} 
Lib.Dom.removeEvent = 			function (obj, eventName, dlg){	
							if ( obj.detachEvent ) { 
							  obj.detachEvent( 'on'+type, obj[type+fn] ); 
							  obj[type+fn] = null; 
							} else 
							  obj.removeEventListener( type, fn, false ); 
};
Lib.Dom._domLoadedFunctionList	=	[];
Lib.Dom._domLoaded =			false;
Lib.Dom.callWhenDOMLoaded = 		function (func) {

							if (Lib.Dom._domLoaded) {
								try {func();}catch(e){Lib.Error.throwError(e);}
							} else {
								Lib.Dom._domLoadedFunctionList.push(func);
							}
};
Lib.Dom._domLoadedEvent	=		function() {
							Lib.Dom._domLoaded=true;
							
							if (arguments.callee.done) return;
							
							arguments.callee.done = true;
							
							for (var i=0;i<Lib.Dom._domLoadedFunctionList.length;i++) {
							  try {Lib.Dom._domLoadedFunctionList[i]();}catch(e){Lib.Error.throwError(e);}
							}
};





Lib.Dom.expandList = {

/*
expanding list

- container:	 div.drop
- header: 	 h4
- dropped 	div: div.dropped


e.g.

<div class="drop">
 <h4>header</h4>
 <div class="dropped">
   this content will open when header is clicked
 </div>
</div>

this has lots of room for expansion. too much is hardcoded into this. - mikee
*/

  'initialise'	: 	function (){
  				
  				Lib.Dom.expandList.open = false;
  				Lib.Dom.expandList.drops = Lib.Dom.getElementsByClassName(document, 'div', 'drop');
  				if (Lib.Dom.expandList.drops.length > 0){
  				 Lib.Dom.expandList.dropped = [];
				 for (var i=0; i<Lib.Dom.expandList.drops.length; i++){
				  Lib.Dom.expandList.dropped.push(Lib.Dom.Elm.first(Lib.Dom.expandList.drops[i], "div"));
				  Lib.Dom.Elm.Style.add (Lib.Dom.expandList.dropped[Lib.Dom.expandList.dropped.length-1], {'display':'none'});
				  Lib.Dom.addEvent(Lib.Dom.Elm.first(Lib.Dom.expandList.drops[i], "h4"), "click", Lib.delegate(this, Lib.Dom.expandList.openSec, Lib.Dom.expandList.dropped[Lib.Dom.expandList.dropped.length-1]));
				 }
				}
				

				
  },
  'closeSec'	: 	function (){
  				if (Lib.Dom.expandList.open){
  					Lib.Dom.expandList.open.open = false;
  					Lib.Dom.Elm.Style.revertToOriginalStyle(Lib.Dom.Elm.first(Lib.Dom.expandList.open.parentNode, "h4"));
  					Lib.Dom.Elm.Style.add(Lib.Dom.expandList.open, {'display': 'none'});
  				}
  },
  'openSec' 	: 	function (e, i){
  				if (i.open != true){
  				 Lib.Dom.expandList.closeSec();
  				 Lib.Dom.expandList.open = i;
  				 i.open = true;
				 Lib.Dom.Elm.Style.add(i, {'display':'block'});
				 Lib.Dom.Elm.Style.changeStyle(Lib.Dom.Elm.first(i.parentNode, "h4"), "Sel");
				}else {
				 Lib.Dom.expandList.open = i;
				 Lib.Dom.expandList.open.open = true;
				 Lib.Dom.expandList.closeSec();
				}
  },
  'openLast' 	: 	function (){
  				Lib.Dom.expandList.openSec(false, Lib.Dom.expandList.dropped[Lib.Dom.expandList.dropped.length-1]);
  }
};




Lib.Dom.LinkPanels = {};
/*

To initalise: 

callWhenDOMLoaded(Lib.Dom.LinkPanels.initialise);



<div class="linkpanel">
 <p>Other html tags</p>
 <a href="#">click for more info</a>
</div>


this will make the whole of 'linkpanel' a link.

Also works if you have multiple classes on the div. e.g.

<div class="sidepanel linkpanel">
 <p>Other html tags</p>
 <a href="#">click for more info</a>
</div>

*/
Lib.Dom.LinkPanels.getParentDiv = 	function (linkDivElement) {
							while ( (linkDivElement != null) && 
									(linkDivElement.clickhref==null)
								) { 
								linkDivElement=linkDivElement.parentNode;
							}
							return linkDivElement;
};
Lib.Dom.LinkPanels.click = 		function (e, eventObj) {

							var linkDivElement = $(eventObj);
							while ( (linkDivElement != null) 
								&& (linkDivElement.clickhref==null)
								&& (linkDivElement.tagName.toLowerCase() !='a')  ){
								linkDivElement=linkDivElement.parentNode;
							}
							if ( (linkDivElement != null) ) {
								window.location.href=linkDivElement.clickhref;
							}
};
Lib.Dom.LinkPanels.rollover = 		function (e, eventObj) {
							Lib.Dom.Elm.Style.addClass(Lib.Dom.LinkPanels.getParentDiv($(eventObj)),"Hover");
	
};
Lib.Dom.LinkPanels.rollout = 		function (e, eventObj) {
							Lib.Dom.Elm.Style.revertToOriginalStyle(Lib.Dom.LinkPanels.getParentDiv($(eventObj)));
};	

Lib.Dom.LinkPanels.initialise = 	function (container, tags) {
							var divList=Lib.Dom.getElementsByClassName($(container), tags, 'linkpanel');
						
							for (var i=0;i<divList.length;i++) {
								var divElement=divList[i];
									var atags=divElement.getElementsByTagName("a");
									if (atags.length>0) {
										divElement.clickhref=atags[0].getAttribute('href');
										Lib.Dom.Elm.Style.add(divElement, { 'cursor' : 'pointer'});
										Lib.Dom.addEvent(divElement, "click", Lib.delegate(this, Lib.Dom.LinkPanels.click, divElement));
										Lib.Dom.addEvent(divElement, "mouseover", Lib.delegate(this, Lib.Dom.LinkPanels.rollover, divElement));
										Lib.Dom.addEvent(divElement, "mouseout", Lib.delegate(this, Lib.Dom.LinkPanels.rollout, divElement));
									}
								
							}
};
//
Lib.Dom.Images = {};
Lib.Dom.Images.fixPNGs =		function (){
							if(Lib.Browser.get().isIE){
							  var allpngs = Lib.Dom.getElementsByClassName(document, "img", "likeimg");

							  for(var a=0; a<allpngs.length; a++)
							  {

							    var img = allpngs[a]

							    var imgName = img.src.toUpperCase()

							    if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
							    {
							       var imgID = (img.id) ? "id='" + img.id + "' " : ""
							       var imgClass = (img.className) ? "class='" + img.className + "' " : ""
							       var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
							       var imgStyle = "display:inline-block;" + img.style.cssText
							       if (img.align == "left") imgStyle = "float:left;" + imgStyle
							       if (img.align == "right") imgStyle = "float:right;" + imgStyle

							       var strNewHTML = "<span " + imgID + imgClass + imgTitle
							       + " style=\"" + "width:7px; height:14px;" + imgStyle + ";"
							       + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
							       + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
							       img.outerHTML = strNewHTML

							    }
							  }
							}
 
}
Lib.Dom.Images.SimpleRoll = {

	setup : 			function (){
	
							var allRollovers = Lib.Dom.getElementsByClassName(document, "img", "rollover");
							var preLoadedImgs = [];
							for (i=0; i<allRollovers.length; i++){
							 if (allRollovers[i].nodeName.toLowerCase() == "img"){
							  var fullImgPath = allRollovers[i].src;
							  var extPos = fullImgPath.lastIndexOf(".");
							  var imgPath = fullImgPath.substring(0, extPos);
							  var imgExt = fullImgPath.substring(extPos, fullImgPath.length);

							  var overImg = imgPath + "_over" + imgExt;


							  var tmp = new Image();
							  tmp.src = overImg;
							  allRollovers[i].overimg = overImg;
							  allRollovers[i].outimg = fullImgPath;
							  preLoadedImgs.push(tmp);
							  parentTag = allRollovers[i].parentNode;
							  Lib.Dom.addEvent(parentTag, 'mouseover', Lib.Dom.Images.SimpleRoll.rollover);
							  Lib.Dom.addEvent(parentTag, 'mouseout', Lib.Dom.Images.SimpleRoll.rollout);

							 }
							}
	
	},
	rollover : 			function (e){
							var elm = $(e);
							if (elm.nodeName.toLowerCase() != "a"){
							  elm = elm.parentNode;
							}
							var imag = elm.getElementsByTagName("img")[0];
							imag.src = imag.overimg;
	},
	rollout : 			function (e){
							var elm = $(e);
							if (elm.nodeName.toLowerCase() != "a"){
							  elm = elm.parentNode;
							}
							var imag = elm.getElementsByTagName("img")[0];
							imag.src = imag.outimg;
	}

};

Lib.Dom.Lightbox = Base.extend({
	constructor : 			function (color, opacity){
							this.color = (color?color:'#ffffff');
							this.opacity = (opacity?opacity:50);
							this.loadingimg = baseurl+'img/loader.gif';
							this.loadingimgwidth = 16;
							this.loadingimgheight = 16;
							this.pagex = 400;
							this.pagey = 400;
							this.padding = [20, 10, 10, 10];
							callWhenDOMLoaded(Lib.delegate(this, this.initiate));
							Lib.Dom.addEvent(window, "resize", Lib.delegate(this, this.onResize));
							
							
	},
	updateDim : 			function (){
							this.dim = Lib.Browser.dim();
	},
	onResize : 			function (){
							if (this.status==1){
							 this.coverpage();
							 this.repositionElements();
							}
	},
	initiate : 			function (a){
	
							var preloadimg = new Image();
							preloadimg.src = this.loadingimg;
							this.updateDim();
							this.body = Lib.Dom.Elm.first(document,'body');	
	
							var elms = Lib.Dom.getElementsByClassName(document, 'a' ,'lightbox');
							
							for (var i=0; i<elms.length; i++){
							  Lib.Dom.addEvent(elms[i], "click", Lib.delegate(this, this.open, elms[i]));
							  elms[i].link = elms[i].href;
							  elms[i].target = "_self";
							  elms[i].href = 'javascript:void(0);';
							}

							this.elmloadingimg = Lib.Dom.Elm.create("img", {
										'display'	: 'none',
										'top'		: '0px',
										'left'		: '0px',
										'width'		: this.loadingimgwidth + 'px',
										'height'	: this.loadingimgheight + 'px',
										'position'	: 'absolute',
										'zIndex'	: 1000001
											});
							this.elmloadingimg.src = this.loadingimg;
							this.body.appendChild(this.elmloadingimg);
							
	},
	create :			function (){
							
							this.fullscreen = Lib.Dom.Elm.create("div", {
											'display' : 'none'	
											});
							this.fullscreen.id = 'lightbox_fullscreen';
							this.contentviewer = Lib.Dom.Elm.create("div", {
											'display'		: 'none',
											'backgroundColor'	: '#FFFFFF',
											'position'		: 'absolute',
											'top'			: '0px',
											'left'			: '0px',
											'zIndex'		: '1000001'
											});
							this.innercontentviewer = Lib.Dom.Elm.create("div", {

											'paddingTop'		: this.padding[0]+'px',
											'paddingRight'		: this.padding[1]+'px',
											'paddingBottom'		: this.padding[2]+'px',
											'paddingLeft'		: this.padding[3]+'px'
							})
							this.ajaxholder = Lib.Dom.Elm.create("div", {
									'overflow' : 'auto',
									'display'  : 'none'
										});
							this.holderimage = Lib.Dom.Elm.create("img", {
											'display'		: 'none'
											});
							this.fullscreen.id = 'lightbox_content';
							this.createCloseButton();
							this.innercontentviewer.appendChild(this.holderimage);
							this.innercontentviewer.appendChild(this.ajaxholder);
							this.contentviewer.appendChild(this.innercontentviewer);
							Lib.Dom.Elm.Style.add(this.ajaxholder, {
											'overflow'		: 'auto'	
										});
							this.ajaxholder.id = 'ajaxholder';
							this.body.appendChild(this.contentviewer);
							this.body.appendChild(this.fullscreen);
	},
	showloader : 			function (){
							Lib.Dom.Elm.Style.add(this.elmloadingimg, {
											'display'		: 'block'
											});
							Lib.Dom.Elm.Style.add(this.elmloadingimg, {
											'left' 			: (this.dim.xfull/2)-(this.loadingimgwidth/2) + 'px',
											'top' 			: ((this.dim.yview/2)+this.dim.yscroll)-(this.loadingimgheight/2) + 'px'
											});
										
	},
	removeloader : 			function (){
							Lib.Dom.Elm.Style.add(this.elmloadingimg, {
											'display'		: 'none'
											});
	},
	open : 				function (e,elm){
							this.updateDim();
							this.coverpage();
							this.showloader();
							
							var link = elm.link;
							
							link = link.split("?")[0];
							link = link.split("&")[0];
							
							var ext = (link.substring((link.lastIndexOf(".")+1))).toLowerCase();
							if (ext == "gif" || ext == "jpg" || ext == "jpeg" || ext == "png"){
							  this.callImage(elm);
							}else {
							  this.callPage(elm);
							}
	},
	openDirectImage : 		function (link){
							this.updateDim();
							this.coverpage();
							this.showloader();
							this.callPath(link);
	
	},
	close : 			function (){
							this.uncoverpage();
							this.closePage();
							this.hideCloseButton();
	},
	coverpage : 			function (){
							if (!this.fullscreen){
								this.create();
							}
							Lib.Dom.Elm.Style.add(this.fullscreen, {
											'backgroundColor'	: this.color,
											'width'			: this.dim.xfull + 'px',
											'height'		: this.dim.yfull + 'px',
											'position'		: 'absolute',
											'top'			: '0px',
											'left'			: '0px',
											'display'		: 'block',
											'zIndex'		: '1000000'
											});
							Lib.Dom.Elm.Opacity.changeOpac(this.opacity, this.fullscreen);
	},
	uncoverpage : 			function (){
							Lib.Dom.Elm.Style.add(this.fullscreen, {
											'width'			: '200px',
											'height'		: '200px',
											'display'		: 'none'
											});
							
	},
	callImage : 			function (elm){
							var loadedimg = new Image();
							loadedimg.onload=Lib.delegate(this, this.recieveImage, elm.link);
							loadedimg.src = elm.link;
							
	},
	callPath : 			function (path){
							var loadedimg = new Image();
							loadedimg.onload=Lib.delegate(this, this.recieveImage, path);
							loadedimg.src = path;
							
	},
	recieveImage : 			function (uselink, link){
	                
							this.status = 1;
							if (link){
							 uselink = link;
							}
							this.holderimage.style.width = 'auto';
							this.holderimage.style.height = 'auto';
							Lib.Dom.Elm.Opacity.changeOpac(0, this.contentviewer);
							
							this.holderimage.src = uselink;
							this.repositionElements();
							
														
	},
	repositionElements : 		function (){
							this.updateDim();
							Lib.Dom.Elm.Style.add(this.contentviewer, {
									'display'	: 'block',
									'left'		: '-1000px',
									'top'		: '-1000px'
									});
							Lib.Dom.Elm.Style.add(this.holderimage, {
									'display'	: 'block'
									});
									
							Lib.Dom.Elm.Style.add(this.ajaxholder, {
									'display'	: 'none'
									});
									

							var width = this.holderimage.clientWidth;
							var height = this.holderimage.clientHeight;
							var ratio_orig = width/height;
							if (width > this.dim.xview || height > this.dim.yview){
							  if (this.dim.xview/this.dim.yview > ratio_orig) {
							    width = this.dim.yview*ratio_orig;
							    height = this.dim.yview;
							  }else {
							    height = this.dim.xview/ratio_orig;
							    width = this.dim.xview;
							  }
							  this.holderimage.style.width = width-this.padding[1]-this.padding[3] + 'px';
							  this.holderimage.style.height = height-this.padding[0]-this.padding[2] + 'px';
							}else {
							 this.holderimage.style.width = width+'px';
							 this.holderimage.style.height = height+'px';
							 width += this.padding[1]+this.padding[3];
							 height += this.padding[0]+this.padding[2];
							}
							this.updateDim();
							this.showPage(width, height);
							this.showCloseButton(width, height);
							this.removeloader();
	},
	callPage : 			function (elm){
							var sendpage = elm.link;
							sendpage += ((sendpage.indexOf("?") == -1?'?':'&')+'popup=1');
							this.ajax = new Lib.Ajax.HttpText(elm.link);
							this.ajax.onrecieve = Lib.delegate(this, this.recievePage);
							this.ajax.send();
	},
	recievePage : 			function (data){
							this.status = 1;
							this.updateDim();
							this.removeloader();
							Lib.Dom.Elm.Style.add(this.ajaxholder, {
									'display' 	: 'block'
							});
							Lib.Dom.Elm.Style.add(this.holderimage, {
									'display'	: 'none'
									});
							this.showPage();
							this.showCloseButton();
							this.ajaxholder.scrollTop = 0;
							this.ajaxholder.innerHTML = data;
							
	},
	showPage : 			function(width, height){
	 
							if (!width || !height){
							  width = this.pagex;
							  height = this.pagey;
							}
							
							Lib.Dom.Elm.Style.add(this.contentviewer, {
									'display'		: 'block',
									'width'			: width+'px',
									'height'		: height+'px',
									'left' 			: (this.dim.xfull/2)-(width/2) + 'px',
									'top' 			: ((this.dim.yview/2)+this.dim.yscroll)-(height/2) + 'px'
								});
							
							Lib.Dom.Elm.Style.add(this.ajaxholder, {
									'height'		: height-(this.padding[0]+this.padding[2])+'px'
								});
								Lib.Dom.Elm.Opacity.changeOpac(100, this.contentviewer);

	
							
	},
	closePage : 			function (){
							this.status = 0;
							this.ajaxholder.innerHTML = '';
							Lib.Dom.Elm.Style.add(this.ajaxholder, {
											'width'		: 'auto'
									});
							Lib.Dom.Elm.Style.add(this.contentviewer, {
											'display' 		: 'none',
											'width'			: '200px',
											'height'		: '200px',
											'left'			: '0px',
											'top'			: '0px'
								});
							Lib.Dom.Elm.Style.add(this.holderimage, {
									'display'	: 'none'
									});
							
	},
	createCloseButton : 		function (){
							this.closebutton = Lib.Dom.Elm.create("a", {
											'position'		: 'absolute',
											'display' 		: 'none',
											'width'			: '100px',
											'zIndex'		: '1000002'
							});
							this.closebutton.href = 'javascript:void(0);';
							Lib.Dom.addEvent(this.closebutton, 'click', Lib.delegate(this, this.close));
							this.closebutton.innerHTML = "<img src=\""+baseurl+"img/close.gif\" border=\"0\" />";
							this.closebutton.id = 'lightbox_close';
							this.body.appendChild(this.closebutton);
							
	},
	showCloseButton : 		function (width, height){
							if (!this.closebutton){
							  this.createCloseButton();
							}
							if (!width || !height){
							  width = this.pagex;
							  height = this.pagey;
							}
							Lib.Dom.Elm.Style.add(this.closebutton, {
											'position'		: 'absolute',
											'display' 		: 'block',
											'zIndex'		: '1000002',
											'textAlign'		: 'right',
											'left' 			: (this.dim.xfull/2)+(width/2)-100 + 'px',
											'top' 			: ((this.dim.yview/2)+this.dim.yscroll)-(height/2) + 'px'
							});
	},
	hideCloseButton : 		function (){
							Lib.Dom.Elm.Style.add(this.closebutton, {
											'display'		: 'none',
											'left'			: '0px',
											'top'			: '0px'
							
							});
	}
});

Lib.Self = {};
Lib.Self.Libraries = {
	get:				function (){
							this.libraries = [];
							this._getLib(Lib, "Lib");
							return this.libraries;
	},
	_getLib: 			function (library, source){
							for (param in library){
							 if (typeof library[param] == "object"){
							  this._getLib(library[param], source+'.'+param);
							 }else if (typeof library[param] == "function"){
							  if (typeof library[param].prototype != undefined){
							   if (param != "extend" && param != "base" && param != "constructor" && param.substr(0,1) != "_"){
								this.libraries.push(source+'.'+param+"()");
								this._getLib(library[param].prototype, source+'.'+param);
							   }
							  }
							 }
							}
	}
};
Lib.XML = {};



Lib.XML._XMLToObject = Base.extend({
	constructor :			function (params, type){
							this.type = type;
							this.filledreturn = this.parse(params);
	},
	parse : 			function (params, myobj){

							myobj = (myobj?myobj:this.create());
							var pCounter = 0;

							for (var p=0; p<params.childNodes.length; p++){
							
								if (params.childNodes[p].nodeType == 1){

								  if (params.getElementsByTagName(params.childNodes[p].nodeName).length > 1){
									var useName = params.childNodes[p].nodeName + "_"+pCounter;
								  }else {
									var useName = params.childNodes[p].nodeName;
								  }
								  
								  var checkchild = false;
								  if (params.childNodes[p].childNodes.length > 0){
								   for (var a=(params.childNodes[p].childNodes.length-1); a>=0; --a){
								    if (params.childNodes[p].childNodes[a].nodeType != 3){
								      checkchild  = params.childNodes[p].childNodes[a];
								    }
								   }
								  }
								 

								  if (checkchild){
								   if (checkchild.nodeType == 4){
								    var val = checkchild.nodeValue;
								   }else {
								    var val = this.parse(params.childNodes[p], this.create());
								   }
								   (this.type == Lib.Collections.Hashtable?myobj.put(useName,val):myobj[useName] =val);
								  }
								  pCounter++;
								}
							}
							return myobj;
	},
	create : 			function (){
							if (this.type){
							 return new (this.type)();
							}else {
							 return {};
							}
	},
	get :				function (){
							return this.filledreturn;
	}
});
Lib.XML.xmlToObject = 			function (params, type){
							var obj = new Lib.XML._XMLToObject(params, type);
							return obj.get();
};


Lib.Dom.Images.PreloadImage = Base.extend({
				'constructor'		: function (path){
											this.path = path;
											this.image = new Image();
											this.width = false;
											this.height = false;
				},
				'setblurb' :      function (blurb){
				                            this.blurb = blurb;
				},
				'getblurb'  :       function (){
				                            return this.blurb;
				},
				'load'				: function (){
											this.image.onload = Lib.delegate(this, this.beforeonload);
											this.image.src = this.path;
				},
				'beforeonload'		: function (){
											this.width = this.image.width;
											this.height = this.image.height;
											this.onload(this);			
				},
				'onload'			: function (){
										
				}
});
var advSS = Base.extend({
    constructor : function (holderid, transactiontime, pause){
									
										this.container_height = 0;
										this.container_width = 0;
										this.container = null;
										this.started = false;
										this.images = [];
										this.currentimage = false;
										this.displayimages = [];
										this.paths = {};
										this.loadedimages = [];
										this.switchCount = 0;
										this.transactiontime = transactiontime;
										this.pause = pause;
										this.panspeed = 25;
									    this.holderid = holderid;
										callWhenDOMLoaded(Lib.delegate(this, this.create))
    },
    addImage :  function (image, text){
                                        this.paths[image] = text;
    },
    create: function (){
                                        this.holder = $(this.holderid);
                                        this.blurbholder = Lib.Dom.getElementsByClassName(this.holder, "div", "ssblurb")[0];
                                        this.container = Lib.Dom.getElementsByClassName(this.holder, "div", "ssimgholder")[0];
										this.container_height = this.container.clientHeight;
										this.container_width = this.container.clientWidth;
										
										var defaultImageStyle = {
											'position'	: 	'absolute',
											'height'	:  this.container_height + 'px',
											'cursor' : 'pointer'
										};
										this.container.innerHTML = '';
										var dispimg = Lib.Dom.Elm.create("img",defaultImageStyle);
										Lib.Dom.addEvent(dispimg, "click", Lib.delegate(this, this.onclick));
										this.displayimages.push(dispimg);
										var dispimg2 = Lib.Dom.Elm.create("img",defaultImageStyle);
										Lib.Dom.addEvent(dispimg2, "click", Lib.delegate(this, this.onclick));
										this.displayimages.push(dispimg2);
										for (var i=0; i<this.displayimages.length; i++){
											this.displayimages[i].id = 'display_'+i;
										}
										
										Lib.Dom.Elm.Style.add(this.container, {
											'overflow'	: 	'hidden',
											'position' 	:   'relative'
										});
										
										
										for (var i=0; i<this.displayimages.length; i++){
											Lib.Dom.Elm.Opacity.changeOpac(0, this.displayimages[i]);
											this.container.appendChild(this.displayimages[i]);
										}
										
	
										this.createButtons();
									
										for (param in this.paths ){
											var img = new Lib.Dom.Images.PreloadImage(param);
											img.setblurb(this.paths[param]);
											img.onload = Lib.delegate(this, this.imageLoad, img);
											img.load();
											this.images.push(img);
										}
										
										
										
    },
    createButtons           : function (){
                                        this.backbutton = Lib.Dom.Elm.create("a", {
                                                'position' : 'absolute',
                                                'bottom'    : '0px',
                                                'left'      : '0px',
                                                'display' : 'block',
                                                'width'  : '35px',
                                                'height' : '34px',
                                                'backgroundColor' : '#000',
                                                'textIndent' : '-1000px',
                                                'backgroundImage' : 'url('+baseurl+'img/slideshowback.gif)',
                                                'zIndex' : 1000
                                        });
                                        this.backbutton.appendChild(document.createTextNode("<<"));
                                        this.container.appendChild(this.backbutton);
                                        this.backbutton.href = 'javascript:void(0);';
                                        Lib.Dom.addEvent(this.backbutton, "click", Lib.delegate(this,this.back));
                                        
                                        this.forwardbutton = Lib.Dom.Elm.create("a", {
                                                'position' : 'absolute',
                                                'bottom'    : '0px',
                                                'right'      : '0px',
                                                'display' : 'block',
                                                'width'  : '35px',
                                                'height' : '34px',
                                                'backgroundColor' : '#000',
                                                'zIndex' : 1000,
                                                'textIndent' : '-1000px',
                                                'backgroundImage' : 'url('+baseurl+'img/slideshowforward.gif)'
                                        });
                                        this.forwardbutton.href = 'javascript:void(0);';
                                        Lib.Dom.addEvent(this.forwardbutton, "click", Lib.delegate(this,this.forward));
                                        this.forwardbutton.appendChild(document.createTextNode(">>"));
                                        this.container.appendChild(this.forwardbutton);
    },
    back :                  function (){
										var tmp = this.loadedimages.pop();
										this.loadedimages.unshift(tmp);
										var image = this.loadedimages.pop();
										var holder = this.displayimages.shift();
										
										
										this.currentimage = image.path;
										holder.left = 0;
										holder.top = 0;
										Lib.Dom.Elm.Opacity.changeOpac(0,holder);
										holder.src = image.path;
										Lib.Dom.Elm.Style.add(holder, {
												'zIndex' : this.switchCount++,
												'width'  : image.usewidth + 'px',
												'height' : image.useheight + 'px',
												'top'	 : '0px',
												'left'	 : '0px'
												});
												
										this.blurbholder.innerHTML = image.getblurb();
										
										distanceWidth = image.usewidth-this.container_width;
										distanceHeight = image.useheight-this.container_height;
									
										totaltransactiontime = (this.transactiontime+this.pause)*1.1;
										
										perjump_x = (distanceWidth>0)?((distanceWidth/totaltransactiontime)*this.panspeed):0;
										perjump_y = (distanceHeight>0)?((distanceHeight/totaltransactiontime)*this.panspeed):0;
										
										clearTimeout(holder.movetimeout);
										holder.movetimeout = setTimeout(Lib.setTimeoutDelegate(this, this.moveImage, holder, perjump_x, perjump_y), this.panspeed);
										Lib.Dom.Elm.Opacity.opacity(holder.id, false, 100, this.transactiontime);
										this.loadedimages.push(image);
										this.displayimages.push(holder);
										clearTimeout(holder.changetimeout);
										holder.changetimeout =setTimeout(Lib.setTimeoutDelegate(this, this.changeImage, image), this.transactiontime+this.pause);             
                                      
    },
    forward :               function (){
                                        this.changeImage();
    },
    onclick                 : function (){
										lightbox.openDirectImage(this.currentimage);
    },
	imageLoad				: function (e,image){
										if (image.useheight == null || image.usewidth == null){
												var width = 0;
												var height = 0;
												var ratio = (image.width/image.height);
												if (this.container_width/this.container_height < ratio) {
													image.useheight = Math.floor(this.container_height);
													image.usewidth = Math.floor(this.container_height*ratio);
												}else {
													image.usewidth = Math.floor(this.container_width);
													image.useheight = Math.floor(this.container_width/ratio);
												}
										}
										this.loadedimages.unshift(image);
										if (!this.started) this.start();
	},
	start				: 		function (){
										this.started = true;
										this.changeImage();
	},
	changeImage			: 	function (){
										var image = this.loadedimages.shift();
										var holder = this.displayimages.shift();
										this.currentimage = image.path;
										holder.left = 0;
										holder.top = 0;
										Lib.Dom.Elm.Opacity.changeOpac(0,holder);
										holder.src = image.path;
										Lib.Dom.Elm.Style.add(holder, {
												'zIndex' : this.switchCount++,
												'width'  : image.usewidth + 'px',
												'height' : image.useheight + 'px',
												'top'	 : '0px',
												'left'	 : '0px'
												});
												
										this.blurbholder.innerHTML = image.getblurb();
										
										distanceWidth = image.usewidth-this.container_width;
										distanceHeight = image.useheight-this.container_height;
									
										totaltransactiontime = (this.transactiontime+this.pause)*1.1;
										
										perjump_x = (distanceWidth>0)?((distanceWidth/totaltransactiontime)*this.panspeed):0;
										perjump_y = (distanceHeight>0)?((distanceHeight/totaltransactiontime)*this.panspeed):0;
										
										clearTimeout(holder.movetimeout);
										holder.movetimeout = setTimeout(Lib.setTimeoutDelegate(this, this.moveImage, holder, perjump_x, perjump_y), this.panspeed);
										Lib.Dom.Elm.Opacity.opacity(holder.id, false, 100, this.transactiontime);
										this.loadedimages.push(image);
										this.displayimages.push(holder);
										clearTimeout(holder.changetimeout);
										holder.changetimeout =setTimeout(Lib.setTimeoutDelegate(this, this.changeImage, image), this.transactiontime+this.pause);
	},
	moveImage		: 	function (holder, perjump_x, perjump_y){
							if (holder.left == null){
								holder.left = 0;
							}
							if (holder.top == null){
								holder.top = 0;
							}
							holder.left-=perjump_x;
							holder.top-=perjump_y;
							Lib.Dom.Elm.Style.add(holder, {
								'left'		: Math.round(holder.left)+'px',
								'top'		: Math.round(holder.top)+'px'	
							});

							if ((0-holder.left) <  (holder.width-this.container_width)|| 0-holder.top < (holder.height-this.container_height)){
								clearTimeout(holder.movetimeout);
								holder.movetimeout = setTimeout(Lib.setTimeoutDelegate(this, this.moveImage, holder,perjump_x, perjump_y), this.panspeed);
							}
							
	}
});

// shortcut to Lib.Dom.Elm.find()
$ = function (e){return Lib.Dom.Elm.find(e);};
// shortcut to call when dom loaded
callWhenDOMLoaded = function(a){return Lib.Dom.callWhenDOMLoaded(a);};
if (document.addEventListener) {
  document.addEventListener("DOMContentLoaded", Lib.Dom._domLoadedEvent, null);
}
window.onload = Lib.Dom._domLoadedEvent;

