function Ajax() {
	this.req = null;
	this.url = null;
	this.method = 'GET';
	this.async = true;
	this.status = null;
	this.statusText = '';
	this.postData = null;
	this.readyState = null;
	this.responseText = null;
	this.responseXML = null;
	this.handleResp = null;
	this.responseFormat = 'text'; // 'text', 'xml' or 'object'
	this.mimeType = null;

	this.init = function() {
		if(!this.req) {
			try {
				// Try to create object for Firefox, Safari, IE7, etc.
				this.req = new XMLHttpRequest();
			}
			catch(e) {
				try {
					// Try to create object for later versions of IE.
					this.req = new ActiveXObject('MSXML2.XMLHTTP');
				}
				catch(e) {
					try {
						// Try to create object for early versions of IE.
						this.req = new ActiveXObject('Microsoft.XMLHTTP');
					}
					catch(e) {
						// could not create an XMLHttpRequest object.
						return false;
					}
				}
			}
		}
		return this.req;
	};
	
	this.doReq = function() {
		if(!this.init()) {
			alert('Could not create XMLHttpRequest object.');
			return;
		}
		
		this.req.open(this.method, this.url, this.async);
		if(this.mimeType) {
			try {
				req.overrideMimeType(this.mimeType);
			}
			catch(e) {
				// Couldn't override MIME type -- IE6 or Opera?
			}
		}

		var self = this;	// Fix loss-of-scope in inner function
		this.req.onreadystatechange = function() {
			var resp = null;
			if(self.req.readyState == 4) {
				switch (self.responseFormat) {
					case 'text':
						resp = self.req.responseText;
						break;
					case 'xml':
						resp = self.req.responseXML;
						break;
					case 'object':
						resp = req;
						break;
				}
				if(self.req.status >= 200 && self.req.status <= 299) {
					self.handleResp(resp);
				}
				else {
					self.handleErr(resp);
				}
			}
		};
		this.req.send(this.postData);
	};
	
	this.setMimeType = function(mimeType) {
		this.mimeType = mimeType;
	};
	
	this.handleErr = function() {
		var errorWin;
		try {
			errorWin = window.open('', 'errorWin');
			errorWin.document.body.innerHTML = this.responseText;
		}
		catch(e) {
			alert('An error occurred, but the error message cannot be '
			    + 'displayed. This is probably because your browser\'s '
				+ 'pop-up blocker.\n'
				+ 'Please allow pop-ups from this website if you want to '
				+ 'see the full error messages.\n'
				+ 'Status Code: ' + this.req.status + '\n'
				+ 'Status Description: ' + this.req.statusText);
		}
	};
	
	this.abort = function() {
		if(this.req) {
			this.req.onreadystatechange = function() { };
			this.req.abort();
			this.req = null;
		}
	};
	
	this.doGet = function(url, hand, format) {
		this.url = url;
		this.handleResp = hand;
		this.responseFormat = format || 'text';
		this.doReq();
	};
}

function buyNowCapture(pcode,type,linktype,domain) {
	var ajax = new Ajax();
	ajax.async = false; // Synchronous mode, ie. wait to finish before continuing.
	//alert('/tools/buy-now-capture.php?pcode=' + pcode + '&type=' + type + '&page=' + window.location.href + '&linktype=' + linktype + '&domain=' + domain);
	ajax.doGet('/tools/buy-now-capture.php?pcode=' + pcode + '&type=' + type + '&page=' + window.location.href + '&linktype=' + linktype + '&domain=' + domain);
}

// Pre load over tab image.
pic1= new Image(119,24);
pic1.src="/images/global/tabOver.jpg";

function getElementsByClassName(classname, node)  {
    if(!node) node = document.getElementsByTagName("body")[0];
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}

function identifyBrowser() {
   var agent = navigator.userAgent.toLowerCase();

   if(typeof navigator.vendor != "undefined" && navigator.vendor == "KDE" && typeof window.sidebar != "undefined") {
      return "kde";
   }else if(typeof window.opera != "undefined") {
      var version = parseFloat(agent.replace(/.*opera[\/ ]([^ $]+).*/, "$1"));
      if(version >= 7) {
         return "opera7";
      }else if (version >= 5) {
         return "opera 5";
      }
      return false;
   }else if (typeof document.all != "undefined") {
      if(typeof document.getElementById != "undefined") {
         var browser = agent.replace(/.*ms(ie[\/ ][^ $]+).*/, "$1").replace(/ /, "");
         if(typeof document.uniqueID != "undefined") {
            if(browser.indexOf("5.5") != -1) {
               return browser.replace(/(.*5\.5).*/, "$1");
            }else {
               return browser.replace(/(.*)\..*/, "$1");
            }
         }else {
            return "ie5mac";
         }
      }
      return false;
   }else if(typeof document.getElementById != "undefined") {
      if(navigator.vendor.indexOf("Apple Computer, Inc.") != -1) {
         if(typeof window.XMLHttpRequest != "undefined") {
            return "safari1.2";
         }
         return "safari1";
      }else if(agent.indexOf("gecko") != -1) {
         return "mozilla";
      }
   }
   return false;
}

function getScrollPosition() {
   var position = [0, 0];

   if(typeof window.pageYOffset != 'undefined') {
      position = [
      window.pageXOffset,
      window.pageYOffset,
      ];
   }else if (typeof document.documentElement.scrollTop != 'undefined' && document.documentElement.scrollTop > 0) {
      position = [
      document.documentElement.scrollLeft,
      document.documentElement.scrollTop,
      ];
   }else if(typeof document.body.scrollTop != 'undefined') {
      position = [
      document.body.scrollLeft,
      document.body.scrollTop,
      ];
   }
   return position;
}

function getBrowserSize() {
   var size = [0, 0];

   if(typeof window.innerWidth != 'undefined') {
      size = [
      window.innerWidth,
      window.innerHeight
      ];
   }else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
      size = [
      document.documentElement.clientWidth,
      document.documentElement.clientHeight
      ];
   }else {
      size = [
      document.getElementsByTagName('body')[0].clientWidth,
      document.getElementsByTagName('body')[0].clientHeight,
      ];
   }
   return size;
}

// Cookie Functions
function trim(sString) {
   while (sString.substring(0,1) == ' ') {
      sString = sString.substring(1, sString.length);
   }
   while (sString.substring(sString.length-1, sString.length) == ' ') {
      sString = sString.substring(0,sString.length-1);
   }

   return sString;
}

function setCookie(cookieName, cookieValue, nDays, secure) {
   var theCookie = cookieName + "=" + cookieValue;

   // Cookie expiry date
   var today = new Date();
   var expire = new Date();
   expire.setTime(today.getTime() + 3600000*24*nDays);
   theCookie += ";expires=" + expire.toGMTString();

   // Cookie domain
   //theCookie += ";domain=dev.mobileshop.com";

   // Cookie path
   theCookie += ";path=/";

   // Secure cookie (https)
   if(secure) {
      theCookie += ";secure";
   }

   document.cookie = theCookie;
}

function writeSessionCookie (cookieName, cookieValue) {

   document.cookie = escape(cookieName) + "=" + escape(cookieValue) + "; path=/";
}

// this fixes an issue with the old method, ambiguous values
// with this test document.cookie.indexOf( name + "=" );
function getCookie( check_name ) {
   // first we'll split this cookie up into name/value pairs
   // note: document.cookie only returns name=value, not the other components
   var a_all_cookies = document.cookie.split( ';' );
   var a_temp_cookie = '';
   var cookie_name = '';
   var cookie_value = '';
   var b_cookie_found = false; // set boolean t/f default f

   for ( i = 0; i < a_all_cookies.length; i++ )
   {
      // now we'll split apart each name=value pair
      a_temp_cookie = a_all_cookies[i].split( '=' );

      // and trim left/right whitespace while we're at it
      cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

      // if the extracted name matches passed check_name
      if ( cookie_name == check_name )
      {
         b_cookie_found = true;
         // we need to handle case where cookie has no value but exists (no = sign, that is):
         if ( a_temp_cookie.length > 1 )
         {
            cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
         }
         // note that in cases where cookie is initialized but no value, null is returned
         return cookie_value;
         break;
      }
      a_temp_cookie = null;
      cookie_name = '';
   }
   if ( !b_cookie_found )
   {
      return false;
   }
}

function getEventTarget(event)
{
   var targetElement = null;

   if (typeof event.target != "undefined")
   {
      targetElement = event.target;
   }
   else
   {
      targetElement = event.srcElement;
   }

   while (targetElement.nodeType == 3 &&
   targetElement.parentNode != null)
   {
      targetElement = targetElement.parentNode;
   }

   return targetElement;
}

// Gives us the ability to assign any number of load event handlers
function addLoadListener(fn)
{
   if(typeof window.addEventListener != 'undefined')
   {
      window.addEventListener('load', fn, false);
   }
   else if(typeof document.addEventListener != 'undefined')
   {
      document.addEventListener('load', fn, false);
   }
   else if(typeof window.attachEvent != 'undefined')
   {
      window.attachEvent('onload', fn);
   }
   else
   {
      var oldfn = window.onload;
      if(typeof window.onload != 'function')
      {
         window.onload.fn;
      }
      else
      {
         window.onload = function()
         {
            oldfn();
            fn();
         };
      }
   }
}

// This sets what values are passed to the function attachEventListener().
function attachEventListener(target, eventType, functionRef, capture) {
   if(typeof target.addEventListener != "undefined") { // If target.addEventListener can be defined in browser.
      target.addEventListener(eventType, functionRef, capture); // Use these values in target.addEventListener.
   }else if(typeof target.attachEvent != "undefined") { // If IE browser - target.attachEvent can be defined.
      target.attachEvent("on" + eventType, functionRef); // Add 'on' to the begining of the event type e.g. 'onclick'.
   }else {
      // This is for really old browsers.
      eventType = "on" + eventType;

      if(typeof target[eventType] == "function") {
         var oldListener = target[eventType];
         target[eventType] = function() {
            oldListener();
            return functionRef;
         };
      }else {
         target[eventType] = functionRef;
      }
   }
}

function debug(data) {
   var win = window.open('', win, 'width=800,height=600');

   win.document.open();
   win.document.write('<ul>');
   for(var i = 0; i < data.length; i++) {
      win.document.write('<li>' + i + '=' + data[i] + '</li>');
   }
   win.document.write('</ul>');
   win.document.close();
}

// Global popup
function getScrollPosition() {
   var position = [0, 0];

   if(typeof window.pageYOffset != 'undefined') {
      position = [
      window.pageXOffset,
      window.pageYOffset,
      ];
   }else if (typeof document.documentElement.scrollTop != 'undefined' && document.documentElement.scrollTop > 0) {
      position = [
      document.documentElement.scrollLeft,
      document.documentElement.scrollTop,
      ];
   }else if(typeof document.body.scrollTop != 'undefined') {
      position = [
      document.body.scrollLeft,
      document.body.scrollTop,
      ];
   }
   return position;
}

function getBrowserSize() {
   var size = [0, 0];

   if(typeof window.innerWidth != 'undefined') {
      size = [
      window.innerWidth,
      window.innerHeight
      ];
   }else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
      size = [
      document.documentElement.clientWidth,
      document.documentElement.clientHeight
      ];
   }else {
      size = [
      document.getElementsByTagName('body')[0].clientWidth,
      document.getElementsByTagName('body')[0].clientHeight,
      ];
   }
   return size;
}

function identifyBrowser() {
   var agent = navigator.userAgent.toLowerCase();

   if(typeof navigator.vendor != "undefined" && navigator.vendor == "KDE" && typeof window.sidebar != "undefined") {
      return "kde";
   }else if(typeof window.opera != "undefined") {
      var version = parseFloat(agent.replace(/.*opera[\/ ]([^ $]+).*/, "$1"));
      if(version >= 7) {
         return "opera7";
      }else if (version >= 5) {
         return "opera 5";
      }
      return false;
   }else if (typeof document.all != "undefined") {
      if(typeof document.getElementById != "undefined") {
         var browser = agent.replace(/.*ms(ie[\/ ][^ $]+).*/, "$1").replace(/ /, "");
         if(typeof document.uniqueID != "undefined") {
            if(browser.indexOf("5.5") != -1) {
               return browser.replace(/(.*5\.5).*/, "$1");
            }else {
               return browser.replace(/(.*)\..*/, "$1");
            }
         }else {
            return "ie5mac";
         }
      }
      return false;
   }else if(typeof document.getElementById != "undefined") {
      if(navigator.vendor.indexOf("Apple Computer, Inc.") != -1) {
         if(typeof window.XMLHttpRequest != "undefined") {
            return "safari1.2";
         }
         return "safari1";
      }else if(agent.indexOf("gecko") != -1) {
         return "mozilla";
      }
   }
   return false;
}

function creatediv(id, html, width, height, left, top, type) {
   var ie6 = false;
   if(identifyBrowser() == 'ie6') {
      ie6 = true;
   }
   var defaultWidth     = 160;
   var defaultHeight    = 160;
   var widthAddition    = 80;
   var newDefaultWidth  = defaultWidth + widthAddition;
   var newDefaultHeight = defaultHeight + widthAddition;
   var rowsWidth        = 0;
   var rowsHeight 	    = 0;
   var posWidth 		= 0;
   var posHeight 	    = 0;
   
   // This is to stop scroll bars appearing on ie6.
   if(width && ie6 == true) {
	   width = width + 30;
   }
   
   // This is to stop scroll bars appearing on ie6.
   if(height && ie6 == true) {
	   height = height + 30;
   }
   
   // Set the correct width for the positioning.
   if(width > defaultWidth) {
      posWidth = width + widthAddition;
   }else {
      posWidth = newDefaultWidth;
   }

   if(height > defaultHeight) {
      posHeight = height + widthAddition;
   }else {
      posHeight = newDefaultHeight;
   }

   // Get users screen and scroll details.
   var scrollPos = getScrollPosition();
   var dimentions = getBrowserSize();
   if(ie6 == true) {
      // This will need looking at to get the correct x pos.
      dimentions[0] = document.getElementById('mainContainer').clientWidth;
   }
   var positionx = (dimentions[0] - posWidth)/2;
   //var positiony = ((dimentions[1] - height)/2) + scrollPos[1];
   var positiony = ((dimentions[1] - posHeight)/2);

   var newdiv = document.createElement('div');
   newdiv.setAttribute('id', id);

   if (width) {
      // Set a minimum size of 160 x 160.
      if(width > defaultWidth) {
         // Set the outer most div width.
         var newWidth = width + widthAddition;
         newdiv.style.width = newWidth + 'px';
         // Set the other div widths.
         rowsWidth = width + 'px';
         var rowsWidthIe6 = width - 20;
      }else {
         // Set the outer most div width.
         newdiv.style.width = newDefaultWidth + 'px';
         // Set the other div widths.
         rowsWidth = defaultWidth + 'px';
      }
   }else {
      // Set the outer most div width.
      newdiv.style.width = newDefaultWidth + 'px';
      // Set the other div widths.
      rowsWidth = defaultWidth + 'px';
   }


   if (height) {
      // Set a minimum size of 160 x 160.
      if(height > defaultHeight) {
         // Set the outer most div height.
         var newHeight = height + widthAddition;
         newdiv.style.height = newHeight + 'px';
         // Set the other div heights.
         rowsHeight = height + 'px';
         var rowsHeightIframe = height - 20;
      }else {
         // Set the outer most div height.
         newdiv.style.height = newDefaultHeight + 'px';
         // Set the other div heights.
         rowsHeight = defaultHeight + 'px';
         var rowsHeightIframe = defaultHeight - 20;
      }
   }else {
      // Set the outer most div height.
      newdiv.style.height = newDefaultHeight + 'px';
      // Set the other div heights.
      rowsHeight = defaultHeight + 'px';
   }

   if(ie6 == true) {
      positiony = positiony + scrollPos[1]
   }
   newdiv.style.left = positionx + 'px';
   newdiv.style.top  = positiony + 'px';

   if(ie6 == true) {
      rowsWidthIframe = rowsWidthIe6;
   }else {
      rowsWidthIframe = rowsWidth;
   }
	
   var completeHTML = '<div id="tl-corner"></div><div style="width:' + rowsWidth + ';" id="t-row"></div><div id="tr-corner"></div><div style="height:' + rowsHeight + ';" id="l-row"></div><div style="width:' + rowsWidth + '; height:' + rowsHeight + ';" id="popupContent"><span id="closeBtn"><a title="Close" href="javascript:closePopup();"><img onmouseover="this.src=\'/images/global/popup/closeOver.gif\'" onmouseout="this.src=\'/images/global/popup/closeUp.gif\'" alt="Close" src="/images/global/popup/closeUp.gif" /></a></span>';
   // iframe for URL's.
   if(type != "id" && type != null && type == "url") {
      completeHTML += '<iframe frameborder="0" width="' + rowsWidthIframe + '" height="' + rowsHeightIframe + '" src="' + html + '" scrolling="auto" align="middle">';
      // else use the ripped html.
   }else if(type == "id" && type != null && type != "url") {
      completeHTML += html;
   }else {
      return false;
   }
   // iframe for URL's.
   if(type != "id" && type != null) {
      completeHTML += '</iframe>';
   }
   completeHTML += '</div><div style="height:' + rowsHeight + ';" id="r-row"></div><div id="bl-corner"></div><div style="width:' + rowsWidth + ';" id="b-row"></div><div id="br-corner"></div>';

   if (html) {
      newdiv.innerHTML = completeHTML;
   } else {
      newdiv.innerHTML = "nothing";
   }

   if(ie6 == true) {
      var newiframe = document.createElement('iframe');
      newiframe.setAttribute('scrolling', 'no');
      newiframe.setAttribute('frameBorder', '0');
      newiframe.setAttribute('src', '/dynamicPopupIFrame.html');
      newiframe.setAttribute('id', 'dynamicPopupIFrame');
      newiframe.style.position = 'absolute';
      newiframe.style.display  = 'block';
      newiframe.style.bgColor  = 'transparent';
      newiframe.style.zIndex   = 0;
      newiframe.style.width    = parseInt(newdiv.style.width) - 48;
      newiframe.style.height   = parseInt(newdiv.style.height) - 49;
      newiframe.style.left     = (positionx + 23) + 'px';
      newiframe.style.top      = (positiony + 23)+ 'px';

      document.getElementById('mainContainer').insertBefore(newiframe,document.getElementById('pageHeader'));
   }

   document.getElementById('mainContainer').insertBefore(newdiv,document.getElementById('pageHeader'));
   
   // Uncomment this once IE6 problem is solved.
   // This is to make the global poup dynamic.
   //document.getElementById('dynamicPopup').makeDraggable();
}

function globalPopUp(content, width, height) {
   // Check if the content is either a div id or a URL.
   var contentType = 'none';
   if(document.getElementById(content)) {
      contentType = 'id';
   }else {
      contentType = 'url';
   }

   // Get the div contents if contentType is an id.
   var popupContent = '';
   if(contentType == 'id') {
      popupContent = document.getElementById(content).innerHTML;
   }else if(contentType == 'url') {
      popupContent = content;
   }else {
      return false;
   }

   // If a popup is already being displayed.
   if(document.getElementById('dynamicPopup')) {
      // Close current popup ready for new one.
      closePopup();
      // Create the div and insert the content.
      creatediv('dynamicPopup', popupContent, width, height, 0, 0, contentType);
   }else {
      // Create the div and insert the content.
      creatediv('dynamicPopup', popupContent, width, height, 0, 0, contentType);
   }
}

function closePopup() {
   var d = document.getElementById('mainContainer');
   var olddiv = document.getElementById('dynamicPopup');
   d.removeChild(olddiv);

   var ie6 			    = false;
   if(identifyBrowser() == 'ie6') {
      var ie6              = true;
   }

   if(ie6 == true) {
      var oldiframe = document.getElementById('dynamicPopupIFrame');
      d.removeChild(oldiframe);
   }
}

// This is for links that open the global popup.
document.onclick = function(e) {
   var target = e ? e.target : window.event.srcElement;
   while (target && !/^(a|body)$/i.test(target.nodeName)) {
      target = target.parentNode;
   }

   if (target && target.getAttribute('rel')) {
      // If no width or height is specified.
      if(target.rel == 'globalPopup') {
         var width = 600;
         var height = 400;
         globalPopUp(target.href,width,height);
         return false;
      }else {
         // If a width and height is given.
         var targetRel = target.rel.split("-");
         if(targetRel[0] == 'globalPopup') {
            var width = parseInt(targetRel[1]);
            var height = parseInt(targetRel[2]);
            globalPopUp(target.href,width,height);
            return false;
         }
      }
   }
}

// Global popup end.

// Show hide.
var dhtmlgoodies_slideSpeed = 50;	// Higher value = faster
var dhtmlgoodies_timer = 1;	// Lower value = faster

var objectIdToSlideDown = false;
var dhtmlgoodies_activeId = false;
var dhtmlgoodies_slideInProgress = false;
function showHideContent(e,inputId)
{

   // Change the words show and hide around.
   var linkText      = document.getElementById('question_link_text').innerHTML;
   var linkTextArray = linkText.split(' ');
   var linkTextArrayCount = linkTextArray.length;
   var newLinkText = '';

   for(var inc=0; inc<=linkTextArrayCount; inc++) {
      if(linkTextArray[inc] == 'Show') {
         newLinkText += 'Hide ';
      }else if(linkTextArray[inc] == 'show') {
         newLinkText += 'hide ';
      }else if(linkTextArray[inc] == 'hide') {
         newLinkText += 'show ';
      }else if(linkTextArray[inc] == 'Hide') {
         newLinkText += 'Show ';
      }else if(linkTextArray[inc] != undefined) {
         newLinkText += linkTextArray[inc] + ' ';
      }
   }

   document.getElementById('question_link_text').innerHTML = newLinkText;

   if(dhtmlgoodies_slideInProgress)return;
   dhtmlgoodies_slideInProgress = true;
   if(!inputId)inputId = this.id;
   inputId = inputId + '';
   var numericId = inputId.replace(/[^0-9]/g,'');
   var answerDiv = document.getElementById('dhtmlgoodies_a' + numericId);

   objectIdToSlideDown = false;

   if(!answerDiv.style.display || answerDiv.style.display=='none'){
      if(dhtmlgoodies_activeId &&  dhtmlgoodies_activeId!=numericId){
         objectIdToSlideDown = numericId;
         slideContent(dhtmlgoodies_activeId,(dhtmlgoodies_slideSpeed*-1));
      }else{

         answerDiv.style.display='block';
         answerDiv.style.visibility = 'visible';

         slideContent(numericId,dhtmlgoodies_slideSpeed);
      }
   }else{
      slideContent(numericId,(dhtmlgoodies_slideSpeed*-1));
      dhtmlgoodies_activeId = false;
   }
}

function slideContent(inputId,direction)
{

   var obj =document.getElementById('dhtmlgoodies_a' + inputId);
   var contentObj = document.getElementById('dhtmlgoodies_ac' + inputId);
   height = obj.clientHeight;
   if(height==0)height = obj.offsetHeight;
   height = height + direction;
   rerunFunction = true;
   if(height>contentObj.offsetHeight){
      height = contentObj.offsetHeight;
      rerunFunction = false;
   }
   if(height<=1){
      height = 1;
      rerunFunction = false;
   }

   obj.style.height = height + 'px';
   var topPos = height - contentObj.offsetHeight;
   if(topPos>0)topPos=0;
   contentObj.style.top = topPos + 'px';
   if(rerunFunction){
      setTimeout('slideContent(' + inputId + ',' + direction + ')',dhtmlgoodies_timer);
   }else{
      if(height<=1){
         obj.style.display='none';
         if(objectIdToSlideDown && objectIdToSlideDown!=inputId){
            document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.display='block';
            document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.visibility='visible';
            slideContent(objectIdToSlideDown,dhtmlgoodies_slideSpeed);
         }else{
            dhtmlgoodies_slideInProgress = false;
         }
      }else{
         dhtmlgoodies_activeId = inputId;
         dhtmlgoodies_slideInProgress = false;
      }
   }
}



function initShowHideDivs()
{
   var divs = document.getElementsByTagName('DIV');
   var divCounter = 1;
   for(var no=0;no<divs.length;no++){
      if(divs[no].className=='dhtmlgoodies_question'){
         divs[no].onclick = showHideContent;
         divs[no].id = 'dhtmlgoodies_q'+divCounter;
         var answer = divs[no].nextSibling;
         while(answer && answer.tagName!='DIV'){
            answer = answer.nextSibling;
         }
         answer.id = 'dhtmlgoodies_a'+divCounter;
         contentDiv = answer.getElementsByTagName('DIV')[0];
         contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px';
         contentDiv.className='dhtmlgoodies_answer_content';
         contentDiv.id = 'dhtmlgoodies_ac' + divCounter;
         answer.style.display='none';
         answer.style.height='1px';
         divCounter++;
      }
   }
}
window.onload = initShowHideDivs;

// Show hide end.

// Fade the strap line in/out.
for(var count=1; count<lineArraySize; count++) {
	//tagWindow.fadeIn(250);
	//alert(count);
	
	if(count == lineArraySize) {
		count = count - lineArraySize;
	}
}

var lineArray;
var lineArraySize;
var tagWindow;
var count = 0;

function tagLineInnit() {
	lineArray     = getElementsByClassName('tagLine');
	lineArraySize = lineArray.length;
	tagWindow     = document.getElementById('tagWindow');
	changeTagLine();
	if(lineArraySize > 1) {
		setInterval("changeTagLine()",8000);
	}
}

function changeTagLine() {
	
	tagWindow.innerHTML = lineArray[count++].innerHTML;
	
	if(count == lineArraySize) {
		count = 0;
	}
}

if(document.getElementById('tagWindow')) {
	addLoadListener(tagLineInnit);
}
// Fade the strap line in/out end.

// Global Tool tip.
function tooltipStarter(e) {
	var elementRef = '';
	var type       = '';
	if(getEventTarget(e).rel) {
		elementRef = getEventTarget(e).rel;
		type       = 'rel';
	}else if(getEventTarget(e).title) {
		elementRef = getEventTarget(e).title;
		type	   = 'title';
	}else {
		return false;
	}
	
	tooltip.show(elementRef,type);
}

function tooltipHider() {
	tooltip.hide();
}

var tooltip=function(){
	var id = 'tt';
	var top = 3;
	var left = 3;
	var maxw = 300;
	var speed = 15;
	var timer = 20;
	var endalpha = 95;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
	return{
		show:function(v,t,w){
			if(tt == null){
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				t = document.createElement('div');
				t.setAttribute('id',id + 'top');
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				b = document.createElement('div');
				b.setAttribute('id',id + 'bot');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
				tt.style.opacity = 0;
				tt.style.filter = 'alpha(opacity=0)';
				document.onmousemove = this.pos;
			}
			tt.style.display = 'block';
			
			// Set the tool tips innerHTML to be
			// a div on page that contains the content.
			//c.innerHTML = v;
			// We can use either link titles or divs.
			if(t == 'title') {
				c.innerHTML = v;
			}else {
				c.innerHTML = document.getElementById(v).innerHTML;
			}
			
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				//t.style.display = 'none';
				//b.style.display = 'none';
				//tt.style.width = tt.offsetWidth;
				//t.style.display = 'block';
				//b.style.display = 'block';
			}
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(1)},timer);
		},
		pos:function(e){
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			tt.style.top = (u - h) + 'px';
			tt.style.left = (l + left) + 'px';
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(tt.timer);
				if(d == -1){tt.style.display = 'none'}
			}
		},
		hide:function(){
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();

function pageHotSpotsFunction() {
	var pageHotSpots   = getElementsByClassName('hotspot');
	var pageHotSpotsNo = pageHotSpots.length;
	for(var hotspotCount=0; hotspotCount<pageHotSpotsNo; hotspotCount++) {
		attachEventListener(pageHotSpots[hotspotCount], "mouseover", tooltipStarter, false);
		attachEventListener(pageHotSpots[hotspotCount], "mouseout", tooltipHider, false);
	}
	
}

if(getElementsByClassName('hotspot')) {
	addLoadListener(pageHotSpotsFunction);
}

// Global Tool tip end.

// This is for the main handset drop down.
function selectphone() {
	var form = document.getElementById('phonesel');
	var dropindex = document.getElementById('phonesel').selectedIndex;
	location.href = form.options[dropindex].value;
}

function submitDealFinderForm() {
	document.mainsearch.submit();
}

function browserGoBack() {
	history.go(-1);
}

function historyBackFunction() {
	var btn = document.getElementById('historyBack');
	attachEventListener(btn, "click", browserGoBack, false);
}

// Listen to the top submit button.
function listenTopSubmitBtn() {
	var topBtn = document.getElementById('topSubmitBtn');
	attachEventListener(topBtn, "click", submitDealFinderForm, false);
}

// This is so we can send users back.
if(document.getElementById('historyBack')) {
	addLoadListener(historyBackFunction);
}

// This is for the top submit button on the deal finders.
if(document.getElementById('topSubmitBtn')) {
	addLoadListener(listenTopSubmitBtn);
}

function trackPage(pagename) {
	// Added 04/09/2008 by CS
	// This function enables a tag to be recorded in Google Analytics when a page is loaded
	// Amended 24/11/2008 by CS
	// chnaged the tracking from urchinTracker() to pageTracker._trackPageview()
	addLoadListener(function() {
		urchinTracker(pagename);
		//pageTracker._trackPageview(pagename);
	});
}