﻿var monthName=new Array(12);
monthName[1]="January";
monthName[2]="February";
monthName[3]="March";
monthName[4]="April";
monthName[5]="May";
monthName[6]="June";
monthName[7]="July";
monthName[8]="August";
monthName[9]="September";
monthName[10]="October";
monthName[11]="November";
monthName[12]="December";

/* Fix background flicker problem */
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

function process_form(theForm)
{
    new ajax.Loader("","",updateForum,theForm);
	return false
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		var obj2 = obj;
		while (obj2 = obj2.offsetParent) {
		    if (obj2.offsetLeft != undefined)
			    curleft += obj2.offsetLeft;
            if (obj2.offsetTop != undefined)
			    curtop += obj2.offsetTop;
		}
		
		// Now compensate for scollbars
		var oHTML = document.getElementsByTagName("html")[0];
		var body=document.getElementsByTagName("BODY")[0];
		while (((obj = obj.parentNode) && obj != body) && obj.className != "box") {
		    if (obj != oHTML) {
		        if (obj.scrollLeft != undefined)
    			    curleft -= obj.scrollLeft;
                if (obj.scrollTop != undefined) {
    			    curtop -= obj.scrollTop;
    			}
    	    }
		}
		
	}
	return [curleft,curtop];
}

function mousePos(e)
{
    if (e.pageX || e.pageY) 	{
		curleft = e.pageX;
		curtop = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		curleft = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		curtop = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	
	return [curleft, curtop]

}

function getElementByClass(parent,tagName,className)
{
    var selection=null;
    
    var elements = parent.getElementsByTagName(tagName);
    for (i=0;i<elements.length;i++) {
        if (elements[i].className==className)
            selection = elements[i];
    }
    
    return selection;
}

function getParentElementByClass(src,tagName,className)
{
    var selection=null;
    
    var element = src.parentNode;
    if (element)
        if (element.className != className || element.tagName != tagName)
            element = getParentElementByClass(element,tagName,className);
    
    return element;
}

function RGBToHex(rgb) {
	var response="";
	rgb = rgb.replace(/[^0-9,]/g,"");
	var bits = rgb.split(",");
	
	for (var i=0;i< bits.length;i++) {
		bits[i] = parseInt(bits[i]).toString(16);
		if (bits[i].length < 2)
			response += "0";
		response += bits[i];
	}
	
	return response;
} 

function getStyle(element,style)
{
	var result = null;
	var hyphen = style.indexOf("-");
	ieStyle = style;
	//IE needs to have "-" stripped out of style names whereas firefox doesn't
	if (hyphen > 0) {
	    ieStyle = style.substr(0,hyphen) + style.substr(hyphen+1,1).toUpperCase() + style.substr (hyphen +2);
	}
	
	if (element.currentStyle)
		var result = element.currentStyle[ieStyle];
	else if (window.getComputedStyle)
		var result = document.defaultView.getComputedStyle(element,null).getPropertyValue(style);
		
	// strip "px"
	result = result.replace(/px/,"");
		
	return result;
}



var menuX;
var menuFinalX;
var menu=0;

function SubMenu(id)
{
return;
    var d = document.getElementById(id);
	for (var i = 1; i<=13; i++) {
		if (document.getElementById('sMenu'+i)) {
		    document.getElementById('sMenu'+i).style.display='none';
		}
	}

    if (d && boxDragging==null) {
        var cur = findPos(d.parentNode);
        d.style.left = cur[0] + "px";
        d.style.top = cur[1] + "px";
        d.style.display='block';
    }        
}

function defined(obj)
{
    if (typeof obj == "undefined")
        return false;
    else
        return true;
}

function getMouseXY(e) // works on IE6,FF,Moz,Opera7
{ 

  var mouseX=0;
  var mouseY=0;
  
  if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event)

  if (e)
  { 
    
    if (e.pageX || e.pageY)
    { // this doesn't work on IE6!! (works on FF,Moz,Opera7)
      mouseX = e.pageX;
      mouseY = e.pageY;
    }
    else if (e.clientX || e.clientY)
    { // works on IE6,FF,Moz,Opera7
      mouseX = e.clientX + document.body.scrollLeft;
      mouseY = e.clientY + document.body.scrollTop;
      if (document.documentElement) {
        if (document.documentElement.scrollLeft)
            mouseX += document.documentElement.scrollLeft;
        if (document.documentElement.scrollTop)
            mouseY += document.documentElement.scrollTop;
            
      }
            
    }  
  }
  

    // Now compensate for scollbars
    var oHTML = document.getElementsByTagName("html")[0];
    obj = document.getElementsByTagName("BODY")[0].firstChild;
    var body=document.getElementsByTagName("BODY")[0];
    while ((obj = obj.parentNode && obj != body) && obj.className != "box") {
        if (obj != oHTML) {
            if (obj.scrollLeft != undefined)
		        mouseX -= obj.scrollLeft;
            if (obj.scrollTop != undefined)    {
		        mouseY -= obj.scrollTop;
		    }
        }
    }
  
  return [mouseX,mouseY];
}

function testMouseOver(e,obj)
{
    var isOver = false;
    
    if (!e) e = window.event;
    
    rep = document.getElementById("adverts");    
    
    if (e) {
        isOver = true;
        var mouse = getMouseXY(e);
        var cur = findPos(obj);
        if (mouse[0] < cur[0] || mouse[0] > (cur[0] + obj.clientWidth) 
            || mouse[1] < cur[1] || mouse[1] > cur[1] + obj.clientHeight) {
            isOver = false;
            rep.innerHTML = rep.innerHTML + "mx=" + mouse[0] + ";my=" + mouse[1] + ";<br>divx=" + cur[0] + ";divy=" + cur[1];
            }
    }
    
    return isOver;
}


function isChildOf(node,parent) 
{
    while (node) {
        if (node == parent)
            return true;
        node=node.parentNode;
    }		    
    
    return false;
}

function toggleAll(src)
{
    var prefix = src.name.substring(0,3);
    var index = src.name.substring(3);
    var obj;
    
    // If we have set "all", clear the rest
    
    if (index == 0 && src.checked == true) {
        var cnt=1;
        var objs = src.parentNode.parentNode.getElementsByTagName("INPUT");
        for (var i=0;i<objs.length;i++) {
            if (objs[i].id != prefix + "0")
                objs[i].checked = false;
        }
    }
    if (index != 0 && src.checked == true)
        document.getElementById(prefix + "0").checked=false;
}

function toggleAllGeneric(src, allId)
{
    // If we have set "all", clear the rest
    if (src.id == allId && src.checked == true) {
        var objs = src.parentNode.parentNode.getElementsByTagName("INPUT");
        for (var i=0;i<objs.length;i++) {
            if (objs[i].id != allId)
                objs[i].checked = false;
        }
    }
    if (src.id != allId && src.checked == true)
        document.getElementById(allId).checked=false;
}


function wrDummy()
{
}

function wrAlert(HTMLResponse)
{
    if (HTMLResponse !== false) {
        if (HTMLResponse != "")
            alert(HTMLResponse);
    }
}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    if (opacity == 100)
        object.filter = "";        
    else
        object.filter = "alpha(opacity=" + opacity + ")";
        
    
} 

function cancelEvent(e)
{
  if(!e)
    e = window.event;
  if (e) {
	  if(e.stopPropagation)
		e.stopPropagation();
	  if(e.preventDefault)
		e.preventDefault();
	  e.cancelBubble = true;
	  e.cancel = true;
	  e.returnValue = false;
  }
  return false;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function tabSelect(src) {
    var obj = document.getElementById(src);
    if (!obj)
        return;
    var objParent = obj.parentNode;
    
    // Reset selected tab
    var objs = objParent.getElementsByTagName("A");
    for (var i=0;i<objs.length;i++) {
        if (objs[i].className == "selected")
            objs[i].className = "";
        if (objs[i].id == src + "Tab")
            objs[i].className = "selected";
    }
    
    // Show tab content
    var objs = objParent.getElementsByTagName("DIV");
    for (i=0;i<objs.length;i++) {
        if (objs[i].className == "wrTabContent") {
            if (objs[i].id == src) {
                objs[i].style.display = "block";
                setChildFocus(objs[i]);
            }
            else
                objs[i].style.display = "none";
        }
    }
}

function setChildFocus(src) 
{
	var focusObjs = src.getElementsByTagName("*");
	var focusIndex=0;
	var hidden;
	while (focusIndex < focusObjs.length) {
		if (focusObjs[focusIndex].tagName == "A" || (focusObjs[focusIndex].tagName == "INPUT" && focusObjs[focusIndex].type != "hidden" && !focusObjs[focusIndex].disabled) || focusObjs[focusIndex].tagName == "SELECT" || focusObjs[focusIndex].tagName == "TEXTAREA") {
			focusObjs[focusIndex].focus();
			return;
		}

		focusIndex++;		
	}
}

function wrTrim(src)
{
	var	src = src.replace(/^\s\s*/, ''),
		ws = /\s/,
		i = src.length;
	while (ws.test(src.charAt(--i)));
	return src.slice(0, i + 1);
}

function wrSetFocus(obj, defaultText)
{
    obj.focus();
    if (obj.value == defaultText)
        obj.select();

}

function doPopup(src,openNew,e)
{
	if (!openNew)
		openNew = "Y";
		
	var url = src.href;
	url=url + "&" + "new=";
	
	if (openNew == "Y") {
		var newWindow = window.open(url + "1", '_blank', "");
		if (newWindow)
			newWindow.focus();
	} 
	else
		window.location = url + "0";
	
	if (window.event) {
		window.event.returnValue = false;
		window.event.cancelBubble = true;
	} 
	else if (e) {
		e.stopPropagation();
		e.preventDefault();
	}		
	return false;
	
}

function getVar(name)
{

	var params = document.location.search.substring(1).split("&");
	var length = params.length;
	var response=null;
	
	var bits;
	
	for (var i=0;i<length;i++) {
		bits = params[i].split("=");
		if (bits[0] == name)
			response = bits[1];
	}
	
	return response;
}

function showSubMenu(src)
{                
    if (src.className == "menuOption")
        src.getElementsByTagName("div")[0].style.display="block";
    else
        src.style.display="block";
}

function hideSubMenu()
{
    // Hide all submenus
    var objs = document.getElementById("menuStrip").getElementsByTagName("div");
    for (var i=0;i<objs.length;i++)
        if (objs[i].className == "subMenu")
            objs[i].style.display = "none";                
}        
﻿// Context for popups;
popupContext=function(name)
{
	this.name = name;
    this.popup=null; // The popup element
    this.popupId=""; // The id of the popup element
    this.src=null; // The element which is triggering the popup
    this.newSrc=null; // The element which is triggering the popup (new caller)
    this.showFunction=null; // The function to call when the popup is displayed
    this.newShowFunction=null; // The function to call when the popup is displayed (new caller)
    this.hideFunction=null; // The function to call when the popup is hidden
    this.newHideFunction=null; // The function to call when the popup is hidden (new caller)
    this.immediate=false; // Set to true to popup immediately and to persist till explicitly closed    
    this.select=false; // Are we using the popup for a select box?
    this.selectSize=0; // Amount to adjust select popup boxes by to align with input box
    this.clickedPopup=false; // Used to distinguish between a click in a popup and on the page background    
    this.shadow=null;
};

// Constructor
popupClass=function()
{
	this.contexts = new Array();
	this.contexts[0] = new popupContext(""); // Set default content
    this.popupsAllowed=true; // Set this to false during drag and drop etc.
	this.highlightText = ""; // Set text to describe what you are hovering over
    this.highlight=false; // Set to true in mouseover to show that a popup is available    
    this.problemsHidden=false; // Record if we have hidden flash and selects before showing a popup
    this.body = document.getElementsByTagName("BODY")[0];

    
    this.body.onmouseover=function(e) {
        if (!e) 
            e = window.event;

        if (popup)
            popup.mouseover(e);

    };
    this.body.onmousemove=function(e) {
        if (!e) 
            e = window.event;
        if (popup)
            popup.mousemove(e);
    };    
    this.body.onclick=function(e) {
        if (!e) 
            e = window.event;
            /*TODO - deal with clickedPopup*/    
		if (popup.clickedPopup == false && popup.select == true)
			popup.hidePopup();
		popup.clickedPopup = false;			
    };
    
};

popupClass.prototype.getContext=function(contextName)
{
	if (!contextName)
		contextName="";

	for (this.ic=0;this.ic < this.contexts.length;this.ic++) {
		if (this.contexts[this.ic].name == contextName)
			return this.contexts[this.ic];
	}
	
	// If none found create a new context
	var newContext = new popupContext(contextName);
	this.contexts[this.contexts.length] = newContext;
	
	return newContext;
}

popupClass.prototype.show=function(popupId,src,showFunc,hideFunc,immediate,select,contextName, offsetX, offsetY, bringToTop, moveable)
{
	if (!contextName)
		contextName="";
	if (!offsetX)
		offsetX=0;
	if (!offsetY)
		offsetY=0;
	if (!bringToTop)
		bringToTop=true;
	if (!moveable)
		moveable=false;
		
	var context = this.getContext(contextName);
	context.offsetX = offsetX;
	context.offsetY = offsetY;
    if (this.popupsAllowed == true) {
        context.clickedPopup = true;
        
        if (immediate)
            context.immediate = true;
        else
            context.immediate = false;
        if (select)
            context.select = true;
        else
            context.select = false;            
        // record that a popup has been requested
        context.popupId = popupId;
        context.newShowFunction = showFunc;
        context.newHideFunction = hideFunc; 
        context.newSrc = src;    
        
               
        // Display popup if still required after short delay
        if (context.immediate)
            this.displayPopup(src.id,contextName, bringToTop);
        else
            setTimeout("popup.displayPopup('"+src.id+"','"+contextName+"',"+bringToTop+","+moveable+")",300);
    }
}

popupClass.prototype.displayPopup=function(srcId,contextName,bringToTop,moveable)
{
	if (!contextName)
		contextName="";
		
    var context = this.getContext(contextName);
    
    // Only display if we have not had other requests since the original
    if (context.newSrc == null) return;
    
    if (srcId == context.newSrc.id) {
        this.hideHighlight(); // Hide popup icon
        
        // Hide any previous popup
        if (context.popup != null) {
            this.hidePopup(contextName);
        }
        
        // Add shadow to popup if not already there
        var tempPopup = document.getElementById(context.popupId);
        if (tempPopup.parentNode.className != "popupShadow") {
            context.shadow = document.createElement("div");
            context.shadow.className = "popupShadow";
            context.shadow.id = this.getShadowName(tempPopup.id);
            context.shadow.onclick=function() {popup.clickedPopup = true;}
            tempPopup.parentNode.insertBefore(context.shadow,tempPopup);
            context.shadow.appendChild(tempPopup);            
            if (moveable) {
				var dragBar = document.createElement("div");
				dragBar.className="dragBar";
				dragBar.innerHTML = "&nbsp;Click, &amp; drag to move&nbsp;";
				dragBar.onmousedown=function(e) {
						var shPopup = this.parentNode;
						var pos = getMouseXY(e);
						document.body.movingPopup=shPopup;
						document.body.popupOffsetX=shPopup.style.left.replace(/px/,"") - pos[0];
						document.body.popupOffsetY=shPopup.style.top.replace(/px/,"") - pos[1];
					}
					
				if (!document.body.moveable) {
					document.body.moveable=true;
					if (document.body.onmousemove)
						document.body.oldOnmousemove = document.body.onmousemove;
						
					document.body.onmousemove=function(e) {
							if (document.body.movingPopup) {
								var pos = getMouseXY(e);
								document.body.movingPopup.style.left = pos[0] + document.body.popupOffsetX + "px";
								document.body.movingPopup.style.top = pos[1] + document.body.popupOffsetY + "px";
								popup.clearSelection();
							}					
							if (document.body.oldOnmousemove)
								document.body.oldOnmousemove(e);
							
						}
					if (document.body.onmouseup)
						document.body.oldOnmouseup = document.body.onmouseup;

					document.body.onmouseup=function(e) {
							document.body.movingPopup = null;
							if (document.body.oldOnmouseup)
								document.body.oldOnmouseup(e);
					}
				}
				context.shadow.insertBefore(dragBar,tempPopup);
            }
        }
        
        
        context.popup = document.getElementById(context.popupId);
        
        // Hide flash objects
        if (!this.problemsHidden) {
			this.hiddenObjs = document.getElementsByTagName("OBJECT");
			for (this.i=0;this.i<this.hiddenObjs.length;this.i++) {
				if (!isChildOf(this.hiddenObjs[this.i],context.popup)) {
					if (this.hiddenObjs[this.i].style.visible)
						this.hiddenObjs[this.i].lastVisibility = this.hiddenObjs[this.i].style.visible;
					else
						this.hiddenObjs[this.i].lastVisibility = "visible";
					this.hiddenObjs[this.i].style.visibility = "hidden";
				}
			}
			this.hiddenObjs = document.getElementsByTagName("SELECT");
			for (this.i=0;this.i<this.hiddenObjs.length;this.i++) {
				if (!isChildOf(this.hiddenObjs[this.i],context.popup)) {
					if (this.hiddenObjs[this.i].style.visible)
						this.hiddenObjs[this.i].lastVisibility = this.hiddenObjs[this.i].style.visible;
					else
						this.hiddenObjs[this.i].lastVisibility = "visible";
					this.hiddenObjs[this.i].style.visibility = "hidden";
				}
			}
			
			this.problemsHidden = true;
		}
                
        // Move new caller properties to current properties
        context.showFunction = context.newShowFunction;
        context.hideFunction = context.newHideFunction;
        context.src = context.newSrc;
        context.newSrc = null;
        context.shadow = context.popup.parentNode;
        if (context.showFunction)
            context.showFunction(context.src, context.popup);
        // Ensure popup is a child of the main div to ensure the best z-index
       
		if (bringToTop) {
			this.body.insertBefore(context.shadow,null);
		}			
		
		// position popup next to the src
		var position = findPos(context.src);
		// Add 5 for shadow
		var popupLeft = position[0] + 4;
		var popupTop = position[1] + 4;
		if (context.selectSize > 0) {
			popupLeft = position[0] - (context.selectSize - 20);
			popupTop = position[1] + 16;
		}
        
		// Include and offsets
		popupLeft += context.offsetX;
		popupTop += context.offsetY;
        
		// Override position if popup is a select box
		context.shadow.style.left = popupLeft + "px";
		context.shadow.style.top= popupTop + "px";

        context.shadow.style.display="block";
        context.popup.style.display="block";
        
        changeOpac(0, context.shadow.id);
        opacity(context.shadow.id, 0, 100, 200);

	    // Adjust the postion if it has gone off the screen
	    // Get the right and left edge of the visible screen taking in to account scroll bar positions
	    var leftEdge = this.posLeft();
	    var rightEdge = this.posRight();
	    var margin = 45;
	    // If the popup is going off the right edge, pull it pack so it is fully visible
	    if (popupLeft + context.shadow.clientWidth + margin > rightEdge) {
		    popupLeft = rightEdge - context.shadow.clientWidth - margin;
		    context.shadow.style.left = popupLeft+"px";
	    }
    	
	    // If the popup is now going off the left edge push it back forward - hopefully this won't really happen unless the browser window is tiny
	    if (popupLeft < leftEdge)
		    context.shadow.style.left = leftEdge+"px";
		        		
	    // Get the top and bottom edge of the visible screen taking in to account scroll bar postions
	    var topEdge = this.posTop();
	    var bottomEdge = this.posBottom();
	    var marginBottom = 20;
	    // If the popup is going off the bottom, place it above the cursor rather than below
	    if (popupTop + context.shadow.clientHeight + marginBottom > bottomEdge) {
		    popupTop = bottomEdge - context.shadow.clientHeight - marginBottom;
		    context.shadow.style.top = popupTop + "px";
	    }
	    // if the popup is now going off the top of the screen move it back down, but this is very unlikely to happen unless the browser window is tiny or the poup is massive
	    if (popupTop < topEdge)
		    context.shadow.style.top = topEdge + "px";

    }		
}

popupClass.prototype.hidePopup=function(contextName)
{
	if (!contextName)
		contextName="";
		
	var context = this.getContext(contextName);
	
    if (context.hideFunction)
        context.hideFunction(context.src,context.popup);        
            
    if (!context.popup) 
        return;

    if (context.shadow)
        context.shadow.style.display="none";
        
    context.popup = null; 
    context.src = null;       
    context.showFunction=null;
    context.hideFunction=null; 
    this.hideHighlight(); // Hide popup icon   
    
    // if this is th e last popup to be hidden, show problem fields
    var lastPopup = true;
	for (var ic=0;ic < this.contexts.length;ic++) {
		if (this.contexts[ic].popup != null)
			lastPopup = false;
			
	}
	if (lastPopup) {
		// Restore hidden flash
		this.hiddenObjs = document.getElementsByTagName("OBJECT");
		for (this.i=0;this.i<this.hiddenObjs.length;this.i++) {
			if (this.hiddenObjs[this.i].lastVisibility != "hidden")
				this.hiddenObjs[this.i].style.visibility = "visible";
		}
		this.hiddenObjs = document.getElementsByTagName("SELECT");
		for (this.i=0;this.i<this.hiddenObjs.length;this.i++) {
			if (this.hiddenObjs[this.i].lastVisibility != "hidden")
				this.hiddenObjs[this.i].style.visibility = "visible";
		}
		this.problemsHidden = false;
	}    
	
    context.selectSize = 0;
}


// This event ensures the popup is hidden when it looses focus
popupClass.prototype.mouseover=function(e)
{

	// Process for each context
	var context=null;
	var ignore=false;
	for (var ic=0;ic < this.contexts.length;ic++) {
		context=this.contexts[ic];
		ignore=false;

		// don't process for immediate popups
		if (!context.immediate) {
			if (!e) 
				e = window.event;
			// only process if we can get event object
			if (e) {
				this.target = (window.event) ? e.srcElement : e.target;

				// Deal with pending popup requests
				if (context.newSrc != null) {
					// Cancel popup request if we have moved over something else.
					if (!isChildOf(this.target,context.newSrc)) {
						this.hideHighlight(); // Hide popup icon
						context.newSrc = null;
					}
					ignore=true;
				}
				
				if (context.src == null || context.popup == null)
					ignore=true;

				if (!ignore) {
					// Hide popup if we have moved over something other than popup or source of request
					if (!isChildOf(this.target,context.src) && !isChildOf(this.target,context.popup.parentNode)) {
						this.hidePopup(context.name);
					}
				}
			}
		}
		this.hideHighlight(); // Hide popup icon
	}
	//return cancelEvent(e);
}

popupClass.prototype.mousemove=function(e)
{
	if (this.popupsAllowed == false) {
        this.highlight=false;
        return;
    }
    
	if (!this.icon) {
		this.icon=document.createElement("DIV");
        this.icon.id="popupIcon";
        this.icon.style.display="none";
        var img=document.createElement("IMG");
        img.src="http://cache3.headstartdesign.co.uk/images/generic/popup.gif";
		this.icon.appendChild(img);        
		this.iconText = document.createElement("SPAN");
		this.iconText.innerHTML = "";
		this.icon.appendChild(this.iconText);
    }
	
    this.body.appendChild(this.icon);

       
	if (this.highlight) {
	    this.mouse = getMouseXY(e);
	    this.icon.style.top=this.mouse[1] + "px";
	    this.icon.style.left=this.mouse[0] + "px";
	    this.icon.style.display="block";
	    if (this.highlightText == "")
			this.iconText.style.display="none";
		else {
			this.iconText.style.display="block";
			this.iconText.innerHTML = this.highlightText;
		}
	}
}

popupClass.prototype.hideHighlight=function(e)
{
    // Hide popup icon
    this.highlight=false;
    if (this.icon)
        this.icon.style.display="none";
}

popupClass.prototype.getShadowName=function(id)
{
	var response = id + "shadow";
	return response.replace(/^[ec]_/,"");
}

popupClass.prototype.showNext=function(src)
{
	// Have we shown this popup before?
	var objs = src.parentNode.getElementsByTagName("*");
	var srcPopup = null;
	var foundSrc = false;
	var i=0;
	var length = objs.length;
	while (srcPopup == null && i < length) {
		if (foundSrc && objs[i].className) {
			if (objs[i].className == "popup")
				srcPopup = objs[i];
		}
		if (objs[i].id) {
			if (objs[i].id == src.id)
				foundSrc = true;
		}
		i++;
	}
	
	this.show(srcPopup.id,src,null,null,false,false,"",20,15,false);
}


popupClass.prototype.pageWidth=function() {
	return window.innerWidth != null? window.innerWidth: document.documentElement && document.documentElement.clientWidth ? 		document.documentElement.clientWidth:document.body != null? document.body.clientWidth:null;
}
popupClass.prototype.pageHeight=function() {
	return window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null;
}
popupClass.prototype.posLeft=function() {
	return typeof window.pageXOffset != 'undefined' ? window.pageXOffset:document.documentElement && document.documentElement.scrollLeft? 		document.documentElement.scrollLeft:document.body.scrollLeft? document.body.scrollLeft:0;
}
popupClass.prototype.posTop=function() {
	return typeof window.pageYOffset != 'undefined' ? window.pageYOffset:document.documentElement && document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop?document.body.scrollTop:0;
}
popupClass.prototype.posRight=function() {
	return this.posLeft()+this.pageWidth();
}
popupClass.prototype.posBottom=function() {
	return this.posTop()+this.pageHeight();
}

popupClass.prototype.clearSelection=function()
{
    if (document.selection)
        document.selection.empty();
    else 
        if (window.getSelection)
            window.getSelection().removeAllRanges();
}
