﻿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();
}// namespacing object
var ajax=new Object();

// Constructor
ajax.Loader=function(target,parameters,func,theForm,containerId,fadeId)
{
	this.request=null;
	this.containerId = containerId;
	this.fadeId = fadeId;
	this.startTime = new Date().getTime();
	this.loadingDiv = null;
	if (this.fadeId) {
	    this.loadingDiv = document.getElementById(this.fadeId + "_loading");
	    var container = document.getElementById(this.fadeId);
	    if (container) {
			this.hadBackgroundColour="N";
			if (container.style.backgroundColor)
				this.hadBackgroundColour="Y";
			else
				container.style.backgroundColor = "#ffffff";
			if (!this.loadingDiv) {
				this.loadingDiv = document.createElement("DIV")
				this.loadingDiv.id=this.fadeId + "_loading";
				this.loadingDiv.className = "wrLoading";
				container.parentNode.appendChild(this.loadingDiv);
			}
			this.loadingDiv.style.marginTop = ((container.clientHeight/2) * -1) - (36/2) + "px";
			this.loadingDiv.style.marginLeft = ((container.clientWidth/2)) - (89/2) + "px";
			this.loadingDiv.style.display = "block";
		    opacity(this.fadeId, 100, 50, 500);
		}
	}
	this.target=target;
	this.parameters=parameters;
	this.method="post";
	if (this.containerId) {
	    this.func=this.processHTML;
        var obj=document.getElementById(this.containerId + "Popup");
        if (obj) 
            obj.parentNode.removeChild(obj);
    }	    
	else
	    this.func=func;
	if (theForm) {
	    if (this.processForm(theForm) == false) return false;
	}
	this.loadXMLDoc();
	return true;
}

ajax.Loader.prototype.processHTML=function(HTMLResponse)
{
    document.getElementById(this.containerId).innerHTML = HTMLResponse;
}

// Process a form being submitted
ajax.Loader.prototype.processForm=function(theForm)
{
    if (this.parameters !="")
        this.parameters +="&";
        
    var value="";

	if (document.all || document.getElementById)
	{
		// Process all the inputs on the form
		for (i = 0; i < theForm.length; ++i)
		{
			var elem = theForm.elements[i]
			if (elem.name && elem.name.substring(0, 4) == "req_")
			{
				if (elem.type && (elem.type=="text" || elem.type=="textarea" || elem.type=="password" || elem.type=="file") && elem.value=='')
				{
					alert("\"" + elem.name.substring(4) + "\" is a required field in this form")
					elem.focus()
					return false
				}
			}
			if (elem.name) {
			    if (theForm.elements[i].type != "checkbox" || theForm.elements[i].checked == true) {
			        // Add to the parameter string to submit via Ajax
                    this.parameters += theForm.elements[i].name+"=" + theForm.elements[i].value+"&";
                }
            }
            
		}
	}
	
    // We need to extract action, because forum uses button called "action" too, which corrupts the .action property
    if (this.target == "") {
        var html = theForm.parentNode.innerHTML;
        var index = html.indexOf("action=",0);
        var index2 = html.indexOf(" ",index+7);
        var action = html.substr(index+7,index2-(index+7));
        action = action.replace(/\"/g,"");
        this.target = action;
	    this.method = theForm.method;
	}
	
	return true;
}

// Send request
ajax.Loader.prototype.loadXMLDoc=function()
{
	if (window.XMLHttpRequest){
		this.request=new XMLHttpRequest();
	} else if (window.ActiveXObject){
		this.request=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	if (!this.request) return;

//	SetTimer();
	  
	try {
		var loader=this;
		this.request.onreadystatechange=function(){ajax.Loader.onReadyState.call(loader);}
		// TODO Add bit of logic to get rif of Origination and make this generic
		var url="";

		if (this.target.indexOf("http://") < 0)
		    var url=HTTP_SERVER + this.target;
		else
		    var url = this.target;
		   
        if (this.method=="post") {
	        this.request.open(this.method,url,true);
	    }
	    else {
	        this.request.open(this.method,url+"?"+this.parameters,true);
	    }
	    this.request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	    this.request.send(this.parameters);

	} catch (err) {
		this.processResponse(true);
	}

}

// Process reply
ajax.Loader.onReadyState=function()
{
	var request=this.request;
	var ready=request.readyState;
	
	var READY_STATE_UNINITIALISED=0;
	var READY_STATE_LOADING=1;
	var READY_STATE_INTERACTIVE=3;
	var READY_STATE_COMPLETE=4;
	
	//	Make sure we have got the reply
	if(ready==READY_STATE_COMPLETE){
		var httpStatus=request.status;
		if (httpStatus==200 || httpStatus==0){
            var thisObj = this;
            var timeRemaining = 750 - (new Date().getTime() - this.startTime);
            if (timeRemaining > 0)
                setTimeout(function(){ thisObj.processResponse() }, timeRemaining);
            else
                this.processResponse();
  		} else {
			this.processResponse(true);
		}
	}
}

ajax.Loader.prototype.processResponse=function(cancel)
{     
    if (this.fadeId) {
		if (this.loadingDiv) {
			this.loadingDiv.style.display="none";
			opacity(this.fadeId, 50, 100, 500);
			if (this.hadBackgroundColour=="N") {
				var thisObj = this;
    			setTimeout(function(){ thisObj.resetBackground() }, 500);
			}
		}
    }
    
    // Returned text must start with a tag "<"
    if (cancel)
        this.func(false);
    else {
		if (this.request.responseText)
			this.func(this.request.responseText.replace(/^[^<]*</, '<'));    
    }
}

ajax.Loader.prototype.resetBackground=function()
{
    var container = document.getElementById(this.fadeId);
    if (container)
		container.style.backgroundColor = "";
}

/*	SWFObject v2.2 <http://code.google.com/p/swfobject/> 
	is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
*/
var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();function productButton(src)
{
	try {
		var id = src.id;

		var action="0";
		var bg= 'http://cache3.headstartdesign.co.uk/webB/headstart/images/productButton.png';
		if (src.checked) {
			bg = 'http://cache3.headstartdesign.co.uk/webB/headstart/images/productButtonHighlight.png';
			action="1";
		}
		document.getElementById(id + '_box').style.backgroundImage = 'url(' + bg + ')';
		document.getElementById(id + 'End_box').style.backgroundImage = 'url(' + bg + ')';

		new ajax.Loader(HTTP_SERVER + 'ajax/updateEstimate.php','action='+action+'&id=' + id,estimateUpdated);
	} catch (ex) {}	
}

function removeProduct(src)
{
	var objName = src.id.substr(6);
	var obj = document.getElementById(objName);
	
	if (obj) {
		obj.checked = false;
		productButton(obj);
	} else 
		new ajax.Loader(HTTP_SERVER + 'ajax/updateEstimate.php','action=0&id=' + objName,estimateUpdated);
	
}
function estimateUpdated(htmlResponse)
{
	var hideStyle='block';
	
	if (htmlResponse.indexOf("price") > 0)
		hideStyle='none';

	document.getElementById("estimate").innerHTML = htmlResponse;
	document.getElementById("estimateAlt").style.display=hideStyle;
}

function samplePopup(src)
{
	try {
		var id=src.id.replace("link","popup");
		if (id != null) {
			// load image
			var obj = document.getElementById(id);
			if (obj) {
				var imgObj = obj.getElementsByTagName("img")[0];
				var spanObj = obj.getElementsByTagName("b")[0];
				if (imgObj && spanObj)
					imgObj.src = spanObj.innerHTML;
				popup.show(id,src);
			}
		}
		
	} catch(ex) {
	};	
}


function showSample(id)
{
	sampleObj = document.getElementById("samples");
	
	var objs = document.getElementById("samplesLinks").getElementsByTagName("A");
	for (var i=0;i<objs.length;i++) {
		if (i == id -1)
			objs[i].className = "selected";
		else
			objs[i].className = "";
	}
	
	currentMargin = sampleObj.style.marginLeft.replace("px","");
	if (currentMargin == "")
		currentMargin = 0;
	else
		currentMargin = parseInt(currentMargin);
	
	var dt = new Date();
	startTime = dt.getTime();
	var newMargin = (id -1)* 240 * -1;
	marginDiff = newMargin - currentMargin;

	setTimeout("scrollPage()",10);
	
	return false;

}

var sampleObj;
var scrollDuration = 1000;
var framesPerSecond = 10;

var piIndex = Math.PI * 0.5;
var stepTime = 1000 / framesPerSecond;
var startTime;
var currentMargin;
var marginDiff;

function scrollPage()
{
	var adj
	var dt = new Date();
	var frame = dt.getTime() - startTime;
	
	if (frame > 0) {
		if (frame > scrollDuration)
			adj = 1;
		else {
			adj = Math.sin(frame/scrollDuration * piIndex);
			setTimeout("scrollPage()",stepTime);
		}
		var margin = marginDiff * adj;
		margin += currentMargin; 
		sampleObj.style.marginLeft = margin + "px";
	}
}














