    //BEGIN CORE JS
function getElem(a) { return document.getElementById(a); }
var sPOS = 0;
var doc = new Function();
//##parse ("includes/XMLRPC_JS.vm")

//Browser Detection JS
isIE = false;
isMoz = false;

var childInt = 0;
var updateColorVars = new Array(); //modules with non-reloading tabbing systems require this variable to be present on page load, so it cannot live in themeChange.js

if (navigator.appName=="Netscape") { isMoz = true; childInt = 1;}
if (navigator.appName=="Microsoft Internet Explorer") { isIE = true; }

// Container for all objects on the page
function Universe() 
{
    // Array of modules, indexed by modID.  e.g. this.modules['HO']
    this.modules = new Array();
    this.modLayout = new Array();
}

// Create a new module, and add it to the list of modules
Universe.prototype.addModule = function(modID, compID, modTitle) 
{
    this.modules[modID] = new Module(modID, compID, null, null, modTitle);
    return this.modules[modID];
}
Universe.prototype.getCount = function() 
{
    return (this.modules.length-1);
}
Universe.prototype.getLayout = function() 
{
    
    return "layoutstring here";
}

// Module Object
function Module(modID, compID, bEditable, bPreview, modTitle) 
{
    if (bEditable == null || bEditable == '') bEditable = 0;
    if (bPreview == null) bPreview = 0;
    this.modID = modID;
    this.compID = compID;
    this.title = modTitle;
    this.bEditable = bEditable;
    this.xmlReq;    // Object for requesting new data for the module
    this.popupDiv;
    this.plainPopupDiv = null;
    this.plainCloseInterval = null;
    this.fullPopupDiv = null;
    this.loadingDiv = null;
    this.bPreview = bPreview;
	this.sTimeout = 100;
	this.sid = "";
	this.sLoadedVar = "";
}

// Wrappers for getState
Module.prototype.doEdit = function(args, callback, supressLoadingDiv) {
    this.getState('doEdit', args, callback, supressLoadingDiv);
}
Module.prototype.doView = function(args, callback, supressLoadingDiv) {
    this.getState('doView', args, callback, supressLoadingDiv);
}
Module.prototype.doError = function() {
    this.getState('doError');
}
//TODO: minimize/max
//TODO: close

Module.prototype.addToPage = function (callback, args) {
	if (args == null) args = "";
    this.doEdit('MODID,m0,CACTION,doView,ADDMOD,'+this.compID+',COL,2,POS,0'+args, callback);
}
// Get new content for a module
Module.prototype.getState = function(state, args, callback, supressLoadingDiv){
    currentModule = this;
    if (callback == null) callback = this.redrawFromXML;
    if (state == null) state = 'doView';
    if (supressLoadingDiv == null) supressLoadingDiv = false;
    var url = 'module.jhtml?ACTION=' + state;
    if (args == null || args.indexOf(',ADDMOD,') == -1) {
        url += '&COMPID=' + this.compID;
    }
    //var url = 'edit.htm?COMPID=' + this.compID + '&ACTION=' + state;
    
    if (this.modID != "tempModule") {
        url += '&MODID=' + this.modID;
    }
    if (args!= null && args.length > 1) {
        if (args.indexOf('NOSPLIT') < 0) {
            args = args.split(',');
            for (var i = 0; i < args.length; i+=2) {
              url += '&' + args[i] + '=' + args[i+1];
            }
        } else {
            url += args.substring(7,args.length);
        }
    }   
    if ((this.modID == 'tempModule' || (this.bPreview)) && url.indexOf('ADDMOD=') == -1 ) {
        url += '&preview=true';
    }

    this.xmlReq = new XMLRequest(url, callback);

    /* Loading Div */
    if (!supressLoadingDiv) {
    	g.closeLoadingDiv();  // Close any open loading divs
	    if (this.loadingDiv == null) {
   	     this.loadingDiv = createDiv();
   	     this.loadingDiv.id = this.modID + "Loading";
   		} 
	    moduleDiv = getElem(this.modID);
		if (mouseY) {
		  this.loadingDiv.style.top = mouseY + 10; //moduleDiv.offsetTop + (moduleDiv.offsetHeight/2);
		  this.loadingDiv.style.left = mouseX + 20; //moduleDiv.offsetLeft + (moduleDiv.offsetWidth/3);
		  this.loadingDiv.innerHTML = "<div style='background-color:#CCCCCC;padding:5px;color:#FFFFFF;font-weight:bold;'>Loading...</div>";
		  this.loadingDiv.display = 'inline';
		}
    	currentModule = this;
    	// This setTimeout might cause problems if you have more multiple requests
    	// in a short period of time.  Not sure yet.
    	// We need to put it in a timeout though, or the loadingDiv doesn't show
    	// until the request comes back, which defeats the purpose
	    setTimeout("currentModule.xmlReq.getData()",1);
    
    /* End Loading Div */   
	} else if (supressLoadingDiv == "preview") {
		// Interesting way to show the "big" loading div
		setTimeout("currentModule.xmlReq.getData()",1);
	} else {
		this.xmlReq.getData();
    }
    
}

Module.prototype.rS = function() {
  //    if ((getElem(this.sid).readyState == 'loaded') || (getElem(this.sid).readyState == 'complete'))
  if (this.sLoadedVar)
    if (eval("typeof(" + this.sLoadedVar + ")") != 'undefined')
        eval(this.func);
    else if (this.sLoadingInt < (this.sTimeout*10)) {
        this.sLoadingInt++;
        setTimeout("g." + this.modID + "Module.rS()", 500);
    }
}

//for saving min/max state
Module.prototype.minMax = function(state) {
 //var url = 'persist.htm?COMPID='+this.compID+'&MODID='+this.modID+'&MODSTATE='+((state==1)?'MAX':'MIN');

  //currentModule = this;
  g.m0Module.doEdit('CHGMOD,' + this.modID + ',MODSTATE,' + ((state==1)?'MAX':'MIN'), z, true);
//  this.xmlReq = new XMLRequest(url, z);
//  currentModule.xmlReq.getData();
};

//##for when something in a module triggers the registration dialog


Module.prototype.tooMany = function() { 
    this.popWin();  
    var p = this.popupDiv;
    if(typeof(closeHTML)!='undefined'){
        p.innerHTML='<div style="padding:6px;border:1px solid #AAA;background-color:#F2F2F2;">'+closeHTML+getRegHTML('tml')+'</div>';
    }else{      
        p.innerHTML = getRegHTML('tml');
    }
    var p = p.style;
    p.top = mouseY-100;
    p.left = mouseX-100;
    p.width='400px';
    p.display='inline';
}

Universe.prototype.closeLoadingDiv = function (module) {
	/*
	if (module == null) {
		module = currentModule;
	}
	*/
	if (module !=null && module.loadingDiv != null) {
   		 _del(module.modID + "Loading");
   		 module.loadingDiv = null;
	} else {
		for (var i=0;i<g.modules.length;i++) {
			if (g.modules[i].loadingDiv != null) {
   				 _del(g.modules[i].modID + "Loading");
   				 g.modules[i].loadingDiv = null;
			}
		}
	}
}

Module.prototype.evalJS = function(moduleContents){ 
    if (moduleContents.indexOf("<!--end js-->") > -1) {
        var s = moduleContents.split('<!--end js-->');
        s[0] = s[0].replace(/<.+?cript[^>]*>/ig,"");
        s[0] = s[0].replace(/<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)\>/g, "");
        eval(s[0]);
        moduleContents = s[1];
    }
    if (moduleContents.indexOf("<!--start js-->") > -1) {
        var s = moduleContents.split('<!--start js-->');
        s[1] = s[1].replace(/<[\/a-z]+?cript[^>]*>/ig,"");
        s[1] = s[1].replace(/<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)\>/g, "");
        eval(s[1]);
        moduleContents = s[0];
    }
    return moduleContents;
}


Module.prototype.redraw = function(moduleContents) 
{

  g.closeLoadingDiv(currentModule);
  
  var c = document.getElementById(this.modID);
  var js1;

    if (moduleContents.indexOf("<!--start js-->") > -1) {
      var s = moduleContents.split('<!--start js-->');
      s[1] = s[1].replace(/<[\/a-z]+?cript[^>]*>/ig,"");
      s[1] = s[1].replace(/<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)\>/g, "");
      js1 = s[1];
      retHTML = s[0];
    } else {
      retHTML = moduleContents;
    }
    if (retHTML.indexOf("<!--end js-->") > -1) {
      var s = retHTML.split('<!--end js-->');
      s[0] = s[0].replace(/<.+?cript[^>]*>/ig,"");
      s[0] = s[0].replace(/<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)\>/g, "");
      
      //alert(s[0]);
      eval(s[0]);
      retHTML = s[1];
    }    

  if (navigator.appName.indexOf('xplorer') > -1) {
    c.outerHTML = retHTML;
    //eval(js1); -- this is taken care of below.  no reason to have it here.
  } else {
    if(!this.bPreview){    
      origC = c;         
      c.id = 'tmpToRemove';     
      var l = true;

      while (c && l) {
        c = c.parentNode;
        if (c && c.id && c.id.indexOf('col')>-1)
         l = false;
      }
      if (!c) {   // Handle components not in columns (e.g. module picker)
      	c = origC.parentNode;
      }

      var t = '';
      t = c.innerHTML.replace(/<div (.*?)tmpToRemove./ig, retHTML + '<div id=tmpToRemove ');
      c.innerHTML = t;
  
      var d = getElem('tmpToRemove');
      d.parentNode.removeChild(d);
    }else{
        mouseY-=50;
        createAddToPreview("<table style='width:100%;'><tr><td>&nbsp;</td><td style='text-align:center;' onclick='addPreview();' >&nbsp;<img class='greyx'  src='"+imgPath+"/addTo.gif' /> <span class='addTo' style='position:relative;top:-3px;'>Add to my page</span></td><td style='text-align:right;'><img class='greyx'  src='"+imgPath+"/btn_close_small.gif' alt='Close' onclick='hideEle(this.parentNode.parentNode.parentNode.parentNode.parentNode);' /></td></tr></table>"+moduleContents);
    }
  }
  eval(js1);
  
}


// Redraw from the RPC response
Module.prototype.redrawFromXML = function() 
{
    currentModule.redraw(currentModule.xmlReq.req.responseText);
}


Module.prototype.showXHL = function(xhl) {
var html = '';

	var popHeader = '<div id=' + this.modID + '_pop class=module style="position:relative;width:250px;" onmousedown = "isPo=true">		<div class="modContents popupMod modPad" style="width:250px;" id="' + this.modID + '_pop_body" >';

	html += popHeader;
	
	html += xhl;
	
	


	var popFooter = '	</div></div>';

	html += popFooter;
	html += '</div></font></div>';
	this.popWin();
	currentModule = this;
	this.fillPopWin(html);
}
Module.prototype.hideXHL = function() {
	if (getElem(this.modID + '_pop') != null) {
		_del(this.modID + '_pop');
	}
}


/* News functions */

Module.prototype.openNewsReader = function(storyToOpen, storyIndex) {
    this.doPopFullView('format,newsReader,storyToShow,'+storyToOpen+',storyIndex,'+storyIndex);
}
Module.prototype.openNewsReaderStory = function(storyToOpen) {
    if (storyToOpen != null) {
        var storyDivToOpen = getElem(this.modID + '_newsReaderHeadline' + storyToOpen);
        if (storyDivToOpen != null) {
            storyDivToOpen.style.display = 'block';
        }
    }
}
Module.prototype.closeNewsReaderStory = function(storyToClose) {
    if (storyToClose != null) {
        var storyDivToClose = getElem(this.modID + '_newsReaderHeadline' + storyToClose);
        if (storyDivToClose != null) {
            storyDivToClose.style.display = 'none';
        }
    }
}
Module.prototype.toggleNewsReaderStory = function(storyToToggle) {
    if (storyToToggle != null) {
        var storyDivToToggle = getElem(this.modID + '_newsReaderHeadline' + storyToToggle);
        if (storyDivToToggle != null) {
            if (storyDivToToggle.style.display == 'none') {
                this.openNewsReaderStory(storyToToggle);
            } else {
                this.closeNewsReaderStory(storyToToggle);
            }
        }
    }
}
Module.prototype.enforceLimit = function(check, index) {
	if (check && check.checked) {	
		cForm = check.form;
		var checkedCount = 0;
		for (var i=0;i< cForm.selectedFeeds.length;i++) {
			if (cForm.selectedFeeds[i].checked) {
				if (++checkedCount > 5) {
					alert("Sorry, you can only select five categories");
					check.checked = false;
					return false;
				}
			}
		}
	}
}
/* End News Functions */

// Create the Universe
var g = new Universe();

g.getScript = function(src,sid,modid,varToCheck, callback) {
  if (modid != null)
    g.modules[modid].sid = sid;
  if (callback == null) {
  	callback = "g." + modid + "Module.rS()";
  }
  var script = document.createElement('script');
  script.src = src;
  script.id = sid;
  script.type = 'text/javascript';
  script.defer = true;
  var head = document.getElementsByTagName('head').item(0);
  head.appendChild(script);
  if (modid != null)
    setTimeout("g.checkScript('" + callback + "','" + varToCheck + "');", 100);
}

g.checkScript = function(func,vtc) {
  if (eval("typeof(" + vtc + ") != 'undefined'"))
	eval(func);
  else
	setTimeout("g.checkScript('" + func + "','" + vtc + "');", 1000);
}
//TODO: g.prototype.getLayout()


var mouseX;
var mouseY;

function createDiv() {
    var nd;
        nd=document.createElement("DIV");
        nd.style.display="inline";
        nd.style.position="absolute";
        nd.style.paddingBottom="0px";
        nd.innerHTML='<div style="text-align:center;background-color:#fff;" class="stTip"><br/>Loading...<br/><img src="http://ak.imgfarm.com/images/funwebproducts/whiptones/progress_anim_01.gif" /><br/><br/></div>';
        
        document.body.appendChild(nd)
    return nd;
}
function setEvents(e) {
    evt = nn6?e:event;
    mouseX = (nn6?evt.pageX:evt.clientX+document.body.scrollLeft);
    mouseY = (nn6?evt.pageY:evt.clientY+document.body.scrollTop);
}
function genX(x,w) {
    var d = document.body.clientWidth - (x+w);
    if (d < 0) x = x+d-20; 
    return x;
}
function genY(y) {
    return y;
}

//##generic popHeader (for use with JS pop functions)
function popHeader(title,modID) {
    if (!modID)
        modID = 99;
        
    if (!title){title='';for(var i=0;i<20;i++)title += '&nbsp;';}
    
    return '<div id=m'+modID+'_pop class=module style="position:relative;" onmousedown = "isPo=true"><table class=modWrp cellspacing=0 cellpadding=0><tr onmouseover=showEdit(\'m99_pop\') onmouseout=hideEdit(\'m99_pop\')><td class=modLeft><img src=http://ak.imgfarm.com/images/spacer.gif width=8 height=1></td><td class=modTitle id=m_m'+modID+'_pop_h>'+title+'</td><td class=modEdit id=edit_m'+modID+'_pop align=right><span class="modButton" onclick="setEvents(event);_del(\'m'+modID+'_pop\');sPOS=0;currentModule.popupDiv=null;void(0);">&nbsp;X&nbsp;</span></td>          <td class=modRight><img src=http://ak.imgfarm.com/images/spacer.gif width=8 height=1></td></tr></table><font size=-1><div id=m'+modID+'_pop_body>';
}


//##popup div creator
var p,po; 
Module.prototype.doPopView = function(args) {
    this.popWin();
    this.doView(args, this.redrawPopFromXML);   
}
Module.prototype.popWin = function(arg) {   
    if (!this.popupDiv){
        this.popupDiv = createDiv();    
    }else{
        if(arg){            
            isPo = false;
            sPOS=0;
            //HACK -- module needs to be REMOVED, not just blanked out
            this.popupDiv.innerHTML='';
            //END HACK
            this.popupDiv=null;
            this.popupDiv = createDiv();    
        }   
    }
    currentModule = this;
}
Module.prototype.redrawPopFromXML = function () {
    currentModule.fillPopWin(currentModule.xmlReq.req.responseText);
}

Module.prototype.popY = 0;
Module.prototype.popX = 0;
Module.prototype.origpopX = 0;
Module.prototype.origpopY = 0;

Module.prototype.fillPopWin = function(html) {

	g.closeLoadingDiv(currentModule);

    currentModule.popupDiv.innerHTML = currentModule.evalJS(html);  

    
		currentModule.popupDiv.style.top=mouseY+10; 		
		currentModule.popupDiv.style.left=mouseX+10;	

	//fix for popups that scroll offscreen
		var divX = mouseX+10;
		if ((mouseX+10+currentModule.popupDiv.scrollWidth) > self.screen.width)
			currentModule.popupDiv.style.left = divX - ((mouseX+10+currentModule.popupDiv.scrollWidth) - self.screen.width+75);

   // if (sPOS < 1)
   //     setPosOnScreen(currentModule.popupDiv); 
    currentModule.popupDiv.style.display='inline';
}




//##plain popup div creator
Module.prototype.doPlainPopView = function(args,bNoCloseWin,width) {
    this.bNoCloseWin=bNoCloseWin;
    this.popPlainWin(width);
    this.doView(args, this.redrawPlainPopFromXML);  
}
Module.prototype.popPlainWin = function(arg) {  
    if (!this.plainPopupDiv){
        this.plainPopupDiv = createDiv();   
    }else{
        if(arg){            
            isPo = false;
            sPOS=0;
            //HACK -- module needs to be REMOVED, not just blanked out
            this.plainPopupDiv.innerHTML='';
            //END HACK
            this.plainPopupDiv=null;
            this.plainPopupDiv = createDiv();   
        }   
    }
    currentModule = this;
    if (arg)
        this.plainPopupDiv.style.width = arg;
}
Module.prototype.redrawPlainPopFromXML = function () {
    currentModule.fillPlainPopWin(currentModule.xmlReq.req.responseText);
}
Module.prototype.fillPlainPopWin = function(html) {


	g.closeLoadingDiv(currentModule);
	
	var bSetPos = false;
	
	var divX = mouseX+10;
	//if (!currentModule.plainPopupDiv.style.top) {
		currentModule.plainPopupDiv.style.top=mouseY+10; 		
		currentModule.plainPopupDiv.style.left=divX;
		currentModule.origPlainPopY = mouseY;
		currentModule.origPlainPopX = mouseX;		
		bSetPos = true;


    //} 
    
	currentModule.plainPopupDiv.innerHTML = '<table width=100%><tr><td>' + currentModule.evalJS(html) + '</td></tr></table>';

	//so the window doesn't go offscreen
	if ((mouseX+10+currentModule.plainPopupDiv.scrollWidth) > self.screen.width)
		currentModule.plainPopupDiv.style.left = divX - ((mouseX+10+currentModule.plainPopupDiv.scrollWidth) - self.screen.width+75);

    currentModule.plainPopupDiv.zIndex=10;
    //if (bSetPos)
    //  setPosOnScreen(currentModule.plainPopupDiv);    
    currentModule.plainPopupDiv.style.display='inline';
    
    
    if (currentModule.plainCloseInterval != "undefined") {
        clearInterval(currentModule.plainCloseInterval);
    }
    currentModule.plainPopupDiv.style.display='inline';
    if(!this.bNoCloseWin){
	    // Close if the mouse goes away from popup without going over it.
	    currentModule.plainCloseInterval = setInterval("if (currentModule.plainPopupDiv != null && (mouseX < parseInt(currentModule.plainPopupDiv.style.left) - 20 || mouseX > parseInt(currentModule.plainPopupDiv.style.left) + parseInt(currentModule.plainPopupDiv.childNodes[0].style.width) + 20 || mouseY < parseInt(currentModule.plainPopupDiv.style.top) - 20 || mouseY > parseInt(currentModule.plainPopupDiv.style.offsetHeight) + 20)) {clearInterval(currentModule.plainCloseInterval);showHideSelects(1); _del(currentModule.modID + '_plainPop'); currentModule.plainPopupDiv = null; } else if (currentModule.plainPopupDiv == null) { clearInterval(currentModule.plainCloseInterval); } ", 500); 
    }
}



Module.prototype.doPopFullView = function(args) {
    this.doView(args, this.redrawPopFullFromXML);   
}

Module.prototype.redrawPopFullFromXML = function () {
    currentModule.fillPopFullWin(currentModule.xmlReq.req.responseText);
}
Module.prototype.fillPopFullWin = function(html) {
	currentModule.fullPopupDiv = createDiv();   
	currentModule.fullPopupDiv.style.display = 'none';
    g.closeLoadingDiv(currentModule);
	
    currentModule.fullPopupDiv.innerHTML = "<div id='newsReaderDiv' style='border:1px solid black;width:780px;height:580px;margin:0 auto;z-index:1'>" + currentModule.evalJS(html) + "</div>";
    currentModule.fullPopupDiv.zIndex=11;
    if (parseInt(document.body.scrollTop == 0)) {
		currentModule.fullPopupDiv.style.top = (parseInt(document.body.scrollTop) + 60 - 0) + "px";
	} else {
		currentModule.fullPopupDiv.style.top = (parseInt(document.body.scrollTop) + 10 - 0) + "px";
	}
    currentModule.fullPopupDiv.style.position = "absolute";
	currentModule.fullPopupDiv.style.textAlign = 'center';		
	currentModule.fullPopupDiv.style.width = '100%';	
	currentModule.fullPopupDiv.id="newsReaderContainer";
	
	
	showHideSelects(false);	
	animateShow(currentModule.fullPopupDiv,false);
	currentModule.fullPopupDiv.style.display = 'block';

}

function reloadPage() {
  window.location.href = window.location.href;
}

//END CORE JS

//BEGIN LAYOUT.JS
/***********************************************
* Disable select-text script- ? Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var isPo = false; //is it a popup div?

//form tags to omit in NS6+:
var omitformtags=["input", "textarea", "select"]

omitformtags="|" + omitformtags.join("|") + "|";

function disableselect(e){
if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)
return false
}

function reEnable(){
return true
}

if (typeof document.onselectstart!="undefined")
document.onselectstart=checkSelect;
else{
document.onmousedown=disableselect
document.onmouseup=reEnable
}

//only selectable elements are elements whose ids begin with 'd_'
function checkSelect() {
	var n = event.srcElement.id;
	var t = event.srcElement.tagName.toLowerCase();
	if(n.indexOf('d_')<0 && omitformtags.indexOf("|" + t + "|") == -1)
		return false;
}
/**
 * BEGIN REAL LAYOUT SCRIPT
 **/

document.onmousemove=movemouse;
 
var x,y;        // original mouse position of drag begin
var tx, ty;     // original left, top position of module at drag begin

var debug = false;
var debug_level1 = true;

var ie          =   document.all;
var nn6         =   document.getElementById&&!document.all;
var isdrag      =   false;
var nw          =   null;       // reference to the copy of the module floating with the mouse
var origModule  =   null;       // another reference to the original module being dragged
var indicator   =   null;       // reference to the indicator module div
// Moved to main.vm to set to true when $context.layoutType == 2Col after refresh or return visit
//var layout_2col = false;      // flag for whether or not in 2 column layout mode
var lastClosest =   null;       // last closest node to the node being dragged
var lastClosestSign = null;     // whether or not the dragged module was above or below the closest module

/**
  * Creates a div element that makes the box
  * to indicate where the module would be dropped
  * if the user let go of mouse
  **/
function createIndicator( height ) {

    indicator = document.createElement("div");
    indicator.id = "indicator";
    indicator.style.width = "100%";
    indicator.style.height = height +"px";
    indicator.style.marginBottom = "20px";
    indicator.style.border = "1px solid #000000";
    indicator.innerHTML = "&nbsp;";
    document.body.appendChild( indicator );
    
    return indicator;
}

function movemouse(e)
{
    setEvents(e);
    if (isdrag) {   // make sure the user has click on a module header
        target = nn6?e.target:event.srcElement;
        evt = nn6?e:event;
        cX = (nn6?evt.pageX:evt.clientX+document.body.scrollLeft);
        cY = (nn6?evt.pageY:evt.clientY+document.body.scrollTop);
        
        // set the floating(dragging) module's position, relative to where the mouse is
        if (isPo) {     
            if(currentModule==null){currentModule=nn6?e.target:event.srcElement;}
            currentModule.popX = nw.style.left = nn6 ? tx + e.pageX - x : tx + cX - x;
            currentModule.popY = nw.style.top  = nn6 ? ty + e.pageY - y : ty + cY - y;
        } else {
            nw.style.left = nn6 ? tx + e.pageX - x : tx + cX - x;
            nw.style.top  = nn6 ? ty + e.pageY - y : ty + cY - y;
        }
    
        // find out what column we are in after this mouse move
        newCol = getNewCol( target, evt );
    
        // retrive the actual node reference to the new column
        myCol = document.getElementById(newCol);
        closestNode = null;
        closestDist = 10000000000;
        
        // if target column has no children, insert indicator
        if (myCol.childNodes.length == 0) {
            myCol.insertBefore( indicator, null );
        } else {
            // loop through each module in the column and find the one that is closest to the 
            // dragged module
            for( var i = 0; i < myCol.childNodes.length; i++ ) {
                dist = Math.sqrt( Math.pow( cX-myCol.childNodes[i].offsetLeft, 2) + Math.pow( cY-myCol.childNodes[i].offsetTop, 2) );
                if( dist < closestDist ) {
                    closestDist = dist;
                    closestNode = myCol.childNodes[i];
                }
            }
            
	    	if ((closestNode.id != '') && (closestNode.id != 'indicator') && (g[closestNode.id + 'Module'].immoveable)) {
				return false;
			}
			
            // now move the indicator node to the appropriate spot in the column
            if (!isPo) {
                if( closestNode != null && origModule.nextSibling != closestNode ) {
                    
                    if( cY > closestNode.offsetTop ) {  // if floating module is above it's closest node
                        // make sure the closest node isn't the same closest node from the last mouse move
                        // if it is the same node, however, see if we've moved from below the closest
                        // node to above the closest node
                        if( closestNode != lastClosest || ( closestNode == lastClosest && lastClosestSign == -1) ) {
                            next = closestNode.nextSibling;
                            if( next ) {
                                next.parentNode.insertBefore( indicator, next );
                            
                            }
                            else {
                                // indicator to be placed at bottom
                                closestNode.parentNode.insertBefore( indicator, null );
                                
                            }
                        }
                        lastClosestSign = 1;
                    } else {
                        // make sure the closest node isn't the same closest node from the last mouse move
                        // if it is the same node, however, see if we've moved from above the closest node
                        // to below the closest node
                        if( closestNode != lastClosest || ( closestNode == lastClosest && lastClosestSign == 1 ) ) {
                            closestNode.parentNode.insertBefore( indicator, closestNode );
                            lastClosestSign = -1;
                            
                        }
                    }
                    lastClosest = closestNode;
                }
            }
        } // END if (myCol.childNodes.length == 0)

    return false;
    }
}

function selectmouse(e) 
{
  evt = nn6?e:event;
  setEvents(evt);
  
  origModule     = nn6 ? e.target : event.srcElement;
  var topelement = nn6 ? "HTML" : "BODY";
  var goodToGo = false;
  lastClosest = null;
  lastClosestSign = 0;
  // make sure we've clicked on the right class of div
  while (origModule.tagName != topelement && (origModule.className != "module" && origModule.className != "moduleEdit") && origModule.className != "modEdit" && origModule.className != "modButton" && origModule.className != "modCloseEdit")
  {
     if( origModule.className == "modTitle" || origModule.className == "modHeaderContents" || origModule.className == "modEdit" || origModule.className == "modCloseEdit" ) goodToGo = true;
    origModule = nn6 ? origModule.parentNode : origModule.parentElement;
  }
  
  // if the event target is a module and the event target is the top node of the module (ie. not modEdit yada yada)
  if ((origModule.className == "module" || origModule.className == "moduleEdit") && goodToGo && origModule.id != "temp" && origModule.id != "tempModule" && origModule.id.indexOf("_popFull") == -1)
  {

    isdrag = true;
	doc = document.onmousedown;
	document.onmousedown = function() { mouseup(); };

    if (!isPo) {
      createIndicator(origModule.offsetHeight);     // create the indicator node
      createCopy( origModule );                     // create a copy of the node to follow the mouse during dragging
      origModule.parentNode.insertBefore( indicator, origModule.nextSibling );
      origModule.parentNode.removeChild( origModule );
    } else {
      nw = origModule;
    }
    
    tx = parseInt(nw.offsetLeft);   // record the original x,y position of the module
    ty = parseInt(nw.offsetTop);
    
    x = nn6 ? e.pageX : event.clientX+document.body.scrollLeft; // record original x position of mouse event
    y = nn6 ? e.pageY : event.clientY+document.body.scrollTop;  // record original y position of mouse event
    
    return false;   // who knows why i put this here. if i were you though, i wouldn't touch it
  }
}

/**
  * creates a copy of the module to follow the mouse around
  * the screen
  **/
function createCopy( obj ) {
    if( !nw ) {
        
        nw = document.createElement("div");
        nw.style.display = "block";
        nw.style.position = "absolute";
        nw.style.cursor = "move";
        nw.style.paddingBottom = "0px";
        nw.style.left = obj.offsetLeft;
        nw.style.top = obj.offsetTop;
        nw.style.height = obj.offsetHeight;
        nw.style.width = obj.offsetWidth;
        nw.innerHTML = '<div class=module>' + obj.innerHTML + '</div>';
        
        document.body.appendChild( nw );

    }
}


/**
  * method to find out where we need to put our original module
  **/
function mouseup(e) {
    target = nn6?e.target:event.srcElement;
    evt = nn6?e:event;
    if( isdrag ) {      // make sure we're actually dragging a module
        isdrag = false;
        goodToGo = false;
        
        if(!isPo) {
            indicator.parentNode.insertBefore( origModule, indicator );
        }
        
        // clean up settings for use with next drag event
        if (!isPo) {
          nw.style.display = "none";
          nw.parentNode.removeChild(nw);
          indicator.style.display = "none";
          indicator.parentNode.removeChild(indicator);
          saveLayout();
        } else {
          isPo = false;
        }
        nw = null;
        origModule = null;
        lastClosest = null;
        lastClosestSign = 0;
		document.onmousedown = doc;
    } else {
        // incase we get here, just hide the copy of some module if it happens to be defined
        if( nw != null ) {
            nw.style.display = "none";
        }
    }
    
}

/**
  * method to find out if the mouse has moved the module into a new column.
  * I think this might need some work to deal with when the addContent pane is open.
  **/
function getNewCol( target, evt ) {
    retVal = null;
    cX = (nn6?evt.pageX:evt.clientX+(layout_2col?-150:0)+document.body.scrollLeft);
    cY = (nn6?evt.pageY:evt.clientY+document.body.scrollTop);
    
    if( cX < (getElem("colB").offsetLeft+getElem('cpnl').offsetWidth) ) { // in column A
        retVal = "colA";
        
        if(debug) document.getElementById("debug").innerHTML += "<br>colA " + target.offsetLeft;
    } else if( (cX >= getElem("colB").offsetLeft && layout_2col) || cX < (document.getElementById("colC").offsetLeft+getElem('cpnl').offsetWidth) ) { // in column b
        retVal = "colB";
        
        if(debug) document.getElementById("debug").innerHTML += "<br>colB " + target.offsetLeft;
    } else if( cX >= getElem("colC").offsetLeft ) { // in column c
        retVal = "colC";
        
        if(debug) document.getElementById("debug").innerHTML += "<br>colC " + target.offsetLeft;
    } 

    return retVal;
}

// this is useful for when the elements directly under colA,colB,colC arent always divs
function getFirstDiv( nArray ) {
    for( var i = 0; i < nArray.length; i++ ) {
        if( nArray[i].nodeName == "DIV" ) return nArray[i];
    
    }
    return null;
}

document.onmousedown=selectmouse;
document.onmouseup=mouseup;

// stuff to manage recording the positions of everything on the page
// this code will be useful when you need to save the module positions to
// the personalization server.
var mods_A = new Array();
var mods_B = new Array();
var mods_C = new Array();
var orig_layout_2col,layout_backed;

var save_mods = new Array();
save_mods['A'] = new Array();
save_mods['B'] = new Array();
save_mods['C'] = new Array();

/**
 *  Call this when the user changes their layout
 *  preference in the addContent panel
 **/
function backupLayout() {
    orig_layout_2col = layout_2col;
    layout_backed = true;
    mods_A = new Array();
    mods_B = new Array();
    mods_C = new Array();
    
    // store column A's modules
    aCol = getElem("colA");
    var dStr = "";
    if( typeof(aCol) != undefined ) {
        aNodes = aCol.childNodes;
        for( i = 0; i < aNodes.length; i++ ) {
            if(aNodes[i].nodeName == "DIV" && ((aNodes[i].className == "module") || (aNodes[i].className=="moduleNoDrag"))) {
                mods_A.push( aNodes[i].id );
            }
        }
    }
    
    // store column B's modules
    bCol = getElem("colB");
    if( typeof(bCol) != undefined ) {
        bNodes = bCol.childNodes;
        for( i = 0; i < bNodes.length; i++ ) {
            if(bNodes[i].nodeName == "DIV" && bNodes[i].className == "module") {
                mods_B.push( bNodes[i].id );
            }
        }
    }
    
    // store column C's modules
    cCol = getElem("colC");
    if( typeof(cCol) != undefined ) {
        cNodes = cCol.childNodes;
        for( i = 0; i < cNodes.length; i++ ) {
            if(cNodes[i].nodeName == "DIV" && cNodes[i].className == "module") {
                mods_C.push( cNodes[i].id );
            }
        }
    }
}

function setUpLayout() {
    save_mods['A'] = new Array();
    save_mods['B'] = new Array();
    save_mods['C'] = new Array();
    
    // store column A's modules
    aCol = getElem("colA");
    var dStr = "";
    if( typeof(aCol) != undefined && aCol) {
        aNodes = aCol.childNodes;
        for( i = 0; i < aNodes.length; i++ ) {
            if(aNodes[i].nodeName == "DIV") {
                save_mods['A'].push( aNodes[i].id );
            }
        }
    }
    
    // store column B's modules
    bCol = getElem("colB");
    if( typeof(bCol) != undefined && bCol) {
        bNodes = bCol.childNodes;
        for( i = 0; i < bNodes.length; i++ ) {
            if(bNodes[i].nodeName == "DIV") {
                save_mods['B'].push( bNodes[i].id );
            }
        }
    }
    
    // store column C's modules
    cCol = getElem("colC");
    if( typeof(cCol) != undefined && cCol) {
        cNodes = cCol.childNodes;
        for( i = 0; i < cNodes.length; i++ ) {
            if(cNodes[i].nodeName == "DIV") {
                save_mods['C'].push( cNodes[i].id );
            }
        }
    }
}

function saveLayout() { 
  setUpLayout(); //this puts the modules into three arrays - one for each col
  var url = 'module.jhtml?ACTION=doEdit&MODID=m0';
 
  

  var a = new Array('A','B','C');
  var b = null;
  var numCols = 0;

  for (var j = 0; j < a.length; j++) {
  	if (typeof(save_mods[a[j]]) != "undefined") {
	    b = save_mods[a[j]];
	    if (b) {
	    	if (b.length > 0)
		    	numCols++;
	      var c = j+1;
	      url+='&COL'+c+'=';
	      for (var i = 0; i < b.length; i++) {
	        url+=(i>0?',':'')+b[i];
	      }
    	}
    }
  }
  if (numCols >= 3) {
  	url += "&NUMCOLS=3";
  } else {
  	url += "&NUMCOLS=2";
  }
  url=url.replace(/indicator,/ig,""); //just in case -- possibly safe to kill
  
/*
  if (typeof(oToolbarController.sPartnerID)!='undefined' && oToolbarController.sPartnerID!=null) url += "&partner=" + oToolbarController.sPartnerID;
  if (typeof(oToolbarController.sUID)!='undefined' && oToolbarController.sUID!=null) url += "&uid=" + oToolbarController.sUID;
  if (typeof(oToolbarController.sVersion)!='undefined' && oToolbarController.sVersion!=null) url += "&version=" + oToolbarController.sVersion;
*/
  currentModule = g.m0Module;
  g.m0Module.xmlReq = new XMLRequest(url, z);
  g.m0Module.xmlReq.getData();
}

function z() { }

function restoreLayout() {
    var ca = getElem('colA');
    var cb = getElem('colB');
    var cc = getElem('colC');
    var colT = getElem('colTable');
    var bcs = document.getElementById('barCSpace');
    var csc = document.getElementById('colCspc');
    
    if( mods_A.length <= 0 & mods_B.length <= 0) return;
    if( orig_layout_2col ) {
        cc.style.display="none";
        ca.style.width="314";
        cb.style.width='400';
        cc.style.width='1';
        cc.style.display='none';
        colT.style.width='736';
        csc.style.width='1';
        csc.style.display='none';
        bcs.width = 1;
        
        _del('barC');
        _del('barA');
        // insert original modules into column A
        for( i = 0; i < mods_A.length; i++ ) {
            ca.insertBefore( getElem( mods_A[i] ), null );
        }
        var colABar = document.createElement("DIV");
        colABar.innerHTML = '<img src="http://ak.imgfarm.com/images/spacer.gif" width="400" height="1" id="barA" border="0" >';
        ca.insertBefore(colABar, null);
        
        _del('barB');
        // insert original modules into column B
        for( i = 0; i < mods_B.length; i++ ) {
            cb.insertBefore( getElem( mods_B[i] ), null );
        }
        var colBBar = document.createElement("DIV");
        colBBar.innerHTML = '<img src="http://ak.imgfarm.com/images/spacer.gif" width="314" height="1" id="barB" border="0" >';
        cb.insertBefore(colBBar, null);
        
        layout_2col = true;
    
    } else {
        cc.style.display = "block";
        ca.style.width='33%';
        cb.style.width='33%';
        cc.style.width='33%';
        bcs.width=20;
        cc.style.display='inline';
        csc.style.display='inline';
        colT.style.width='90%';
        
        _del('barA');
        // insert original modules into column A
        for( i = 0; i < mods_A.length; i++ ) {
            ca.insertBefore( getElem( mods_A[i] ), null );
        }
        var colABar = document.createElement("DIV");
        colABar.innerHTML = '<img src="http://ak.imgfarm.com/images/spacer.gif" width="300" height="1" id="barA" border="0" >';
        //colABar.innerHTML = 
        ca.insertBefore(colABar, null);
        
        
        _del('barB');
        // insert original modules into column B
        //colBBar.innerHTML = 
        for( i = 0; i < mods_B.length; i++ ) {
            cb.insertBefore( getElem( mods_B[i] ), null );
        }
        var colBBar = document.createElement("DIV");
        colBBar.innerHTML = '<img src="http://ak.imgfarm.com/images/spacer.gif" width="300" height="1" id="barB" border="0" >';
        cb.insertBefore(colBBar, null);
        
        
        // insert original modules into column C
        for( i = 0; i < mods_C.length; i++ ) {
            cc.insertBefore( getElem( mods_C[i] ), null );
        }
        var colBBar = document.createElement("DIV");
        colABar.innerHTML = '<img src="http://ak.imgfarm.com/images/spacer.gif" width="300" height="1" id="barC" border="0" >';
       // colCBar.innerHTML = 
        cc.insertBefore(colCBar, null)
        
        layout_2col = false;
    }
}
/**
 *  Call this when the addContent window is closed
 *  or cancel is hit
 **/
function clearBackup() {
    layout_backed = false;
    mods_A = new Array();
    mods_B = new Array();
    mods_C = new Array();
}

function twocols() {
  getElem('header').style.width='738px';
  secondaryHeader = getElem('headerSecondary');
  if (secondaryHeader != null) {
  	secondaryHeader.style.width='738px';
  }
  getElem('headerSearch').style.width='738px';
  getElem('page').style.width='738px';
    if(layout_backed && orig_layout_2col ) {
        restoreLayout();
    } else {
        backupLayout();
        layout_2col = true;
        _del('barB');
        _del('barC');
        var ca = document.getElementById('colA');
        var cb = document.getElementById('colB');
        var cc = document.getElementById('colC');
        var ba = document.getElementById('barA');
        var csc = document.getElementById('colCspc');
        var bcs = document.getElementById('barCSpace');
        cb.innerHTML += cc.innerHTML;
        var colBBar = document.createElement("DIV");
        colBBar.innerHTML = '<img src="http://ak.imgfarm.com/images/spacer.gif" width="314 height="1" id="barB" border="0">';
        cb.insertBefore(colBBar, null);
        cc.innerHTML = "";
        cc.style.display="none";
        ba.width=400;
        var bb = document.getElementById('barB');
        bb.width=314;
        ca.style.width="400";
        cb.style.width='314';
        csc.style.width='1';
        cc.style.width='1';
        csc.style.width = '1';
        bcs.width = 1;
        cc.style.display='none';
        csc.style.display = 'none';
    }
    saveLayout();
	//now resize all modules in column A
	for (var i = 0; i < mods_A.length; i++) {
		getElem(mods_A[i]).style.width='400px';
	}
	clearBackup();
}


function threecols() {
  getElem('header').style.width='90%';
  secondaryHeader = getElem('headerSecondary');
  if (secondaryHeader != null) {
  	secondaryHeader.style.width='90%';
  }
  getElem('headerSearch').style.width='90%';
  getElem('page').style.width='100%';
    if( layout_backed && !orig_layout_2col ) {
        restoreLayout();
        clearBackup();
    } else {
        backupLayout();
        layout_2col = false;
        var ba = document.getElementById('barA');
        var bb = document.getElementById('barB');
        var ca = document.getElementById('colA');
        var cb = document.getElementById('colB');
        var cc = document.getElementById('colC');
        var csc = document.getElementById('colCspc');
        var colT = document.getElementById('colTable');
        var bcs = document.getElementById('barCSpace');
        //_del('barB');
        // Move last module in col B to col C
        // Need to upgrade this to handle special cases (0 or 1 module in col B, etc.)
        var tempArr = mods_B;
        cc.appendChild(getElem(tempArr[tempArr.length-1]));
        var colCBar = document.createElement("DIV");
        colCBar.innerHTML = '<img src="http://ak.imgfarm.com/images/spacer.gif" width="300" height="1" id="barC" border="0" >'
        cc.appendChild(colCBar);
        colCBar.style.display='block';
        ba.width=300;
        bb.width=300;
        csc.style.width='20';
        bcs.width=20;
        ca.style.width='33%';
        cb.style.width='33%';
        cc.style.width='33%';
        colT.style.width='90%';
        if (isIE) {
        cc.style.display='inline';
        csc.style.display = 'inline';
        } else {
        cc.style.display='table-cell';
        csc.style.display = 'table-cell';
        }
    }
    saveLayout();
}
//END LAYOUT.JS

document.onclick = setEvents;


function getElem(a){return document.getElementById?document.getElementById(a):null}
function getElemTag(a){return document.getElementsByTagName?document.getElementsByTagName(a):new Array()}

function trim(a){return a.replace(/^\s*|\s*$/g,"")}
function fEscape(a){return window.encodeURIComponent?encodeURIComponent(a):escape(a)}
function fEscapeTag(a){return a.replace(/</g,"&lt;").replace(/>/g,"&gt;")}


function showEdit(a) {
    if(!isdrag && (typeof(getElem("edit_"+a).childNodes[childInt]) != 'undefined')) getElem("edit_"+a).childNodes[childInt].style.display = "inline";
}
function hideEdit(a) {
    if(!isdrag && (typeof(getElem("edit_"+a).childNodes[childInt]) != 'undefined')) getElem("edit_"+a).childNodes[childInt].style.display = "none";
}

function openWin(url) {
    var features="";
    window.open(url, "_blank", features);
}

function pageViewPixel() {
    setUpLayout(); //This defines: save_mods_A, save_mods_B and save_mods_C arrays

    var pixelURL = "http://t.myway.com/images/nocache/nc/pw.gif";

    var a = new Array('A','B','C');
    var b = null;

    pixelURL+="?l=";
    for (var j = 0; j < a.length; j++) {
    	if (typeof(save_mods[a[j]]) != "undefined") {
       	   b = save_mods[a[j]];
     	   if (b) {
        	    var c = j+1;
    	        pixelURL+='COL'+c+':';
	            for (var i = 0; i < b.length; i++) {
				  if (g.modules[b[i]])
    	            pixelURL+=(i>0?',':'')+g.modules[b[i]].compID;
	            }
	        }
        }
        pixelURL+=(j<a.length-1?'|':'');
    }
    
    document.write('<img src="'+pixelURL+'" width="1" height="1" alt="" border="0" />');
}

function trackClick(action, val, compID, modID,kw) {
    var url = "http://t.myway.com/images/nocache/nc/c.gif?a="+action;
    if(val){ url+="&v="+val; }
    if(compID){ url+="&c="+compID; }
    if(modID){ url+="&m="+modID; }
    if(kw){ url+="&k="+kw; }
    
    /*
    if (typeof(oToolbarController.sPartnerID)!='undefined' && oToolbarController.sPartnerID!=null) { url+="&b="+oToolbarController.sPartnerID; }
    */
    var tempIMG = new Image();
    tempIMG.src=url;
}


function getNumModules(){
    var numMods = 0;
    var divList = document.getElementsByTagName("div");
    for(i=0;i<divList.length;i++){
        if(divList[i].className=='module' && divList[i].id != 'tempModule'){
            numMods++
        }
    }
    return numMods;
}

function setPosOnScreen(obj,xOff,yOff){ 
    var n,w,cWidth,cHeight,quad,sTop,objLeft,objTop,objWidth,objHeight,newTopTall,newTopShort;

    sTop = document.body.scrollTop;
    
    if(document.all){
        cWidth=document.body.clientWidth;
        cHeight=document.body.clientHeight;
    }else{
        cWidth=window.innerWidth;
        cHeight=window.innerHeight;
    }   

    objLeft = obj.offsetLeft;
    objTop = obj.offsetTop;
    objWidth = obj.offsetWidth;
    objHeight = obj.offsetHeight;
    
    w = cWidth/2;
    n = cHeight/2;
    
    //figure out where it launched
    if (mouseY < n) {
        if (mouseX < w) {
            quad=1;
        } else {
            quad=2;
        }   
    } else {
        if (mouseX < w) {
            quad=3;
        } else {
            quad=4;
        }       
    }
    
    newTopShort = mouseY-objHeight;
    newTopTall = objTop-(cHeight-(cHeight-mouseY))+sTop;
    newLeftShort = objLeft-objWidth;
    newLeftWide = objLeft-mouseX;
    
    switch(quad) {
        case 1:
            if ((mouseY+objHeight) > cHeight) 
                obj.style.top = currentModule.origpopY = newTopTall;
            if (mouseX+objWidth > cWidth)
                obj.style.left = currentModule.origpopX = newLeftWide;
            break;
        case 2:
            obj.style.left = currentModule.origpopX = newLeftShort;
            if ((mouseY+objHeight) > cHeight) 
                obj.style.top = currentModule.origpopY = newTopTall;
            break;
        case 3:
            if ((mouseY-objHeight) > sTop)
                obj.style.top = currentModule.origpopY = newTopShort;
            else 
                obj.style.top = currentModule.origpopY = newTopTall;
            if (mouseX+objWidth > cWidth)
                obj.style.left = currentModule.origpopX = newLeftWide;
            break;
        case 4:
            obj.style.left = currentModule.origpopX = newLeftShort;
            if ((mouseY-objHeight) > sTop)
                obj.style.top = currentModule.origpopY = newTopShort;
            else 
                obj.style.top = currentModule.origpopY = newTopTall;
            break;
    }
}


var sSearchAJ = "AJ";
var sSearchGG = "GG";
var sSearchAW = "AW";


// Start search type/provider code
var globProv = sSearchAJ;
var globSearchType = "web";

function changeSrchType(radbttn, prov) {
    var formAction = "http://search.mywebsearch.com/mywebsearch/" + prov;
    if (radbttn.value == "w") {
        formAction += "main.jhtml";
        globSearchType = "web";
    } else if (radbttn.value == "i") {
        formAction += "image.jhtml";
        globSearchType = "images";
    } else if (radbttn.value == "n") {
        if (prov == "AW") {
            formAction += "nws.jhtml";
        } else {
            formAction += "news.jhtml";
        }
        globSearchType = "news";
    }
    document.smileytoday.action = formAction;
}

function changeSrchProv(prov) {
    document[globProv].src = eval(globProv + "_default.src");
    globProv = prov;
    document[globProv].src = eval(globProv + "_on.src");
    document.smileytoday.type[0].checked = true;
    globSearchType = "web";
    var formAction = "http://search.mywebsearch.com/mywebsearch/" + globProv + "main.jhtml";
    
    if ((globProv == "AJ") || (globProv == "AW")) {
        document.getElementById("iRadCell").style.display = "";
        document.getElementById("iTxtCell").style.display = "";
        document.getElementById("nRadCell").style.display = "";
        document.getElementById("nTxtCell").style.display = "";
    } else if (globProv == "GG") {
        document.getElementById("iRadCell").style.display = "";
        document.getElementById("iTxtCell").style.display = "";
        document.getElementById("nRadCell").style.display = "none";
        document.getElementById("nTxtCell").style.display = "none";
    }
    
    document.smileytoday.action = formAction;
}

// Search
var gp="AJ";

function toggleST(dd,p){
    var fa="http://search.myway.com/search/"+p;
    var dv=dd.options[dd.selectedIndex].value;
    if(dv=="w"){
        fa+="main.jhtml";
    }else if(dv=="i"){
        fa+="image.jhtml";
    }else if(dv=="n"){
        if(p=="AW"){
            fa+="nws.jhtml";
        }else{
            fa+="news.jhtml";
        }
    }else if(dv=="d"){
        fa+="dirs.jhtml";
    }else if(dv=="v"){
        fa+="vid.jhtml";
    }else if(dv=="a"){
        fa+="aud.jhtml";
    }
    document.topSearchForm.action=fa;
}

function toggleSP(rb){
    var rv=rb.value;
    var fa="http://search.myway.com/search/"+rv+"main.jhtml";
    gp=rv;
    setDD(gp);
    document.topSearchForm.action=fa;
}

function setDD(p){
    gp=p;
    dd=document.topSearchForm.stype;
    if(dd[1]!=null)dd[1]=null;
    if(dd[1]!=null)dd[1]=null;
    if(dd[1]!=null)dd[1]=null;
    if(dd[1]!=null)dd[1]=null;  
    if(p=="AJ"){
        dd[dd.length]=new Option("Images","i");
        dd[dd.length]=new Option("News","n");
    }else if(p=="GG"){
        dd[dd.length]=new Option("Images","i");
        dd[dd.length]=new Option("Directory","d");
    }else if(p=="AW"){
        dd[dd.length]=new Option("Images","i");
        dd[dd.length]=new Option("News","n");
        dd[dd.length]=new Option("Video","v");
        dd[dd.length]=new Option("Audio","a");
    }
    dd[0].selected=true;
}

function doSearch(searchType,provider){	
    var fa="http://search.myway.com/search/"+provider;
    var trackType = ""
    if(searchType=="w"){
        fa+="main.jhtml";
        trackType="web";
    }else if(searchType=="i"){
        fa+="image.jhtml";
        trackType="image";
    }else if(searchType=="n"){
        if(p=="AW"){
            fa+="nws.jhtml";
        }else{
            fa+="news.jhtml";
        }
        trackType="news";
    }else if(searchType=="d"){
        fa+="dirs.jhtml";
        trackType="dir";
    }else if(searchType=="v"){
        fa+="vid.jhtml";
        trackType="video";
    }else if(searchType=="a"){
        fa+="aud.jhtml";
        trackType="audio";
    }
    document.topSearchForm.action=fa;
	
    var srchForm=document.topSearchForm;
    var srchStr=srchForm.searchfor.value;
    var href=srchForm.action+"?searchfor="+escape(srchStr);
    
    var trackUrl = "http://t.myway.com/images/nocache/nc/c.gif?a=search";
    trackUrl += "&p=" + provider;
    trackUrl += "&t=" + trackType;
    trackUrl += "&k=" + escape(srchStr);

    var tempIMG = new Image();
    tempIMG.src=trackUrl;
    
    location.href=href;
}

function searchSomeone(prov) {
    document.getElementById('searchAJ').src = searchOff['AJ'];
    document.getElementById('searchGG').src = searchOff['GG'];
    document.getElementById('searchAW').src = searchOff['AW'];
	
	document.getElementById('search' + prov).src = searchOn[prov];
    var fa="http://search.myway.com/search/" + prov + "main.jhtml"; 
    document.topSearchForm.action=fa;
	globCurrentProv=prov;
	if (prov == 'AJ') {
		if (document.getElementById('searchImage') != null ) {
			document.getElementById('searchImage').src = 'http://ak.imgfarm.com/bz/home/eden/compSearch/websearchAsk.gif';
		}
		if (document.getElementById('PoweredBy') != null ) {
	    	document.getElementById('PoweredBy').src = imgPoweredBy;
	    }
	} else if (prov == 'GG') {
		if (document.getElementById('searchImage') != null ) {
			document.getElementById('searchImage').src = 'http://ak.imgfarm.com/bz/home/eden/compSearch/websearchGoogle.gif';
		}
		if (document.getElementById('PoweredBy') != null ) {
	    	document.getElementById('PoweredBy').src = "http://ak.imgfarm.com/images/spacer.gif";
	    }
	} else if (prov == 'AW') {
		if (document.getElementById('searchImage') != null ) {
			document.getElementById('searchImage').src = 'http://ak.imgfarm.com/bz/home/eden/compSearch/websearchYahoo.gif';
		}
		if (document.getElementById('PoweredBy') != null ) {
	    	document.getElementById('PoweredBy').src = "http://ak.imgfarm.com/images/spacer.gif";
	    }
	}
	hideSearchType();
}

function searchAsk() {
    searchSomeone('AJ');
}
function searchGoogle() {
    searchSomeone('GG');
}
function searchYahoo() {
    searchSomeone('AW');
}
function hideSearchType(){
		document.getElementById('showSearchMod').style.zIndex = '0';
		document.getElementById('dvSelectSearchTypeAJ').style.display = 'none';
		document.getElementById('dvSelectSearchTypeGG').style.display = 'none';
		document.getElementById('dvSelectSearchTypeAW').style.display = 'none';
}


var currentModule;

// XML Request object
//  - URL :  URL to request
//  - Callback : Function to call when complete
function XMLRequest(url, callback, async) {
    this.req;
    this.url = url;
    this.callback = callback;
	this.async = false;
	if (async)
		this.async = async;
}
XMLRequest.prototype.checkStatus = function() {
    if (currentModule.xmlReq.req.readyState == 4 && currentModule.xmlReq.req.status == 200) {
        currentModule.xmlReq.callback();
    } else if (currentModule.xmlReq.req.readyState == 4) {
    	g.closeLoadingDiv(currentModule);
    	currentModule.doError();
    }
}

// Perform the HTTP Request
XMLRequest.prototype.getData = function() {
    if (window.XMLHttpRequest) {
        this.req = new XMLHttpRequest();
        this.req.onreadystatechange = this.checkStatus;
        this.req.open("POST", this.url, true);
        this.req.send(null);
    } else if (window.ActiveXObject) {
        this.req = new ActiveXObject("Microsoft.XMLHTTP");
        if (this.req) {
            this.req.onreadystatechange = this.checkStatus;
            this.req.open("POST", this.url, this.async);
            this.req.send('');
        }
    }
}



//JS FROM MAIN BELOW SCRIPT SRC INCLUDES
var mouseX;
var mouseY;
function setEvents(e) {
    evt = nn6?e:event;
    mouseX = (nn6?evt.pageX:evt.clientX+document.body.scrollLeft);
    mouseY = (nn6?evt.pageY:evt.clientY+document.body.scrollTop);
}
//delete a div
// If it's a module div, record it via layout change AJAX call and pixel request
function _del(a) {
    if(a!='$MODID'){       
    	if (getElem(a) != null) { 
	        var className = getElem(a).className;
	        try{var b = getElem(a).parentNode.removeChild(getElem(a));}catch(e){}
	        if (a.indexOf('pop')==-1 && a.indexOf('Pop')==-1 && a.indexOf('Loading')==-1 && className == 'module'){
	            if(g.modules[a]){
	           	  var url = 'module.jhtml?ACTION=doEdit&MODID=m0&DELMOD=' + a;
	               
	                var imgurl = "http://t.myway.com/images/nocache/nc/mod.gif?a=delete_module&c="+g.modules[a].compID+"&m="+a;
	                var tempIMG = new Image();
	                tempIMG.src=imgurl;
                
					   currentModule = g.m0Module;
					  g.m0Module.xmlReq = new XMLRequest(url, z, true);
					  g.m0Module.xmlReq.getData();
	            }

    	        saveLayout();

        	}else{
	            isPo = false;
	        }
        
    	    //display no mod module
	        if(getNumModules()==0 && className == 'module'){
	            previewCompID='NOMOD';
	            addPreview();
    	    }
		}
    }
}
//minimize
function _min(a) {
    if(('body_' + a) != 'body_$MODID') {
        if (getElem('body_' + a).style.display != 'none') {
            getElem('body_' + a).style.display = "none";
            getElem('body_footer_' + a + '_spacer').style.display = "none";
            getElem('min_' + a).style.display = "none";
            getElem('max_' + a).style.display = "inline";
            //alert("calling " + "g."+a+"Module.minMax(1);");
            eval("g."+a+"Module.minMax(0);");
        } else {
            getElem('body_' + a).style.display = "block";
            getElem('body_footer_' + a + '_spacer').style.display = "inline";
            getElem('min_' + a).style.display = "inline";
            getElem('max_' + a).style.display = "none";
            //alert("calling " + "g."+a+"Module.minMax(0);");
            eval("g."+a+"Module.minMax(1);");
        }
        //save settings change here
    }
    //saveLayout();
}

var tpFlag=true;//flag to expand or collapse theme chooser
function _tp(flag, whichTab){
    var ac=document.getElementById('cpnl');
    sW=225;
    if (flag == null) {
        flag = tpFlag;
    }
    ac.style.display='block';
    if (whichTab != null) {
        togglePickerTabs(whichTab)
    }
    if(ac.offsetWidth==1){
        scrollOut(ac,sW);
        if (whichTab == 'content') {
		    if (g.mpModule != null) {
	    		g.mpModule.doView();
		    }
		}
    }else if (flag==false){
        if(typeof(confirmCC)=='function'){
            confirmCC();//confirm users' color changes
        }
        ac.style.overflow = 'hidden';
        scrollIn(ac,sW);
    }
}
function scrollOut(sObj,sW){
    cw=sObj.offsetWidth;
    if(cw<sW){
        sObj.style.width=cw+25;
        clInt=setTimeout(function(){scrollOut(sObj,sW)},25);
    } else {
		sObj.style.overflow = 'visible';
	}
}
function scrollIn(sObj,sW){
    cw=sObj.offsetWidth;
    if(cw>2){
        sObj.style.width=cw-25;
        clInt=setTimeout(function(){scrollIn(sObj,sW)},25);
    }else{  
        sObj.style.width='1px';
    	sObj.style.display='none';
    }
}
function toggleMenus(b) {
    if (b) {
        for (j=1;j<=numMenus;j++) {
            if (dropped[j] == 0) dropMenu(j,'arrow'+j,'chgl'+j);
        }
    } else {
        for (j=1;j<=numMenus;j++) {
            if (dropped[j] == 1) dropMenu(j,'arrow'+j,'chgl'+j);
        }
    }
}
//NEXT SCRIPT BLOCK

g.m0Module = g.addModule('m0', 'PAGE'); 

//END JS FROM MAIN BELOW SCRIPT SRC INCLUDES




Universe.prototype.fullPop = function(sHTML,sHeader) {
	var POP_ID='dvBigPopCont';
	var cont;
	if(document.getElementById(POP_ID)==null){
		cont = document.createElement("DIV");
	   	document.body.appendChild(cont);
		cont.style.width = "100%";
	   	cont.id = POP_ID;
	   	cont.zIndex = "10";
		cont.style.position = "absolute";
		cont.style.left = "3%";	
		cont.style.padding = "5px";
		//cont.style.textAlign = "center";
	}else{
		cont=document.getElementById(POP_ID);
		cont.style.display='block';
	}
	cont.style.top = (parseInt(document.body.scrollTop) + 60 - 0) + "px";
	var closeNewHTML='<img class="greyx" src="'+imgPath+'/btn_close_small.gif" alt="Close" />';
	var popHTML='<div class="dvLargePopCont">'+
		'<table class="tblLargePopHeader"';	
	if(document.all)popHTML+=' style="width:105%;"';//dont know why but it works
	popHTML+='><tr>'+
				'<td class="dvLargePopHeader">&nbsp;'+sHeader+'</td>'+
				//'<td style="text-align:right;" onclick="hideEle(this.parentNode.parentNode.parentNode.parentNode);" >'+closeNewHTML+' &nbsp;</td>'+
				'<td style="text-align:right;" onclick="showHideSelects(true);_del(\''+POP_ID+'\');" >'+closeNewHTML+' &nbsp;</td>'+
			'</tr>'+
		'</table>'+
		sHTML+
	'</div>';	
	cont.innerHTML=popHTML;

	
	showHideSelects(false);	
	animateShow(cont,false)

}


var aniInt;
function animateShow(ele,started){
    //init - call only first time for each element
    if(!started){
        anInt=null;
        ele.style.overflow='hidden';
        ele.style.height='1px';
        ele.style.display='block';
        if(ele.firstChild.nodeType==1){
            eleHeight=ele.firstChild.offsetHeight;
        }else{
            eleHeight=ele.firstChild.nextSibling.offsetHeight;
        }
    }
    try{
        if(ele.offsetHeight>eleHeight){
            ele.style.overflow='visible';
            anInt=null;
        }else{              
            ele.style.height=ele.offsetHeight+30;
            aniInt=setTimeout(function(){animateShow(ele,true)},8);        
        }
    }catch(ex){}
}
function animateHide(ele,started){
    //init - call only first time for each element
    if(!started){           
        anInt=null;
        ele.style.overflow='hidden';
        movingEle=ele;
    }
    try{
        if(ele.offsetHeight<15){
            ele.style.display='none';
            ele.style.overflow='visible';
            anInt=null;
        }else{
            ele.style.height=ele.offsetHeight-10;
            aniInt=setTimeout(function(){animateHide(ele,true)},10);
        }
    }catch(ex){}  //if an error is thrown the div is already in motion
}

function toggleAddContent(){
    var POP_ID='dvBigPopCont';
    var oPDiv=document.getElementById(POP_ID);
    if(oPDiv==null){
        showAddContent();
        showHideSelects(0);
    }else if(oPDiv.offsetHeight>0){
        animateHide(oPDiv);
        showHideSelects(1);
    }else{
        showAddContent();
        showHideSelects(0);
    }
}






var imgPath = 'http://ak.imgfarm.com/images/fwp/smileytoday/';

var previewCompID;
var closeHTML='<div style="text-align:right;padding-bottom:8px;padding-top:4px;padding-right:1px;"><img class="greyx"  src="'+imgPath+'/btn_close_small.gif" alt="Close" onclick="hideEle(this.parentNode.parentNode);" /></div>';
var initialArgs = "";
function addModule(compID, args) {
	if (isLoggedIn!="true") {
		if(getNumModules()<=20 ){
	        createAddToPreview(closeHTML+'<div style="background-color:#fff;border:1px solid #E0DFE3;text-align:center;"><br/><br/><span class="stTip">Loading...</span><br/><img src="http://ak.imgfarm.com/images/funwebproducts/whiptones/progress_anim_01.gif" /><br/><br/></div>');
	        previewCompID=compID;
	        g.tempModuleModule = new Module('tempModule',compID,'',true);
	        if (args == null || args == "") args = "";
	        else args = "," + args ;
	        initialArgs = args;
	        g.tempModuleModule.getState('doView','isNew,true,preview,true'+args,addModuleCB, "preview");
		}else{ //show reg popup
			addToHTML=closeHTML+getRegHTML('tmm');
			createAddToPreview(addToHTML);	
		}
	} else {
		createAddToPreview(closeHTML+'<div style="background-color:#fff;border:1px solid #E0DFE3;text-align:center;"><br/><br/><span class="stTip">Loading...</span><br/><img src="http://ak.imgfarm.com/images/funwebproducts/whiptones/progress_anim_01.gif" /><br/><br/></div>');
        previewCompID=compID;
        g.tempModuleModule = new Module('tempModule',compID,'',true);
        if (args == null || args == "") args = "";
        else args = "," + args ;
        initialArgs = args;
        g.tempModuleModule.getState('doView','isNew,true,preview,true'+args,addModuleCB, "preview");
	}
}
function addModuleCB(){
	var previewX, previewY;
	if (currentModule.loadingDiv != null) {
		previewX = currentModule.loadingDiv.style.left;
		previewY = currentModule.loadingDiv.style.top;
	}
	g.closeLoadingDiv(currentModule);
    if(currentModule.xmlReq.req.responseText.length!=0){
        addToHTML="<table style='width:100%;'><tr><td>&nbsp;</td><td style='text-align:center;' onclick='addPreview();' >&nbsp;<img class='greyx'  src='"+imgPath+"/addTo.gif' /> <span class='addTo' style='position:relative;top:-3px;'>Add to my page</span></td><td style='text-align:right;'><img class='greyx'  src='"+imgPath+"/btn_close_small.gif' alt='Close' onclick='hideEle(this.parentNode.parentNode.parentNode.parentNode.parentNode);' /></td></tr></table>";
        addToHTML+=currentModule.xmlReq.req.responseText;
        createAddToPreview(addToHTML);
        currentModule.evalJS(currentModule.xmlReq.req.responseText);
    }else{
        msg='There was an error loading this module';
        addToHTML=closeHTML+'<div style="background-color:#fff;border:1px solid #E0DFE3;padding:10px;">'+msg+'</div>';
        createAddToPreview(addToHTML);  
    }
}

function createAddToPreview(html, x, y){
    if(html.length < 1){ 
        return false;
    }
    if(document.getElementById('previewCol')){
        cont = document.getElementById('previewCol');
    }else{
        cont = document.createElement("DIV");
        document.body.appendChild(cont);
        cont.style.width = "320px";
        cont.style.padding = "6px";
        cont.style.border = "1px solid #AAA";
        cont.style.backgroundColor = "#F2F2F2";
        cont.id = "previewCol";
        cont.zIndex = "10";
        cont.style.position = "absolute";
    }
    cont.innerHTML = html;
    if (x != null && y != null) {
	    cont.style.left = x;
	    cont.style.top = y;
    } else {
	    cont.style.left = mouseX;
	    cont.style.top = mouseY;
	}
    cont.style.display = "block";
}
function addWOPreview(sCompID){
    previewCompID=sCompID;
    addPreview();
}
function addPreview(){
    g.tempModuleModule.addToPage(addPreviewCB, initialArgs); 
	initialArgs = "";

}

function waitForContent(){
    if(currentModule.xmlReq.req.readyState != 4){
    setTimeout("waitForContent();",100);
    }else{
    currentModule.evalJS(currentModule.xmlReq.req.responseText);
    }
}

function addPreviewCB(){
    //2vs3 cols 
    g.closeLoadingDiv(currentModule);
    var cc = document.getElementById('colC');
    var addTo = document.getElementById('colB');
    if(cc.offsetWidth==0 || cc.style.display=='none'){      
        addTo = document.getElementById('colB');
    }
    
    addTo.innerHTML=currentModule.xmlReq.req.responseText+addTo.innerHTML;  
    
    //hide no modules mod
    if(g.isNoMod){
        _del(g.noModId);
        g.isNoMod=false;
    }
    waitForContent();

    //hide preview if exists
    try{
        hideEle(document.getElementById('previewCol'));
        document.getElementById('previewCol').innerHTML=''; 
    }catch(e){}
    
    var url = "http://t.myway.com/images/nocache/nc/mod.gif?a=add_module&c="+currentModule.compID;
    var tempIMG = new Image();
    tempIMG.src=url;
    
    //This was used when the module picker was in the popup
    //hideEle(document.getElementById('dvBigPopCont'));
}
function hideEle(obj){ obj.style.display='none'; }
function showHideSelects(arg){
    if(document.all){
        var sVis = arg?'visible':'hidden';
        arrSelects = document.getElementsByTagName('select');
        for(i=0;i<arrSelects.length;i++){
            arrSelects[i].style.visibility=sVis;        
        }
    }
}

// Cookie logic start
var cookTimestamp = "Wed, 29 Dec 2010 23:23:59 GMT";
var globProvRadBtn = "";
var globLangPref = "";

function saveCustInfo(modid) {
    var custForm = document.customizeForm;
    var selectedProv = "";
    var selectedLang = "";
    for (i=0; i<custForm.searchProv.length; i++) {
        if (custForm.searchProv[i].checked) {
            selectedProv = custForm.searchProv[i].value;
        }
    }

    selectedLang = custForm.languageChooser.options[custForm.languageChooser.selectedIndex].value;

    g.modules[modid].doView('searchProv,'+selectedProv+',searchLang,'+selectedLang);
}

function setCookie (n,v,h,p,d,s){
    if(h){
        if ((typeof(h)=='string')&&Date.parse(h)){
            var hN=h;
        }else if(typeof(h)=='number'){
            var hN=(new Date((new Date()).getTime()+h*3600000)).toGMTString();
        }
    }
document.cookie=n+'='+escape(v)+((hN)?(';expires='+hN):'')+((p)?';path='+p:'')+((d)?';domain='+d:'')+((s&&(s==true))?';secure':'');
}

function readCookie(n) {
    n+="=";
    if(document.cookie==''){
        return false;
    }else{
        var a,z;
        var c=document.cookie;
        a=c.indexOf(n);
        var i=c.indexOf(n);
        var j=c.substring(i-1,i);
        if (j!=""&&j!=" "){
            n=' '+n;
            a=c.indexOf(n);
        }
        if(a!=-1) {
        if(a!=-1)a+=n.length;
            z=c.indexOf(';',a);
        if(z==-1)z=c.length;
            return unescape(c.substring(a,z));
        }else{
            return false;
        }
    }
}

function newCookieParse2(sChip,sCookVal){
	var c = new RegExp("(?:\\&|^)"+sChip+"=(?:\\w|\\.)+(\\&|$)");
	var tmp = sCookVal;
	var b = 0;
	if ((tmp != null) && (tmp != "")) {	
		var rtmp = c.exec(tmp);
		if ((rtmp != null) && (typeof rtmp.length == 'number')){
			b = rtmp[0];
			if(b.indexOf("&")==0){//remove first &
				b=b.substring(1,(b.length));
			}
			if(b.indexOf("&")!=-1){//remove &
				b=b.substring(0, (b.length-1));
			}
			b=b.substring(sChip.length+1);
		}
	}
	return b;
}

function newCookieParse(k,kvS){
if(!kvS||kvS.length==0) return '';
var kS=k+'=';
var kvL=kvS.length;
var kSI=0;
var v='';
while(kSI<kvL){
var i=kSI+kS.length;
if (kvS.substring(kSI,i)==kS){
var x=kvS.indexOf('&',i);
if(x==-1)x=kvL;
v=kvS.substring(i,x);
return v;
}
kSI=kvS.indexOf('&',kSI)+1;
if(kSI==0)kSI=kvL;
}
return '';
}
var acceptsCookies=false;
if(document.cookie==''){
document.cookie='acceptsCookies=yes';
if(document.cookie.indexOf('acceptsCookies=yes')!=-1)acceptsCookies=true;
}else{
acceptsCookies=true;
}

function killCookie(n,p,d){
var v=readCookie(n);
if(v) document.cookie=n+'='+v+';expires=Fri,13-Apr-1970 00:00:00 GMT'+((p)?';path='+p:'')+((d)?';domain='+d:'');
}
function sharedCookieExists(c, cc) {
return ((cc.indexOf(c + "=") == 0) || (cc.indexOf("&" + c + "=") > 0))
}
function updateCookieShared (n,c,v){
var cS=readCookie(n);
var cSc=c+"="+v+"&";
if (readCookie(n)==""){
var cSn=cSc;
}else{
var tries = 0;
while (sharedCookieExists(c,cS) && tries++ < 100) {
var thisChip=c+"="+newCookieParse(c,cS)+"&";
cS=cS.replace(thisChip,'');
}
var cSn=cS+cSc;
}
if(n=='PC' || n=='search')var e='Wed, 29 Dec 2010 23:23:59 GMT';
else var e='';
setCookie(n,cSn,e,'/',document.domain.substring(document.domain.indexOf(".")));
}
function deleteCookieShared (n,c){
var cS=readCookie(n);
var cSc=newCookieParse(c,readCookie(n));
if (cS!=""||cS!="false"){
if(cSc!=""&&cSc!="undefined"&&cSc!=null){
var thisChip=c+"="+cSc+"&";
cSn=cS.replace(thisChip,"");
if(cSn=="") var cSn="foo&";
setCookie(n,cSn,'Wed, 29 Dec 2010 23:23:59 GMT','/',document.domain.substring(document.domain.indexOf(".")));
}
}
}
var CookieSearch=readCookie('search');
function readCookieSearch (c){
return (newCookieParse(c,CookieSearch));
}
function updateCookieSearch (c,v){
updateCookieShared('search',c,v);
}
function deleteCookieSearch(c){
deleteCookieShared('search',c);
}

function setLangCookie() {
	//Store language preference
	var storeLang = document.forms['customizeForm'].languageChooser[document.forms['customizeForm'].languageChooser.selectedIndex].value;
	updateCookieSearch("l",storeLang.toLowerCase());
}

// Cookie logic end

// Validate URL
function validateUrl(sUrl){ 
    var r = new RegExp("[A-Za-z0-9-]+\.[A-Za-z0-9]+"); 
    if(r.test(sUrl)){ 
         return true; 
    }else{ 
         return false; 
    } 
}

//stuff for plusminus
g.plusMinusList = '';
g.plusMinusMod = '';
function showhidePlusMinus(mod) {
	if (g.plusMinusMod != mod && g.plusMinusMod != '') {
		if (typeof(g.modules[g.plusMinusMod].hidePlusMinus()) != "undefined") {
			g.modules[g.plusMinusMod].hidePlusMinus();
		}
	}
	if (g.plusMinusList.indexOf('|'+mod+'|') > -1) {
			g.plusMinusMod = mod;
			if (typeof(g.modules[mod].showPlusMinus) != 'undefined') g.modules[mod].showPlusMinus();
	}
}



function getDecVal(hexChar) {
	hexChar = hexChar.toLowerCase();
	switch (hexChar) {
		case 'a':	return 10;
		case 'b':	return 11;
		case 'c':	return 12;
		case 'd': 	return 13;
		case 'e':	return 14;
		case 'f':	return 15;
		default:	return parseInt(hexChar);
	}
}
function getHexVal(decNum) {
	if (decNum < 0 || decNum > 15) return "";
	var hexChars = new Array("a", "b", "c", "d", "e", "f");
	if (decNum >= 10) {	return hexChars[decNum - 10]}
	else { return decNum + "";	}
}

function hexToDec(hex) {
	hex = "" + hex;
	var dec = 0;
	for (var i=0;i<hex.length;i++) {
		dec += (getDecVal(hex.charAt(i)) * Math.pow(16, (hex.length - (i+1))));
	}
	return dec;
}
function decToHex(dec) {
	if (dec > 255) return "ff";
	if (dec == 0) return "00";
	var hex = "";
	while ( dec > 0 ) {
		var mod = dec % 16;
		dec = Math.floor( dec / 16);
		hex = getHexVal(mod) + hex;
	}
	if (hex.length == 1) hex = "0" + hex;
	return hex;
}

function changeColor(color, percent) {
	color = color.replace("#", "");
	var redB16, greenB16, blueB16;
	var redB10, greenB10, blueB10;
	if (color.indexOf("rgb") == 0) {
		color = color.substring(4, color.length-1);
		colors = color.split(",");
		redB10 = parseInt(colors[0]);
		greenB10 = parseInt(colors[1]);
		blueB10 = parseInt(colors[2]);
	} else {
		if (color.length == 6) {
			redB16 = color.substring(0, 2);	greenB16 = color.substring(2, 4); blueB16 = color.substring(4, 6);
		} else if (color.length == 3) {
			redB16 = color.charAt(0) + color.charAt(0);
			greenB16 = color.charAt(1) + color.charAt(1);
			blueB16 = color.charAt(2) +  color.charAt(2);
		}
		redB10 = hexToDec(redB16);	blueB10 = hexToDec(blueB16);	greenB10 = hexToDec(greenB16);
	}
	redB10 = Math.round(.01 * percent * redB10);
	blueB10 = Math.round(.01 * percent * blueB10);
	greenB10 = Math.round(.01 * percent * greenB10);
	redB16 = decToHex(redB10);	blueB16 = decToHex(blueB10);	greenB16 = decToHex(greenB10);
	return "#"+redB16+""+greenB16+""+blueB16;
}
function sEscape(a) { return escape(a).replace(/-/g, '%2D').replace(/\+/g, '%2B'); }


var themeCallbacks = new Array();
function registerThemeCallback(modid, callback) {
	themeCallbacks[themeCallbacks.length] = callback;
}
function triggerThemeCallbacks(theme) {
	for (var i=0;i<themeCallbacks.length;i++) {
		var func = themeCallbacks[i];
		func(theme);
	}
}
function refreshPage() {
	window.location.href = window.location.href;
}