function portalEngine() {
	this.xmlHttpObject = '';
	this.weatherTimeout = '';
	this.userUpdate = 0;
	this.modules = new Array();
	this.contentMainHeight;

	Event.onDOMReady(function(){
		portalEngine.loadColumns();

		if (document.getElementById('weatherBox')) portalEngine.getWeather(portalEngine.readCookie('zipCode'));
	});

	this.loadColumns = function() {
		portalEngine.columnsArray = new Array();

		if (document.getElementById('RightSort')) portalEngine.columnsArray[portalEngine.columnsArray.length] = 'RightSort';
		if (document.getElementById('LeftSort')) portalEngine.columnsArray[portalEngine.columnsArray.length] = 'LeftSort';

		for(var i=0;i < portalEngine.columnsArray.length;i++) {
			portalEngine.arrayNames = new Array(portalEngine.columnsArray[i]);

			for(var i2=0;i2 < portalEngine.columnsArray.length;i2++) {
				if (portalEngine.columnsArray[i2]!=portalEngine.columnsArray[i]) {
					portalEngine.arrayNames[portalEngine.arrayNames.length] = portalEngine.columnsArray[i2];
				}
			}

			Sortable.create(eval('"' + portalEngine.columnsArray[i] + '"'),{
				dropOnEmpty:true,
				containment:portalEngine.arrayNames,
				constraint:false,
				handle: 'hover',
				onUpdate:function(){
					for(var i2=0;i2 < portalEngine.columnsArray.length;i2++) {
						var sortValues = Sortable.serialize(portalEngine.columnsArray[i2]);
						if (sortValues=='') sortValues = 'empty';
						portalEngine.createCookie(portalEngine.columnsArray[i2], sortValues, 365);
					}
				}
			});
		};
	};

	this.getWeather = function(zipCode) {
		if (zipCode=='' || zipCode==null || zipCode==false) zipCode = 0;
		portalEngine.createCookie('zipCode', zipCode, 365);
		document.getElementById('weatherBox').innerHTML = 'Loading... please wait.';
		this.setHTTP(extraForumPath + 'functions/mods/weather/get_weather.asp', 'Path=' + extraForumPath + 'functions/mods/weather/&zipCode=' + zipCode);
		this.weatherTimeout = clearTimeout(this.weatherTimeout);
		this.weatherTimeout = setTimeout('portalEngine.getWeather(\'' + zipCode + '\');', 2000000);
	};

	this.setHTTP = function(pageURL, sendInput) {
		this.xmlHttpObject = portalEngine.GetXmlHttpObject();
		this.xmlHttpObject.open('POST', pageURL)
		this.xmlHttpObject.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		this.xmlHttpObject.send(sendInput);
	};

	this.GetXmlHttpObject = function() {
		//holds the XML object if supported. blank if not
		var objXmlHttp = '';

		if (window.ActiveXObject) {
			try {
				objXmlHttp = new ActiveXObject('Msxml2.XMLHTTP');
				objXmlHttp.onReadyStateChange = function() {eval(this.responseText);};
			} catch(e) {
				try {
					objXmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
					objXmlHttp.onReadyStateChange = function() {eval(this.responseText);};
				} catch(e) {
					objXmlHttp = '';
				}
			}
		} else	if (window.XMLHttpRequest) {
			try {
				objXmlHttp = new XMLHttpRequest();
				objXmlHttp.onload = function() {eval(this.responseText);};
				//objXmlHttp.onerror = this.onReadyStateChanged;
			} catch(e) {
				objXmlHttp = '';
			}
		}

		return objXmlHttp;
	};


	/* function for when the toggle button is pressed */
	this.startSizeDown = function(tableID) {
		/* get the size of the first <p> element so we can get its sized used for box resizing... add 35px to its width for some extra padding */
		var targetHeight = document.getElementById(tableID).offsetHeight;

		portalEngine.createCookie(tableID, 'Close', 365);

		if (document.getElementById(tableID).style.display == 'none') {
			document.getElementById(tableID).style.display = 'block';
			return false;
		}

		document.getElementById(tableID).style.overflow = 'hidden';

		/* record the modules height */
		if (!portalEngine.modules[tableID]) {
			contentMainHeight = document.getElementById(tableID).offsetHeight;

			document.getElementById(tableID).style.height = contentMainHeight + 'px';

			portalEngine.modules[tableID] = contentMainHeight;
		} else {
			contentMainHeight = portalEngine.modules[tableID]
		}

		/* Star the size procedure */
		portalEngine.resizeDown(tableID, 0, parseInt(contentMainHeight), 1)

		/* change the image if there is one */
		if (document.getElementById(tableID + '_image')) {
			document.getElementById(tableID + '_image').src = document.getElementById(tableID + '_image').src.replace('min','max');

			/* change the onclick event, we added the function instead of a function for extra browser support */
			document.getElementById(tableID + '_image').onclick = eval('function() {portalEngine.startSizeUp(\'' + tableID + '\');}');
		}
	};

	/* function for when the toggle button is pressed */
	this.startSizeUp = function(tableID) {
		portalEngine.createCookie(tableID, 'Open', 365);

		/* Star the size procedure */
		portalEngine.resizeUp(tableID, portalEngine.modules[tableID], parseInt(document.getElementById(tableID).style.height.replace('px','')), 0)

		/* change the image */
		document.getElementById(tableID + '_image').src = document.getElementById(tableID + '_image').src.replace('max','min');

		/* change the onclick event, we added the function instead of a function for extra browser support */
		document.getElementById(tableID + '_image').onclick = eval('function() {portalEngine.startSizeDown(\'' + tableID + '\');}');
	};

	/* function used to size up the container */
	this.resizeUp = function(tableID, targetSize, currentHeight, increaseAmount) {
		/* if target size is greater than the width of the element, then set the real size and stop */
		if (targetSize < currentHeight) {
			document.getElementById(tableID).style.height = targetSize + 'px'; /* set the target size */
		/* resize element and continue */
		} else {
			document.getElementById(tableID).style.height = parseInt(currentHeight) + 'px'; /* set the new width */
			if ((currentHeight % 2) == 1) increaseAmount += 1;
			if (currentHeight < (portalEngine.modules[tableID] / 2)) increaseAmount += 1;
			currentHeight += increaseAmount; /* set the new width */
			setTimeout('portalEngine.resizeUp(\'' + tableID + '\',' + targetSize + ', ' + currentHeight + ', ' + increaseAmount + ')', 1); /* set a timeout so we can continue resizing */
		}
	};

	/* function used to size down the container */
	this.resizeDown = function(tableID, targetSize, currentHeight, increaseAmount) {
		/* if target size is less than the width of the element, then set the real size and stop */
		if (targetSize > currentHeight) {
			document.getElementById(tableID).style.height = targetSize + 'px'; /* set the target size */
		/* resize element and continue */
		} else {
			document.getElementById(tableID).style.height = parseInt(currentHeight) + 'px'; /* set the new width */
			if ((currentHeight % 2) == 1) increaseAmount += 1;
			if (currentHeight < (portalEngine.modules[tableID] / 2)) increaseAmount += 1;
			currentHeight -= increaseAmount; /* set the new width */
			setTimeout('portalEngine.resizeDown(\'' + tableID + '\',' + targetSize + ',' + currentHeight + ',' + increaseAmount + ')', 1); /* set a timeout so we can continue resizing */
		}
	};

	this.createCookie = function(name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	};

	this.readCookie = function(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
}

var portalEngine = new portalEngine();

//Function to jump to another forum
function ForumJump(URL) {
	if (URL.options[URL.selectedIndex].value != "") self.location.href = URL.options[URL.selectedIndex].value;
	return true;
}

//Function to open pop up window
function openWin(theURL,winName,features) {
  	window.open(theURL,winName,features);
}

//Function to open preview post window
function OpenPreviewWindow(targetPage, formName){

	now = new Date

	//Open the window first
   	openWin('','preview','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=680,height=400')

   	//Now submit form to the new window
   	formName.action = targetPage + "?ID=" + now.getTime();
	formName.target = "preview";
	formName.submit();
}

//Function to check avatar image
function AvatarImage(objImage, newSize) {
	imgWidth = objImage.width;
	imgHeight = objImage.height;

	if (imgWidth > newSize) {
		objImage.width = newSize;
	}

	if (imgHeight > newSize) {
		objImage.height = newSize;
	}
}
/*

Correctly handle PNG transparency in Win IE 5.5 & 6.
http://homepage.ntlworld.com/bobosola. Updated 18-Jan-2006.

Use in <HEAD> with DEFER keyword wrapped in conditional comments:
<!--[if lt IE 7]>
<script defer type="text/javascript" src="pngfix.js"></script>
<![endif]-->


<!--[if lt IE 7]>
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

if ((version >= 5.5) && (document.body.filters))
{
   for(var i=0; i<document.images.length; i++)
   {
      var img = document.images[i]
      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
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
         img.outerHTML = strNewHTML
         i = i-1
      }
   }
}
<![endif]-->
*/