/**
 * Project:     WOMBAT
 * File:        DOMbat.js
 * Description:	Library for DOM propeties and manipulation
 * *
 * @copyright 2006 Multimedia Foundry Holdings, LLC
 * @copyright Use subject to licensing.
 * @author Joseph Bulaswad <joe.bulaswad at mf dot bz>
 * @package WOMBAT
 * @version alpha
 */
var Ajax={
	//TODO: create async option for firefox
	request:function(strXmlUrl,boolAsync,strCallBack){
		if (navigator.appName=='Microsoft Internet Explorer') {
	        var objXmlDoc = new ActiveXObject("Microsoft.XMLDOM");
	        //var objXmlDoc=Ajax.fetchXmlHttpRequest();
	        if(boolAsync){
	        	objXmlDoc.async=true;
	        	objXmlDoc.onreadystatechange=function(){
	        		if(objXmlDoc.readyState==4){
			        	try{
			        		eval(strCallBack);
			        	}catch(error){}
        				return objXmlDoc;
	        		}
	        	};
	        	objXmlDoc.load(strXmlUrl);
	        } else {
	        	objXmlDoc.async = false;
	        	objXmlDoc.load(strXmlUrl);
	        	try{
	        		eval(strCallBack);
	        	}catch(error){}
	        	return objXmlDoc;
	        }
		} else if(navigator.userAgent.indexOf("Firefox")!=-1){
			var objXmlHttpRequest=Ajax.fetchXmlHttpRequest();
	        objXmlHttpRequest.open("GET", strXmlUrl, false);
	        objXmlHttpRequest.send(null);
	        return objXmlHttpRequest.responseXML;
		}
	},
	requestPlainText:function(strUrl,callBackFunction){
		if (navigator.appName=='Microsoft Internet Explorer') {
	        var objXmlDoc=new ActiveXObject("Microsoft.XMLDOM");
	        objXmlDoc.async = false;
	        objXmlDoc.load(strXmlUrl);
	        return objXmlDoc;
		} else if(navigator.userAgent.indexOf("Firefox")!=-1){
			var objXmlHttpRequest=Ajax.fetchXmlHttpRequest();
	        objXmlHttpRequest.open("GET", strUrl, true);
	        objXmlHttpRequest.onreadystatechange=function(callBackFunction) {
					if(objXmlHttpRequest.readyState==4){
						if(objXmlHttpRequest.status==200){
							eval(objXmlHttpRequest.responseText);
						}
					}
	        };
	        objXmlHttpRequest.send(null);
	       // return objXmlHttpRequest.responseText;
		}
	},
	update:function(strXmlUrl,objElement){
		if (navigator.appName=='Microsoft Internet Explorer') {
	        var objXml;
	        objXML=new ActiveXObject("Microsoft.XMLHTTP");
	        objXml.async = false;
	        objXml.load(strXmlUrl);
	        Element.update(objElement,objXML);
		} else if(navigator.userAgent.indexOf("Firefox")!=-1){
			var objXmlHttpRequest=Ajax.fetchXmlHttpRequest();
	        objXmlHttpRequest.open("GET", strXmlUrl, false);
	        objXmlHttpRequest.send(null);
	        Element.update(objElement,objXmlHttpRequest.responseXML);
		}
	},
	fetchXmlHttpRequest:function(){
		try {
			if(window.XMLHttpRequest) {
				var objXMLHttpRequest = new XMLHttpRequest();
				// some versions of Mozilla do not support the readyState property and the onreadystate event so we patch it!
				if(objXMLHttpRequest.readyState === null) {
					objXMLHttpRequest.readyState = 1;
					objXMLHttpRequest.addEventListener("load",function(){objXMLHttpRequest.readyState=4;if(typeof objXMLHttpRequest.onreadystatechange == "function")objXMLHttpRequest.onreadystatechange();},false);
				}
				return objXMLHttpRequest;
			}
			if(window.ActiveXObject) return new ActiveXObject(Ajax._fetchMSXmlHttpProgramId());
		} catch (ex) {  }
		throw new Error("Your browser does not support XmlHttp objects");
	},
	_fetchMSXmlHttpProgramId:function(){
		//test to see if the program id is set
		var arrProgramIds = ["Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
		var objActiveXObject;
		for(var i = 0; i < arrProgramIds.length; i++) {
			try {
				objActiveXObject = new ActiveXObject(arrProgramIds[i]);
				return arrProgramIds[i];
			} catch (ex) {};
		}
		throw new Error("Could not find an installed XML parser");
	}
};
Array.prototype.inArray=function(value){
	var i;
	for(i=0; i < this.length; i++){
		if(this[i] === value){
			return true;
		}
	}
	return false;
};
if (!Array.prototype.push) {
    Array.prototype.push = function(elem) {
        this[this.length] = elem;
    }
}
Array.prototype.rand=function(arrData){
	for(var i,j,k=arrData.length;k;i=parseInt(Math.random()*k),j=arrData[--k],arrData[k]=arrData[i],arrData[i]=j);
	return arrData;
};
var Effect={
	fontGrow:function(objElementId,intCurrent,intTo,intSpeed){
		if(intCurrent!==intTo){
			intCurrent++;
			document.getElementById(objElementId).style.fontSize=intCurrent+'pt';
			setTimeout("Effect.fontGrow('"+objElementId+"',"+intCurrent+","+intTo+")",intSpeed);
		} else {
			return true;
		}
	}
};
var Browser={
	getFullScreenHeight:function() {
		return document.all ? Math.max(Math.max(document.documentElement.offsetHeight, document.documentElement.scrollHeight), Math.max(document.body.offsetHeight, document.body.scrollHeight)) : (document.body ? document.body.scrollHeight : ((document.documentElement.scrollHeight != 0) ? document.documentElement.scrollHeight : 0));
	},
	getVisibleScreenHeight:function() {
		return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
	},
	getVisibleScreenWidth:function() {
		return  window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?  document.documentElement.clientWidth : document.body != null? document.body.clientWidth : null;
	},
	showFullSizeImage:function (imageURL, imageTitle, intWidth, intHeight) {
		// Create mask
		var objDiv = document.createElement('div');
		objDiv.style.position = "absolute";
		objDiv.style.top = 0;
		objDiv.style.left = 0;
		if (intWidth) {
			objDiv.style.width = intWidth + "px";
		}
		if (intHeight) {
			objDiv.style.height = intHeight + "px";
		}
		objDiv.style.backgroundColor = "#000000";
		if (navigator.appName.indexOf("Netscape") != -1 && parseInt(navigator.appVersion) >= 5) {
			objDiv.style.MozOpacity=0.35
			objDiv.style.opacity=0.35;
		} else if (navigator.appName.indexOf("Microsoft") != -1 && parseInt(navigator.appVersion) >= 4){
			objDiv.style.filter="alpha(opacity=35)";
		} else {
			objDiv.style.opacity="0.35";
		}
		objDiv.style.width = Browser.getVisibleScreenWidth() + "px";
		objDiv.style.height = Browser.getFullScreenHeight() + "px";
		document.body.appendChild(objDiv);
		// Create container
		var objContainer = document.createElement('div');
		objContainer.style.position = "absolute";
		objContainer.style.border = "2px solid #083056";
		objContainer.style.left = 0;
		objContainer.style.top = 0;
		objContainer.style.cursor = "move";
		// Create image
		var objImg = new Image();
		objImg.src = imageURL;
		objImg.style.border = "1px solid #444444";
		if (intWidth) {
			objImg.style.width = intWidth + "px";
		}
		if (intHeight) {
			objImg.style.height = intHeight + "px";
		}
		objContainer.appendChild(objImg);
		document.body.appendChild(objContainer);
		// Create close button
		var objButton = document.createElement('button');
		objButton.style.width = "75px";
		objButton.style.position = "absolute";
		objButton.style.border = "2px solid #000000";
		objButton.style.backgroundColor = "#FFFFFF";
		objButton.style.fontWeight = "bold";
		objButton.style.cursor = "pointer";
		objButton.appendChild(document.createTextNode('Close'));
		objContainer.appendChild(objButton);
		// Positioning / sizing event
		var objAddMe = function () {
			var intScrollTop;
			if (document.body.parentElement) {
				intScrollTop = document.body.parentElement.scrollTop;
			} else {
				intScrollTop = document.body.parentNode.scrollTop;
			}
			objContainer.style.left = ((Browser.getVisibleScreenWidth() / 2) - (Element.width(objContainer) / 2)) + "px";
			objContainer.style.top = ((Browser.getVisibleScreenHeight() / 2) - (Element.height(objContainer) / 2)) + intScrollTop + "px";
			objButton.style.left = '5px';//((Browser.getVisibleScreenWidth() / 2) - (Element.width(objContainer) / 2)) + "px";
			objButton.style.top = '5px';//((Browser.getVisibleScreenHeight() / 2) - (Element.height(objContainer) / 2) + 5) + intScrollTop + "px";
			// Make it draggable
		    dojo.require("dojo.dnd.Moveable");
		    var objDrag = new dojo.dnd.Moveable(objContainer);
			// Events
			var objRemoveMe = function (e) {
				if (window.event) {
					window.event.cancelBubble = true;
				}
				document.body.removeChild(objContainer);
				document.body.removeChild(objDiv);
				delete objImg;
				delete objDiv;
				delete objButton;
				return false;
			}
			objDiv.onclick = objRemoveMe;
			objButton.onclick = objRemoveMe;
		}
		objImg.onload = objAddMe;
		objAddMe();
	}
};
var Cookie={
	create:function(strName, strValue, intHours){
		intHours = 3;
		if(intHours){
			var objDate=new Date();
			objDate.setTime(objDate.getTime()+(intHours*60*60*1000));
			var strExpires=objDate.toGMTString();
		} else {
			var strExpires='';
		}
		//TODO add secure bool when ready
		document.cookie=strName+'='+encodeURIComponent(strValue)+'; expires='+strExpires+';path=/;';
		
	},
	destroy:function(strValues){
		Cookie.create(strValues,-1);
	},
	
	fetch:function(strName){
		var dc = document.cookie;
		var prefix = strName + "=";
		var begin = dc.indexOf("; " + prefix);
		if (begin == -1) {
			begin = dc.indexOf(prefix);
			if (begin != 0) return null;
		} else
			begin += 2;
		var end = document.cookie.indexOf(";", begin);
		if (end == -1)
			end = dc.length;
		return unescape(dc.substring(begin + prefix.length, end));
	},
	
	toQueryString:function(){
		var arrCookie=String(document.cookie).split(';');
		var strCookie=arrCookie.join('&');
		return String(strCookie).replace(/ /,"");
	},
	
	GetCookie:function( strName ) {
		var start = document.cookie.indexOf( strName + "=" );
		var len = start + strName.length + 1;
		if ( ( !start ) && ( strName != document.cookie.substring( 0, strName.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 ) );
	},
	
	CheckCookies:function() {
		this.create( 'test', 'none', '' );
		if ( this.GetCookie( 'test' ) ) {
			//do nothing, cookies are enabled.
			cookie_set = true;
			this.destroy('test', '/', '');
			error = null;
		} else {
			error = 'Cookies are not currently enabled. You must enable cookies to use this site.';
			cookie_set = false;
		}
		return error;
	}
};
var DOM={
	createTable:function(intPadding,intSpacing,intBorder,strAttributes){
		if(!intPadding) intPadding=0;
		if(!intSpacing) intSpacing=0;
		if(!intBorder) intBorder=0;
		try{
			var objTable=document.createElement('<table cellpadding="'+intPadding+'" cellspacing="'+intSpacing+'" border="'+intBorder+'" '+strAttributes+'/>');
		}catch(error){
			var objTable=document.createElement("table");
			objTable.setAttribute("cellpadding",intPadding);
			objTable.setAttribute("cellspacing",intSpacing);
			objTable.setAttribute("border",intBorder);
			if(strAttributes){
				var arrAttributes=strAttributes.split(' ');
				for(var i=1;i<arrAttributes.length;i++){
					if(arrAttributes[i].match('=')){
						arrAttrib=arrAttributes[i].split('=');
						objTable.setAttribute(arrAttrib[0],arrAttrib[1].replace(/"/,'')); //"Comment because of Zend
					} else {
						objTable.setAttribute(arrAttributes[i]);
					}
				}
			}
		}
		objTable.body=document.createElement("tbody");
		objTable.appendChild(objTable.body);
		objTable.body.row=document.createElement("tr");
		objTable.body.appendChild(objTable.body.row);
		objTable.body.row.cell=document.createElement("td");
		objTable.body.row.appendChild(objTable.body.row.cell);
		return objTable;
	},
	createImgSpacer:function(strPath,intWidth,intHeight){
		if(!intWidth) intWidth=1;
		if(!intHeight) intHeight=1;
		try{
			var objImg=document.createElement('<img src="'+strPath+'" width="'+intWidth+'" height="'+intHeight+'" border="0"/>');
		}catch(error){
			var objImg=document.createElement("img");
			objImg.setAttribute("src",strPath);
			objImg.setAttribute("width",intWidth);
			objImg.setAttribute("height",intHeight);
			objImg.setAttribute("border",0);
		}
		return objImg;
	}
}
var Element={
	disableHighlight:function(objElement){
		objElement.contentEditable=true;
		objElement.onselectstart=function(){
			return false;
		}
	},
	disableSelect:function(objElement){
		objElement.onselectstart=function(){return false;}
		objElement.onmousedown=function(){return false;}
	},
	height:function(objElement){
		return objElement.offsetHeight;
	},
	totalOffsetLeft:function(objElement){
		var left=0;
		while(objElement.offsetParent){
			left+=objElement.offsetLeft||0;
			objElement=objElement.offsetParent;
		}
		left+=objElement.offsetLeft;
		return left;
	},
	totalOffsetTop:function(objElement){
		var top=0;
		while(objElement.offsetParent){
			top+=objElement.offsetTop||0;
			objElement=objElement.offsetParent;
		}
		top+=objElement.offsetTop;
		return top;
	},
	update:function(objElement,strContent){
		if(navigator.appName=='Microsoft Internet Explorer'){
			objElement.innerHTML=strContent;
		} else if(navigator.userAgent.indexOf("Firefox")!=-1){
			objElement.innerHTML='';
			objElement.appendChild(strContent);
		}
	},
	replace:function(objElement,objNewNode,objParent ){
		if(navigator.appName=='Microsoft Internet Explorer'){
			objElement.innerHTML=objNewNode;
		} else if(navigator.userAgent.indexOf("Firefox")!=-1){
			//TODO: Replace Child for this element
			objElement.appendChild(objNewNode);			
		}
	},
	width:function(objElement){
		return objElement.offsetWidth;
	}
};
var EventManager = {
    _registry: null,
    Initialize: function () {
        if (this._registry == null) {
            this._registry = [];
            EventManager.add(window, "unload", this.clean);
        }
    },
    add: function (obj, type, fn, useCapture) {
        this.Initialize();
        if (typeof obj == "string") {
            obj = document.getElementById(obj);
        }
        if (obj == null || fn == null) {
            return false;
        }
        // Mozilla
        if (obj.addEventListener) {
            obj.addEventListener(type, fn, useCapture);
            this._registry.push({obj: obj, type: type, fn: fn, useCapture: useCapture});
            return true;
        }
        // IE
        if (obj.attachEvent && obj.attachEvent("on" + type, fn)) {
            this._registry.push({obj: obj, type: type, fn: fn, useCapture: false});
            return true;
        }
        return false;
    },
    clean: function () {
        for (var i = 0; i < EventManager._registry.length; i++) {
            with (EventManager._registry[i]) {
                if (obj.removeEventListener) {
                	obj.removeEventListener(type, fn, useCapture);
                } else if (obj.detachEvent) {
                    obj.detachEvent("on" + type, fn);
                }
            }
        }
        EventManager._registry = null;
    },
    getTarget: function (e) {
		var objTarget;
		if (!e) var e = window.event;
		if (e.target) objTarget = e.target;
		else if (e.srcElement) objTarget = e.srcElement;
		if (objTarget.nodeType == 3) {
			objTarget = objTarget.parentNode;
		}
		return objTarget;
    },
    remove: function (obj, type, fn, useCapture) {
		if (obj.removeEventListener) {
			obj.removeEventListener(type, fn, useCapture);
		} else if (obj.detachEvent) {
			obj.detachEvent("on" + type, fn);
		}
    }
};
var Form={
	inputsToQueryString:function(objElement){
        var strValues='';
        var objFormElement;
        var strLastElemName = '';
        // Inputs
        var objArrInputs=objElement.getElementsByTagName('input');
        for (var i=0;i<objArrInputs.length;i++) {
            objFormElement=objArrInputs[i];
            if (objFormElement.name != ''){
	            switch (objFormElement.type) {
	                case 'checkbox':
		                if(objFormElement.checked)
		                       strValues+=objFormElement.name+'='+escape(objFormElement.value)+'&';
		                	else
		                       strValues+=objFormElement.name+'=0&';
		                    break;
					case 'radio':
		                if(objFormElement.checked)
		                       strValues+=objFormElement.name+'='+escape(objFormElement.value)+'&';
		                    break;
	                case 'text':
	                case 'select-one':
	                case 'hidden':
	                case 'password':
	                       strValues+=objFormElement.name+'='+escape(objFormElement.value)+'&'
	                break;
	            }
            }
        }
        // FCK editor
        var objArrFCKeditors=objElement.getElementsByTagName('iframe');
        for (var i=0;i<objArrFCKeditors.length;i++) {
       		FCKeditorAPI.GetInstance(objArrFCKeditors[i].nextSibling.name).UpdateLinkedField();
        }
        // Textareas
        var objArrTextareas=objElement.getElementsByTagName('textarea');
        for (var i=0;i<objArrTextareas.length;i++) {
            if (objArrTextareas[i].name != ''){
				strValues+=objArrTextareas[i].name+'='+escape(objArrTextareas[i].value)+'&'
            }
        }
        // Selects
        var objArrSelects=objElement.getElementsByTagName('select');
        for (var i=0;i<objArrSelects.length;i++) {
            if (objArrSelects[i].name != ''){
				strValues+=objArrSelects[i].name+'='+escape(objArrSelects[i].value)+'&'
            }
        }
        return strValues.substr(0,strValues.length-1);
	},
	toQueryString:function(objForm){
        var strValues='';
        var objFormElement;
        var strLastElemName = '';
        for (var i=0;i<objForm.elements.length;i++) {
            objFormElement=objForm.elements[i];
            
            if (objFormElement.name != ''){
	            switch (objFormElement.type) {
	                case 'checkbox':
	                if(objFormElement.checked)
	                       strValues+=objFormElement.name+'='+escape(objFormElement.value)+'&';
	                	else
	                       strValues+=objFormElement.name+'=0&';
	                    break;
					case 'radio':
		                if(objFormElement.checked)
		                       strValues+=objFormElement.name+'='+escape(objFormElement.value)+'&';
		                    break;
	                case 'text':
	                case 'select-one':
	                case 'hidden':
	                case 'password':
	                case 'textarea':
	                       strValues+=objFormElement.name+'='+escape(objFormElement.value)+'&'
	                break;
	            }
            }
        }
        return strValues.substr(0,strValues.length-1);
	},
	disabled_onFieldsChange:function(objForm,strAction,arrFields){
		if(!objForm){
			var boolChange=false;
			for(var i=0;i<Form.fieldsChange.form.elements.length;i++){
	            //add listener
	            switch (Form.fieldsChange.form.elements[i].type) {
	                case 'text':
	                case 'select-one':
	                case 'hidden':
	                case 'password':
	                case 'textarea':
	                	if (Form.fieldsChange.fields[i]!==Form.fieldsChange.form.elements[i].value) boolChange=true;
	                	break;
	                case 'checkbox':
	                	if (Form.fieldsChange.fields[i]!==Form.fieldsChange.form.elements[i].checked) boolChange=true;
	                	break;
	            }
			}
			if(boolChange==true){
				eval(Form.fieldsChange.action);
				clearInterval(Form.FieldsChangeInterval);
				Form.onFieldsChange(Form.fieldsChange.form,Form.fieldsChange.action);
			}
		} else {
			Form.fieldsChange=new Array();
			Form.fieldsChange.fields=new Array();
			Form.fieldsChange.form=objForm;
			Form.fieldsChange.action=strAction;
			for(var i=0;i<objForm.elements.length;i++){
				var strValue=objForm.elements[i].value;
	            //add listener
	            switch (objForm.elements[i].type) {
	            	case 'text':
	                case 'select-one':
	                case 'hidden':
	                case 'password':
	                case 'textarea':
	                	Form.fieldsChange.fields[i]=objForm.elements[i].value;
	                	break;
	                case 'checkbox':
	                	Form.fieldsChange.fields[i]=objForm.elements[i].checked;
	                	break;
					case 'radio':
		                Form.fieldsChange.fields[i]=objForm.elements[i].checked;
		                    break;
	            }
			}
			Form.fieldsChange.interval=setInterval(Form.onFieldsChange,500);
		}
	}
};
var Listener={
	variable:function(objVar,objVal,strStatement){
		var objListener=setInterval("Listener.evaluate('"+objVar+"','"+objVal+"','"+strStatement+"')",100);
	},
	evaluate:function(objVar,objVal,strStatement){
		if(objVar==objVal){
			clearInterval(this.objListener);
			strStatement;
		}
	}
};

var Mouse={
	track:function(e){
		if(navigator.userAgent.indexOf("Firefox")!=-1){
			try{
				x=e.pageX||0;
				y=e.pageY||0;
			}catch(error){
				x=0;
				y=0;
			}
		}else{
			try{
				x=event.clientX+document.body.scrollLeft||0;
				y=event.clientY+document.body.scrollTop||0;
			}catch(error){
				x=0;
				y=0;
			}
		}
		Mouse._x=x;
		Mouse._y=y;
		//window.status='x:'+Mouse._x+' y: '+Mouse._y;
		return true;
	}
}

String.prototype.escapeHTMLEntities=function(){
	var strThis=unescape(this);
	strThis=strThis.replace(/&amp;/g,"&"); //&
	strThis=strThis.replace(/&#38;/g,"&"); //&
	strThis=strThis.replace(/&#43;/g,"&"); //+
	return strThis;
}

var XML={
	createNode:function(strName,strContent,arrAttributes){
		var strAttributes,strNode;
		if(arrAttributes){
			strAttributes=XML._formatAttributes(arrAttributes);
		}
		if(!strContent){
			strNode='<'+strName+strAttributes+'/>';
		} else {
			strNode='<'+strName+strAttributes+'>'+strContent+'</'+strName+'>'
		}
		return strNode;
	},
	fetchLastChild:function(objXMLDoc){
		var objLastChild=objXMLDoc.lastChild;
		while(objLastChild.nodeType!=1){
			objLastChild=objLastChild.previousSibling;
		}
		return objLastChild;
	},
	_formatAttributes:function(arrAttributes){
		var strApos="'";
		var strQuot='"';
		var arrEscQuot=new Array();
		arrEscQuot[strApos]='&quot;';
		arrEscQuot[strQuot]='&apos;';
		var strAttrValue;
		var intAposPos,intQuotPos;
		var strUseQuot,strEscape,boolQuotToEscape
		var strAttributes;
		var objRegExp;
		var strResult='';
		for(var key in arrAttributes){
			strAttrValue=arrAttributes[key];
			//find quotes
			intAposPos=strAttrValue.indexOf(strApos);
			intQuotPos=strAttrValue.indexOf(strQuot);
			//use inputted escaped
			if(intAposPos==-1&&intQuotPos==-1){
				strAttributes=' '+key+"='"+strAttrValue+"'";
				strResult+=strAttributes;
				continue;
			}
			//use single quote unless not possible
			if(intQuotPos!=-1&&intQuotPos<intAposPos){
				strUseQuot=strApos;
			} else {
				strUseQuot=strQuot;
			}
			strEscape=arrEscQuot[strUseQuot];
			objRegExp=new RegExp(strUseQuot,'g');
			strAttributes=' '+key+'='+strUseQuot+strAttrValue.replace(objRegExp,strEscape)+strUseQuot;
			strResult+=strAttributes;
		}
		return strResult;
	}
}

var XSLT={
	create:function(strName,strBody){
		var strHeader='<?xml version="1.0" encoding="utf-8"?>'+
					  '<?xml-stylesheet type="text/xsl"?>'+
					  '<'+strName+'><content></content></'+strName+'>';
//					  '<Component:'+strName+' xmlns:Component="http://www.multimediafoundry.com/wombat/namespaces.html#Component"><content></content></'+strName+'>';
		if (navigator.appName=='Microsoft Internet Explorer') {
	        var objXSLDoc=new ActiveXObject("Microsoft.XMLDOM");
	        objXSLDoc.async=false;
	        objXSLDoc.loadXML(strHeader);
	        var objXMLDoc=new ActiveXObject("Microsoft.XMLDOM");
	        objXMLDoc.async=false;
	        objXMLDoc.loadXML(strBody);
	        objXSLDoc.getElementsByTagName(strName)[0].replaceChild(objXMLDoc.getElementsByTagName('SOAP-ENV:Body')[0],objXSLDoc.getElementsByTagName('content')[0]);
		} else if (navigator.userAgent.indexOf("Firefox")!=-1) {
	        var objXSLParser=new DOMParser();
	        var objXSLDoc=objXSLParser.parseFromString(strHeader,"text/xml");
	        var objXMLParser=new DOMParser();
	        var objXMLDoc=objXMLParser.parseFromString(strBody,"text/xml");
	        objXSLDoc.getElementsByTagName(strName)[0].replaceChild(objXMLDoc.getElementsByTagName('Body')[0],objXSLDoc.getElementsByTagName('content')[0]);
		}
		return objXSLDoc;
	},
	transform:function(objXml, strXslUrl) {
		if (navigator.appName=='Microsoft Internet Explorer') {
	        var objXsl = new ActiveXObject("Microsoft.XMLDOM");
	        objXsl.async = false;
	        objXsl.load(strXslUrl);
	        var objTransformed=objXml.transformNode(objXsl);
		} else if (navigator.userAgent.indexOf("Firefox")!=-1) {
	        var objXsl=Ajax.request(strXslUrl);
	        var objXsltProcessor = new XSLTProcessor();
	        objXsltProcessor.importStylesheet(objXsl);
	        var objTransformed=objXsltProcessor.transformToFragment(objXml, document);
		}
		return objTransformed;
	},
	update:function(strXmlUrl, strXslUrl) {
		if (navigator.appName=='Microsoft Internet Explorer') {
	        var objXml = new ActiveXObject("Microsoft.XMLDOM");
	        objXml.async = false;
	        objXml.load(strXmlUrl);
	        var objXsl = new ActiveXObject("Microsoft.XMLDOM");
	        objXsl.async = false;
	        objXsl.load(strXslUrl);
	        var objTransformed=objXml.transformNode(objXsl);
		} else if (navigator.userAgent.indexOf("Firefox")!=-1) {
	        var objXml=Ajax.request(strXmlUrl);
	        var objXsl=Ajax.request(strXslUrl);
	        var objXsltProcessor = new XSLTProcessor();
	        objXsltProcessor.importStylesheet(objXsl);
	        var objTransformed=objXsltProcessor.transformToFragment(objXml, document);
		}
		return objTransformed;
	}
};

/**************************************************************************************************
* Drag Class
* 
* Creates a drag object. 
* Must be defined via the name drag as an object of the element. 
* Example: document.getElementById('name').drag=new objClassElementDrag();
* 
* @link http://www.logicorps.com/
* @copyright 2007 Logicorps
* @author Joseph M. Bulaswad <joe.bulaswad@logicorps.com>
* @package DOMbat
* @version 1.0.0
*
* @param object objToDrag - object to drag
* @param object objHandle - object handle to initialize drag
* @param boolean boolCopy - option to create and drag a "ghost" copy of the object
* @param integer minX - minumum X position
* @param integer minY - minimum Y position
* @param integer maxX - maximum X position
* @param integer maxY - maximum Y position
* @param string strOnStartCallBack - function to call on drag start
* @param string strOnStopCallBack - function to call on drag stop
*
* Global Objects
* objDrag - used as a pointer for the current drag object
*/
var objDrag=new Object();
function objClassElementDrag(objToDrag,objHandle,boolCopy,minX,minY,maxX,maxY,strOnStartCallBack,strOnDuringCallBack,strOnStopCallBack){
	//properties
	this.intCursorStartX=0;
	this.intCursorStartY=0;
	this.intElementStartX=0;
	this.intElementStartY=0;
	this.minX=minX;
	this.minY=minY;
	this.maxX=maxX;
	this.maxY=maxY;
	this.boolCopy=boolCopy;
	this.boolEnabled=true;
	this.boolTargets=false;
	this.actionFirstQuadrant=new Array();
	this.actionSecondQuadrant=new Array();
	this.actionThirdQuadrant=new Array();
	this.onStartCallBack=strOnStartCallBack;
	this.onDuringCallBack=strOnDuringCallBack;
	this.onStopCallBack=strOnStopCallBack;
	//objects
	this.OriginalElement=objToDrag;
	this.Handle=objHandle;
	this.Element=objToDrag;
	this.timeout=new Object();
	//create a copy	
	if(this.boolCopy==true){
		this.copy();
	}
	//modify these functions and create an observer for each class instance
	if(navigator.appName=='Microsoft Internet Explorer'){
		this.Handle.attachEvent("onmousedown",this.startDrag);
	} else if(navigator.userAgent.indexOf("Firefox")!=-1){
		this.Handle.addEventListener("mousedown",this.startDrag,true);
	}
}
/**
* Drag Out
* 
* Drag Class: Option
* 
* This option will cause an element to be dragged if the element is dragged,
* rather than on mousedown
*/
objClassElementDrag.prototype.dragOut=function(){
	if(navigator.appName=='Microsoft Internet Explorer'){
		this.Handle.detachEvent("onmousedown",this.startDrag);
		this.Handle.attachEvent("ondragstart",this.startDrag);
	} else if(navigator.userAgent.indexOf("Firefox")!=-1){
//		this.Handle.removeEventListener("mousedown",this.startDrag,true);
//		this.Handle.addEventListener("dragstart",this.startDrag,true);
	}
}
/**
* Set Targets
* 
* Drag Class: Option
* 
* This option defines targets for the drag operation, quadrants, and functions to execute 
* @param string strOrientation - quadrant orientation switch *not implemented*
* @param string strActions - ampersand delimited functions to run on defined quadrants.
* @param array objArrElements - drop targets
*/
objClassElementDrag.prototype.setTargets=function(strOrientation,objArrElements,objArrCallBacks){
	this.boolTargets=true;
	this.targets=objArrElements;
	this.actionFirstQuadrant[strOrientation]=objArrCallBacks[0];
	this.actionSecondQuadrant[strOrientation]=objArrCallBacks[1];
	this.actionThirdQuadrant[strOrientation]=objArrCallBacks[2];
}
/**
* Enabled
* 
* Drag Class: Option
* 
* This option can be used to temporary disable the drag properties of an object
* @param boolean boolEnabled - drag the object? true of false
*/
objClassElementDrag.prototype.enabled=function(boolEnabled){
	this.boolEnabled=boolEnabled;
}
/**
* Start Drag
* 
* Drag Class: Internal
* 
* Executes the drag effect
*/
objClassElementDrag.prototype.startDrag=function(objEvent){
	document.onmousemove=Mouse.track;
	if(objEvent){
		if(navigator.appName=='Microsoft Internet Explorer'){
			objEventParent=objEvent.srcElement.parentElement;
			while(objEventParent.parentElement){
				if(objEventParent.drag){
					objDrag=objEventParent.drag;
					break;
				}
				objEventParent=objEventParent.parentElement
			}
		} else if(navigator.userAgent.indexOf("Firefox")!=-1){
			objEventParent=objEvent.target.parentNode;
			while(objEventParent.parentNode){
				if(objEventParent.drag){
					objDrag=objEventParent.drag;
					break;
				}
				objEventParent=objEventParent.parentNode;
			}
		}
	}
	try{
		eval(objDrag.onStartCallBack);
	}catch(error){}
	if(objDrag.boolEnabled==true){
		try{
			document.body.appendChild(objDrag.Element);
		}catch(error){}
		try{
			eval(strOnStartCallBack);
		} catch(error){}
		//save cursor and element starting position
		objDrag.intCursorStartX=Mouse._x;
		objDrag.intCursorStartY=Mouse._y;
		objDrag.intElementStartX=Element.totalOffsetLeft(objDrag.Element);
		objDrag.intElementStartY=Element.totalOffsetTop(objDrag.Element);
		
		if(navigator.appName=='Microsoft Internet Explorer'){
			document.attachEvent("onmousemove",objDrag.drag);
			document.attachEvent("onmouseup",objDrag.stopDrag);
			window.event.cancelBubble=true;
			window.event.returnValue=false;
		} else if(navigator.userAgent.indexOf("Firefox")!=-1){
			document.addEventListener("mousemove",objDrag.drag,true);
			document.addEventListener("mouseup",objDrag.stopDrag,true);
			objEvent.preventDefault();
		}
	}
}
/**
* Drag
* 
* Drag Class: Internal
* 
* Drag the element. 
* Prevents the element from being dragged outside the defined constraint area
* Continuously checks defined target quadrant mouseovers
*/
objClassElementDrag.prototype.drag=function(objEvent){
	objDrag.Element.style.position='absolute';
	
	var intPosX=(objDrag.intElementStartX+Mouse._x-objDrag.intCursorStartX);
	var intPosY=(objDrag.intElementStartY+Mouse._y-objDrag.intCursorStartY);

	//move X
	if(objDrag.minX==null&&objDrag.maxX==null){
		objDrag.Element.style.left=intPosX+'px';
	}else{
		//restrict X
		if(intPosX>objDrag.minX&&intPosX<(objDrag.maxX-Element.width(objDrag.Element))){
			objDrag.Element.style.left=intPosX+'px';
		} else if(intPosX<=objDrag.minX){
			objDrag.Element.style.left=objDrag.minX+'px';
		} else if(intPosX>=(objDrag.maxX-Element.width(objDrag.Element))){
			objDrag.Element.style.left=(objDrag.maxX-Element.width(objDrag.Element))+'px';
		}
	}
	//move Y
	if(objDrag.minY==null&&objDrag.maxY==null){
		objDrag.Element.style.top=intPosY+'px';
	}else{
		//restrict Y
		if(intPosY>objDrag.minY&&intPosY<(objDrag.maxY-Element.height(objDrag.Element))){
			objDrag.Element.style.top=intPosY+'px';
		} else if(intPosY<=objDrag.minY){
			objDrag.Element.style.top=objDrag.minY+'px';
		} else if(intPosY>=(objDrag.maxY-Element.height(objDrag.Element))){
			objDrag.Element.style.top=(objDrag.maxY-Element.height(objDrag.Element))+'px';
		}
	}
	
	if(navigator.appName=='Microsoft Internet Explorer'){
		window.event.cancelBubble=true;
		window.event.returnValue=false;
	} else if(navigator.userAgent.indexOf("Firefox")!=-1){
		objEvent.preventDefault();
	}
	
	if(objDrag.boolTargets==true){
		for(var i=0;i<objDrag.targets.length;i++){
			var intDividedHeight=Math.floor(Element.height(objDrag.targets[i])/3);
			//top quadrant detection
			if( (Mouse._x > Element.totalOffsetLeft(objDrag.targets[i])) &&
				(Mouse._x < Element.totalOffsetLeft(objDrag.targets[i])+Element.width(objDrag.targets[i])) &&
				(Mouse._y > Element.totalOffsetTop(objDrag.targets[i])) &&
				(Mouse._y < Element.totalOffsetTop(objDrag.targets[i])+intDividedHeight)) {
					objDrag.targets[i].style.borderTop='1px solid #000000';
					objDrag.targets[i].style.paddingTop='0';
			} else {
				objDrag.targets[i].style.borderTop='0';
				objDrag.targets[i].style.paddingTop='1px';
			}
			//middle quadrant detection
			if( (Mouse._x > Element.totalOffsetLeft(objDrag.targets[i])) &&
				(Mouse._x < Element.totalOffsetLeft(objDrag.targets[i])+Element.width(objDrag.targets[i])) &&
				(Mouse._y > Element.totalOffsetTop(objDrag.targets[i])+intDividedHeight) &&
				(Mouse._y < Element.totalOffsetTop(objDrag.targets[i])+(intDividedHeight*2))) {
					objDrag.targets[i].style.backgroundColor='#F0F0F0';
			} else {
				objDrag.targets[i].style.backgroundColor='';
			}
			//bottom quadrant detection
			if( (Mouse._x > Element.totalOffsetLeft(objDrag.targets[i])) &&
				(Mouse._x < Element.totalOffsetLeft(objDrag.targets[i])+Element.width(objDrag.targets[i])) &&
				(Mouse._y > Element.totalOffsetTop(objDrag.targets[i])+(intDividedHeight*2)) &&
				(Mouse._y < Element.totalOffsetTop(objDrag.targets[i])+(intDividedHeight*3))) {
					objDrag.targets[i].style.borderBottom='1px solid #000000';
					objDrag.targets[i].style.paddingBottom='0';
			} else {
				objDrag.targets[i].style.borderBottom='0';
				objDrag.targets[i].style.paddingBottom='1px';
			}
			objDrag.targets[i].style.cursor='default';
		}
	}
	try{
		eval(objDrag.onDuringCallBack);
	}catch(error){}
}
/**
* Stop Drag
* 
* Drag Class: Internal
* 
* Stops the drag and performs cleanup. Executes callBacks on defined targets.
*/
objClassElementDrag.prototype.stopDrag=function(objEvent){
	if(navigator.appName=='Microsoft Internet Explorer'){
		document.detachEvent("onmousemove",objDrag.drag);
		document.detachEvent("onmouseup",objDrag.stopDrag);
	} else if(navigator.userAgent.indexOf("Firefox")!=-1){
		document.removeEventListener("mousemove",objDrag.drag,true);
		document.removeEventListener("mouseup",objDrag.stopDrag,true);
	}
	if(objDrag.boolTargets==true){
		for(var i=0;i<objDrag.targets.length;i++){
			var intDividedHeight=Math.floor(Element.height(objDrag.targets[i])/3);
			var arrAction=new Array();
			//top quadrant detection
			if( (Mouse._x > Element.totalOffsetLeft(objDrag.targets[i])) &&
				(Mouse._x < Element.totalOffsetLeft(objDrag.targets[i])+Element.width(objDrag.targets[i])) &&
				(Mouse._y > Element.totalOffsetTop(objDrag.targets[i])) &&
				(Mouse._y < Element.totalOffsetTop(objDrag.targets[i])+intDividedHeight)) {
					objDrag.actionFirstQuadrant.ondragstop(objDrag.targets[i],objDrag.Element);							
			}
			//middle quadrant detection
			if( (Mouse._x > Element.totalOffsetLeft(objDrag.targets[i])) &&
				(Mouse._x < Element.totalOffsetLeft(objDrag.targets[i])+Element.width(objDrag.targets[i])) &&
				(Mouse._y > Element.totalOffsetTop(objDrag.targets[i])+intDividedHeight) &&
				(Mouse._y < Element.totalOffsetTop(objDrag.targets[i])+(intDividedHeight*2))) {
					objDrag.actionSecondQuadrant.ondragstop(objDrag.targets[i],objDrag.Element);
			}
			//bottom quadrant detection
			if( (Mouse._x > Element.totalOffsetLeft(objDrag.targets[i])) &&
				(Mouse._x < Element.totalOffsetLeft(objDrag.targets[i])+Element.width(objDrag.targets[i])) &&
				(Mouse._y > Element.totalOffsetTop(objDrag.targets[i])+(intDividedHeight*2)) &&
				(Mouse._y < Element.totalOffsetTop(objDrag.targets[i])+(intDividedHeight*3))) {
					objDrag.actionThirdQuadrant.ondragstop(objDrag.targets[i],objDrag.Element);
			}
			//reset styles
			objDrag.targets[i].style.cursor='pointer';
			objDrag.targets[i].style.backgroundColor='';
			objDrag.targets[i].style.borderTop='0';
			objDrag.targets[i].style.paddingTop='1px';
			objDrag.targets[i].style.borderBottom='0';
			objDrag.targets[i].style.paddingBottom='1px';
		}
	}
	if(objDrag.boolCopy==true){
		objDrag.recopy();
	}
	try{
		eval(objDrag.onStopCallBack);
	}catch(error){}
	document.onmousemove=null;
}
/**
* Copy
* 
* Drag Class: Internal
* 
* This function creates a "ghost" copy of the element be dragged 
* rather than the actual element itself
*/
objClassElementDrag.prototype.copy=function(){
	//clone/copy element
	var objClone=this.OriginalElement.cloneNode(true);
	//transparency
	if(navigator.appName=='Microsoft Internet Explorer'){
		objClone.style.filter="alpha(opacity=35)";
	} else if(navigator.userAgent.indexOf("Firefox")!=-1){
		objClone.style.opacity=".35";
	}
	this.Element=objClone;
	this.Element.style.position='absolute';
	this.Element.style.left=Element.totalOffsetLeft(this.OriginalElement)+'px';
	this.Element.style.top=Element.totalOffsetTop(this.OriginalElement)+'px';
}
/**
* Recopy
* 
* Drag Class: Internal
* 
* Implemented on copy option. Removes the "ghost" copy of the element when dragging stops
*/
objClassElementDrag.prototype.recopy=function(){
	try{
		document.body.removeChild(this.Element);
	}catch(error){}
	this.copy();
}

/**************************************************************************************************
* Resize Class
* 
* Creates a resize object. 
* Must be defined via the name resize as an object of the element. 
* Example: document.getElementById('name').resize=new objClassElementResize();
* 
* @link http://www.logicorps.com/
* @copyright 2007 Logicorps
* @author Joseph M. Bulaswad <joe.bulaswad@logicorps.com>
* @package DOMbat
* @version 1.0.0
*
* @param object objToResize - object to resize
* @param object objHandle - object handle to initialize resize
* @param integer minWidth - minimum width
* @param integer minHeight - minimum height
* @param integer maxWidth - maximum width
* @param integer maxHeight - maximum height
* @param string strOnStartCallBack - function to call on resize start
* @param string strOnStopCallBack - function to call on resize stop
*
* Global Objects
* objResize - used as a pointer for the current resize object
*/
var objResize=new Object();
function objClassElementResize(objToResize,objHandle,minWidth,minHeight,maxWidth,maxHeight,minX,minY,maxX,maxY,strResizePos,strOnStartCallBack,strOnDuringCallBack,strOnStopCallBack){
	
	this.intCursorStartX=0;
	this.intCursorStartY=0;
	this.intElementStartWidth=0;
	this.intElementStartHeigh=0;
	this.intHandleStartX=0;
	this.intHandleStartY=0;
	this.Element=objToResize;
	this.Handle=objHandle;
	this.minHeight=minHeight;
	this.minWidth=minWidth;
	this.maxHeight=maxHeight;
	this.maxWidth=maxWidth;
	this.minX=minX;
	this.minY=minY;
	this.maxX=maxX;
	this.maxY=maxY;
	this.resizePos=strResizePos;
	this.onStartCallBack=strOnStartCallBack;
	this.onDuringCallBack=strOnDuringCallBack;
	this.onStopCallBack=strOnStopCallBack;
	
	if(navigator.appName=='Microsoft Internet Explorer'){
		this.Handle.attachEvent("onmousedown",this.startResize);
	} else if(navigator.userAgent.indexOf("Firefox")!=-1){
		this.Handle.addEventListener("mousedown",this.startResize);
	}
}
/**
* Start Resize
* 
* Resize Class: Internal
* 
* Executes the resize effect
*/
objClassElementResize.prototype.startResize=function(objEvent){
	document.onmousemove=Mouse.track;
	if(objEvent){
		if(navigator.appName=='Microsoft Internet Explorer'){
			objEventParent=objEvent.srcElement;
			while(objEventParent.parentElement){
				if(objEventParent.resize){
					objResize=objEventParent.resize;
					break;
				}
				objEventParent=objEventParent.parentElement
			}
		} else if(navigator.userAgent.indexOf("Firefox")!=-1){
			objEventParent=objEvent.target;
			while(objEventParent.parentNode){
				if(objEventParent.resize){
					objResize=objEventParent.resize;
					break;
				}
				objEventParent=objEventParent.parentNode
			}
		}
	}
	try{
		eval(objResize.onStartCallBack);
	}catch(error){}
	//save cursor and element starting position
	objResize.intCursorStartX=Mouse._x;
	objResize.intCursorStartY=Mouse._y;
	objResize.intElementStartWidth=Element.width(objResize.Element);
	objResize.intElementStartHeight=Element.height(objResize.Element);
	objResize.intHandleStartX=Element.totalOffsetLeft(objResize.Handle);
	objResize.intHandleStartY=Element.totalOffsetTop(objResize.Handle);
	if(navigator.appName=='Microsoft Internet Explorer'){
		document.attachEvent("onmousemove",objResize.resize);
		document.attachEvent("onmouseup",objResize.stopResize);
		window.event.cancelBubble=true;
		window.event.returnValue=false;
	} else if(navigator.userAgent.indexOf("Firefox")!=-1){
		document.addEventListener("mousemove",objResize.resize,true);
		document.addEventListener("mouseup",objResize.stopResize,true);
		objEvent.preventDefault();
	}
}
/**
* Stop Resize
* 
* Resize Class: Internal
* 
* Stops the resize event
*/
objClassElementResize.prototype.stopResize=function(){
	if(navigator.appName=='Microsoft Internet Explorer'){
		document.detachEvent("onmousemove",objResize.resize);
		document.detachEvent("onmouseup",objResize.stopResize);
	} else if(navigator.userAgent.indexOf("Firefox")!=-1){
		document.removeEventListener("mousemove",objResize.resize,true);
		document.removeEventListener("mouseup",objResize.stopResize,true);
	}
	try{
		eval(objResize.onStopCallBack);
	}catch(error){}
	document.onmousemove=null;
}
/**
* Resize
* 
* Resize Class: Internal
* 
* Resizes the object while maintaining user-defined contraints
*/
objClassElementResize.prototype.resize=function(objEvent){
			
	objResize.Element.style.position='absolute';
	objResize.Handle.style.position='absolute';
	
	//adjust from the top or bottom
	if(objResize.resizePos=='top'){
		var intHeight=(objResize.intElementStartHeight+objResize.intCursorStartY-Mouse._y);
		if(Element.totalOffsetTop(objResize.Element)>objResize.minY&&Element.totalOffsetTop(objResize.Element)+intHeight<objResize.maxY && Element.totalOffsetTop(objResize.Element)+intHeight>objResize.minY && intHeight>objResize.minHeight){
			objResize.Element.style.height=intHeight+'px';
			objResize.Element.style.top=(objResize.intHandleStartY+Mouse._y-objResize.intCursorStartY)+'px';
			objResize.Handle.style.top=(objResize.intHandleStartY+Mouse._y-objResize.intCursorStartY)+'px';
		}
	}
	//adjust from the right
	if(objResize.resizePos=='right'){
		var intWidth=(objResize.intElementStartWidth+Mouse._x-objResize.intCursorStartX);
		if((Element.totalOffsetLeft(objResize.Element)+intWidth)<objResize.maxX && Element.totalOffsetLeft(objResize.Element)+intWidth>objResize.minX && intWidth>objResize.minWidth){
			objResize.Element.style.width=intWidth+'px';
			objResize.Handle.style.left=(objResize.intHandleStartX+Mouse._x-objResize.intCursorStartX)+'px';
		}
	}
	//adjust from the bottom
	if(objResize.resizePos=='bottom'){
		var intHeight=(objResize.intElementStartHeight+Mouse._y-objResize.intCursorStartY);
		if(Element.totalOffsetTop(objResize.Element)+intHeight<objResize.maxY && Element.totalOffsetTop(objResize.Element)+intHeight>objResize.minY && intHeight>objResize.minHeight){
			objResize.Element.style.height=intHeight+'px';
			objResize.Handle.style.top=(objResize.intHandleStartY+Mouse._y-objResize.intCursorStartY)+'px';
		}
	}
	//adjust from the left
	if(objResize.resizePos=='left'){
		var intWidth=(objResize.intElementStartWidth+objResize.intCursorStartX-Mouse._x);
		if((Element.totalOffsetLeft(objResize.Element)+intWidth)<objResize.maxX && Element.totalOffsetLeft(objResize.Element)+intWidth>objResize.minX && intWidth>objResize.minWidth){
			objResize.Element.style.left=(objResize.intHandleStartX+Mouse._x-objResize.intCursorStartX)+'px';
			objResize.Element.style.width=intWidth+'px';
			objResize.Handle.style.left=(objResize.intHandleStartX+Mouse._x-objResize.intCursorStartX)+'px';
		}
	}
	//adjust from the bottom right
	if(objResize.resizePos=='bottom right'){
		var intWidth=(objResize.intElementStartWidth+Mouse._x-objResize.intCursorStartX);
		var intHeight=(objResize.intElementStartHeight+Mouse._y-objResize.intCursorStartY);
		if((Element.totalOffsetLeft(objResize.Element)+intWidth)<objResize.maxX && Element.totalOffsetLeft(objResize.Element)+intWidth>objResize.minX && intWidth>objResize.minWidth){
			objResize.Element.style.width=intWidth+'px';
			objResize.Handle.style.left=(objResize.intHandleStartX+Mouse._x-objResize.intCursorStartX)+'px';
		}
		if(Element.totalOffsetTop(objResize.Element)+intHeight<objResize.maxY && Element.totalOffsetTop(objResize.Element)+intHeight>objResize.minY && intHeight>objResize.minHeight){
			objResize.Element.style.height=intHeight+'px';
			objResize.Handle.style.top=(objResize.intHandleStartY+Mouse._y-objResize.intCursorStartY)+'px';
		}
	}
	//adjust from the bottom left
	if(objResize.resizePos=='bottom left'){
		var intWidth=(objResize.intElementStartWidth+objResize.intCursorStartX-Mouse._x);
		var intHeight=(objResize.intElementStartHeight+Mouse._y-objResize.intCursorStartY);
		if((Element.totalOffsetLeft(objResize.Element)+intWidth)<objResize.maxX && Element.totalOffsetLeft(objResize.Element)+intWidth>objResize.minX && intWidth>objResize.minWidth){
			objResize.Element.style.left=(objResize.intHandleStartX+Mouse._x-objResize.intCursorStartX)+'px';
			objResize.Element.style.width=intWidth+'px';
			objResize.Handle.style.left=(objResize.intHandleStartX+Mouse._x-objResize.intCursorStartX)+'px';
		}
		if(Element.totalOffsetTop(objResize.Element)+intHeight<objResize.maxY && Element.totalOffsetTop(objResize.Element)+intHeight>objResize.minY && intHeight>objResize.minHeight){
			objResize.Element.style.height=intHeight+'px';
			objResize.Handle.style.top=(objResize.intHandleStartY+Mouse._y-objResize.intCursorStartY)+'px';
		}
	}
	//adjust from the top right
	if(objResize.resizePos=='top right'){
		var intWidth=(objResize.intElementStartWidth+Mouse._x-objResize.intCursorStartX);
		var intHeight=(objResize.intElementStartHeight+objResize.intCursorStartY-Mouse._y);
		if((Element.totalOffsetLeft(objResize.Element)+intWidth)<objResize.maxX && Element.totalOffsetLeft(objResize.Element)+intWidth>objResize.minX && intWidth>objResize.minWidth){
			objResize.Element.style.width=intWidth+'px';
			objResize.Handle.style.left=(objResize.intHandleStartX+Mouse._x-objResize.intCursorStartX)+'px';
		}
		if(Element.totalOffsetTop(objResize.Element)+intHeight<objResize.maxY && Element.totalOffsetTop(objResize.Element)+intHeight>objResize.minY && intHeight>objResize.minHeight){
			objResize.Element.style.height=intHeight+'px';
			objResize.Element.style.top=(objResize.intHandleStartY+Mouse._y-objResize.intCursorStartY)+'px';
			objResize.Handle.style.top=(objResize.intHandleStartY+Mouse._y-objResize.intCursorStartY)+'px';
		}
	}
	//adjust from the top left
	if(objResize.resizePos=='top left'){
		var intWidth=(objResize.intElementStartWidth+objResize.intCursorStartX-Mouse._x);
		var intHeight=(objResize.intElementStartHeight+objResize.intCursorStartY-Mouse._y);
		if((Element.totalOffsetLeft(objResize.Element)+intWidth)<objResize.maxX && Element.totalOffsetLeft(objResize.Element)+intWidth>objResize.minX && intWidth>objResize.minWidth){
			objResize.Element.style.left=(objResize.intHandleStartX+Mouse._x-objResize.intCursorStartX)+'px';
			objResize.Element.style.width=intWidth+'px';
			objResize.Handle.style.left=(objResize.intHandleStartX+Mouse._x-objResize.intCursorStartX)+'px';
		}
		if(Element.totalOffsetTop(objResize.Element)+intHeight<objResize.maxY && Element.totalOffsetTop(objResize.Element)+intHeight>objResize.minY && intHeight>objResize.minHeight){
			objResize.Element.style.height=intHeight+'px';
			objResize.Element.style.top=(objResize.intHandleStartY+Mouse._y-objResize.intCursorStartY)+'px';
			objResize.Handle.style.top=(objResize.intHandleStartY+Mouse._y-objResize.intCursorStartY)+'px';
		}
	}
	
	if(navigator.appName=='Microsoft Internet Explorer'){
		window.event.cancelBubble=true;
		window.event.returnValue=false;
	} else if(navigator.userAgent.indexOf("Firefox")!=-1){
		objEvent.preventDefault();
	}
	try{
		eval(objResize.onDuringCallBack);
	}catch(error){}
}

/**************************************************************************************************
* Drop Down Menu Class
* 
* Creates a drop down menu. 
* 
* @link http://www.logicorps.com/
* @copyright 2007 Logicorps
* @author Joseph M. Bulaswad <joe.bulaswad@logicorps.com>
* @package DOMbat
* @version 1.0.0
*
* @param object intId - unique id
* @param object objElement - where to put the element
* @param integer strLabel - menu label
* @param integer strAction - action to perform onClick
* @param integer boolApplicationStyle - menus act like application menus. i.e. click to activate
*
* Global Objects
* objDropDownMenu - used as a pointer for the current object
*/
//var objDropDownMenu=new Object;
function objClassDropDownMenu(intId,objElement,strLabel,strAction,boolApplicationStyle,strClassPrefix){
	//variables
	this.id=intId;
	this.boolApplicationStyle=boolApplicationStyle;
	this.classPrefix=strClassPrefix||'';
	this.subMenuPosition=='bottom';
	//objects
	this.menu=document.createElement('div');
	this.label=document.createTextNode(strLabel.escapeHTMLEntities());
	this.subMenu=new Array;
	this.hideTimeout=new Object;
	//set classes
	this.menu.className=this.classPrefix+"objClassDropDownMenu_menu";
	//assign actions	
	this.menu.onmouseover=function(){
		this.className=this.classObj.classPrefix+"objClassDropDownMenu_menu_over";
		//hide other menus if needed
		if(_global.objClassDropDownMenu&&(this.classObj.id!=_global.objClassDropDownMenu.id)){
			this.classObj.hideSubMenus(_global.objClassDropDownMenu.menu, false);
		}
		// Event to remove on body click
		EventManager.add(document.body, 'mousedown', objClassDropDown_FunctionMenuHideMenus, false);
	}
	this.menu.onmouseout = function () {
		this.className = String(this.className).substring(0,String(this.className).lastIndexOf('_over'));
	}
	if(strAction){
		this.menu.onmousedown=function(){
			eval(strAction);
		}
	}
	//assemble menu
	this.menu.appendChild(this.label);
	objElement.appendChild(this.menu);
	this.menu.classObj = this;
}
function objClassDropDown_FunctionMenuHideMenus() {
	if (_global.objClassDropDownMenu) {
		_global.objClassDropDownMenu.hideSubMenus(_global.objClassDropDownMenu.menu, false);
	}
	//EventManager.remove(document.body, 'mousedown', objClassDropDown_FunctionMenuHideMenus, false);
}
/**
 * Add Bullet
 */
objClassDropDownMenu.prototype.addBullet=function(strSrc,boolBefore){
	this.bullet=document.createElement('img');
	this.bullet.src=strSrc;
	this.bullet.border=0;
	if(boolBefore){
		this.menu.insertBefore(this.bullet,this.label);
	}else{
		this.menu.appendChild(this.bullet);
	}
}
/**
 * Add Sub Menu
 */
objClassDropDownMenu.prototype.addSubMenu=function(intId,boolMain,intParentId){
	if(boolMain){
		if(this.boolApplicationStyle==true){
			//set main menu actions
			this.menu.onmousedown=function(){
				this.classObj.displaySubMenu(this.classObj.id,this.classObj.menu);
			}
			this.menu.onmouseover=function(){
				this.className=this.classObj.classPrefix+"objClassDropDownMenu_menu_over";
				//hide other menus if needed
				if(_global.objClassDropDownMenu&&(this.classObj.id!=_global.objClassDropDownMenu.id)){
					this.classObj.hideSubMenus(_global.objClassDropDownMenu.menu,false);
				}
			}
		} else {
			//set main menu actions
			this.menu.onmouseover=function(){
				this.className=this.classObj.classPrefix+"objClassDropDownMenu_menu_over";
				//hide other menus if needed
				if(_global.objClassDropDownMenu&&(this.classObj.id!=_global.objClassDropDownMenu.id)){
					this.classObj.hideSubMenus(_global.objClassDropDownMenu.menu,false);
				}
				this.classObj.displaySubMenu(this.classObj.id,this.classObj.menu);
			}
		}
		//to unset the mouseout
		this.menu.onmouseout=null;
		//make child of main menu
		var objParent=this.menu;
	} else {
		//make a child of parent menu
		var objParent=this.subMenu[intParentId].body.items[intId];
	}
	//variables
	this.subMenu[intId]=new Array;
	this.subMenu[intId].body=new Array;
	this.subMenu[intId].greatest_width=new Number(0);
	//objects
	this.subMenu[intId]=document.createElement('div');
	this.subMenu[intId].id='objClassDropDownMenu_subMenu'+intId;
	this.subMenu[intId].body=document.createElement('div');
	//set classes
	this.subMenu[intId].className=this.classPrefix+'objClassDropDownMenu_subMenu_frame';
	this.subMenu[intId].body.className=this.classPrefix+'objClassDropDownMenu_subMenu';
	var objThis = this;
	this.subMenu[intId].body.onmouseover = function () {
		//objThis.boolFrameOver = true;
	}
	//assemble menu
	this.subMenu[intId].appendChild(this.subMenu[intId].body);
	objParent.appendChild(this.subMenu[intId]);
	//create item object array if none exists
	if(!this.subMenu[intId].body.items) this.subMenu[intId].body.items=new Array;
}
/**
 * Timed Timeout Cancel
 */
objClassDropDownMenu.prototype.timedTimeoutCancel=function(intParentId,intId){
	objElement=this.subMenu[intParentId].body.items[intId];
	if(_global.objClassDropDownMenu.hideTimeout&&(((Mouse._x>Element.totalOffsetLeft(objElement)&&Mouse._x<Element.totalOffsetLeft(objElement)+Element.width(objElement)))&&((Mouse._y>Element.totalOffsetTop(objElement)&&Mouse._y<Element.totalOffsetTop(objElement)+Element.height(objElement))))){
		clearTimeout(_global.objClassDropDownMenu.hideTimeout);
	}
}
/**
 * Set As Sub Menu
 */
objClassDropDownMenu.prototype.setAsSubMenu=function(intParentId,intId){
	//set classes
	this.subMenu[intParentId].body.items[intId].className=this.classPrefix+"objClassDropDownMenu_subMenu_item_menu";
	//assign actions
	var strClassPrefix=this.classPrefix;
	this.subMenu[intParentId].body.items[intId].onmouseover=function(){
		//set a timeout for the clearing of the hide timeout (I know, sounds redundant, but it is necessary)
		setTimeout('_global.objClassDropDownMenu.timedTimeoutCancel('+intParentId+','+intId+')',200);
		//display children
		_global.objClassDropDownMenu.displaySubMenu(intId,this);
		//change class
		this.className=strClassPrefix+"objClassDropDownMenu_subMenu_item_menu_over";
	}
	this.subMenu[intParentId].body.items[intId].onmouseout=null;
	//create submenu
	this.addSubMenu(intId,false,intParentId);
}
/**
 * Add Sub Menu Item
 */
objClassDropDownMenu.prototype.addSubMenuItem=function(intParentId,intId,strLabel,strAction){
	var strClassPrefix=this.classPrefix;
	//objects
	this.subMenu[intParentId].body.items[intId]=document.createElement('div');
	this.subMenu[intParentId].body.items[intId].id='objClassDropDownMenu_subMenu_item'+intId;
	this.subMenu[intParentId].body.items[intId].parentId=intParentId;
	var txtLabel=document.createTextNode(strLabel);
	//set classes
	this.subMenu[intParentId].body.items[intId].className=this.classPrefix+"objClassDropDownMenu_subMenu_item";
	//assign actions
	var objThis = this;
	this.subMenu[intParentId].body.items[intId].onmouseover=function(){
		//clear delay
		if(_global.objClassDropDownMenu.hideTimeout>0) clearTimeout(_global.objClassDropDownMenu.hideTimeout);
		//kill all other submenu children
		_global.objClassDropDownMenu.killSubMenuChildren(this);
		//change class
		this.className=strClassPrefix+"objClassDropDownMenu_subMenu_item_over";
	}
	this.subMenu[intParentId].body.items[intId].onmouseout=function(){
		//this.className=strClassPrefix+"objClassDropDownMenu_subMenu_item";
		this.className = String(this.className).substring(0,String(this.className).lastIndexOf('_over'))
		//set delayed hide
		_global.objClassDropDownMenu.startHideSubMenus(intParentId,true);
	}
	if(strAction){
		this.subMenu[intParentId].body.items[intId].onmousedown=function(){
			if(navigator.appName=='Microsoft Internet Explorer'){
				window.event.cancelBubble=true;
				window.event.returnValue=false;
			}
			//remove menu
			_global.objClassDropDownMenu.hideSubMenus(_global.objClassDropDownMenu.menu,false);
			//execute
			eval(strAction);
		}
	}
	// Assemble menu
	this.subMenu[intParentId].body.items[intId].appendChild(txtLabel);
	this.subMenu[intParentId].body.appendChild(this.subMenu[intParentId].body.items[intId]);
	// Set width
	if(this.subMenu[intParentId].body.items[intId].offsetWidth > this.subMenu[intParentId].greatest_width){
		this.subMenu[intParentId].greatest_width = this.subMenu[intParentId].body.items[intId].offsetWidth;
	}
	if (this.subMenu[intParentId].greatest_width) {
		for (var i = 0; i < this.subMenu[intParentId].body.items.length; i++) {
			this.subMenu[intParentId].body.items[i].style.width = this.subMenu[intParentId].greatest_width + 'px';
		}
	}
}
/**
 * Add Sub Menu Spacer
 */
objClassDropDownMenu.prototype.addSubMenuItemSpacer=function(intParentId,intId){
	//objects
	this.subMenu[intParentId].body.items[intId]=document.createElement('div');
	//set classes
	this.subMenu[intParentId].body.items[intId].className=this.classPrefix+"objClassDropDownMenu_subMenu_spacer";
	//assign actions
	this.subMenu[intParentId].body.items[intId].onmouseout=function(){
		//set delayed hide
		_global.objClassDropDownMenu.startHideSubMenus(intParentId,true);
	}
	this.subMenu[intParentId].body.items[intId].onmouseover=function(){
		//clear delay
		if(_global.objClassDropDownMenu.hideTimeout) clearTimeout(_global.objClassDropDownMenu.hideTimeout);
	}
	//assemble menu
	this.subMenu[intParentId].body.appendChild(this.subMenu[intParentId].body.items[intId]);
}
/**
 * Display Sub Menu
 */
objClassDropDownMenu.prototype.displaySubMenu=function(intId,objParent){
	// Set global variable
	_global.objClassDropDownMenu=this;
	if(this.menu==objParent){
		if(this.subMenuPosition=='right'){
			// Position menu to the right
			this.subMenu[intId].style.left=Element.totalOffsetLeft(objParent)+Element.width(objParent)+'px';
			this.subMenu[intId].style.top=Element.totalOffsetTop(objParent)+'px';			
		}else{
			// Position menu below
			this.subMenu[intId].style.left=Element.totalOffsetLeft(objParent)+'px';
			this.subMenu[intId].style.top=Element.totalOffsetTop(objParent)+Element.height(objParent)+'px';
		}
	} else {
		// Position menu to the right		
		if(navigator.appName=='Microsoft Internet Explorer'){
			this.subMenu[intId].style.left=Element.width(objParent)+'px';
		} else if(navigator.userAgent.indexOf("Firefox")!=-1){ //TODO: firefox is retarded
//			this.subMenu[intId].parentNode.removeChild(this.subMenu[intId]);
//			document.body.appendChild(this.subMenu[intId]);
//			this.subMenu[intId].style.top=Element.totalOffsetTop(objParent)+Element.height(this.subMenu[intId])+'px';
//			this.subMenu[intId].style.left=Element.totalOffsetLeft(objParent)+Element.width(objParent)+'px';
			this.subMenu[intId].style.left=Element.width(objParent)+'px';
		}
	}
	if (Element.width(objParent)>10) {
		this.subMenu[intId].style.width = Element.width(objParent) +'px';
	}
	// Reveal menu
	this.subMenu[intId].className=this.classPrefix+"objClassDropDownMenu_subMenu_frame";
	this.subMenu[intId].style.display="block";
}
/**
 * Start Hide Sub Menus
 */
objClassDropDownMenu.prototype.startHideSubMenus=function(intId,boolReverse){
	if (!this.boolFrameOver) {
		this.hideTimeout=setTimeout('_global.objClassDropDownMenu.hideSubMenus('+intId+','+boolReverse+');',250);
	}
}
/**
 * Kill Sub Menus
 */
objClassDropDownMenu.prototype.killSubMenuChildren=function(objElement){
	if(navigator.appName=='Microsoft Internet Explorer'){
		var objElements=objElement.parentElement.getElementsByTagName('div'); //damn thing grabs them all, won't work for 3 tiers or more
	} else if(navigator.userAgent.indexOf("Firefox")!=-1){
		var objElements=objElement.parentNode.getElementsByTagName('div'); //damn thing grabs them all, won't work for 3 tiers or more
	}
	for(var i=0;i<objElements.length;i++){
		if(objElements[i].className=='objClassDropDownMenu_subMenu_item_menu'||objElements[i].className=='objClassDropDownMenu_subMenu_item_menu_over'){
			objElements[i].className=this.classPrefix+"objClassDropDownMenu_subMenu_item_menu";
			this.hideSubMenus(objElements[i],false);
		}
	}
}
/**
 * Hide Sub Menus
 */
objClassDropDownMenu.prototype.hideSubMenus=function(intId,boolReverse){
	if(boolReverse==true){
		if(_global.objClassDropDownMenu.subMenu[intId]){
			objElement=_global.objClassDropDownMenu.subMenu[intId].body;
			
			if(navigator.appName=='Microsoft Internet Explorer'){
				while(objElement.parentElement){
					if(objElement.className.indexOf('objClassDropDownMenu_subMenu_frame') !== -1){
						objElement.style.display='none';
					} else if(objElement.className.indexOf('objClassDropDownMenu_subMenu_item_menu_over') !== -1) {
						objElement.className = String(objElement.className).substring(0,String(objElement.className).lastIndexOf('_over'));
					} else if(objElement.className.indexOf('objClassDropDownMenu_menu_over') !== -1) {
						objElement.className = String(objElement.className).substring(0,String(objElement.className).lastIndexOf('_over'));
						break;
					}
					objElement=objElement.parentElement;
				}
			} else if(navigator.userAgent.indexOf("Firefox") !== -1){
				while(objElement.parentNode){
					if(objElement.className.indexOf('objClassDropDownMenu_subMenu_frame') !== -1) {
						objElement.style.display = 'none';
					} else if(objElement.className.indexOf('objClassDropDownMenu_subMenu_item_menu_over') !== -1) {
						objElement.className = String(objElement.className).substring(0,String(objElement.className).lastIndexOf('_over'));
					} else if(objElement.className.indexOf('objClassDropDownMenu_menu_over') !== -1) {
						objElement.className = String(objElement.className).substring(0,String(objElement.className).lastIndexOf('_over'));
						break;
					}
					objElement=objElement.parentNode;
				}
			}
		}
	} else if(boolReverse==false) {
		var objElement = intId;
		if(objElement.className.indexOf('objClassDropDownMenu_menu' !== -1) || objElement.className.indexOf('objClassDropDownMenu_menu_over') !== -1) {
			objElement.className = String(objElement.className).substring(0,String(objElement.className).lastIndexOf('_over')) || objElement.className;
		}
		//get all children
		var objElements = objElement.getElementsByTagName('div');
		for(var i = 0; i < objElements.length; i++){
			if(objElements[i].className.indexOf('objClassDropDownMenu_subMenu_frame') !== -1) {
				objElements[i].style.display = 'none';
				objElements[i].className = 'objClassDropDownMenu_subMenu_frame_hidden'; //IE Fix - otherwise, border remains
			} else if(objElements[i].className.indexOf('objClassDropDownMenu_subMenu_item_menu_over') !== -1) {
				objElements[i].className = String(objElements[i].className).substring(0,String(objElements[i].className).lastIndexOf('_over'));
			}
		}
	}
}

/**
* Get DOM Parser
* 
* Fetch the correct DOM Parser for use
*
*/
function getDOMParser(strResponse){
	if(window.ActiveXObject){
        objDOMParser=new ActiveXObject("Microsoft.XMLDOM");
        objDOMParser.async=false;
		objDOMParser.loadXML(strResponse);
		if(objDOMParser.parseError.errorCode)
			throw new Error(objDOMParser.parseError.reason);
	} else {
		var objParser=new DOMParser();
		objDOMParser=objParser.parseFromString(strResponse,"text/xml");
	}
	
	return objDOMParser;
}