// graft() function
// Originally by Sean M. Burke from interglacial.com
// Closure support added by Maciek Adwent
// http://schf.uc.org/articles/2006/10/15/making-javascript-dom-a-piece-of-cake-with-the-graft-function

var graft = function(parent, t, doc) {

    // Usage: graft( somenode, [ "I like ", ['em',
    //               { 'class':"stuff" },"stuff"], " oboy!"] )

    doc = (doc || parent.ownerDocument || document);
    var e;

    if(t == undefined) {
        throw complaining( "Can't graft an undefined value");
    } else if(t.constructor == String) {
        e = doc.createTextNode( t );
    } else if(t.length == 0) {
        e = doc.createElement( "span" );
        e.setAttribute( "class", "fromEmptyLOL" );
    } else {
        for(var i = 0; i < t.length; i++) {
            if( i == 0 && t[i].constructor == String ) {
                var snared;
                snared = t[i].match( /^([a-z][a-z0-9]*)\.([^\s\.]+)$/i );
                if( snared ) {
                    e = doc.createElement(   snared[1] );
                    e.setAttribute( 'class', snared[2] );
                    continue;
                }
                snared = t[i].match( /^([a-z][a-z0-9]*)$/i );
                if( snared ) {
                    e = doc.createElement( snared[1] );  // but no class
                    continue;
                }

                // Otherwise:
                e = doc.createElement( "span" );
                e.setAttribute( "class", "namelessFromLOL" );
            }

            if( t[i] == undefined ) {
                throw complaining("Can't graft an undefined value in a list!");
            } else if(  t[i].constructor == String ||
                                    t[i].constructor == Array ) {
                graft( e, t[i], doc );
            } else if(  t[i].constructor == Number ) {
                graft( e, t[i].toString(), doc );
            } else if(  t[i].constructor == Object ) {
                // hash's properties => element's attributes
                for(var k in t[i]) {
                    // support for attaching closures to DOM objects
                    if(typeof(t[i][k])=='function'){
                        e[k] = t[i][k];
                    } else {
                        e.setAttribute( k, t[i][k] );
                    }
                }
            } else {
                throw complaining( "Object " + t[i] +
                    " is inscrutable as an graft arglet." );
            }
        }
    }

    parent.appendChild( e );
    return e; // return the topmost created node
};

var complaining = function(s) { alert(s); return new Error(s); }


											
/* Simple AJAX Code-Kit (SACK) */
/* ©2005 Gregory Wild-Smith */
/* www.twilightuniverse.com */
/* Software licenced under a modified X11 licence, see documentation or authors website for more details */

function sack(file){
	this.AjaxFailedAlert = "Your browser does not support the enhanced functionality of this website, and therefore you will have an experience that differs from the intended one.\n";
	this.requestFile = file;
	this.method = "POST";
	this.URLString = "";
	this.encodeURIString = true;
	this.execute = false;

	this.onLoading = function() { };
	this.onLoaded = function() { };
	this.onInteractive = function() { };
	this.onCompletion = function() { };

	this.createAJAX = function() {
		try {
			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (err) {
				this.xmlhttp = null;
			}
		}
		if(!this.xmlhttp && typeof XMLHttpRequest != "undefined")
			this.xmlhttp = new XMLHttpRequest();
		if (!this.xmlhttp){
			this.failed = true; 
		}
	};
	
	this.setVar = function(name, value){
		if (this.URLString.length < 3){
			this.URLString = name + "=" + value;
		} else {
			this.URLString += "&" + name + "=" + value;
		}
	}
	
	this.encVar = function(name, value){
		var varString = encodeURIComponent(name) + "=" + encodeURIComponent(value);
	return varString;
	}
	
	this.encodeURLString = function(string){
		varArray = string.split('&');
		for (i = 0; i < varArray.length; i++){
			urlVars = varArray[i].split('=');
			if (urlVars[0].indexOf('amp;') != -1){
				urlVars[0] = urlVars[0].substring(4);
			}
			varArray[i] = this.encVar(urlVars[0],urlVars[1]);
		}
	return varArray.join('&');
	}
	
	this.runResponse = function(){
		eval(this.response);
	}
	
	this.runAJAX = function(urlstring){
		this.responseStatus = new Array(2);
		if(this.failed && this.AjaxFailedAlert){ 
			alert(this.AjaxFailedAlert); 
		} else {
			if (urlstring){ 
				if (this.URLString.length){
					this.URLString = this.URLString + "&" + urlstring; 
				} else {
					this.URLString = urlstring; 
				}
			}
			if (this.encodeURIString){
				var timeval = new Date().getTime(); 
				this.URLString = this.encodeURLString(this.URLString);
				this.setVar("rndval", timeval);
			}
			if (this.element) { this.elementObj = document.getElementById(this.element); }
			if (this.xmlhttp) {
				var self = this;
				if (this.method == "GET") {
					var totalurlstring = this.requestFile + "?" + this.URLString;
					this.xmlhttp.open(this.method, totalurlstring, true);
				} else {
					this.xmlhttp.open(this.method, this.requestFile, true);
				}
				if (this.method == "POST"){
  					try {
						this.xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded')  
					} catch (e) {}
				}

				this.xmlhttp.send(this.URLString);
				this.xmlhttp.onreadystatechange = function() {
					switch (self.xmlhttp.readyState){
						case 1:
							self.onLoading();
						break;
						case 2:
							self.onLoaded();
						break;
						case 3:
							self.onInteractive();
						break;
						case 4:
							self.response = self.xmlhttp.responseText;
							self.responseXML = self.xmlhttp.responseXML;
							self.responseStatus[0] = self.xmlhttp.status;
							self.responseStatus[1] = self.xmlhttp.statusText;
							self.onCompletion();
							if(self.execute){ self.runResponse(); }
							if (self.elementObj) {
								var elemNodeName = self.elementObj.nodeName;
								elemNodeName.toLowerCase();
								if (elemNodeName == "input" || elemNodeName == "select" || elemNodeName == "option" || elemNodeName == "textarea"){
									self.elementObj.value = self.response;
								} else {
									self.elementObj.innerHTML = self.response;
								}
							}
							self.URLString = "";
						break;
					}
				};
			}
		}
	};
this.createAJAX();
}

// END Ajax.js

// Ajax-content.js
var enableCache = true;
var jsCache = new Array();

var C_Objects = new Array();

function ajax_showContent(divId,ajaxIndex,url)
{
	document.getElementById(divId).innerHTML = C_Objects[ajaxIndex].response;
	centerOnPage()
	if(enableCache){
		jsCache[url] = 	C_Objects[ajaxIndex].response;
	}
	C_Objects[ajaxIndex] = false;
}



function ajax_loadContent(divId,url)
{
	if(enableCache && jsCache[url]){
		document.getElementById(divId).innerHTML = jsCache[url];
		return;
	}
	
	var ajaxIndex = C_Objects.length;
	//document.getElementById(divId).innerHTML = '<div style="overflow:hidden;text-align:center;padding:20px;width:100%;height:auto;"><br><br><embed src="../images/flash/spruz_loader.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="30" height="30" name="Spruz Loader" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></div>';
	document.getElementById(divId).innerHTML = 'Loading...'

	C_Objects[ajaxIndex] = new sack();
	C_Objects[ajaxIndex].requestFile = url;	
	C_Objects[ajaxIndex].onCompletion = function(){ ajax_showContent(divId,ajaxIndex,url); };	// Load the file
	C_Objects[ajaxIndex].runAJAX();		// Execute function	
	
	
}
function chatbox_loadContent(divId,url)
{

	var ajaxIndex = C_Objects.length;
	//document.getElementById(divId).innerHTML = '<font color="#333333">Retrieving Data...Please wait.</font>';
	C_Objects[ajaxIndex] = new sack();
	C_Objects[ajaxIndex].requestFile = url;
	C_Objects[ajaxIndex].onCompletion = function(){ ajax_showContent(divId,ajaxIndex,url); };	// Load the file
	C_Objects[ajaxIndex].runAJAX();		// Execute function	
	
	
}
function noinner_loadContent(divId,url)
{

	var ajaxIndex = C_Objects.length;
	//document.getElementById(divId).innerHTML = '<font color="#333333">Retrieving Data...Please wait.</font>';
	C_Objects[ajaxIndex] = new sack();
	C_Objects[ajaxIndex].requestFile = url;
	C_Objects[ajaxIndex].onCompletion = function(){ ajax_showContent(divId,ajaxIndex,url); };	// Load the file
	C_Objects[ajaxIndex].runAJAX();		// Execute function	
	
	
}
function ajax_send(url)
{
	var ajaxIndex = C_Objects.length;
	C_Objects[ajaxIndex] = new sack();
	C_Objects[ajaxIndex].requestFile = url;
	if(arguments[1]){	
		C_Objects[ajaxIndex].onCompletion = arguments[1];	// Load the file
	}
	C_Objects[ajaxIndex].runAJAX();		// Execute function	
}
function ajax_getJSON(url,exe,cache,exarg)
{
	if(cache){
		var dcache = SAUI.util.DomStorage.get(url,7200);
	}
	else{
		var dcache = false;
	}
	if(dcache==false){
		var ajaxIndex = C_Objects.length;
		C_Objects[ajaxIndex] = new sack();
		C_Objects[ajaxIndex].requestFile = url;
		C_Objects[ajaxIndex].onCompletion = function(){
			try{
				if(!exarg){
					exe(eval(C_Objects[ajaxIndex].response));
				}else{exe(eval(C_Objects[ajaxIndex].response),exarg);}
				if(cache){
					SAUI.util.DomStorage.set(url,C_Objects[ajaxIndex].response);
				}
			}catch(Error){};
			C_Objects[ajaxIndex] = false;
		}
		C_Objects[ajaxIndex].runAJAX();		// Execute function	
	}
	else{
		if(!exarg){
			exe(eval(dcache));
		}else{exe(eval(dcache),exarg);}
	}
}

// END Ajax-content.js

// Ajax-tools.js

var x_offset_DropDown = -50;
var y_offset_DropDown = 15;


var ajax_DropDown = false;
var ajax_DropDown_iframe = false;

var ajax_DropDown_MSIE = false;
if(navigator.userAgent.indexOf('MSIE')>=0)ajax_DropDown_MSIE=true;




function ajax_dropitdown(externalFile,inputObj,width)
{

	if(!ajax_DropDown)
	{
		ajax_DropDown = document.createElement('DIV');
		ajax_DropDown.style.position = 'absolute';
		ajax_DropDown.style.width = width+'px';
		
		ajax_DropDown.style.zIndex = '50002';
		ajax_DropDown.style.backgroundColor = '#FFF';
		ajax_DropDown.id = 'ajax_DropDown';		
		document.body.appendChild(ajax_DropDown);

		
		//var leftDiv = document.createElement('DIV');
		//leftDiv.className='ajax_tooltip_arrow';
		//leftDiv.id = 'ajax_tooltip_arrow';
		//ajax_DropDown.appendChild(leftDiv);
		
		var contentDiv = document.createElement('DIV');
		contentDiv.className = 'ajax_tooltip_content';
		//contentDiv.style.width = width+'px';
		ajax_DropDown.appendChild(contentDiv);
		contentDiv.id = 'ajax_DropDown_content';
		
		if(ajax_DropDown_MSIE){	/* Create iframe object*/
			ajax_DropDown_iframe = document.createElement('<IFRAME frameborder="0">');
			ajax_DropDown_iframe.style.position = 'absolute';
			ajax_DropDown_iframe.border='0';
			ajax_DropDown_iframe.frameborder=0;
			ajax_DropDown_iframe.style.backgroundColor='#FFF';
			ajax_DropDown_iframe.src = 'about:blank';
			contentDiv.appendChild(ajax_DropDown_iframe);
			ajax_DropDown_iframe.style.left = '0px';
			ajax_DropDown_iframe.style.top = '0px';
		}

		
	}
	// Find position of tooltip
	ajax_DropDown.style.display='block';
	ajax_DropDown.style.width = width+'px';
	//document.getElementById('ajax_tooltip_content').style.width = width+'px';
	ajax_loadContent('ajax_DropDown_content',externalFile);
	if(ajax_DropDown_MSIE){
		ajax_DropDown_iframe.style.width = ajax_DropDown.clientWidth + 'px';
		ajax_DropDown_iframe.style.height = ajax_DropDown.clientHeight + 'px';
	}

	ajax_positionDropDown(inputObj);
}

function ajax_positionDropDown(inputObj)
{
    /* old Setting
	var leftPos = (ajaxTooltip_getLeftPos(inputObj) + inputObj.offsetWidth + x_offset_tooltip);
	*/
	

	var leftPos = (ajaxTooltip_getLeftPos(inputObj) + x_offset_DropDown);

	var topPos = ajaxTooltip_getTopPos(inputObj) + y_offset_DropDown;
	//var rightPosname = 'right'
	//var rightPos = ajaxTooltip_getRightPos(inputObj)
	
	//var rightedge=ajax_tooltip_MSIE? document.body.clientWidth-leftPos : window.innerWidth-leftPos
	//var bottomedge=ajax_tooltip_MSIE? document.body.clientHeight-topPos : window.innerHeight-topPos
	var windowedge = ajax_DropDown_MSIE? document.body.clientWidth : window.innerWidth
	var rightedge=ajax_DropDown_MSIE? document.body.clientWidth-leftPos : window.innerWidth-leftPos
	var bottomedge=ajax_DropDown_MSIE? document.body.clientHeight-topPos : window.innerHeight-topPos
	var tooltipWidth = document.getElementById('ajax_DropDown_content').offsetWidth 
	var tooltipHeight = document.getElementById('ajax_DropDown_content').offsetHeight

	var offset = tooltipWidth + leftPos;
	
	//var leftPos = rightedge 
	//document.write(tooltipWidth)
	var adjustloc = (offset - windowedge);
	if(offset>windowedge)leftPos = leftPos - adjustloc - 20;
	if(leftPos<0)leftPos = 20;

	//alert(adjustloc)
	//alert(leftPos - tooltipWidth)
	ajax_DropDown.style.left = leftPos + 'px';
	ajax_DropDown.style.top = topPos + 'px';	
	
	
}

var x_offset_tooltip = -50;
var y_offset_tooltip = 15;


var ajax_tooltipObj = false;
var ajax_tooltipObj_iframe = false;

var ajax_tooltip_MSIE = false;
if(navigator.userAgent.indexOf('MSIE')>=0)ajax_tooltip_MSIE=true;

function ajax_showTooltip_menu(externalFile,inputObj,width)
{

	if(!document.getElementById('ajax_tooltipObj_menu'))
	{
		ajax_tooltipObj = document.createElement('DIV');
		ajax_tooltipObj.style.position = 'absolute';
		ajax_tooltipObj.style.width = width+'px';
		
		ajax_tooltipObj.style.zIndex = '50001';
		ajax_tooltipObj.style.backgroundColor = 'transparent';
		ajax_tooltipObj.id = 'ajax_tooltipObj_menu';		
		document.body.appendChild(ajax_tooltipObj);

		
		var leftDiv = document.createElement('DIV');
		//leftDiv.className='ajax_tooltip_arrow';
		leftDiv.id = 'ajax_tooltip_arrow';
		ajax_tooltipObj.appendChild(leftDiv);
		
		var contentDiv = document.createElement('DIV');
		//contentDiv.className = 'ajax_tooltip_content';
		//contentDiv.style.width = width+'px';
		ajax_tooltipObj.appendChild(contentDiv);
		contentDiv.id = 'ajax_tooltip_content';
		
		if(ajax_tooltip_MSIE){	/* Create iframe object*/
			ajax_tooltipObj_iframe = document.createElement('<IFRAME frameborder="0">');
			ajax_tooltipObj_iframe.style.position = 'absolute';
			ajax_tooltipObj_iframe.border='0';
			ajax_tooltipObj_iframe.frameborder=0;
			ajax_tooltipObj_iframe.style.backgroundColor='#FFF';
			ajax_tooltipObj_iframe.src = 'about:blank';
			contentDiv.appendChild(ajax_tooltipObj_iframe);
			ajax_tooltipObj_iframe.style.left = '0px';
			ajax_tooltipObj_iframe.style.top = '0px';
		}

		
	}
	// Find position of tooltip
	ajax_tooltipObj.style.display='block';
	ajax_tooltipObj.style.width = width+'px';
	//document.getElementById('ajax_tooltip_content').style.width = width+'px';
	ajax_loadContent('ajax_tooltip_content',externalFile);
	if(ajax_tooltip_MSIE){
		ajax_tooltipObj_iframe.style.width = ajax_tooltipObj.clientWidth + 'px';
		ajax_tooltipObj_iframe.style.height = ajax_tooltipObj.clientHeight + 'px';
	}

	//ajax_positionTooltip(inputObj);
	
	getOptionBox('ajax_tooltipObj_menu',inputObj)

}

function ajax_showSiteIntro(externalFile)
{
	document.getElementById('container').style.display = 'none';
	(function(){
		var outer = document.createElement('div');
		outer.id = 'ajax_siteintro-outer';
		outer.style.cssText = 'position: absolute; top: 0; left: 0; margin: 0; padding: 0; width: 100%;';
		var topbar = document.createElement('div');
		topbar.className = 'element-row1';
		topbar.style.cssText = 'margin: 0 0 10px 0; padding: 10px; border-bottom: 1px solid #808080; text-align: center; font-size: 1.15em; font-weight: bold;';
		var closelink = document.createElement('a');
		closelink.href = '#';
		closelink.onclick = function(){
			document.getElementById('ajax_siteintro-outer').style.display = 'none';
			document.getElementById('container').style.display = '';
			try{
				document.getElementById('ajax_siteintro-outer').parentNode.removeChild(document.getElementById('ajax_siteintro-outer'));
			}catch(Error){}
			return false;
		}
		closelink.innerHTML = 'Continue to ' + document.title;
		var inner = document.createElement('div');
		inner.id = 'ajax_siteintro';
		topbar.appendChild(closelink);
		outer.appendChild(topbar);
		outer.appendChild(inner);
		document.getElementsByTagName('body')[0].insertBefore(outer,document.getElementsByTagName('body')[0].childNodes[0]);
	})();
	ajax_loadContent('ajax_siteintro',externalFile);
	
}


var optionbox;
var keep_ob_centered;

function centerOnPage(){
	if (optionbox != null){
	
		
	
		var ie=document.all && !window.opera
		var dom=document.getElementById
		var iebody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
		var objref=(dom)? document.getElementById(optionbox) : document.all.optionbox
	var t100 = new Date().getTime();

		var scroll_top=(ie)? iebody.scrollTop : window.pageYOffset
		//var scroll_top = 0;
	
	
		var docwidth=(window.innerWidth)? window.innerWidth : iebody.clientWidth;
		var docheight=(window.innerHeight)? window.innerHeight : iebody.clientHeight;
	var t101 = new Date().getTime();
	//alert(t101-t100);
		
		var objwidth=objref.offsetWidth
		var objheight=objref.offsetHeight
		
		
		objref.style.left=docwidth/2-objwidth/2+"px"
		if(docheight-objheight > 0){
			objref.style.top=scroll_top+docheight/2-objheight/2+"px"
		}
		else{
			objref.style.top = scroll_top + "px";
		}
		
	}
}
window.onresize= checkforcentered;
window.onscroll= checkforcentered;

function checkforcentered() {
	if(keep_ob_centered){
		if (optionbox != null){
		var ie=document.all && !window.opera
		var dom=document.getElementById
		iebody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
		objref=(dom)? document.getElementById(optionbox) : document.all.optionbox
		var scroll_top=(ie)? iebody.scrollTop : window.pageYOffset
		var docwidth=(ie)? iebody.clientWidth : window.innerWidth
		docheight=(ie)? iebody.clientHeight: window.innerHeight
		var objwidth=objref.offsetWidth
		objheight=objref.offsetHeight
		}

		if(keep_ob_centered == true && docheight-objheight > 0){
			centerOnPage()
		}
	}
}


function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

var getOptionBox = function(boxid,origin,options){
	if(boxid == 'new'){
		boxid = 'ob-tr96581';
		
		(function(){
			var objholder = {};
			objholder.tr = [];
			objholder.td = [];
			objholder.tdclass = ['tl','t','tr','l','susdialog-inner','r','bl','b','br'];
			var container = document.createElement('div');
			container.id = 'ob-tr96581';
			container.style.cssText = 'visiblity: hidden; display: block; position: absolute; z-index: 50001; top: 0; left: 0;';

			
			container.style.width = options.width || '500px'; // Option
			
			var table = document.createElement('table');
			table.width = '100%';
			table.border = '0';
			table.setAttribute('cellSpacing','0');
			table.setAttribute('cellPadding','0');
			table.className = 'susdialog';
			var tablebody = document.createElement('tbody');
			
			for(i=0;i<3;i++){
				var trnum = objholder.tr.length;
				objholder.tr[trnum] = document.createElement('TR');
				for(ii=0;ii<3;ii++){
					var tdnum = objholder.td.length;
					objholder.td[tdnum] = document.createElement('TD');
					objholder.td[tdnum].className = objholder.tdclass[tdnum];
					var span = '<span></span>';
					if(trnum == 0 || trnum == 2){
						objholder.td[tdnum].height = '42';
						objholder.td[tdnum].innerHTML = span;
						if(objholder.tdclass[tdnum] != 't' && objholder.tdclass[tdnum] != 'b'){
							objholder.td[tdnum].width = '42';
						}
					}
					if(objholder.tdclass[tdnum] == 'l' || objholder.tdclass[tdnum] == 'r'){
						objholder.td[tdnum].width = '42';
						objholder.td[tdnum].innerHTML = span;
					}
					if(objholder.tdclass[tdnum] == 'susdialog-inner'){
						var title = document.createElement('div');
						title.className = 'title';
						var content = document.createElement('div');
						content.className = 'content';
						var tspan = document.createElement('span');
						tspan.innerHTML = options.title || 'Dialog Box'; // Option
						var tclose = document.createElement('a');
						tclose.href= '#';
						tclose.title = 'Close';
						tclose.innerHTML = 'x';
						tclose.onclick = function(){
							hideoptionbox();
							return false;
						}
						title.appendChild(tspan);
						title.appendChild(tclose);
						content.appendChild(options.content); // Option
						objholder.td[tdnum].appendChild(title);
						objholder.td[tdnum].appendChild(content);
					}
					objholder.tr[trnum].appendChild(objholder.td[tdnum]);
				}
				tablebody.appendChild(objholder.tr[trnum]);
			}
			
			
			table.appendChild(tablebody);
			container.appendChild(table);
			document.getElementsByTagName('body')[0].appendChild(container);
			if(options && options.callback){
				options.callback();
			}
			
		})();
	}
	
	optionbox = boxid;
	boxstyle = document.getElementById(boxid).style;
	boxstyle.visibility = "hidden";
	boxstyle.display = "block";
	boxstyle.position = "absolute";
	//var t100 = new Date().getTime();
	centerOnPage();
	//var t101 = new Date().getTime();
	//alert(t101-t100);
	keep_ob_centered = true;
	
	if(origin){
		var target = document.getElementById(boxid)
		var growto = new Array (target.offsetWidth,target.offsetHeight,findPos(target)[0],findPos(target)[1]);
		var growfrom = new Array (origin.offsetWidth,origin.offsetHeight,findPos(origin)[0],findPos(origin)[1]);
		if(document.getElementById('ob-tr96580') == null){
			  var newdiv = document.createElement('div');
			  var divIdName = 'ob-tr96580';
			  newdiv.setAttribute('id',divIdName);
			  document.getElementsByTagName('body')[0].insertBefore(newdiv,document.getElementsByTagName('body')[0].childNodes[0]);
			  //document.getElementsByTagName('body')[0].appendChild(newdiv);
		}
		
		function fadein(){
			var endvis = 100;
			var startvis = 0;
			var cover = document.getElementById(optionbox);
			
			function show(){
				cover.style.filter = "alpha(opacity=" + startvis + ")";
				cover.style.opacity = "." + startvis;
				cover.style.visibility = "visible";
				startvis = startvis + 10;
				if (startvis < endvis){
					window.setTimeout(show, 10);
				}
				else{
					cover.style.removeAttribute('filter');
					cover.style.opacity = "1";
					document.getElementById('ob-tr96580').style.display = 'none';
				}
				
			}
			show();	
		}
		
		function traceout(){
			var endvis = 100;
			var startvis = 60;
			var steps = 10;
			var cover = document.getElementById('ob-tr96580').style;
			cover.display = 'none';
			cover.position = 'absolute';
			cover.backgroundColor = '#ebebeb';
			cover.border = '2px solid #D8D8D8';
			
			var startleft = growfrom[2];
			var starttop = growfrom[3];
			var startwidth = growfrom[0];
			var startheight = growfrom[1];
			var endleft = growto[2];
			var endtop = growto[3];
			var endwidth = growto[0]-4;
			var endheight = growto[1]-4;
			
			var visstep = (endvis - startvis) / steps;
			var leftstep = (endleft - startleft) / steps;
			var topstep = (endtop - starttop) / steps;
			var widthstep = (endwidth - startwidth) / steps;
			var heightstep = (endheight - startheight) / steps;
			
			function grow(){
				cover.left = startleft + 'px';
				cover.top = starttop + 'px';
				cover.width = startwidth + 'px';
				cover.height = startheight + 'px';
				cover.filter = "alpha(opacity=" + startvis + ")";
				cover.opacity = "." + startvis;
				cover.display = "block";
				cover.zIndex = '10';
				
				startvis = startvis + visstep;
				startleft = startleft + leftstep;
				starttop = starttop + topstep;
				startwidth = startwidth + widthstep;
				startheight = startheight + heightstep;
				
				if (steps > 0){
				steps--
				window.setTimeout(grow, 10);
				}
				else{
					//fadein();
					//alert('this');
					document.getElementById(optionbox).style.visibility = "visible";
					cover.display = "none";
				}
				
			}
			grow();
		}
		
		traceout();
	}
	else{
	document.getElementById(boxid).style.visibility = "visible";
	
	}
};

function hideoptionbox(){
	document.getElementById(optionbox).style.visibility="hidden";
	try{
		document.getElementById(optionbox).parentNode.removeChild(document.getElementById(optionbox));
	}catch(Error){}
	keep_ob_centered = false;
}

function ajax_showTooltip(externalFile,inputObj)
{
	if(!ajax_tooltipObj)	/* Check for Box Creation */
	{
		ajax_tooltipObj = document.createElement('DIV');
		ajax_tooltipObj.style.position = 'absolute';
		ajax_tooltipObj.style.zIndex = '50001';
		ajax_tooltipObj.id = 'ajax_tooltipObj';	
		ajax_tooltipObj.style.backgroundColor = 'transparent';
		ajax_tooltipObj.style.width = '470px';
		document.body.appendChild(ajax_tooltipObj);
		
		var contentDiv = document.createElement('DIV'); 
		//contentDiv.className = 'ajax_tooltip_content';
		ajax_tooltipObj.appendChild(contentDiv);
		contentDiv.id = 'ajax_tooltip_content';


		if(ajax_tooltip_MSIE){	/* Create iframe object for MSIE in order to make the tooltip cover select boxes */
			ajax_tooltipObj_iframe = document.createElement('<IFRAME frameborder="0">');
			ajax_tooltipObj_iframe.style.position = 'absolute';
			ajax_tooltipObj_iframe.border='0';
			ajax_tooltipObj_iframe.frameborder=0;
			ajax_tooltipObj_iframe.style.backgroundColor='#FFF';
			ajax_tooltipObj_iframe.src = 'about:blank';
			contentDiv.appendChild(ajax_tooltipObj_iframe);
			ajax_tooltipObj_iframe.style.left = '0px';
			ajax_tooltipObj_iframe.style.top = '0px';
		}

			
	}
	
    //ajax_hideTooltip_menu()
	// Find position of tooltip
	ajax_tooltipObj.style.display='block';
	ajax_loadContent('ajax_tooltip_content',externalFile);
	if(ajax_tooltip_MSIE){
		ajax_tooltipObj_iframe.style.width = ajax_tooltipObj.clientWidth + 'px';
		ajax_tooltipObj_iframe.style.height = ajax_tooltipObj.clientHeight + 'px';
	}

	//ajax_positionTooltip(inputObj);
	getOptionBox('ajax_tooltipObj',inputObj)
}
function ajax_showTooltip_search(externalFile,inputObj)
{
var x_offset_tooltip = -0;
var y_offset_tooltip = 20;
	if(!ajax_tooltipObj)	/* Check for Box Creation */
	{
		ajax_tooltipObj = document.createElement('DIV');
		ajax_tooltipObj.style.position = 'absolute';
		ajax_tooltipObj.style.zIndex = '50001';
		ajax_tooltipObj.id = 'ajax_tooltipObj';		
		document.body.appendChild(ajax_tooltipObj);

		

		
		var contentDiv = document.createElement('DIV'); 
		contentDiv.className = 'ajax_tooltip_content';
		ajax_tooltipObj.appendChild(contentDiv);
		contentDiv.id = 'ajax_tooltip_content';
		
		if(ajax_tooltip_MSIE){	/* Create iframe object for MSIE in order to make the tooltip cover select boxes */
			ajax_tooltipObj_iframe = document.createElement('<IFRAME frameborder="0">');
			ajax_tooltipObj_iframe.style.position = 'absolute';
			ajax_tooltipObj_iframe.border='0';
			ajax_tooltipObj_iframe.frameborder=0;
			ajax_tooltipObj_iframe.style.backgroundColor='#FFF';
			ajax_tooltipObj_iframe.src = 'about:blank';
			contentDiv.appendChild(ajax_tooltipObj_iframe);
			ajax_tooltipObj_iframe.style.left = '0px';
			ajax_tooltipObj_iframe.style.top = '0px';
		}

			
	}
	// Find position of tooltip
	ajax_tooltipObj.style.display='block';
	chatbox_loadContent('ajax_tooltip_content',externalFile);
	if(ajax_tooltip_MSIE){
		ajax_tooltipObj_iframe.style.width = ajax_tooltipObj.clientWidth + 'px';
		ajax_tooltipObj_iframe.style.height = ajax_tooltipObj.clientHeight + 'px';
	}

	var leftPos = (ajaxTooltip_getLeftPos(inputObj) + x_offset_tooltip);
	var topPos = ajaxTooltip_getTopPos(inputObj) + y_offset_tooltip;
	ajax_tooltipObj.style.left = leftPos + 'px';
	ajax_tooltipObj.style.top = topPos + 'px';
}

function ajax_showToolhigh(externalFile,inputObj)
{
	if(!ajax_tooltipObj)	/* Check for Box Creation */
	{
		ajax_tooltipObj = document.createElement('DIV');
		ajax_tooltipObj.style.position = 'absolute';
		ajax_tooltipObj.id = 'ajax_tooltipObj';		
		document.body.appendChild(ajax_tooltipObj);

		

		
		var contentDiv = document.createElement('DIV'); 
		contentDiv.className = 'ajax_tooltip_content';
		ajax_tooltipObj.appendChild(contentDiv);
		contentDiv.id = 'ajax_tooltip_content';
		
		if(ajax_tooltip_MSIE){	/* Create iframe object for MSIE in order to make the tooltip cover select boxes */
			ajax_tooltipObj_iframe = document.createElement('<IFRAME frameborder="0">');
			ajax_tooltipObj_iframe.style.position = 'absolute';
			ajax_tooltipObj_iframe.border='0';
			ajax_tooltipObj_iframe.frameborder=0;
			ajax_tooltipObj_iframe.style.backgroundColor='#FFF';
			ajax_tooltipObj_iframe.src = 'about:blank';
			contentDiv.appendChild(ajax_tooltipObj_iframe);
			ajax_tooltipObj_iframe.style.left = '0px';
			ajax_tooltipObj_iframe.style.top = '0px';
		}

			
	}
	// Find position of tooltip
	ajax_tooltipObj.style.display='block';
	ajax_loadContent('ajax_tooltip_content',externalFile);
	if(ajax_tooltip_MSIE){
		ajax_tooltipObj_iframe.style.width = ajax_tooltipObj.clientWidth + 'px';
		ajax_tooltipObj_iframe.style.height = ajax_tooltipObj.clientHeight + 'px';
	}

	ajax_positionTooltiphigh(inputObj);
}
function ajax_showTooltipmid(externalFile,inputObj)
{
	if(!ajax_tooltipObj)	/* Check for Box Creation */
	{
		ajax_tooltipObj = document.createElement('DIV');
		ajax_tooltipObj.style.position = 'absolute';
		ajax_tooltipObj.style.zIndex = '50001';
		ajax_tooltipObj.id = 'ajax_tooltipObj';
		ajax_tooltipObj.style.left = '200px';
	    ajax_tooltipObj.style.top = '150px';			
		document.body.appendChild(ajax_tooltipObj);

		

		
		var contentDiv = document.createElement('DIV'); 
		contentDiv.className = 'ajax_tooltip_content';
		ajax_tooltipObj.appendChild(contentDiv);
		contentDiv.id = 'ajax_tooltip_content';
		
		if(ajax_tooltip_MSIE){	/* Create iframe object for MSIE in order to make the tooltip cover select boxes */
			ajax_tooltipObj_iframe = document.createElement('<IFRAME frameborder="0">');
			ajax_tooltipObj_iframe.style.position = 'absolute';
			ajax_tooltipObj_iframe.border='0';
			ajax_tooltipObj_iframe.frameborder=0;
			ajax_tooltipObj_iframe.style.backgroundColor='#FFF';
			ajax_tooltipObj_iframe.src = 'about:blank';
			contentDiv.appendChild(ajax_tooltipObj_iframe);
			ajax_tooltipObj_iframe.style.left = '0px';
			ajax_tooltipObj_iframe.style.top = '0px';
		}

			
	}
	// Find position of tooltip
	ajax_tooltipObj.style.display='block';
	ajax_loadContent('ajax_tooltip_content',externalFile);
	if(ajax_tooltip_MSIE){
		ajax_tooltipObj_iframe.style.width = ajax_tooltipObj.clientWidth + 'px';
		ajax_tooltipObj_iframe.style.height = ajax_tooltipObj.clientHeight + 'px';
	}

	//ajax_positionTooltip(inputObj);
}

function ajax_positionTooltip(inputObj)
{
    /* old Setting
	var leftPos = (ajaxTooltip_getLeftPos(inputObj) + inputObj.offsetWidth + x_offset_tooltip);
	*/
	

	var leftPos = (ajaxTooltip_getLeftPos(inputObj) + x_offset_tooltip);

	var topPos = ajaxTooltip_getTopPos(inputObj) + y_offset_tooltip;
	//var rightPosname = 'right'
	//var rightPos = ajaxTooltip_getRightPos(inputObj)
	
	//var rightedge=ajax_tooltip_MSIE? document.body.clientWidth-leftPos : window.innerWidth-leftPos
	//var bottomedge=ajax_tooltip_MSIE? document.body.clientHeight-topPos : window.innerHeight-topPos
	var windowedge = ajax_tooltip_MSIE? document.body.clientWidth : window.innerWidth
	var rightedge=ajax_tooltip_MSIE? document.body.clientWidth-leftPos : window.innerWidth-leftPos
	var bottomedge=ajax_tooltip_MSIE? document.body.clientHeight-topPos : window.innerHeight-topPos
	var tooltipWidth = document.getElementById('ajax_tooltip_content').offsetWidth 
	var tooltipHeight = document.getElementById('ajax_tooltip_content').offsetHeight

	var offset = tooltipWidth + leftPos;
	
	//var leftPos = rightedge 
	//document.write(tooltipWidth)
	var adjustloc = (offset - windowedge);
	if(offset>windowedge)leftPos = leftPos - adjustloc - 20;
	if(leftPos<0)leftPos = 20;

	//alert(adjustloc)
	//alert(leftPos - tooltipWidth)
	ajax_tooltipObj.style.left = leftPos + 'px';
	ajax_tooltipObj.style.top = topPos + 'px';	
	
	
}

function ajax_positionTooltiphigh(inputObj)
{
    /* old Setting
	var leftPos = (ajaxTooltip_getLeftPos(inputObj) + inputObj.offsetWidth + x_offset_tooltip);
	*/
	var tooltipHeight = document.getElementById('ajax_tooltip_content').offsetHeight
	var x_offset_tooltip = -50;
	var y_offset_tooltip = -tooltipHeight;

	var leftPos = (ajaxTooltip_getLeftPos(inputObj) + x_offset_tooltip);

	var topPos = ajaxTooltip_getTopPos(inputObj) + y_offset_tooltip;

	//var rightPosname = 'right'
	//var rightPos = ajaxTooltip_getRightPos(inputObj)
	
	//var rightedge=ajax_tooltip_MSIE? document.body.clientWidth-leftPos : window.innerWidth-leftPos
	//var bottomedge=ajax_tooltip_MSIE? document.body.clientHeight-topPos : window.innerHeight-topPos
	var rightedge=ajax_tooltip_MSIE? document.body.clientWidth-leftPos : window.innerWidth-leftPos
	var bottomedge=ajax_tooltip_MSIE? document.body.clientHeight-topPos : window.innerHeight-topPos
	var tooltipWidth = document.getElementById('ajax_tooltip_content').offsetWidth +  document.getElementById('ajax_tooltip_arrow').offsetWidth; 
	
	// Dropping this reposition for now because of flickering
	var offset = tooltipWidth - rightedge;
	
	//var leftPos = rightedge 
	//document.write(tooltipWidth)
	if(offset>0)leftPos = document.body.clientWidth-leftPos-50;
	//if(offset>0)leftPos = '10';
	//if(leftPos<0)leftPos = leftPos + 200;
	//if(rightPos>0)leftPos = -1000;
	//document.write(document.body.clientWidth/2)
	//document.write(tooltipHeight)
	ajax_tooltipObj.style.left = leftPos + 'px';
	ajax_tooltipObj.style.top = topPos + 'px';	
	
	
}


function ajax_hideTooltip()
{
	ajax_tooltipObj.style.display='none';
}
function ajax_hideTooltip_menu()
{
	ajax_tooltipObj_menu.style.display='none';
}
function ajaxTooltip_getTopPos(inputObj)
{		
  var returnValue = inputObj.offsetTop;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetTop;
  }
  return returnValue;
}

function ajaxTooltip_getLeftPos(inputObj)
{
  var returnValue = inputObj.offsetLeft;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetLeft;
  }
  return returnValue;
}
function ajaxTooltip_getRightPos(inputObj)
{
  var returnValue = inputObj.offsetRight;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetRight;
  }
  return returnValue;
}
var jaybox = false;
var jaybox_iframe = false;
var jaybox_MSIE = false;
if(navigator.userAgent.indexOf('MSIE')>=0)jaybox_MSIE=true;
function ajax_loadfreewindow(externalFile,left_p,top_p,boxsize)
{
	if(!jaybox)	/* Check for Box Creation */
	{
		jaybox = document.createElement('DIV');
		jaybox.style.position = 'absolute';
		jaybox.style.zIndex = '50001';
		jaybox.id = 'jaybox';
		jaybox.style.width = boxsize+'px';
		jaybox.style.border = '50px'
		jaybox.style.left = left_p+'px';
	    jaybox.style.top = top_p+'px';
	    //jaybox.classname = "jayboxdiv"		
		//document.body.appendChild(jaybox);
		document.getElementById('jayboxdiv').appendChild(jaybox);
		document.getElementById('jaybox').style.display='inline';

		document.getElementById('jayboxdiv').style.display = 'inline'
		document.getElementById('jayboxdiv').style.width = boxsize+'px';
		
		var leftDiv = document.createElement('DIV');	/* Create arrow div */
		leftDiv.className='ajax_tooltip_arrow';
		leftDiv.id = 'ajax_jaybox_arrow';
		jaybox.appendChild(leftDiv);
		
		var contentDiv = document.createElement('DIV'); 
		contentDiv.className = 'ajax_tooltip_content';
		jaybox.appendChild(contentDiv);
		contentDiv.id = 'ajax_jaybox_content';
		
		if(jaybox_MSIE){	/* Create iframe object for MSIE in order to make the tooltip cover select boxes */
			jaybox_iframe = document.createElement('<IFRAME frameborder="0">');
			jaybox_iframe.style.position = 'absolute';
			jaybox_iframe.border='0';
			jaybox_iframe.frameborder=0;
			jaybox_iframe.style.backgroundColor='#FFF';
			jaybox_iframe.src = 'about:blank';
			contentDiv.appendChild(jaybox_iframe);
			jaybox_iframe.style.left = '0px';
			jaybox_iframe.style.top = '0px';
		}

			
	}
	// Find position of tooltip
	//jaybox.style.display='block';
	ajax_loadContent('ajax_jaybox_content',externalFile);
	if(jaybox_MSIE){
		jaybox_iframe.style.width = jaybox.clientWidth + 'px';
		jaybox_iframe.style.height = jaybox.clientHeight + 'px';
	}
	    jaybox.style.display='inline';

	//ajax_positionTooltip(inputObj);
}

function displaybox(box,left,top,twidth,theight,fwidth,fheight,steps){
	var ttop = top;
	var lleft = left
	var wfactor = 0;
	var hfactor = 0;
	var width = fwidth;
	var height = fheight;
	var framewidth = document.body.clientWidth;
	var frameheight = document.body.clientHeight;
		box.style.top = ttop + theight + 'px';
		box.style.height = 1 + 'px';
		box.style.overflow = 'hidden';
	if ((lleft + width)<framewidth){
	box.style.left = lleft + 'px';
	}
	if ((lleft + width)>framewidth){
	box.style.left = '';
	box.style.right = (framewidth - (lleft + twidth)) + 15 + 'px';

	}
	//alert('box '+ ttop + ' '+ (ttop + height) + ' Bottom ' + frameheight) + 'Math ' ;
	if ((ttop + height)>frameheight){
	
	box.style.top = ttop - (height) + 'px';
	}
	function grow(){
		box.style.display = 'block';
		box.style.width = wfactor + 'px';
		box.style.height = hfactor + 'px';


		wfactor = width / steps;
		hfactor = height / steps;
		steps--;
		if (steps>=0){
			window.setTimeout(grow, 15)
		}
		else{
		box.style.height = 'auto';
		box.style.overflow = 'auto';
		}

	}
	grow();

}

function getTopPos(inputObj){	
	var returnValue = inputObj.offsetTop;
	while((inputObj = inputObj.offsetParent) != null){
		returnValue += inputObj.offsetTop;
	}
	return returnValue;
}
	
function getLeftPos(inputObj){
	var returnValue = inputObj.offsetLeft;
	while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft;
	return returnValue;
}
	
  
function expandcontent(content,obj,width,height,stepsvar){
	var leftPos = getLeftPos(obj) + 20;
	var topPos = getTopPos(obj) - 5;
	var box = document.getElementById('postto');
	var thiswidth = obj.clientWidth;
	var thisheight = obj.clientHeight;
	var framewidth = width;
	var frameheight = height;
	var steps = stepsvar;
	steps = steps || 10;
	if(box!=null){
		box.innerHTML = '<div style="text-align:left;">'+content+'</div>';
		displaybox(box,leftPos,topPos,thiswidth,thisheight,framewidth,frameheight,steps); 
	}
}

function ajax_function(url,fun,passed)
{
	var ajaxIndex = C_Objects.length;
	C_Objects[ajaxIndex] = new sack();
	C_Objects[ajaxIndex].requestFile = url;
	if(fun){
		if(!passed){	
			C_Objects[ajaxIndex].onCompletion = function(){fun(C_Objects[ajaxIndex].response);}
		}
		else{
			C_Objects[ajaxIndex].onCompletion = function(){fun(C_Objects[ajaxIndex].response,passed);}
		}
	// Load the file
	}
	C_Objects[ajaxIndex].runAJAX();		// Execute function	
}

// END Ajax-tools.js
// END Ajax

//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
	var colors = SUI_GetStyles();
	var sui_colors = 'sRow1C=0x' + colors.row1c + '&sRow1B=0x' + colors.row1bg + '&sRow2C=0x' + colors.row2c + '&sRow2B=0x' + colors.row2bg + '&sLink=0x' + colors.alink;

  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?') + '&' +sui_colors; 
  else
    return src + ext +'?'+ sui_colors;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '';
  if (isIE && isWin && !isOpera)
  {
    str += '<object ';
    for (var i in objAttrs)
    {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else
  {
    str += '<embed ';
    for (var i in embedAttrs)
    {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblclick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

function SUI_GetStyles(){
	function toHex(N) {
	 if (N==null) return "00";
	 N=parseInt(N); if (N==0 || isNaN(N)) return "00";
	 N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
	 return "0123456789ABCDEF".charAt((N-N%16)/16)
	      + "0123456789ABCDEF".charAt(N%16);
	}
	var colors = new Object();

	var gcolorid = "gspot"+Math.random();
	document.write('<div class="element-row1" id="'+gcolorid+'"><a></a><div class="element-row2"><a></a></div></div>');
	function getStyle(el,styleProp,stylePropNS){
		var x = el;
		if (x.currentStyle){
				if(x.currentStyle[styleProp] != "transparent"){
					var y = x.currentStyle[styleProp];
				}
				else{y = 'trans';}
			}
		else if (window.getComputedStyle){
			//var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(stylePropNS);
			//alert(document.defaultView.getComputedStyle(x,null).getPropertyValue(stylePropNS));
				if(document.defaultView.getComputedStyle(x,null).getPropertyValue(stylePropNS) != "transparent"){
					z = document.defaultView.getComputedStyle(x,null).getPropertyValue(stylePropNS).split('(')[1].split(')')[0].split(', ');
				var y = "#"+toHex(z[0],16)+toHex(z[1],16)+toHex(z[2],16);
				}
			//alert("#"+toHex(z[0],16)+toHex(z[1],16)+toHex(z[2],16));
			else{y = 'trans';}
			}
		return y.replace(/#/,"");
	}
	colors.row1c = getStyle(document.getElementById(gcolorid),'color','color');
	colors.row1bg = getStyle(document.getElementById(gcolorid),'backgroundColor','background-color');
	colors.row2c = getStyle(document.getElementById(gcolorid).getElementsByTagName('div')[0],'color','color');
	colors.row2bg = getStyle(document.getElementById(gcolorid).getElementsByTagName('div')[0],'backgroundColor','background-color');
	colors.alink = getStyle(document.getElementById(gcolorid).getElementsByTagName('a')[0],'color','color');
	//colors.ahover = '';
	if(document.removeChild){
		document.getElementById(gcolorid).parentNode.removeChild(document.getElementById(gcolorid));
	}
	else{
		document.getElementById(gcolorid).style.display= 'none';
	}
	return colors;
}

function SUI_MakeCorner(size,corner){
	if (typeof AC_FL_RunContent == 'undefined' ||AC_FL_RunContent == 0) {
		//document.write('Flash cannot be loaded in the area.');
		return false;
	} else {
		AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
			'width', size,
			'height', size,
			'src', 'images/smart/corners?sCorner'+corner+'=1',
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'transparent',
			'devicefont', 'false',
			'id', 'test',
			'bgcolor', '#ffffff',
			'name', 'test',
			'menu', 'false',
			'allowFullScreen', 'false',
			'allowScriptAccess','sameDomain',
			'movie', 'images/smart/corners?sCorner'+corner+'=1',
			'salign', ''
			); //end AC code
	}

}

function SUI_MakeGrad(width,height,side){
	if (typeof AC_FL_RunContent == 'undefined' ||AC_FL_RunContent == 0) {
		//document.write('Flash cannot be loaded in the area.');
		return false;
	} else {
		AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
			'width', width,
			'height', height,
			'src', 'images/smart/grads?sGrad'+side+'=1',
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'exactfit',
			'wmode', 'transparent',
			'devicefont', 'false',
			'id', 'test',
			'bgcolor', '#ffffff',
			'name', 'test',
			'menu', 'false',
			'allowFullScreen', 'false',
			'allowScriptAccess','sameDomain',
			'movie', 'images/smart/grad?sGrad'+side+'=1',
			'salign', ''
			); //end AC code
	}

}

function SUI_MakeConcave(size){
	if (typeof AC_FL_RunContent == 'undefined' ||AC_FL_RunContent == 0) {
		//document.write('Flash cannot be loaded in the area.');
		return false;
	} else {
		AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
			'width', size*.75,
			'height', size,
			'src', 'images/smart/concave',
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'transparent',
			'devicefont', 'false',
			'id', 'test',
			'bgcolor', '#ffffff',
			'name', 'test',
			'menu', 'false',
			'allowFullScreen', 'false',
			'allowScriptAccess','sameDomain',
			'movie', 'images/smart/concave',
			'salign', ''
			); //end AC code
	}

}

// End Flash Loader

/*
  -------------------------------------------------------------------------
	                    JavaScript Form Validator 
                                Version 2.0.2
	Copyright 2003 JavaScript-coder.com. All rights reserved.
	You use this script in your Web pages, provided these opening credit
    lines are kept intact.
	The Form validation script is distributed free from JavaScript-Coder.com

	You may please add a link to JavaScript-Coder.com, 
	making it easy for others to find this script.
	Checkout the Give a link and Get a link page:
	http://www.javascript-coder.com/links/how-to-link.php

    You may not reprint or redistribute this code without permission from 
    JavaScript-Coder.com.
	
	JavaScript Coder
	It precisely codes what you imagine!
	Grab your copy here:
		http://www.javascript-coder.com/
	Changes and Updates contibuted by Spruz Inc.
    -------------------------------------------------------------------------  
*/
function Validator(frmname)
{
  this.formobj=document.forms[frmname];
	if(!this.formobj)
	{
	  alert("BUG: couldnot get Form object "+frmname);
		return;
	}
	if(this.formobj.onsubmit)
	{
	 this.formobj.old_onsubmit = this.formobj.onsubmit;
	 this.formobj.onsubmit=null;
	}
	else
	{
	 this.formobj.old_onsubmit = null;
	}
	this.formobj.onsubmit=form_submit_handler;
	this.addValidation = add_validation;
	this.setAddnlValidationFunction=set_addnl_vfunction;
	this.clearAllValidations = clear_all_validations;
}
function set_addnl_vfunction(functionname)
{
  this.formobj.addnlvalidation = functionname;
}
function clear_all_validations()
{
	for(var itr=0;itr < this.formobj.elements.length;itr++)
	{
		this.formobj.elements[itr].validationset = null;
	}
}
function form_submit_handler()
{
	for(var itr=0;itr < this.elements.length;itr++)
	{
		if(this.elements[itr].validationset &&
	   !this.elements[itr].validationset.validate())
		{
		  return false;
		}
	}
	if(this.addnlvalidation)
	{
	  str =" var ret = "+this.addnlvalidation+"()";
	  eval(str);
    if(!ret) return ret;
	}
	return true;
}
function add_validation(itemname,descriptor,errstr)
{
  if(!this.formobj)
	{
	  alert("BUG: the form object is not set properly");
		return;
	}//if
	var itemobj = this.formobj[itemname];
  if(!itemobj)
	{
	  alert("BUG: Couldnot get the input object named: "+itemname);
		return;
	}
	if(!itemobj.validationset)
	{
	  itemobj.validationset = new ValidationSet(itemobj);
	}
  itemobj.validationset.add(descriptor,errstr);
}
function ValidationDesc(inputitem,desc,error)
{
  this.desc=desc;
	this.error=error;
	this.itemobj = inputitem;
	this.validate=vdesc_validate;
}
function vdesc_validate()
{
 if(!V2validateData(this.desc,this.itemobj,this.error))
 {
    this.itemobj.focus();
		return false;
 }
 return true;
}
function ValidationSet(inputitem)
{
    this.vSet=new Array();
	this.add= add_validationdesc;
	this.validate= vset_validate;
	this.itemobj = inputitem;
}
function add_validationdesc(desc,error)
{
  this.vSet[this.vSet.length]= 
	  new ValidationDesc(this.itemobj,desc,error);
}
function vset_validate()
{
   for(var itr=0;itr<this.vSet.length;itr++)
	 {
	   if(!this.vSet[itr].validate())
		 {
		   return false;
		 }
	 }
	 return true;
}
function validateEmailv2(email)
{
// a very simple email validation checking. 
// you can add more complex email checking if it helps 
    if(email.length <= 0)
	{
	  return true;
	}
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}
function V2validateData(strValidateStr,objValue,strError) 
{ 
    var epos = strValidateStr.search("="); 
    var  command  = ""; 
    var  cmdvalue = ""; 
    if(epos >= 0) 
    { 
     command  = strValidateStr.substring(0,epos); 
     cmdvalue = strValidateStr.substr(epos+1); 
    } 
    else 
    { 
     command = strValidateStr; 
    } 
    switch(command) 
    { 
        case "req": 
        case "required": 
         { 
           if(eval(objValue.value.length) == 0) 
           { 
              if(!strError || strError.length ==0) 
              { 
                strError = objValue.name + " : Required Field"; 
              }//if 
              alert(strError); 
              return false; 
           }//if 
           break;             
         }//case required 
        case "maxlength": 
        case "maxlen": 
          { 
             if(eval(objValue.value.length) >  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : "+cmdvalue+" characters maximum "; 
               }//if 
               alert(strError + "\n[Current length = " + objValue.value.length + " ]"); 
               return false; 
             }//if 
             break; 
          }//case maxlen 
        case "minlength": 
        case "minlen": 
           { 
             if(eval(objValue.value.length) <  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : " + cmdvalue + " characters minimum  "; 
               }//if               
               alert(strError + "\n[Current length = " + objValue.value.length + " ]"); 
               return false;                 
             }//if 
             break; 
            }//case minlen 
        case "alnum": 
        case "alphanumeric": 
           { 
              var charpos = objValue.value.search("[^A-Za-z0-9]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
               if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only alpha-numeric characters allowed "; 
                }//if 
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break; 
           }//case alphanumeric 
        case "num": 
        case "numeric": 
           { 
              var charpos = objValue.value.search("[^0-9.]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only digits allowed "; 
                }//if               
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break;               
           }//numeric 
        case "alphabetic": 
        case "alpha": 
           { 
              var charpos = objValue.value.search("[^A-Za-z]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                  if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only alphabetic characters allowed "; 
                }//if                             
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break; 
           }//alpha 
		case "alnumhyphen":
			{
              var charpos = objValue.value.search("[^A-Za-z0-9\-_]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                  if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": characters allowed are A-Z,a-z,0-9,- and _"; 
                }//if                             
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 			
			break;
			}
        case "email": 
          { 
               if(!validateEmailv2(objValue.value)) 
               { 
                 if(!strError || strError.length ==0) 
                 { 
                    strError = objValue.name+": Enter a valid Email address "; 
                 }//if                                               
                 alert(strError); 
                 return false; 
               }//if 
           break; 
          }//case email 
        case "lt": 
        case "lessthan": 
         { 
            if(isNaN(objValue.value)) 
            { 
              alert(objValue.name+": Should be a number "); 
              return false; 
            }//if 
            if(eval(objValue.value) >=  eval(cmdvalue)) 
            { 
              if(!strError || strError.length ==0) 
              { 
                strError = objValue.name + " : value should be less than "+ cmdvalue; 
              }//if               
              alert(strError); 
              return false;                 
             }//if             
            break; 
         }//case lessthan 
        case "gt": 
        case "greaterthan": 
         { 
            if(isNaN(objValue.value)) 
            { 
              alert(objValue.name+": Should be a number "); 
              return false; 
            }//if 
             if(eval(objValue.value) <=  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : value should be greater than "+ cmdvalue; 
               }//if               
               alert(strError); 
               return false;                 
             }//if             
            break; 
         }//case greaterthan 
        case "regexp": 
         { 
		 	if(objValue.value.length > 0)
			{
	            if(!objValue.value.match(cmdvalue)) 
	            { 
	              if(!strError || strError.length ==0) 
	              { 
	                strError = objValue.name+": Invalid characters found "; 
	              }//if                                                               
	              alert(strError); 
	              return false;                   
	            }//if 
			}
           break; 
         }//case regexp 
        case "dontselect": 
         { 
            if(objValue.selectedIndex == null) 
            { 
              alert("BUG: dontselect command for non-select Item"); 
              return false; 
            } 
            if(objValue.selectedIndex == eval(cmdvalue)) 
            { 
             if(!strError || strError.length ==0) 
              { 
              strError = objValue.name+": Please Select one option "; 
              }//if                                                               
              alert(strError); 
              return false;                                   
             } 
             break; 
         }//case dontselect 
    }//switch 
    return true; 
}
/*
	Copyright 2003 JavaScript-coder.com. All rights reserved.
*/

function smilie(smilieface) {
	if (document.forum_post.body.createTextRange && document.forum_post.body.caretPos) {
		var caretPos = document.forum_post.body.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? smilieface + ' ' : smilieface;
		document.forum_post.body.focus();
	} else {
		document.forum_post.body.value+=smilieface;
		document.forum_post.body.focus();
	}
}

function winhelp(url,name) 
{
    window.open(url,name,'resizable=yes,width=500,height=270');
}
function win2Open(url,name) 
{
    window.open(url,name,'scrollbars=yes,resizable=yes,,width=500,height=300');
}
function chatOpen(url,name) 
{
    window.open(url,name,'scrollbars=yes,resizable=yes,width=640,height=380');
}
function gmcOpen(url,name) 
{
    window.open(url,name,'scrollbars=yes,resizable=yes,width=900,height=640');
}
function helpOpen(url,name) 
{
    window.open(url,name,'scrollbars=yes,resizable=yes,width=500,height=600');
}
function largeOpen(url,name) 
{
    window.open(url,name,'scrollbars=yes,resizable=yes,width=600,height=400');
}
function longOpen(url,name) 
{
    window.open(url,name,'scrollbars=yes,resizable=yes,width=500,height=800');
}


function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)	   //NN4+
    {
       document.layers[szDivID].display = iState ? "inline" : "none";
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.display = iState ? "inline" : "none";
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.display = iState ? "inline" : "none";
    }
}

// END Misc

// Tooltip

function showToolTip(e,text){
	
		var ie=document.all && !window.opera
		var dom=document.getElementById
		iebody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
		var scrollAmount = (document.layers) ? window.pageYOffset : document.body.scrollTop;
		var docwidth=(ie)? iebody.clientWidth : window.innerWidth
		var docheight=(ie)? iebody.clientHeight : window.innerHeight
		if(!document.getElementById('sui_tooltip_container')){
			var tooltip = document.createElement('DIV');
			tooltip.id = 'sui_tooltip_container';
			//tooltip.style.position = 'absolute';
			
			document.getElementsByTagName('body')[0].insertBefore(tooltip,document.getElementsByTagName('body')[0].childNodes[0]);
			
		}
		if(!document.getElementById('sui_tooltip_container').getElementsByTagName('table')[0]){
			var table = '<table border="0" cellspacing="0" cellpadding="0" class="suitooltip" style="visibility: hidden; position: absolute;"><tr><td width="8" height="8" class="tl"><span></span></td><td height="8" class="t"><span></span></td><td width="8" height="8" class="tr"><span></span></td></tr><tr><td width="8" class="l"><span></span></td><td valign="top" class="suitooltip-inner"><div class="content">';
			table = table + text;
			table = table + '</div></td><td width="8" class="r"><span></span></td></tr><tr><td width="8" height="8" class="bl"><span></span></td><td height="8" class="b"><span></span></td><td width="8" height="8" class="br"><span></span></td></tr></table>';
			document.getElementById('sui_tooltip_container').innerHTML = table;
			var tableobj = document.getElementById('sui_tooltip_container').getElementsByTagName('table')[0];
			
			
			if(tableobj.offsetWidth>250){
				tableobj.style.width = '250px';
			}		
			if(tableobj.offsetWidth + (curPos(e).x - 10)>docwidth){
			tableobj.style.left = (curPos(e).x - tableobj.offsetWidth + 15) + 'px';
			}
			else{
				tableobj.style.left = (curPos(e).x - 10) + 'px';
			}
			if(tableobj.offsetHeight - scrollAmount + (curPos(e).y + 5)>docheight){
			tableobj.style.top = (curPos(e).y - tableobj.offsetHeight - 15) + 'px';
			}
			else{
				tableobj.style.top = (curPos(e).y + 20) + 'px';
			}
			if(tableobj.offsetWidth>250){
				tableobj.style.width = '250px';
			}
			tableobj.style.visibility = 'visible';
		}
		else{
			var tableobj = document.getElementById('sui_tooltip_container').getElementsByTagName('table')[0];
			
			if(tableobj.offsetWidth + (curPos(e).x - 10)>docwidth){
			tableobj.style.left = (curPos(e).x - tableobj.offsetWidth + 15) + 'px';
			}
			else{
				tableobj.style.left = (curPos(e).x - 10) + 'px';
			}
			if(tableobj.offsetHeight - scrollAmount + (curPos(e).y + 5)>docheight){
				tableobj.style.top = (curPos(e).y - tableobj.offsetHeight - 15) + 'px';
			}
			else{
				tableobj.style.top = (curPos(e).y + 20) + 'px';
			}
		}
	
}

function hideToolTip(){
	if(document.getElementById('sui_tooltip_container') != null){
		document.getElementById('sui_tooltip_container').innerHTML = '';
		
	}
}
function curPos(e){
     if (!e) var e = window.event;
     var cursor = {x:0, y:0};
     if (e.pageX || e.pageY) {
         cursor.x = e.pageX;
         cursor.y = e.pageY;
     }
     else {
         cursor.x = e.clientX +
             (document.documentElement.scrollLeft ||
             document.body.scrollLeft) -
             document.documentElement.clientLeft;
         cursor.y = e.clientY +
             (document.documentElement.scrollTop ||
             document.body.scrollTop) -
             document.documentElement.clientTop;
     }

    return cursor;
}

// End Tooltip


function suiCommentReply(newId,form,a,name){
	var formref = document.getElementById(form);
	if(formref != null){
		var changetext = document.getElementById(form).parentNode.childNodes;
		var tochange;
		//var oldId;
		//var fieldplace;
		
		var input = document.createElement('INPUT');
		input.value = newId;
		input.name = 'reply_id';
		input.type = 'hidden';
		//input.id = 'SUI-comment-reply-id-field';
		formref.appendChild(input);
		
		for(i=0;i<changetext.length;i++){
			if(changetext[i].className == 'SUI-CommentTitle'){
				var oldtext = changetext[i].innerHTML;
				var span = document.createElement('SPAN');
				span.innerHTML = 'You are Replying to '+name+'. ';
				var atag = document.createElement('A');
				atag.href = 'javascript:void(0);';
				atag.onclick = function(){
					this.parentNode.innerHTML = oldtext;
					formref.removeChild(input);
				}
				atag.innerHTML = '<small>[Cancel Reply]</small>';
				span.appendChild(atag);
				changetext[i].innerHTML = '';
				changetext[i].appendChild(span);
			}
		}
		window.location.href='#'+a;
	}
}

function getElementsByClassName(strClass, strTag, objContElm) {
  strTag = strTag || "*";
  objContElm = objContElm || document;    
  var objColl = objContElm.getElementsByTagName(strTag);
  if (!objColl.length &&  strTag == "*" &&  objContElm.all) objColl = objContElm.all;
  var arr = new Array();                              
  var delim = strClass.indexOf('|') != -1  ? '|' : ' ';   
  var arrClass = strClass.split(delim);    
  for (var i = 0, j = objColl.length; i < j; i++) {                         
    var arrObjClass = objColl[i].className.split(' ');   
    if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
    var c = 0;
    comparisonLoop:
    for (var k = 0, l = arrObjClass.length; k < l; k++) {
      for (var m = 0, n = arrClass.length; m < n; m++) {
        if (arrClass[m] == arrObjClass[k]) c++;
        if ((delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
          arr.push(objColl[i]); 
          break comparisonLoop;
        }
      }
    }
  }
  return arr; 
}

if ( !Array.prototype.push ) Array.prototype.push = function()
{
   var m = this.highestIndex();
   if ( m == undefined ) m = -1;
   for ( var i = 0; i < arguments.length; i++ )
      this[++m]=arguments[i];
}

function addEvent(el,type,listener,useCapture) {
	if(typeof el == 'string') {
		el = document.getElementById(el);
	}
	if(!el){
		return false;
	} 
	if(document.addEventListener) {  // W3C DOM Level 2 Events - used by Mozilla, Opera and Safari
		if(!useCapture) {
			useCapture = false;
		} else {
			useCapture = true;
		}
		el.addEventListener(type,listener,useCapture);
	} else {  // MS implementation - used by Internet Explorer
		el.attachEvent("on"+type, listener);
	}
}
function removeEvent(el,type,listener,useCapture) {
	
	if(typeof el == 'string') {
		el = document.getElementById(el);
	} 
	if(!el){
		return false;
	}
	if(document.removeEventListener) {  // W3C DOM Level 2 Events - used by Mozilla, Opera and Safari
		if(!useCapture) {
			useCapture = false;
		} else {
			useCapture = true;
		}
		el.removeEventListener(type,listener,useCapture);
	} else {  // MS implementation - used by Internet Explorer
		el.detachEvent("on"+type, listener);
	}
}


//==================================================================================================================
//  Trim Whitespace
//------------------------------------------------------------------------------------------------------------------
String.prototype.trim=function(){
	return this.replace(/^\s*|\s*$/g,'');
}
String.prototype.ltrim=function(){
	return this.replace(/^\s*/g,'');
}
String.prototype.rtrim=function(){
	return this.replace(/\s*$/g,'');
}
//==================================================================================================================
//  FIC_checkForm
//  Form Input Checking by JC
/*
		Apply these class names to form elements:

		* required (not blank)
		* validate-number (a valid number)
		* validate-digits (digits only, spaces allowed.)
		* validate-alpha (letters only)
		* validate-alphanum (only letters and numbers)
		* validate-date (a valid date value)
		* validate-email (a valid email address)
		* validate-url (a valid URL)
		* validate-date-au (a date formatted as; dd/mm/yyyy)
		* validate-currency-dollar (a valid dollar value)
		* validate-one-required (At least one checkbox/radio element must be selected in a group)
		* validate-not-first (Selects only, must choose an option other than the first)
		* validate-not-empty (Selects only, must choose an option with a value that is not empty)
		* validate-regex (requires the element to have a 'regex=' attribute applied)

		Also, you can specify this attribute for text, passwird and textarea elements:
		* minlength="x" (where x is the minimum number of characters)
*/
//------------------------------------------------------------------------------------------------------------------
function FIC_checkForm(e) {
	var errs = new Array();

	//this function is called when a form is submitted.
	if (typeof(e) == "string") {
		//the id was supplied, get the object reference
		e = xGetElementById(e);
		if (!e) {
			return true;
		}
	}

	var elm=e;
	if (!e.nodeName) {
		//was fired by yahoo
		elm = (e.srcElement) ? e.srcElement : e.target;
	}
	if (elm.nodeName.toLowerCase() != 'form') {
		elm = searchUp(elm,'form');
	}

	var all_valid = true;

	//access form elements
	//inputs
	var f_in = elm.getElementsByTagName('input');
	//selects
	var f_sl = elm.getElementsByTagName('select');
	//textareas
	var f_ta = elm.getElementsByTagName('textarea');

	//check inputs
	for (i=0;i<f_in.length;i++) {
		if (f_in[i].type.toLowerCase() != 'submit' && f_in[i].type.toLowerCase() != 'button' && f_in[i].type.toLowerCase() != 'hidden') {
			if (isVisible(f_in[i])) {

				var cname = ' '+f_in[i].className.replace(/^\s*|\s*$/g,'')+' ';
				cname = cname.toLowerCase();
				var inv = f_in[i].value.trim();
				var t = f_in[i].type.toLowerCase();
				var cext = '';
				if (t == 'text' || t == 'password') {
					//text box
					var valid = FIC_checkField(cname,f_in[i]);
				} else if(t == 'radio' || t == 'checkbox'){
					// radio or checkbox
					var valid = FIC_checkRadCbx(cname,f_in[i],f_in);
					cext = '-cr';
				} else {
					var valid = true;
				}

				if (valid) {
					removeClassName(f_in[i],'validation-failed'+cext);
					addClassName(f_in[i],'validation-passed'+cext);
				} else {
					removeClassName(f_in[i],'validation-passed'+cext);
					addClassName(f_in[i],'validation-failed'+cext);
					//try to get title
					if (f_in[i].getAttribute('title')){
						errs[errs.length] = f_in[i].getAttribute('title');
					}
					all_valid = false;
				}
			}
		}
	} //end for i

	//check textareas
	for (i=0;i<f_ta.length;i++) {
		if (isVisible(f_ta[i])) {
			var cname = ' '+f_ta[i].className.replace(/^\s*|\s*$/g,'')+' ';
			cname = cname.toLowerCase();
			var valid = FIC_checkField(cname,f_ta[i]);

			if (valid) {
				removeClassName(f_ta[i],'validation-failed');
				addClassName(f_ta[i],'validation-passed');
			} else {
				removeClassName(f_ta[i],'validation-passed');
				addClassName(f_ta[i],'validation-failed');
				//try to get title
				if (f_ta[i].getAttribute('title')){
					errs[errs.length] = f_ta[i].getAttribute('title');
				}
				all_valid = false;
			}
		}
	} //end for i

	//check selects
	for (i=0;i<f_sl.length;i++) {
		if (isVisible(f_sl[i])) {
			var cname = ' '+f_sl[i].className.replace(/^\s*|\s*$/g,'')+' ';
			cname = cname.toLowerCase();
			var valid = FIC_checkSel(cname,f_sl[i]);
			if (valid) {
				removeClassName(f_sl[i],'validation-failed-sel');
				addClassName(f_sl[i],'validation-passed-sel');
			} else {
				removeClassName(f_sl[i],'validation-passed-sel');
				addClassName(f_sl[i],'validation-failed-sel');
				//try to get title
				if (f_sl[i].getAttribute('title')){
					errs[errs.length] = f_sl[i].getAttribute('title');
				}
				all_valid = false;
			}
		}
	} //end for i

	if (!all_valid) {
		if (errs.length > 0){
			alert("We have found the following error(s):\n\n  * "+errs.join("\n  * ")+"\n\nPlease check the fields and try again");
		} else {
			alert('Some required values are not correct. Please check the items in red.');
		}
		YAHOO.util.Event.stopEvent(e);
	}
	return all_valid;
} // end FIC_checkForm

//==================================================================================================================
//  FIC_checkField
//	c = className
//	e = the element
//------------------------------------------------------------------------------------------------------------------
function FIC_checkField(c,e) {
	var valid = true;
	var t = e.value.trim();

	//search for required
	if (c.indexOf(' required ') != -1 && t.length == 0) {
		//required found, and not filled in
		valid = false;
	}

	//check length
	if (c.indexOf(' required ') != -1){
		//check for minlength.
		var m = e.getAttribute('minlength');
		if (m && Math.abs(m) > 0){
			if (e.value.length < Math.abs(m)){
				valid = false;
			}
		}
	}

	//search for validate-
	if (c.indexOf(' validate-number ') != -1 && isNaN(t) && t.match(/[^\d]/)) {
		//number bad
		valid = false;
	} else if (c.indexOf(' validate-digits ') != -1 && t.replace(/ /,'').match(/[^\d]/)) {
		//digit bad
		valid = false;
	} else if (c.indexOf(' validate-alpha ') != -1 && !t.match(/^[a-zA-Z]+$/)) {
		//alpha bad
		valid = false;
	} else if (c.indexOf(' validate-alphanum ') != -1 && t.match(/\W/)) {
		//alpha bad
		valid = false;
	} else if (c.indexOf(' validate-date ') != -1) {
		var d = new date(t);
		
		if (isNaN(d)) {
			//date bad
			valid = false;
		}
	} else if (c.indexOf(' validate-email ') != -1 && !t.match(/\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/)) {
		//email bad
		valid = false;
		if (c.indexOf(' required ') == -1 && t.length == 0) {
			valid = true;
		}
	} else if (c.indexOf(' validate-url ') != -1 && !t.match(/^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i)) {
		//url bad
		valid = false;
	} else if (c.indexOf(' validate-date-au ') != -1 && !t.match(/^(\d{2})\/(\d{2})\/(\d{4})$/)) {
		valid = false;
	} else if (c.indexOf(' validate-currency-dollar ') != -1 && !t.match(/^\$?\-?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}\d*(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$/)) {
		valid = false;
	} else if (c.indexOf(' validate-regex ') != -1) {
        var r = RegExp(e.getAttribute('regex'));
        if (r && ! t.match(r)) {
            valid = false;
        }
    }

	return valid;
}

//==================================================================================================================
//  FIC_checkRadCbx
//	c = className
//	e = this element, radio or checkbox
//	f = input fields dom element
//------------------------------------------------------------------------------------------------------------------
function FIC_checkRadCbx(c,e,f){
	var valid = true;

	//search for required
	if (c.indexOf(' validate-one-required ') != -1) {
		//required found
		//check if other checkboxes or radios have been selected.
		valid = false;
		for (var i=0;i<f.length;i++){
			if(f[i].name.toLowerCase() == e.name.toLowerCase() && f[i].checked){
				valid = true;
				break;
			}
		}
	}

	return valid;
}

//==================================================================================================================
//  FIC_checkSel
//	c = className
//	e = this select element
//------------------------------------------------------------------------------------------------------------------
function FIC_checkSel(c,e){
	var valid = true;
	//search for validate-
	if (c.indexOf(' validate-not-first ') != -1 && e.selectedIndex == 0) {
		//bad
		valid = false;
	} else if (c.indexOf(' validate-not-empty ') != -1 && e.options[e.selectedIndex].value.length == 0) {
		//bad
		valid = false;
	}
	return valid;
}

//==================================================================================================================
//  addClassName
//------------------------------------------------------------------------------------------------------------------
function addClassName(e,t) {
	if (typeof e == "string") {
		e = xGetElementById(e);
	}
	//code to change and replace strings
	var ec = ' ' + e.className.replace(/^\s*|\s*$/g,'') + ' ';
	var nc = ec;
	t = t.replace(/^\s*|\s*$/g,'');
	//check if not already there
	if (ec.indexOf(' '+t+' ') == -1) {
		//not found, add it
		nc = ec + t;
	}
	//return the changed text!
	e.className = nc.replace(/^\s*|\s*$/g,''); //trimmed whitespace
	return true;
}

//==================================================================================================================
//  removeClassName
//------------------------------------------------------------------------------------------------------------------
function removeClassName(e,t) {
	if (typeof e == "string") {
		e = xGetElementById(e);
	}
	//code to change and replace strings
	var ec = ' ' + e.className.replace(/^\s*|\s*$/g,'') + ' ';
	var nc = ec;
	t = t.replace(/^\s*|\s*$/g,'');
	//check if not already there
	if (ec.indexOf(' '+t+' ') != -1) {
		//found, so lets remove it
		nc = ec.replace(' ' + t.replace(/^\s*|\s*$/g,'') + ' ',' ');
	}
	//return the changed text!
	e.className = nc.replace(/^\s*|\s*$/g,''); //trimmed whitespace
	return true;
}

//==================================================================================================================
//  attachToForms
//------------------------------------------------------------------------------------------------------------------
function attachToForms(e) {
	//search dom for all forms
	var frms = document.getElementsByTagName('form');
	for(var i=0;i<frms.length;i++) {
		if(YAHOO.util.Dom.hasClass(frms[i],'validate')){
			YAHOO.util.Event.addListener(frms[i], "submit", FIC_checkForm);
		}
	}
}

//==================================================================================================================
//  isVisible
//------------------------------------------------------------------------------------------------------------------
function isVisible(e) {
	//returns true is should be visible to user.
	if (typeof e == "string") {
		e = xGetElementById(e);
	}
	while (e.nodeName.toLowerCase() != 'body' && e.style.display.toLowerCase() != 'none' && e.style.visibility.toLowerCase() != 'hidden') {
		e = e.parentNode;
	}
	if (e.nodeName.toLowerCase() == 'body') {
		return true;
	} else{
		return false;
	}
}


//==================================================================================================================
//  searchUp
//------------------------------------------------------------------------------------------------------------------
function searchUp(elm,findElm,debug) {
	//this function searches the dom tree upwards for the findElm node starting from elm.
	//check if elm is reference

	if(typeof(elm) == 'string') {
		elm = xGetElementById(elm);
	}
	//search up
	//get the parent findElm
	while (elm && elm.parentNode && elm.nodeName.toLowerCase() != findElm && elm.nodeName.toLowerCase() != 'body') {
		elm = elm.parentNode;
	}
	return elm;
}

//==================================================================================================================
//  xGetElementById
//------------------------------------------------------------------------------------------------------------------
function xGetElementById(e) {
	if(typeof(e)!='string') return e;
	if(document.getElementById) e=document.getElementById(e);
	else if(document.all) e=document.all[e];
	else e=null;
	return e;
}

YAHOO.util.Event.addListener(window, "load", attachToForms);



//SUI NAMESPACE

var SUI = {};
SUI.effects = {};
SUI.style = {};
SUI.draw = {};
SUI.util = {};

SUI.effects.HideInputText = {
	store: {},
	init: function(obj){
		obj = typeof obj == 'object' ? obj : document.getElementById(obj);
		var id = obj.id || "SUI-form-input-text"+Math.random();
		obj.id = id;
		this.store[obj.id] = obj.value;
		obj.onfocus = function(){
			if(this.value==SUI.effects.HideInputText.store[this.id]){
				this.value = '';
			}
		}
		obj.onblur = function(){
			if(this.value == ''){
				this.value = SUI.effects.HideInputText.store[this.id];
			}
		}
		obj.value = '';
	}
};

SUI.effects.ButtonWorking = function(button,message,start){
	if(!SUI.effects.ButtonWorking.store){
		SUI.effects.ButtonWorking.store = {};
	}
	
	button = typeof button == 'object' ? button : document.getElementById(button);

	if(start == true){
		SUI.effects.ButtonWorking.store[button.id] = true;
			
		var anim = {
			num: 0,
			sym: [
				'))  ',
				'  ))',
				'  ((',
				'((  '
			]
		};
		//alert('this');
		var run = function(){
			if(SUI.effects.ButtonWorking.store[button.id] == true){
				if(anim.num == 0){
					var ani = anim.sym[0];
					anim.num = 1;
				}
				else if(anim.num == 1){
					var ani = anim.sym[1];
					anim.num = 2;
				}
				else if(anim.num == 2){
					var ani = anim.sym[2];
					anim.num = 3;
				}
				else{
					var ani = anim.sym[3];
					anim.num = 0;
				}
				button.value = message + ' ' + ani;
				t = setTimeout(run,200);
			}
		}
		run();
	}
	else{
		delete SUI.effects.ButtonWorking.store[button.id];
	}
};

SUI.effects.GalviewFlip = function (source,toggle){
	if(toggle=='over'){
		getElementsByClassName('SUI-Galview-Images', 'div', source)[0].className = 'SUI-Galview-Images over element-row2';
	}
	else{
		getElementsByClassName('SUI-Galview-Images', 'div', source)[0].className = 'SUI-Galview-Images element-row1';
	}
};

SUI.effects.ToggleRow2 = function (obj){
	var classN = obj.className;
	var oldevent = obj.onmouseout;
	obj.className = 'element-row2 ' + classN.replace(/element-row1/g, '');
	obj.onmouseout = function(){
		obj.className = classN;
		obj.removeAttribute('onmouseout');
	}
};

SUI.style.Current = {
	store: {},
	capture: function(target){
		target = typeof target == 'object' ? target : document.getElementById(target);
		var gcolorid = "suicolorspot"+Math.random();
		var toHex = function(N){
			if (N==null) return "00";
			N=parseInt(N); if (N==0 || isNaN(N)) return "00";
			N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
			return "0123456789ABCDEF".charAt((N-N%16)/16)
				+ "0123456789ABCDEF".charAt(N%16);
		};
		var getStyle = function(el,styleProp,stylePropNS){
			var x = el;
			if (x.currentStyle){
					if(x.currentStyle[styleProp] != "transparent"){
							var y = x.currentStyle[styleProp];
					}
					else{y = 'trans';}
				}
			else if (window.getComputedStyle){
					if(stylePropNS.search(/color/i) != -1){
						if(document.defaultView.getComputedStyle(x,null).getPropertyValue(stylePropNS) != "transparent"){
							z = document.defaultView.getComputedStyle(x,null).getPropertyValue(stylePropNS).split('(')[1].split(')')[0].split(', ');
						var y = "#"+toHex(z[0],16)+toHex(z[1],16)+toHex(z[2],16);
						}
						//alert("#"+toHex(z[0],16)+toHex(z[1],16)+toHex(z[2],16));
						else{y = 'trans';}
					}
					else{
						y = document.defaultView.getComputedStyle(x,null).getPropertyValue(stylePropNS);
					}
				}
			return y.replace(/#/,"");
		};
		(function(){
			var div = document.createElement('div');
			div.className = 'element-row1';
			div.id = gcolorid;
			var a = document.createElement('a');
			var div2 = document.createElement('div');
			div2.className = 'element-row2';
			var a2 = document.createElement('a');
			div2.appendChild(a2);
			div.appendChild(a);
			div.appendChild(div2);
			target.insertBefore(div,target.childNodes[0]);
		})();
		//SUI.style.Current.store.contentbg = getStyle(document.getElementById('element-container'),'backgroundColor','background-color');
		SUI.style.Current.store.row1c = getStyle(document.getElementById(gcolorid),'color','color');
		SUI.style.Current.store.row1bg = getStyle(document.getElementById(gcolorid),'backgroundColor','background-color');
		SUI.style.Current.store.row1bgimg = getStyle(document.getElementById(gcolorid),'backgroundImage','background-image');
		SUI.style.Current.store.row2c = getStyle(document.getElementById(gcolorid).getElementsByTagName('div')[0],'color','color');
		SUI.style.Current.store.row2bg = getStyle(document.getElementById(gcolorid).getElementsByTagName('div')[0],'backgroundColor','background-color');
		SUI.style.Current.store.row2bgimg = getStyle(document.getElementById(gcolorid).getElementsByTagName('div')[0],'backgroundImage','background-image');
		SUI.style.Current.store.alink = getStyle(document.getElementById(gcolorid).getElementsByTagName('a')[0],'color','color');
		SUI.style.Current.store.alink2 = getStyle(document.getElementById(gcolorid).getElementsByTagName('a')[1],'color','color');
		if(document.removeChild){
			document.getElementById(gcolorid).parentNode.removeChild(document.getElementById(gcolorid));
		}
		else{
			document.getElementById(gcolorid).style.display= 'none';
		}
	}
};

SUI.style.Bordercolors = function (allchildren){
	var colors = SUI_GetStyles();
	var gcolorid = "gspot"+Math.random();
	document.write('<div id="'+gcolorid+'" style="display:none;"></div>');
	var container = document.getElementById(gcolorid).parentNode;
	if(typeof container == ('object')){
		container.style.borderColor = colors.row2bg;
		var elements = container.childNodes;
		if(allchildren!=false){
			for(i=0;i<elements.length;i++){
				if(elements[i].style){
					elements[i].style.borderColor = colors.row2bg;
				}
			}
		}
	}
};

// DRAW
SUI.draw.MenuBox = function (obj,content,width,mode,target,callback){
	width = width || 200; target = target || document; var orig;

	(function(){ // If canvas exists remove it.
		var canvas = document.getElementById('SUI-Menu-Canvas');
		if(canvas != null){
			SUI.draw.MenuBox.Remove();
		}
	})();
	typeof obj == ('array') ? orig = obj : orig = SUI.util.GetSpace(obj,target); 
	var m = target.createElement('DIV');
	m.id = 'SUI-Menu-Canvas';
	m.className = 'SUI-Menu-Canvas';
	m.style.cssText = 'position: absolute; visibility: hidden; z-index: 50002; width: '+width+'px;';
	var o = target.createElement('DIV');
	o.className = 'option';
	if(mode){
		if(mode == 'object'){
			m.appendChild(content);
		}
	}
	else{
		if(typeof content == ('string')){
			o.onmouseover = function(){this.className = 'option over';}
			o.onmouseout = function(){this.className = 'option';}
			o.onclick = function(){SUI.draw.MenuBox.Remove();}
			o.innerHTML = content;
			m.appendChild(o);
		}
		else if(typeof content == ('array')||typeof content == ('object')){
			for(i=0;content[i];i++){
				var temp = o.cloneNode(true);
				temp.onmouseover = function(){this.className = 'option over';}
				temp.onmouseout = function(){this.className = 'option';}
				temp.onclick = function(){SUI.draw.MenuBox.Remove();}
				temp.innerHTML = content[i];
				m.appendChild(temp);
			}
		}
		else{alert(typeof content)}
	}
	
	target.getElementsByTagName('body')[0].insertBefore(m,target.getElementsByTagName('body')[0].childNodes[0]);
	mspace = SUI.util.GetSpace(m,target);
	mspace[2] + orig[0] < orig[4] ? m.style.left = orig[0] + 'px' : m.style.left = orig[0] + orig[2] - mspace[2] + 'px';
	mspace[3] + orig[1] + orig[3] < orig[5] + orig[7] || mspace[3] > orig[1] ? m.style.top = orig[1] + orig [3] + 'px' : m.style.top = orig[1] - mspace[3] + 'px';
	SUI.draw.MenuBox.Remove = function(){
		if(m){m.parentNode.removeChild(m);}
		removeEvent(document.body, 'click', SUI.draw.MenuBox.Remove);
		if(window.frames){
			for(i=0;window.frames[i];i++){
				try {
				removeEvent(window.frames[i].document.body, 'click', SUI.draw.MenuBox.Remove);
				}
				catch(err){err=err}
			}
		}
		if(window.event){window.event.cancelBubble = false;}
		if(callback){callback();}
	}
	window.event ? m.onclick = function(){window.event.cancelBubble = true} : m.onclick = function(e){e.cancelBubble = true};
	function aTl(){
		addEvent(document.body, 'click', SUI.draw.MenuBox.Remove);
		if(window.frames){
			for(i=0;window.frames[i];i++){
				try {
				addEvent(window.frames[i].document.body, 'click', SUI.draw.MenuBox.Remove);
				}
				catch(err){err=err}
			}
		}
	}
	var t = setTimeout(aTl,20);
	m.style.visibility = 'visible';
};

SUI.draw.YEdit = function(id,options){
	/*
		options{
			height - value (defaults to 300px)
			width - value (defalts to auto)
			doSubmit - tf (off by default, attaches to parent form on submit to save the contents of the editor to form first)
			
			fontstyle - tf (base default)
			textstyle - tf (base default)
				fontbiu - tf (base default (bold,italic,underline))
				textstylext - tf
			alignment - tf
			parastyle - tf
			indentlist - tf (base default)
				indent - tf
				list - tf (base default)
			insertitem - tf (base default)
				link - tf (base default)
				image - tf (base default)
				smiley - tf (base default)
				video - tf
				
			full - t (turns on all settings, can still turn off specific things by setting them to false);
		}
	*/
	var options = options || {};
	var Dom = YAHOO.util.Dom,   
			Event = YAHOO.util.Event;
			var myConfig = {   
				height: options.height || '300px',   
				width: options.width || 'auto',
				animate: true,
				dompath: true,   
				
				toolbar: {
					titlebar: false,
					collapse: false,
					draggable: false,
					buttonType: 'advanced',
					buttons: []
				}
			};
			if(options.focus != false){
				myConfig.focusAtStart = true;
			}
			if(options.fontstyle != false || options.fontstyle == true){ // Set options.fontstyle to false to turn off
				myConfig.toolbar.buttons.push({ 
							group: 'fontstyle', label: 'Font Name and Size',
							buttons: [
								{ type: 'select', label: 'Arial', value: 'fontname', disabled: true,
									menu: [
										{ text: 'Arial', checked: true },   
										{ text: 'Arial Black' },
										{ text: 'Comic Sans MS' },
										{ text: 'Courier New' },
										{ text: 'Lucida Console' },
										{ text: 'Tahoma' },
										{ text: 'Times New Roman' },
										{ text: 'Trebuchet MS' },
										{ text: 'Verdana' }
									]
								},
								{ type: 'spin', label: '13', value: 'fontsize', range: [ 9, 75 ], disabled: true }
							]
						});
			}
			if(options.textstyle != false || options.textstyle == true){ // Set options.textstyle to false to turn off
				
				(function(){
					var newobj = {
						group: 'textstyle', label: 'Font Style',
						buttons: []
					};
					if(options.fontbiu != false || options.fontbiu == true){
						newobj.buttons.push({ type: 'push', label: 'Bold CTRL + SHIFT + B', value: 'bold' });
						newobj.buttons.push({ type: 'push', label: 'Italic CTRL + SHIFT + I', value: 'italic' });
						newobj.buttons.push({ type: 'push', label: 'Underline CTRL + SHIFT + U', value: 'underline' });
					}
					if(options.textstylext || options.full){
						if(options.textstylext != false){
							newobj.buttons.push({ type: 'separator' });
							newobj.buttons.push({ type: 'push', label: 'Subscript', value: 'subscript', disabled: true });
							newobj.buttons.push({ type: 'push', label: 'Superscript', value: 'superscript', disabled: true });
							newobj.buttons.push({ type: 'separator' });
							newobj.buttons.push({ type: 'color', label: 'Font Color', value: 'forecolor', disabled: true });
							newobj.buttons.push({ type: 'color', label: 'Background Color', value: 'backcolor', disabled: true });
							newobj.buttons.push({ type: 'separator' });
							newobj.buttons.push({ type: 'push', label: 'Remove Formatting', value: 'removeformat', disabled: true });
							newobj.buttons.push({ type: 'push', label: 'Show/Hide Hidden Elements', value: 'hiddenelements' });
						}
					}
					if(newobj.buttons.length > 0){
						myConfig.toolbar.buttons.push({ type: 'separator' });
						myConfig.toolbar.buttons.push(newobj);
					}
				})();
			}
			if(options.alignment || options.full){ // Set options.alignment to true to turn this on
				if(options.alignment != false){
					myConfig.toolbar.buttons.push({ type: 'separator' });
					myConfig.toolbar.buttons.push({ 
							group: 'alignment', label: 'Alignment',
							buttons: [
								{ type: 'push', label: 'Align Left CTRL + SHIFT + [', value: 'justifyleft' },
								{ type: 'push', label: 'Align Center CTRL + SHIFT + |', value: 'justifycenter' },
								{ type: 'push', label: 'Align Right CTRL + SHIFT + ]', value: 'justifyright' },
								{ type: 'push', label: 'Justify', value: 'justifyfull' }
							]
						});
				}
			}
			if(options.parastyle || options.full){ // Set options.parastyle to true to turn this on
				if(options.parastyle != false){
					myConfig.toolbar.buttons.push({ type: 'separator' });
					myConfig.toolbar.buttons.push({ 
							group: 'parastyle', label: 'Paragraph Style',
							buttons: [
								{ type: 'select', label: 'Normal', value: 'heading', disabled: true,
									menu: [
										{ text: 'Normal', value: 'none', checked: true },
										{ text: 'Header 1', value: 'h1' },
										{ text: 'Header 2', value: 'h2' },
										{ text: 'Header 3', value: 'h3' },
										{ text: 'Header 4', value: 'h4' },
										{ text: 'Header 5', value: 'h5' },
										{ text: 'Header 6', value: 'h6' }
									]
								}
							]
						});
				}
			}
			if(options.indentlist != false || options.indentlist == true){ // Set options.indentlist to false to turn off
				(function(){
					var newobj = {
						group: 'indentlist',
						buttons: []
					};
					var o = {};
					if(options.indent || options.full){
						if(options.indent != false){
							newobj.buttons.push({ type: 'push', label: 'Indent', value: 'indent', disabled: true });
							newobj.buttons.push({ type: 'push', label: 'Outdent', value: 'outdent', disabled: true });
							o.indent = true;
						}
					}
					if(options.list != false || options.list == true){
						newobj.buttons.push({ type: 'push', label: 'Create an Unordered List', value: 'insertunorderedlist' });
						newobj.buttons.push({ type: 'push', label: 'Create an Ordered List', value: 'insertorderedlist' });
						o.list = true;
					}
					if(o.indent && !o.list){newobj.label = 'Indenting'}
					if(o.list && !o.indent){newobj.label = 'Lists'}
					if(o.list && o.indent){newobj.label = 'Indenting and Lists'}
					
					if(newobj.buttons.length > 0){
						myConfig.toolbar.buttons.push({ type: 'separator' });
						myConfig.toolbar.buttons.push(newobj);
					}
				})();
			}
			if(options.insertitem != false || options.insertitem == true){ // Set options.insertitem to false to turn off
				(function(){
					var newobj = {
						group: 'insertitem',
						label: 'Insert Item',
						buttons: []
					};
					if(options.link != false || options.link == true){
						newobj.buttons.push({ type: 'push', label: 'Create Link (Select the text you wish to turn into a link before clicking this button.)', value: 'createlink', disabled: true });
					}
					if(options.image != false || options.image == true){
						newobj.buttons.push({ type: 'push', label: 'Insert Image', value: 'insertimage' });
					}
					if(options.smiley != false || options.smiley == true){
						newobj.buttons.push({
							type: 'push',
							label: 'Insert Smiley',
							value: 'inserticon',
							id: 'SUI-forum-post-smiley-button',
							menu: function(){
								
								var menu = new YAHOO.widget.Overlay('inserticon', {
									width: '200px',
									height: '250px',
									zIndex: '50002',
									visible: false
								});
								
								var str = '';
								var smillist = SUI.util.ForumFunctions.store.Smileys || null;
								if(smillist){
									for(var i=0;i<smillist.length;i++){
										str += '<a href="#"><img src="'+smillist[i]+'" border="0"></a>';
									}
								}
								else{
									str = 'No smileys available.';
								}
								menu.setBody('<div id="'+id+'iconMenu" class="SUI-editor-iconmenu" style="height: 248px; overflow: auto;">' + str + '</div>');
								menu.beforeShowEvent.subscribe(function() {
									menu.cfg.setProperty('context', [
										SUI.draw.YEdit[id].toolbar.getButtonByValue('inserticon').get('element'),
										'tr',
										'br'
									]);
								});
								//alert('this');
								menu.render(document.body);
								menu.element.style.visibility = 'hidden';
								return menu;
							}()
						});
					}
					if(options.video || options.full){
						if(options.video != false){
							newobj.buttons.push({
								type: 'push',
								label: 'Insert YouTube Video',
								value: 'insertvideo',
								id: 'SUI-forum-post-video-button',
								menu: function(){
									var menu = new YAHOO.widget.Overlay('insertvideo', {
										width: '300px',
										height: 'auto',
										zIndex: '50002',
										visible: false
									});
									var canvas = document.createElement('div');
									canvas.id = id + 'videoMenu';
									canvas.style.height = 'auto';
									(function(){// Build Video Menu
										var str = '<form onsubmit="return false;"><p><strong>Paste your YouTube video embed code below.</strong></p><textarea cols="30" rows="5"></textarea><br /><button>Insert Video</button></form>';
										canvas.innerHTML = str;
									})();
									menu.setBody(canvas);
									menu.beforeShowEvent.subscribe(function() {
										menu.cfg.setProperty('context', [
											SUI.draw.YEdit[id].toolbar.getButtonByValue('insertvideo').get('element'),
											'tr',
											'br'
										]);
									});
									menu.render(document.body);
									menu.element.style.visibility = 'hidden';
									return menu;
								}()
							});
						}
						/*
						if(options.paste != false || options.paste == true){
							newobj.buttons.push({ type: 'push', label: 'Paste', value: 'pasteb' });
						}
						*/
					}
					
					if(newobj.buttons.length > 0){
						myConfig.toolbar.buttons.push({ type: 'separator' });
						myConfig.toolbar.buttons.push(newobj);
					}
				})();
			}
			
			
			if(options.doSubmit == true){
				myConfig.handleSubmit = true;
			}
			
			SUI.draw.YEdit[id] = new YAHOO.widget.Editor(id, myConfig);
			SUI.draw.YEdit[id].invalidHTML = {
				'meta': true,
				'link': true,
				'script': true,
				'iframe': true
			};
			
			SUI.draw.YEdit[id].textid = id;
			SUI.draw.YEdit[id].saveHTML = function(){
				var html = this.cleanHTML();
				
				//CLEAN HTML GOES HERE
				
				//html = html.replace(new RegExp('<meta([^>]*)>(.*?)>', 'gi'), '');
				//html = html.replace(new RegExp('<link([^>]*)>(.*?)>', 'gi'), '');
				//html = html.replace(new RegExp('<!--([^-->]*)', 'gi'), '');
				html = SUI.util.YEdit.imgsToObj(html);
				
				this.get('element').value = html;
				return html;
			};
			
			YAHOO.util.Event.onAvailable(id + 'iconMenu', function() {
				YAHOO.util.Event.on(id + 'iconMenu', 'click', function(ev) {
					var tar = YAHOO.util.Event.getTarget(ev);
					if (tar.tagName.toLowerCase() == 'img') {
						var img = tar.getAttribute('src', 2);
						var _button = this.toolbar.getButtonByValue('inserticon');
						_button.getMenu().hide();
						this.toolbar.fireEvent('inserticonClick', { type: 'inserticonClick', icon: img });
					}
					YAHOO.util.Event.stopEvent(ev);
				}, SUI.draw.YEdit[id], true); 
			}); 
			YAHOO.util.Event.onAvailable(id + 'videoMenu', function() {
				YAHOO.util.Event.on(id + 'videoMenu', 'click', function(ev) {
					var tar = YAHOO.util.Event.getTarget(ev);
					if (tar.tagName.toLowerCase() == 'button') {
						var string = tar.parentNode.getElementsByTagName('textarea')[0].value;
						string = SUI.util.YEdit.objToImg(string);
						
						var _button = this.toolbar.getButtonByValue('insertvideo');
						try{_button.getMenu().hide();}catch(Error){}
						tar.parentNode.getElementsByTagName('textarea')[0].value = '';
						
						this.execCommand('inserthtml', string);
						//alert(string);
					}
					YAHOO.util.Event.stopEvent(ev);
				}, SUI.draw.YEdit[id], true); 
			}); 
				
			SUI.draw.YEdit[id].on('toolbarLoaded', function(){
				SUI.draw.YEdit[id].toolbar.on('inserticonClick', function(ev){
					var icon = '';
					this._focusWindow();
					if (ev.icon) {
						//alert(ev.icon);
						icon = ev.icon;
					}
					smiley = '<img src="' + icon + '" border="0">';
					this.execCommand('inserthtml', smiley);
				}, SUI.draw.YEdit[id], true);
				/*
				SUI.draw.YEdit[id].toolbar.on('pastebClick', function(ev){
					this._focusWindow();
					var data = window.clipboardData.getData('Text');
					alert(data);
					YAHOO.util.Event.stopEvent(ev);
				}, SUI.draw.YEdit[id], true);
				*/
			});
			/*
			SUI.draw.YEdit[id].on('editorContentLoaded', function(){
				Event.on(this._getDoc(), 'contextmenu', function(e){
					var point = SUI.util.GetSpace(e);
					var posx = 0;
					var posy = 0;
					if (!e) var e = window.event;
					if (e.pageX || e.pageY) 	{
						posx = e.pageX;
						posy = e.pageY;
					}
					else if (e.clientX || e.clientY) 	{
						posx = e.clientX + document.body.scrollLeft
							+ document.documentElement.scrollLeft;
						posy = e.clientY + document.body.scrollTop
							+ document.documentElement.scrollTop;
					}
					point[0] = posx;
					point[1] = posy;
					point[2] = '10';
					point[3] = '10';
					//alert(point);
					var div = document.createElement('div');
					(function(){
						var o = document.createElement('div');
						o.innerHTML = 'Option';
						o.style.cssText = 'cursor: pointer; padding: 5px; color: #'+SUI.style.Current.store.alink2+';';
						o.onmouseover = function(){
							this.style.backgroundColor = '#'+SUI.style.Current.store.alink2;
							this.style.color = '#'+SUI.style.Current.store.row2bg;
						}
						o.onmouseout = function(){
							this.style.backgroundColor = 'transparent';
							this.style.color = '#'+SUI.style.Current.store.alink2;
						}

						o.onclick = function(){
							this.style.backgroundColor = 'transparent';
							this.style.color = '#'+SUI.style.Current.store.alink2;
							SUI.draw.MenuBox.Remove();
						}
						div.appendChild(o);
					})();
					//SUI.draw.MenuBox(point,div,'150','object',parent.document);
				
					Event.stopEvent(e);
				});
			});
			*/
			SUI.draw.YEdit[id].on('afterExecCommand', function(){
				document.getElementById('yui-editor-panel').style.zIndex = '50002';
			});
			if(options.callback){
				SUI.draw.YEdit[id].on('afterRender', function(){
					options.callback();
				});
			}
			SUI.draw.YEdit[id].render();  
};

// UTILITY
SUI.util.InitAll = function(){
	SUI.style.Current.capture('container');
	SUI.util.GUI.init();
	SUI.util.AttachRateFunctions();
	SUI.util.AttachForumFunctions();
};

SUI.util.Ref = {
	keyCode: {
		fromCode: {
			8:'backspace',
			9:'tab',
			13:'enter',
			16:'shift',
			17:'ctrl',
			18:'alt',
			19:'pause/break',
			20:'caps lock',
			27:'escape',
			33:'page up',
			34:'page down',
			35:'end',
			36:'home',
			37:'left arrow',
			38:'up arrow',
			39:'right arrow',
			40:'down arrow',
			45:'insert',
			46:'delete',
			48:0,
			49:1,
			50:2,
			51:3,
			52:4,
			53:5,
			54:6,
			55:7,
			56:8,
			57:9,
			65:'a',
			66:'b',
			67:'c',
			68:'d',
			69:'e',
			70:'f',
			71:'g',
			72:'h',
			73:'i',
			74:'j',
			75:'k',
			76:'l',
			77:'m',
			78:'n',
			79:'o',
			80:'p',
			81:'q',
			82:'r',
			83:'s',
			84:'t',
			85:'u',
			86:'v',
			87:'w',
			88:'x',
			89:'y',
			90:'z',
			91:'left window key',
			92:'right window key',
			93:'select key',
			96:'numpad 0',
			97:'numpad 1',
			98:'numpad 2',
			99:'numpad 3',
			100:'numpad 4',
			101:'numpad 5',
			102:'numpad 6',
			103:'numpad 7',
			104:'numpad 8',
			105:'numpad 9',
			106:'multiply',
			107:'+',
			109:'-',
			110:'decimal point',
			111:'divide',
			112:'f1',
			113:'f2',
			114:'f3',
			115:'f4',
			116:'f5',
			117:'f6',
			118:'f7',
			119:'f8',
			120:'f9',
			121:'f10',
			122:'f11',
			123:'f12',
			144:'num lock',
			145:'scroll lock',
			186:';',
			187:'=',
			188:',',
			189:'-',
			190:'.',
			191:'/',
			192:'`',
			219:'[',
			220:'\\',
			221:']',
			222:'\''
		},
		fromName: {
			
		}
	}
};

SUI.util.GUI = {
	store: {
		buttonMenus:{}
	},
	init: function(){
		(function(){//Search for SUI Menu Buttons and Attach Menues
			buttons = getElementsByClassName('SUI-Menu-Button');
			for(var i=0;i<buttons.length;i++){
				try{
					var menucont = document.getElementById(buttons[i].getAttribute('for'));
				}catch(Error){}
				if(menucont){
					SUI.util.GUI.store.buttonMenus[buttons[i].getAttribute('for')] = {};
					var canvas = document.createElement('div');
					canvas.style.cssText = 'text-align: left; background-color: #'+SUI.style.Current.store.row2bg+'; border: 1px solid #'+SUI.style.Current.store.row1bg+';';
					var options = menucont.getElementsByTagName('a');
					for(var ii=0;ii<options.length;ii++){
						var o = document.createElement('div');
						o.innerHTML = options[ii].innerHTML;
						o.style.cssText = 'cursor: pointer; padding: 5px; color: #'+SUI.style.Current.store.alink2+';';
						o.setAttribute('parent',buttons[i].getAttribute('for'));
						if(options[ii].getAttribute('href')){
							o.setAttribute('link',options[ii].getAttribute('href'));
						}
						if(options[ii].getAttributeNode('onclick')){
							o.setAttribute('fun',ii);
							SUI.util.GUI.store.buttonMenus[buttons[i].getAttribute('for')][ii] = options[ii].onclick;
						}
						o.onmouseover = function(){
							this.style.backgroundColor = '#'+SUI.style.Current.store.alink2;
							this.style.color = '#'+SUI.style.Current.store.row2bg;
						}
						o.onmouseout = function(){
							this.style.backgroundColor = 'transparent';
							this.style.color = '#'+SUI.style.Current.store.alink2;
						}

						o.onclick = function(){
							this.style.backgroundColor = 'transparent';
							this.style.color = '#'+SUI.style.Current.store.alink2;
							if(this.getAttribute('fun') && SUI.util.GUI.store.buttonMenus[this.getAttribute('parent')][this.getAttribute('fun')]){
								SUI.util.GUI.store.buttonMenus[this.getAttribute('parent')][this.getAttribute('fun')]();
							}
							else if(this.getAttribute('link') && this.getAttribute('link')!='#' && this.getAttribute('link')!=window.location.href+'#'){
								window.location.href=this.getAttribute('link');
							}
							SUI.draw.MenuBox.Remove();
						}
						canvas.appendChild(o);
					}
					var id = 
					SUI.util.GUI.store.buttonMenus[buttons[i].getAttribute('for')].obj = canvas;
					
					buttons[i].onclick = function(){
						SUI.draw.MenuBox(this,SUI.util.GUI.store.buttonMenus[this.getAttribute('for')].obj,150,'object');
						return false;
					};
				}
			}
		})();
		(function(){// Attatch YUI Editor
			editors = getElementsByClassName('SUI-simple-edit','textarea');
			if(editors.length>0){
				document.getElementsByTagName('body')[0].className = 'yui-skin-sam';
			}
			for(var i=0;i<editors.length;i++){
				var newid = "SUI-NewEditor"+i+'-'+Math.random();
				if(!editors[i].id){
					editors[i].id = newid;
				}
				else{
					newid = editors[i].id;
				}
				var editOptions = {
					height: '150px',
					doSubmit: true,
					smiley: false,
					focus: false
				};
				try{
					var restr = document.getElementById(newid).getAttribute('res');
					if(restr.search('video')!=-1){
						editOptions.video = false;
					}
					if(restr.search('smiley')!=-1){
						editOptions.smiley = false;
					}
					if(restr.search('image')!=-1){
						editOptions.image = false;
					}
					if(restr.search('link')!=-1){
						editOptions.link = false;
					}
				}catch(Error){}
				SUI.draw.YEdit(newid,editOptions);
				//SUI.draw.YEdit['SUI-forum-post-editor'].saveHTML();
				//document.getElementById('SUI-forum-post-editor-form').submit();
			}
		})();
	}
};

SUI.util.YEdit = {
	objToImg: function(code,options){
		//alert(code.split('width="')[1].split('"')[0]);
		//Add support for alignment.
		options = options || {};
		if(options.align){
			var align = ' align="'+options.align+'"';
		}
		else{
			var align = '';
		}
		try{
			var tempobj = document.createElement('div');
			tempobj.innerHTML = code;
			var w = tempobj.getElementsByTagName('embed').length > 0 ? tempobj.getElementsByTagName('embed')[0].getAttribute('width') : tempobj.getElementsByTagName('object')[0].getAttribute('width');
			var h = tempobj.getElementsByTagName('embed').length > 0 ? tempobj.getElementsByTagName('embed')[0].getAttribute('height') : tempobj.getElementsByTagName('object')[0].getAttribute('height');
			//var w = code.split('width="')[1].split('"')[0];
			//var h = code.split('height="')[1].split('"')[0];
			if(!options.obj){
				code = '<img youtube="true"'+align+' style="width: '+w+'px; height: '+h+'px;" src="http://img.youtube.com/vi/'+code.split('youtube.com/v/')[1].substring(0,11)+'/2.jpg" alt="This will display is a video when you post.">';
			}
			else{
				img = document.createElement('img');
				img.setAttribute('youtube','true');
				img.style.cssText = 'width: '+w+'px; height: '+h+'px;';
				if(options.align){
					img.setAttribute('align',options.align);
				}
				img.setAttribute('title','This will display is a video when you post.');
				img.setAttribute('src','http://img.youtube.com/vi/'+code.split('youtube.com/v/')[1].substring(0,11)+'/2.jpg');
				code = img;
			}
			return code;
		}catch(Error){
			alert('Sorry, I could not understand that code. Please use valid YouTube video embed code.');
			return '';
		}
	},
	imgsToObj: function(code){
		var tempobj = document.createElement('div');
		tempobj.innerHTML = code;
		var imgs = tempobj.getElementsByTagName('img');
		for(var i=0;i<imgs.length;i++){
			if(imgs[i].getAttribute('youtube')){
				var w = imgs[i].style.cssText.split('px')[0].split(': ')[1];
				var h = imgs[i].style.cssText.split('px')[1].split(': ')[1];
				var vid = imgs[i].src.split('vi/')[1].split('/2')[0];
				var div = document.createElement('div');
				div.setAttribute('youtube','true');
				//alert(imgs[i].style.cssText);
				div.style.cssText = 'width: '+w+'px; height: '+h+'px;';
				if(imgs[i].align){
					div.style.float = imgs[i].align;
					div.setAttribute('align',imgs[i].align);
				}
				else{
					div.style.display = 'inline';
				}
				div.innerHTML = '<object width="'+w+'" height="'+h+'">'+
				'<param name="movie" value="http://www.youtube.com/v/'+vid+'"></param><param name="wmode" value="transparent"></param><param name="allowFullScreen" value="true"></param>'+
				'<embed src="http://www.youtube.com/v/'+vid+'" type="application/x-shockwave-flash" allowfullscreen="true" wmode="transparent" width="'+w+'" height="'+h+'"></embed></object>';
				imgs[i].parentNode.replaceChild(div,imgs[i]);
				i--;
			}
		}
		return tempobj.innerHTML;
		//alert(tempobj.getElementsByTagName('img').length);
	},
	preObj: function(code){
		var tempobj = document.createElement('div');
		tempobj.innerHTML = code;
		//alert(tempobj.innerHTML);
		var divs = tempobj.getElementsByTagName('div');
		for(var i=0;i<divs.length;i++){
			if(divs[i].getAttribute('youtube')){
				var align= divs[i].getAttribute('align');
				divs[i].parentNode.replaceChild(SUI.util.YEdit.objToImg(divs[i].innerHTML,{align:align,obj:true}),divs[i]);
				i--;
			}
		}
		return tempobj.innerHTML;
	}
};

SUI.util.OrderFunctions = {
	store: {},
	checkDetailsForm: function(){
		//alert('function');
		if(YAHOO.util.Dom.getStyle(document.getElementById('cdomain'),'display') != 'none'){
			//alert('trigger');
			if(document.getElementById('order-domain-name').value == ''){
				alert('You have chosen the option to add a domain. Please enter a domain and check it for availablity before continuing.');
				return false;
			}
			else{
				if(SUI.util.OrderFunctions.store.regGood == false){
					alert('The domain you chose is not available, please choose a different domain name to continue.');
					return false;
				}
				else if(!SUI.util.OrderFunctions.store.regGood && YAHOO.util.Dom.getStyle(document.getElementById('Check-Name'),'display') != 'none'){
					alert('Please check the availability of your domain name before continuing.');
					return false;
				}
				else{
					return true;
				}
			}
		}
		else{
			return true;
		}
	},
	checkDomainAvail: function(button,domain,extention){
		if(!SUI.util.OrderFunctions.store.regGood){
			domain = document.getElementById(domain);
			extention = document.getElementById(extention);
			var callb = function(response){
				//alert(response);
				SUI.effects.ButtonWorking(button,'',false);
				if(response == '210'){
					SUI.util.OrderFunctions.store.regGood = true;
					button.value = 'Domain Available : )';
				}
				else{
					SUI.util.OrderFunctions.store.regGood = false;
					button.value = 'Un-Available - Please try another domain.';
				}
			}
			button.disabled = true;
			SUI.effects.ButtonWorking(button,'Checking Domain',true);
			ajax_function('main/xml_request/register.com.asp?c=lookup&sld='+ domain.value +'&tld='+ extention.options[extention.selectedIndex].value.replace('.',''),callb)
		}
	},
	cancelCheckDomain: function(button){
		button = document.getElementById(button);
		delete SUI.util.OrderFunctions.store.regGood;
		button.value = 'Check Availability';
		button.disabled = false;
	},
	validDomain: function(input){
		var regex=/[^a-zA-Z0-9-]/;
		input.value = input.value.replace(regex,'');
	}
};

//Forums
SUI.util.ForumFunctions = {
	store: {},
	manage: function(orig){
		if(!orig.getAttribute('toggle')){
			YAHOO.util.DragDropMgr.unlock();
			(function(){//show options
				var options = getElementsByClassName('sui-forum-options','span');
				for(i=0;options.length>i;i++){
					options[i].style.display = 'inline';
				}
			})();
			(function(){//style forums blocks
				var forums = getElementsByClassName('forum','li',document.getElementById('forum-categories-holder'));
				for(i=0;forums.length>i;i++){
					forums[i].style.border = '1px dashed #808080';
					forums[i].style.backgroundColor = '#'+SUI.style.Current.store.row2bg;
					forums[i].style.cursor = 'move';
				}
			})();
			orig.setAttribute('toggle','on');
		}
		else{
			YAHOO.util.DragDropMgr.lock();
			(function(){//hide options
				var options = getElementsByClassName('sui-forum-options','span');
				for(i=0;options.length>i;i++){
					options[i].style.display = 'none';
				}
			})();
			(function(){//style forums blocks
				var forums = getElementsByClassName('forum','li',document.getElementById('forum-categories-holder'));
				for(i=0;forums.length>i;i++){
					
					forums[i].style.border = '';
					forums[i].style.backgroundColor = '';
					forums[i].style.cursor = '';
				}
			})();
			orig.removeAttribute('toggle');
		}
	},
	order: function(){
		try{//IE Sends Error even when function is not loaded
			var cats = document.getElementById('forum-categories-holder').childNodes;
		}catch(Error){var cats = [];}
		var newCids = [];
		for(var i=0;i<cats.length;i++){
			if(cats[i].className){
				if(cats[i].className == 'category' || cats[i].className.search('category ') != -1 || cats[i].className.search(' category') != -1){
					var cid = {};
					cid.id = cats[i].getAttribute('id').replace('c-','');
					cid.forums = [];
					var forums = cats[i].getElementsByTagName('ul')[0].childNodes;
					for(var ii=0;ii<forums.length;ii++){
						if(forums[ii].className){
							if(forums[ii].className == 'forum' || forums[ii].className.search('forum ') != -1 || forums[ii].className.search(' forum') != -1){
								cid.forums.push(forums[ii].getAttribute('id').replace('f-',''));
							}
						}
					}
					newCids.push(cid);
				}
			}
		}
		if(!SUI.util.ForumFunctions.store.cids){
			SUI.util.ForumFunctions.store.cids = newCids;
		}
		else{
			var newString = YAHOO.lang.JSON.stringify(newCids);
			var oldString = YAHOO.lang.JSON.stringify(SUI.util.ForumFunctions.store.cids);
			if(oldString != newString){
				var sendString = '';
				for(var i=0;i<newCids.length;i++){
					if(i!=0){
						sendString = sendString + ',';
					}
					sendString = sendString + newCids[i].id;
					if(newCids[i].forums){
						for(var ii=0;ii<newCids[i].forums.length;ii++){
							sendString = sendString + '|' + newCids[i].forums[ii];
						}
					}
				}
				ajax_function('../json/json.asp?page=forums&cmd=updateforums&a='+sendString);
				SUI.util.ForumFunctions.store.cids = newCids;
			}
		}
	},
	newpost: function(){
		
	},
	posteditor: function(type,options){
		var options = options || {};
		var edittools = document.createElement('span');
		edittools.id = 'SUI-forum-post-editor-tools';
		(function(){
			if(document.getElementById('SUI-forum-post-editor-tools')){
				var tools = document.getElementById('SUI-front-toolbar-forum-tools');
				tools.style.display = 'inline-block';
				tools.parentNode.removeChild(document.getElementById('SUI-forum-post-editor-tools'));
			}
				var save = document.createElement('a');
				save.href='#';
				save.innerHTML = '<span class="SUI-forum-icon SUI-forum-savepost-icon"></span>Save';
				save.onclick = function(){
					SUI.draw.YEdit['SUI-forum-post-editor'].saveHTML();
					document.getElementById('SUI-forum-post-editor-form').submit();
					return false;
				}
				edittools.appendChild(save);
				var cancel = document.createElement('a');
				cancel.href='#';
				cancel.innerHTML = '<span class="SUI-forum-icon SUI-forum-cancelpost-icon"></span>Cancel';
				cancel.onclick = function(){
					close();
					return false;
				}
				edittools.appendChild(cancel);
			
		})();
		var open = function(){
			var anim = new YAHOO.util.Anim('SUI-forum-post-editor-container', {height:{to:450}}, 1, YAHOO.util.Easing.backOut);
			anim.onComplete.subscribe(function(){
				document.getElementById('SUI-forum-post-editor-container').style.overflow = 'visible';
				document.getElementById('SUI-forum-post-editor-container').style.height = '100%';
				SUI.draw.YEdit['SUI-forum-post-editor'].show();
				if(SUI.util.OutOfView(document.getElementById('SUI-forum-post-editor-container')) == 'top'){
					var eltop = SUI.util.GetSpace('SUI-forum-post-editor-container')[1];
					//alert(eltop);
					var pageanim = new YAHOO.util.Scroll(document.getElementsByTagName('body')[0],{scroll:{to:[0,(eltop-35)]}},.5, YAHOO.util.Easing.easeIn);
					pageanim.animate();
				}
				if(options.editor){
					//options.editor.header .quote
					if(options.editor.edit){
						SUI.draw.YEdit['SUI-forum-post-editor'].setEditorHTML(SUI.util.YEdit.preObj(options.editor.quote));
						document.getElementById('forum-post-epd').value = options.editor.edit;
					}
					else{
						var contentString = '<blockquote><hr><strong>'+options.editor.header+'</strong>'+
						'<p>'+options.editor.quote+'</p><hr></blockquote><br>';
						SUI.draw.YEdit['SUI-forum-post-editor'].setEditorHTML(SUI.util.YEdit.preObj(contentString));
						document.getElementById('forum-post-epd').value = '';
					}
				}
				else{
					document.getElementById('forum-post-epd').value = '';
				}
			});
			document.getElementById('SUI-forum-post-editor-container').style.cssText = 'overflow: hidden; height: 1px; display: block;';
			
			var tools = document.getElementById('SUI-front-toolbar-forum-tools');
				tools.style.display = 'none';
				tools.parentNode.insertBefore(edittools,tools);
			anim.animate();
		};
		var close = function(){
			var anim = new YAHOO.util.Anim('SUI-forum-post-editor-container', {height:{to:1}}, 1, YAHOO.util.Easing.backIn);
			anim.onComplete.subscribe(function(){
				document.getElementById('SUI-forum-post-editor-container').style.display = 'none';
				SUI.draw.YEdit['SUI-forum-post-editor'].clearEditorDoc();
				SUI.draw.YEdit['SUI-forum-post-editor'].hide();
				
				document.getElementById('content-cell').parentNode.parentNode.parentNode.parentNode.style.zoom = '1';
			});
			document.getElementById('SUI-forum-post-editor-container').style.overflow = 'hidden';
			
			var tools = document.getElementById('SUI-front-toolbar-forum-tools');
				tools.style.display = 'inline-block';
				tools.parentNode.removeChild(document.getElementById('SUI-forum-post-editor-tools'));
				document.getElementById('content-cell').parentNode.parentNode.parentNode.parentNode.style.zoom = '';
			anim.animate();
		};
		
		
		(function(){
			
			var discu = YAHOO.util.Dom.getElementsByClassName('disccon',null,'SUI-forum-post-editor-form');
			var quest = YAHOO.util.Dom.getElementsByClassName('quescon',null,'SUI-forum-post-editor-form');
			var polls = YAHOO.util.Dom.getElementsByClassName('pollcon',null,'SUI-forum-post-editor-form');
			var newpost = YAHOO.util.Dom.getElementsByClassName('newpost',null,'SUI-forum-post-editor-form');
			
			for(var i=0;i<discu.length;i++){
				discu[i].style.display = type == 'dis' ? 'block' : 'none';
			}
			for(var i=0;i<quest.length;i++){
				quest[i].style.display = type == 'que' ? 'block' : 'none';
			}
			for(var i=0;i<polls.length;i++){
				polls[i].style.display = type == 'pol' ? 'block' : 'none';
			}
			for(var i=0;i<newpost.length;i++){
				newpost[i].style.display = !options.reply ? 'block' : 'none';
			}
			
			if(type == 'dis'){
				document.getElementById('forum-post-subject-label').innerHTML = 'Discussion Subject:';
				document.getElementById('forum-post-topic_type').value = 'discussion';
			}
			if(type == 'que'){
				document.getElementById('forum-post-subject-label').innerHTML = 'Question Subject:';
				document.getElementById('forum-post-topic_type').value = 'question';
			}
			if(type == 'pol'){
				document.getElementById('forum-post-subject-label').innerHTML = 'Poll Question:';
				document.getElementById('forum-post-topic_type').value = 'poll';
			}
			if(options.reply ){
				document.getElementById('forum-post-reply_id').value = options.reply;
			}
			else{
				document.getElementById('forum-post-reply_id').value = 'new';
			}
			
		})();
		if(!document.getElementById('SUI-forum-post-editor_container')){
			var editOptions = {
				callback: function(){
					document.getElementsByTagName('body')[0].className = 'yui-skin-sam';
					open();
				 },
				 full: true,
				 video: true
			};
			try{
				var restr = document.getElementById('SUI-forum-post-editor').getAttribute('res');
				if(restr.search('video')!=-1){
					editOptions.video = false;
				}
				if(restr.search('smiley')!=-1){
					editOptions.smiley = false;
				}
				if(restr.search('image')!=-1){
					editOptions.image = false;
				}
				if(restr.search('link')!=-1){
					editOptions.link = false;
				}
			}catch(Error){}
			 SUI.draw.YEdit('SUI-forum-post-editor',editOptions);
		}
		else{
			open();
		}
		
	}
};

SUI.util.AttachForumFunctions = function(){
	
	(function(){// Smileys
		if(getElementsByClassName('location-bar').length>0){
			var smileycall = function(string){
				
				try{
					SUI.util.ForumFunctions.store.Smileys = eval(string);
				}catch(Error){SUI.util.ForumFunctions.store.SmileysFail = string}
			}
			ajax_function('../json/json.asp?page=forums&cmd=smilies',smileycall);
		}
	})();
	(function(){// new
		var toolbar = getElementsByClassName('SUI-front-toolbar');
		var lacationbar = getElementsByClassName('location-bar');
		if(toolbar.length > 0 || lacationbar.length > 0){
			var newstyles = ''+
			'.SUI-front-toolbar .tools a{}'+
			'.SUI-front-toolbar .tools a:hover{background-color: #'+ SUI.style.Current.store.alink2 +'; color: #'+ SUI.style.Current.store.row2bg +'}'+
			'#SUI-forum-post-editor-tools,#SUI-front-toolbar-forum-tools{border-right: 3px solid #'+SUI.style.Current.store.row1bg+'}'+
			'.SUI-front-toolbar .tools .right-tools{border-left: 3px solid #'+SUI.style.Current.store.row1bg+'}'+
			//NOT TOOL BAR RELATED - Should be moved to another loading area.
			'ul.forum-categories div.stats, .forum-dragging div.stats, .fcategory-dragging div.stats, ul.forum-categories div.latest, .forum-dragging div.latest, .fcategory-dragging div.latest{border-width: 0 0 1px 1px; border-style: solid; border-color: #'+ SUI.style.Current.store.row1bg +';}'+
			'.SUI-forum-poll-response a:hover.answer-link{background-color: #'+ SUI.style.Current.store.alink2 +'; color: #'+ SUI.style.Current.store.row2bg +'}'+
			'ul.forum-posts li.post .menu a:hover{background-color: #'+ SUI.style.Current.store.alink2 +'; color: #'+ SUI.style.Current.store.row2bg +'}'+
			'ul.forum-categories li.category, .fcategory-dragging{border: 1px solid #'+SUI.style.Current.store.row2bg+';}'+
			'ul.forum-categories ul.forums{border: 1px solid #'+SUI.style.Current.store.row1bg+';}'+
			'ul.forum-posts li.post{border: 1px solid #'+SUI.style.Current.store.row2bg+';}'+
			'ul.forum-threads li.thread{border-bottom: 1px solid #'+SUI.style.Current.store.row2bg+';}'+
			'.SUI-Pagenav{border: 1px solid #'+SUI.style.Current.store.row1bg+';}';
			var oldcss = document.getElementById('frontadminstyles');
			var newcss = document.createElement("style");
			newcss.type="text/css";
			newcss.media="all";
			newcss.id="frontadminstyles";

			if (oldcss == null){
				document.getElementsByTagName('head')[0].appendChild(newcss);
			}
			else{
				oldcss.parentNode.replaceChild(newcss, oldcss);
			}
			if(newcss.styleSheet) {
				newcss.styleSheet.cssText = newstyles;
			}
			else if(newcss.sheet){
				stylesnode = document.createTextNode(newstyles);
				newcss.appendChild(stylesnode);
			}
		}
		if(document.getElementById('SUI-forum-post-editor-form') && document.getElementById('SUI-forum-post-editor-container')){
			var cloneform = document.getElementById('SUI-forum-post-editor-form').cloneNode(true);
			document.getElementById('SUI-forum-post-editor-form').parentNode.removeChild(document.getElementById('SUI-forum-post-editor-form'));
			document.getElementById('SUI-forum-post-editor-container').appendChild(cloneform);
		}
		if(document.getElementById('SUI-new-forum-post')){
			var postButton = document.getElementById('SUI-new-forum-post');
			var menucanvas = document.createElement('div');
			menucanvas.style.cssText = 'text-align: left; background-color: #'+SUI.style.Current.store.row2bg+'; border: 1px solid #'+SUI.style.Current.store.row1bg+';';
			(function(){//Menu Items
				if(postButton.getAttribute('draw') && postButton.getAttribute('draw').search('dis')!=-1){
					var o1 = document.createElement('div'); // Option 1
					o1.innerHTML = '<span class="SUI-forum-icon SUI-forum-discussion-icon"></span>Discussion';
					o1.style.cssText = 'cursor: pointer; padding: 5px; color: #'+SUI.style.Current.store.alink2+';';
					o1.onmouseover = function(){
						this.style.backgroundColor = '#'+SUI.style.Current.store.alink2;
						this.style.color = '#'+SUI.style.Current.store.row2bg;
					}
					o1.onmouseout = function(){
						this.style.backgroundColor = 'transparent';
						this.style.color = '#'+SUI.style.Current.store.alink2;
					}
					o1.onclick = function(){
						this.style.backgroundColor = 'transparent';
						this.style.color = '#'+SUI.style.Current.store.alink2;
						SUI.util.ForumFunctions.posteditor('dis');
						SUI.draw.MenuBox.Remove();
					}
					menucanvas.appendChild(o1);
				}
				if(postButton.getAttribute('draw') && postButton.getAttribute('draw').search('que')!=-1){
					var o2 = document.createElement('div'); // Option 2
					o2.innerHTML = '<span class="SUI-forum-icon SUI-forum-question-icon"></span>Question';
					o2.style.cssText = 'cursor: pointer; padding: 5px; color: #'+SUI.style.Current.store.alink2+';';
					o2.onmouseover = function(){
						this.style.backgroundColor = '#'+SUI.style.Current.store.alink2;
						this.style.color = '#'+SUI.style.Current.store.row2bg;
					}
					o2.onmouseout = function(){
						this.style.backgroundColor = 'transparent';
						this.style.color = '#'+SUI.style.Current.store.alink2;
					}
					o2.onclick = function(){
						this.style.backgroundColor = 'transparent';
						this.style.color = '#'+SUI.style.Current.store.alink2;
						SUI.util.ForumFunctions.posteditor('que');
						SUI.draw.MenuBox.Remove();
					}
					menucanvas.appendChild(o2);
				}
				if(postButton.getAttribute('draw') && postButton.getAttribute('draw').search('pol')!=-1){
					var o3 = document.createElement('div'); // Option 3
					o3.innerHTML = '<span class="SUI-forum-icon SUI-forum-poll-icon"></span>Poll';
					o3.style.cssText = 'cursor: pointer; padding: 5px; color: #'+SUI.style.Current.store.alink2+';';
					o3.onmouseover = function(){
						this.style.backgroundColor = '#'+SUI.style.Current.store.alink2;
						this.style.color = '#'+SUI.style.Current.store.row2bg;
					}
					o3.onmouseout = function(){
						this.style.backgroundColor = 'transparent';
						this.style.color = '#'+SUI.style.Current.store.alink2;
					}
					o3.onclick = function(){
						this.style.backgroundColor = 'transparent';
						this.style.color = '#'+SUI.style.Current.store.alink2;
						SUI.util.ForumFunctions.posteditor('pol');
						SUI.draw.MenuBox.Remove();
					}
					menucanvas.appendChild(o3);
				}
				
			})();
			document.getElementById('SUI-new-forum-post').onclick = function(){
				SUI.draw.MenuBox(this,menucanvas,150,'object');
				return false;
			};
			
		}
	})();
	(function(){// quote,edit,vote
		try{
			var posts = getElementsByClassName('forum-posts','ul')[0].childNodes;
		}catch(Error){var posts = []}
		for(var i=0;i<posts.length;i++){
			if(posts[i].nodeName.toLowerCase() == 'li'){
				try{
					var quotebutton = getElementsByClassName('quote','a',posts[i])[0];
					quotebutton.onclick = function(){
						var info = getElementsByClassName('info','div',this.parentNode.parentNode)[0].innerHTML;
						var content = getElementsByClassName('content','div',this.parentNode.parentNode)[0].innerHTML;
						var topic = this.getAttribute('topic');
						SUI.util.ForumFunctions.posteditor('dis',{
							reply:topic,
							editor:{
								quote:content,
								header:info
							}
						});
						return false;
					}
				}catch(Error){}
				try{
					var editbutton = getElementsByClassName('edit','a',posts[i])[0];
					editbutton.onclick = function(){
						var info = getElementsByClassName('info','div',this.parentNode.parentNode)[0].innerHTML;
						var content = getElementsByClassName('content','div',this.parentNode.parentNode)[0].innerHTML;
						var topic = this.getAttribute('topic');
						var post = this.getAttribute('post');
						SUI.util.ForumFunctions.posteditor('dis',{
							reply:topic,
							editor:{
								edit:post,
								quote:content,
								header:info
							}
						});
						return false;
					}
				}catch(Error){}
				try{
					var ratebutton = getElementsByClassName('rate','a',posts[i])[0];
					ratebutton.onclick = function(){
						var topic = this.getAttribute('topic');
						var post = this.getAttribute('post');
						var menucanvas = document.createElement('div');
						menucanvas.setAttribute('topic',topic);
						menucanvas.setAttribute('post',post);
						menucanvas.style.cssText = 'text-align: left; background-color: #'+SUI.style.Current.store.row2bg+'; border: 1px solid #'+SUI.style.Current.store.row1bg+';';
						(function(){
							var o1 = document.createElement('div'); // Option 1
							o1.innerHTML = '<span class="SUI-forum-icon SUI-forum-postuseful-icon"></span>Post is Useful';
							o1.style.cssText = 'cursor: pointer; padding: 5px; color: #'+SUI.style.Current.store.alink2+';';
							o1.onmouseover = function(){
								this.style.backgroundColor = '#'+SUI.style.Current.store.alink2;
								this.style.color = '#'+SUI.style.Current.store.row2bg;
							}
							o1.onmouseout = function(){
								this.style.backgroundColor = 'transparent';
								this.style.color = '#'+SUI.style.Current.store.alink2;
							}
							o1.onclick = function(){
								var callback = function(message,rid){
									document.getElementById('SUI-forum-rate-results'+rid).innerHTML = message;
								};
								this.style.backgroundColor = 'transparent';
								this.style.color = '#'+SUI.style.Current.store.alink2;
								ajax_function('../json/json.asp?page=forums&cmd=rate&topic_id='+this.parentNode.getAttribute('post')+'&reply_id='+this.parentNode.getAttribute('topic')+'&rating=1',callback,this.parentNode.getAttribute('post'));
								SUI.draw.MenuBox.Remove();
							}
							menucanvas.appendChild(o1);

							var o2 = document.createElement('div'); // Option 2
							o2.innerHTML = '<span class="SUI-forum-icon SUI-forum-postuseless-icon"></span>Post is Useless';
							o2.style.cssText = 'cursor: pointer; padding: 5px; color: #'+SUI.style.Current.store.alink2+';';
							o2.onmouseover = function(){
								this.style.backgroundColor = '#'+SUI.style.Current.store.alink2;
								this.style.color = '#'+SUI.style.Current.store.row2bg;
							}
							o2.onmouseout = function(){
								this.style.backgroundColor = 'transparent';
								this.style.color = '#'+SUI.style.Current.store.alink2;
							}
							o2.onclick = function(){
								var callback = function(message,rid){
									document.getElementById('SUI-forum-rate-results'+rid).innerHTML = message;
								};
								this.style.backgroundColor = 'transparent';
								this.style.color = '#'+SUI.style.Current.store.alink2;
								ajax_function('../json/json.asp?page=forums&cmd=rate&topic_id='+this.parentNode.getAttribute('post')+'&reply_id='+this.parentNode.getAttribute('topic')+'&rating=0',callback,this.parentNode.getAttribute('post'));
								SUI.draw.MenuBox.Remove();
							}
							menucanvas.appendChild(o2);

						})();

						SUI.draw.MenuBox(this,menucanvas,150,'object');
						return false;
						
					}
				}catch(Error){}
			}
		}
		
	})();
	(function(){// collapse
		SUI.util.AttachForumFunctions.collapse = function(obj){
			var target = obj.parentNode.parentNode.getElementsByTagName('ul')[0];
			if(target.style.display != 'none'){
				target.style.display = 'none';
				obj.innerHTML = '+';
				obj.title = 'Expand Section';
			}
			else{
				target.style.display = 'block';
				obj.innerHTML = '-';
				obj.title = 'Collapse Section';
			}
		};
		var collButtons = getElementsByClassName('collapse','button');
		for(i=0;i<collButtons.length;i++){
			collButtons[i].style.cursor = 'pointer';
			collButtons[i].title = 'Collapse Section';
			collButtons[i].onclick = function(){SUI.util.AttachForumFunctions.collapse(this);}
		}
	})();
	(function(){// Drag and Drop
		if(getElementsByClassName('forum-categories','ul')[0] && getElementsByClassName('SUI-front-toolbar','div')[0]){
			var Dom = YAHOO.util.Dom;
			var Event = YAHOO.util.Event;
			var DDM = YAHOO.util.DragDropMgr;
			SUI.util.FMDragRegSecs = function(){
				var forumcats = getElementsByClassName('forums','ul',getElementsByClassName('forum-categories','ul')[0]);
				for (i=0;i<forumcats.length;i++) {
					new YAHOO.util.DDTarget(forumcats[i].id, "forums");
					var forums = getElementsByClassName('forum','li',forumcats[i]);
					for(ii=0;ii<forums.length;ii++){
						SUI.util.FMDragRegElement(forums[ii].id);
					}
				}
			};
			SUI.util.FMDragRegCatSecs = function(){
				var catholder = getElementsByClassName('forum-categories','ul')[0];
				var categories = getElementsByClassName('category','li',catholder);
				new YAHOO.util.DDTarget(catholder.id, "categories");
				for(i=0;i<categories.length;i++){
					SUI.util.FMDragRegCat(categories[i].id);
				}
				
			};
			SUI.util.FMDragRegElement = function(id,hid){
				var access = Dom.get(id).getAttribute('access');
				(function(){// Add Options Links
					var span = document.createElement('span');
					span.className = 'sui-forum-options';
					span.style.display = 'none';
					if(access.match('move')){
						var move = document.createElement('span');
						move.className = 'move';
						move.innerHTML = 'Move';
						span.appendChild(move);
					}
					if(access.match('edit')){
						var edit = document.createElement('a');
						edit.innerHTML = 'Edit';
						edit.href = '#';
						span.appendChild(edit);
					}
					if(access.match('delete')){
						var del = document.createElement('a');
						del.innerHTML = 'Delete';
						del.href = '#';
						span.appendChild(del);
					}
					if(access.match('add')){
						var add = document.createElement('a');
						add.innerHTML = 'Add';
						add.href = '#';
						span.appendChild(add);
					}
					getElementsByClassName('summary','div',Dom.get(id))[0].appendChild(span);
				})();
				if(access.match('move')){
					dd = new SUI.util.FMDrag(id, "forums");
					if(hid){
						dd.setOuterHandleElId(hid);
						//dd.setHandleElId(hid);
					}
				}
			};
			SUI.util.FMDragRegCat = function(id,hid){
				var access = Dom.get(id).getAttribute('access');
				(function(){// Add Options Links
					var span = document.createElement('span');
					span.className = 'sui-forum-options';
					span.style.display = 'none';
					if(access.match('move')){
						var move = document.createElement('span');
						move.className = 'move';
						move.innerHTML = 'Move';
						span.appendChild(move);
					}
					if(access.match('edit')){
						var edit = document.createElement('a');
						edit.innerHTML = 'Edit';
						edit.href = '#';
						edit.onclick = function(){
							ajax_showTooltip_menu('../ajax/cmd.asp?page=forums&cmd=forums_cat&id='+id.replace('c-',''),this,400);
							return false;
						}
						span.appendChild(edit);
					}
					if(access.match('delete')){
						var del = document.createElement('a');
						del.innerHTML = 'Delete';
						del.href = '#';
						del.onclick = function(){
							ajax_showTooltip_menu('../ajax/cmd.asp?page=forums&cmd=delete&tab=forum_cat&di='+id.replace('c-',''),this,400);
							return false;
						}
						span.appendChild(del);
					}
					getElementsByClassName('title','div',Dom.get(id))[0].appendChild(span);
				})();
				if(access.match('move')){
					dd = new SUI.util.FMDrag(id, "categories");
					if(hid){
						//dd.setOuterHandleElId(hid);
						dd.setHandleElId(hid);
					}
				}
			};
			SUI.util.FMDrag = function(id, sGroup, config){
				SUI.util.FMDrag.superclass.constructor.call(this, id, sGroup, config);
				var el = this.getDragEl();
				Dom.setStyle(el, "opacity", 0.80); // The proxy is slightly transparent
				this.goingUp = false;
				this.lastY = 0;
			};
			YAHOO.extend(SUI.util.FMDrag, YAHOO.util.DDProxy, {
				startDrag: function(x, y) {

					// make the proxy look like the source element
					var dragEl = this.getDragEl();
					var clickEl = this.getEl();
					Dom.setStyle(clickEl, "visibility", "hidden");
					//Dom.setStyle(dragEl, "display", "block");
					dragEl.innerHTML = clickEl.innerHTML;
					
					Dom.setStyle(dragEl, "color", Dom.getStyle(clickEl, "color"));
					Dom.setStyle(dragEl, "backgroundColor", Dom.getStyle(clickEl, "backgroundColor"));
					Dom.setStyle(dragEl, "fontFamily", Dom.getStyle(clickEl, "fontFamily"));
					Dom.setStyle(dragEl, "fontSize", Dom.getStyle(clickEl, "fontSize"));
					Dom.setStyle(dragEl, "border", "0px solid #fff");
					
					if(Dom.hasClass(clickEl,'forum')){
						dragEl.className = 'forum-dragging';
					}
					else if(Dom.hasClass(clickEl,'category')){
						dragEl.className = 'fcategory-dragging';
					}
				},

				endDrag: function(e) {

					var srcEl = this.getEl();
					var proxy = this.getDragEl();
			        

					// Show the proxy element and animate it to the src element's location
					Dom.setStyle(proxy, "visibility", "");
					var a = new YAHOO.util.Motion( 
						proxy, { 
							points: { 
								to: Dom.getXY(srcEl)
							}
						}, 
						0.2, 
						YAHOO.util.Easing.easeOut 
					)
					var proxyid = proxy.id;
					var thisid = this.id;

					// Hide the proxy and show the source element when finished with the animation
					a.onComplete.subscribe(function() {
							
							Dom.setStyle(proxyid, "visibility", "hidden");
							Dom.setStyle(proxyid, "left", "0");
							Dom.setStyle(proxyid, "top", "0");
							Dom.setStyle(proxyid, "width", "1px");
							Dom.setStyle(proxyid, "height", "1px");
							proxy.innerHTML = '';
							Dom.setStyle(thisid, "visibility", "");
							Dom.removeClass(document.getElementById(thisid).parentNode, 'over');
							SUI.util.ForumFunctions.order();
							
						});
					a.animate();
					
					 
					
					//DDM.lock();
				},

				onDragDrop: function(e, id) {

					// If there is one drop interaction, the li was dropped either on the list,
					// or it was dropped on the current location of the source element.
					if (DDM.interactionInfo.drop.length === 1) {

						// The position of the cursor at the time of the drop (YAHOO.util.Point)
						var pt = DDM.interactionInfo.point; 

						// The region occupied by the source element at the time of the drop
						var region = DDM.interactionInfo.sourceRegion; 

						// Check to see if we are over the source element's location.  We will
						// append to the bottom of the list once we are sure it was a drop in
						// the negative space (the area of the list without any list items)
						if (!region.intersect(pt)) {
							var destEl = Dom.get(id);
							var destDD = DDM.getDDById(id);
							destEl.appendChild(this.getEl());
							destDD.isEmpty = false;
							DDM.refreshCache();
						}

					}
				},

				onDrag: function(e) {

					// Keep track of the direction of the drag for use during onDragOver
					var y = Event.getPageY(e);

					if (y < this.lastY) {
						this.goingUp = true;
					} else if (y > this.lastY) {
						this.goingUp = false;
					}

					this.lastY = y;
				},

				onDragOver: function(e, id) {
			    
					var srcEl = this.getEl();
					var destEl = Dom.get(id);

					if(destEl.tagName.toLowerCase() == 'ul' || destEl.tagName.toLowerCase() == 'li'){
						if (destEl.nodeName.toLowerCase() == "li" && Dom.hasClass(destEl, 'forum') || destEl.nodeName.toLowerCase() == "li" && Dom.hasClass(destEl, 'category')) {
							var orig_p = srcEl.parentNode;
							var p = destEl.parentNode;

							if (this.goingUp) {
								p.insertBefore(srcEl, destEl); // insert above
							} else {
								p.insertBefore(srcEl, destEl.nextSibling); // insert below
							}
				            
							DDM.refreshCache();
						}
						else if(destEl.nodeName.toLowerCase() == "ul" && Dom.hasClass(destEl, 'forums')){
							Dom.addClass(destEl, 'over');

							var p = destEl;


								//p.appendChild(srcEl);
							
				            
							DDM.refreshCache();
						}
					}    
				},
				onDragOut: function(e, id) {
					var srcEl = this.getEl();
					var destEl = Dom.get(id);
					
					//if(destEl.nodeName.toLowerCase() == "td" && Dom.hasClass(destEl, 'SAUI-PB-Section')){
						Dom.removeClass(destEl, 'over');
					//}
				}
			});
			SUI.util.FMDragRegSecs();
			SUI.util.FMDragRegCatSecs();
			YAHOO.util.DragDropMgr.lock();
		}
	})();
	SUI.util.ForumFunctions.order();
};

SUI.util.AttachRateFunctions = function(){
	var rateboxes = getElementsByClassName('SUI-RateBox');
	var vbls=[],vdown=[],vup=[],vnum=[],vnd=[];
	for(i=0;rateboxes[i];i++){
		if(!rateboxes[i].getAttribute('set')){
			var objs = rateboxes[i].childNodes;
			vbls[i] = rateboxes[i].getAttribute('vbls');
			
			for(ii=0;objs[ii];ii++){
				if(objs[ii].className == 'down'){
					vdown[i] = objs[ii];
				}
				else if(objs[ii].className == 'number'){
					vnum[i] = objs[ii];
					vnd[i] = parseFloat(vnum[i].innerHTML);
				}
				else if(objs[ii].className == 'number good'){
					vnum[i] = objs[ii];
					vnd[i] = parseFloat(vnum[i].innerHTML);
				}
				else if(objs[ii].className == 'number bad'){
					vnum[i] = objs[ii];
					vnd[i] = parseFloat('-'+vnum[i].innerHTML);
				}
				else if(objs[ii].className == 'up'){
					vup[i] = objs[ii];
				}
			}
			if(vdown[i]){
				vdown[i].setAttribute('rbn',i);
				vdown[i].onclick = function(){
					ajax_send('files/com/call.asp?page=rateit&vbls='+vbls[this.getAttribute('rbn')]+'&vote=-1');
					//alert(vbls[this.getAttribute('rbn')]+' Voted Down ');
					vdown[this.getAttribute('rbn')].className = vdown[this.getAttribute('rbn')].className + ' dis';
					vup[this.getAttribute('rbn')].className = vup[this.getAttribute('rbn')].className + ' dis';
					if(vnd[this.getAttribute('rbn')]-1<0){vnum[this.getAttribute('rbn')].className = 'number bad'}
					else if(vnd[this.getAttribute('rbn')]-1>0){vnum[this.getAttribute('rbn')].className = 'number good'}
					else{vnum[this.getAttribute('rbn')].className = 'number'}
					vnum[this.getAttribute('rbn')].innerHTML = Math.abs(vnd[this.getAttribute('rbn')] - 1);
					vdown[this.getAttribute('rbn')].onclick = function(){return false};
					vup[this.getAttribute('rbn')].onclick = function(){return false};
					return false;
				}
				vup[i].setAttribute('rbn',i);
				vup[i].onclick = function(){
					ajax_send('files/com/call.asp?page=rateit&vbls='+vbls[this.getAttribute('rbn')]+'&vote=1');
					//alert(vbls[this.getAttribute('rbn')]+' Voted Up ');
					vdown[this.getAttribute('rbn')].className = vdown[this.getAttribute('rbn')].className + ' dis';
					vup[this.getAttribute('rbn')].className = vup[this.getAttribute('rbn')].className + ' dis';
					if(vnd[this.getAttribute('rbn')]+1<0){vnum[this.getAttribute('rbn')].className = 'number bad'}
					else if(vnd[this.getAttribute('rbn')]+1>0){vnum[this.getAttribute('rbn')].className = 'number good'}
					else{vnum[this.getAttribute('rbn')].className = 'number'}
					vnum[this.getAttribute('rbn')].innerHTML = Math.abs(vnd[this.getAttribute('rbn')] + 1);
					vdown[this.getAttribute('rbn')].onclick = function(){return false};
					vup[this.getAttribute('rbn')].onclick = function(){return false};
					return false;
				}
			}
			rateboxes[i].setAttribute('set','true');
		}
	}
};

SUI.util.CleanHTML = function(){

};

SUI.util.GetSpace = function (obj,target){// returns the space information for the object and window, takes either an object or an ID
	iebody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
	var scrollt=(iebody.scrollTop)? iebody.scrollTop : window.pageYOffset;
	scrollt = scrollt || 0;
	var scrolll=(iebody.scrollLeft)? iebody.scrollLeft : window.pageXOffset;
	scrolll = scrolll || 0;
	var docwidth=(window.innerWidth)? window.innerWidth : iebody.clientWidth;
	var docheight=(window.innerHeight)? window.innerHeight : iebody.clientHeight;
	target = target || document;
	if(typeof obj == ('string')){obj = target.getElementById(obj);}
	var curwidth = obj.offsetWidth; var curheight = obj.offsetHeight;
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop,curwidth,curheight,docwidth,docheight,scrolll,scrollt];
};

SUI.util.OutOfView = function (obj){
	var s = SUI.util.GetSpace(obj);
	if(s[1] > s[7] && (s[1] + s[3]) < (s[5] + s[7])){
		return false;
	}
	else{
		if(s[1] < s[7]){
			return 'top';
		}
		else{
			return 'bottom';
		}
	} 
};

addEvent(window,'load',SUI.util.InitAll);
