
function set_element_handler_by_class(tagType, className, eventType, functionName)
{
	elements = document.getElementsByTagName(tagType);
	for (var ii = 0; ii < elements.length; ii++)
	{
		if (elements[ii].className.indexOf(className) >= 0)
		{
			var code = "elements[ii]." + eventType + " = " + functionName;
			eval(code);
		}
	}
}

function removePromoCode(promoCode) {
	document.frmOrder.action.value = "removepromo";
	document.frmOrder.actionvalue.value = promoCode;
	document.frmOrder.submit();
}

function highlightRow()
{
	if (this.className != 'on')
	{
		this.className = 'highlight';
	}
}

function unhighlightRow()
{
	if (this.className != 'on')
	{
		this.className = 'row';
	}
}

function highlightHeader()
{
		this.className = 'plan_ov';
}

function unhighlightHeader()
{
		this.className = '';
}


function toggle_row(elementID)
{
// Change feature row style
  toggleclass(elementID, "on", "");

// Now togle the two links and the extrainfo div.
  extrainfobox = elementID + "_info";
  showmorelink = extrainfobox + "_more";
  showlesslink = extrainfobox + "_less";

  toggleme(extrainfobox);
  toggleme(showmorelink);
  toggleme(showlesslink);		  
}


function toggleclass(element, class1, class2)
{
  el = document.getElementById(element);
  
	if (el.className == class1)
	{
	  el.className = class2;
	}
	else
	{
	  el.className = class1;	
	}
}


function closefull()
{
	toggleme('opacitize', '0');
	toggleme('fullimagebox');
}


// SHOW/HIDE Full-size image. Uses DOM to insert/replace the image in "fullimagebox" DIV
function togglefull(imgUrl)  
{      
	//Functions that grab screen dimensions
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	//ID's for affected html elements	
	fullboxID = 'fullimagebox';
	fulllnkID = 'fullimglnk';
	fullimgID = 'fullimg';

	fullbox = document.getElementById(fullboxID);
	fullbox.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 500) / 2) + 'px');
	fullbox.style.left = (((arrayPageSize[0] - 600) / 2) + 'px');

	toggleme('opacitize', '0');

	//Wierd IE7 Bug: If height of opacitize div is over 4096, it won't accept an alpha transparency effect. Workaround:
	if (arrayPageSize[1] > 4096 && document.all) 
	{ 
	document.getElementById('opacitize').style.height = '4096px'; 
	}
	else //do the intended thing
	{
	document.getElementById('opacitize').style.height = (arrayPageSize[1] + 'px');     
	}

	// Bug in IE6 where dropdown boxes show through
	var dropDowns = document.getElementsByTagName('select');
	for (var ii = 0; ii < dropDowns.length; ii++)
	{
		if (dropDowns[ii].style.display == 'none')
		{
			dropDowns[ii].style.display = '';
		}
		else
		{
			dropDowns[ii].style.display = 'none';
		}
	}

	//If IE, force alpha transparency using the "filter" property      
	if (document.all) { document.getElementById('opacitize').style.filter = 'alpha(opacity=50)';}

	toggleme(fullboxID);

	oldimgID = document.getElementById(fullimgID);
	var fullimage=document.createElement('img');	
	fullimage.onload = removebackground; //when image has loaded, change the class of div
	fullimage.src= imgUrl; 
	fullimage.id= fullimgID;
	document.getElementById(fulllnkID).replaceChild(fullimage,oldimgID);

	function removebackground() 
	{
	fullbox.className='imageloaded';
	}
    
}

function closevotingpopup(dontremind)
{
	if (document.getElementById('hintpop') != null)
	{
		var hintpop = document.getElementById('hintpop');
		if (dontremind == "never")
		{
			// Then we are going to start an ajax transaction
			var ajaxurl = '/ajaxserver/dontremindvotingpopup.php5';
			var postString = 'dontremind=1';
			
			// Prevent IE caching
			var d = new Date();
			var t = d.getTime();
			postString += '&TIME=' + t;
			loadXMLDocPost(ajaxurl, postString);
		}
		else
		{
			finishClosingVotingPopup();
		}
	}
}

function finishClosingVotingPopup()
{
	if (document.getElementById('hintpop') != null)
	{
		toggleme('hintpop');
		toggleme('opacitize', '0');
	}
}

// SHOW/HIDE ITEMS

function delay()
{
  return true;	
}

function toggleme(element,fade) //Set fade to 0 if you don't want the fade effect. Default is on.
{	
	// Make sure the element actually exists
	if (document.getElementById(element) != null)
	{
		if (document.getElementById(element).style.display == 'none') 
		{
			// Then we are going to display it
			document.getElementById(element).style.display = ''; 
			if (fade != 0)
			{
				// Then they asked for it to be faded in
				fademein(element);
			}
		}  
		else 
		{
			// We are going to hide it
			document.getElementById(element).style.display = 'none'; 	   
		}
	}
}


function toggleme2(element)
{
 
  if(document.getElementById(element).style.visibility =='hidden') 
  {
	showme(element);
  }  else {
	document.getElementById(element).style.visibility ='hidden'; 	   
  }
}

function showme(element)
{
	if (document.getElementById(element) != null)
	{
		if( document.getElementById(element).style.display == 'none') 
		{
			document.getElementById(element).style.display =''; 
			fademein(element);
		}
		
		if (document.getElementById(element).style.visibility == 'hidden') 
		{
			document.getElementById(element).style.visibility ='visible'; 
			fademein(element);
		}
	}
}

function hideme(elementID)
{
  
  element = document.getElementById(elementID);
  
  if(element.style.display =='') 
  {
	element.style.display ='none'; 
  }
}

// END SHOW/HIDE ITEMS

//GENERAL FADE EFFECTS FOR UNIQUE ELEMENTS
function fademein(element)
{
  var e = document.getElementById(element);
  fadesomething = new Fadomatic(e, 20, 1);
  fadesomething.fadeIn(); 	
}

function fademeout(element)
{
  var e = document.getElementById(element);
  fadesomething = new Fadomatic(e, 20, 100);
  fadesomething.fadeOut(); 	
}
//END GENERAL FADE EFFECTS FOR 

function removetip()
{
    var e = document.getElementById("tip");
	if(window.fadeouttip)  fadeouttip.haltFade();
 	fadeouttip = new Fadomatic(e, 25, 100); //global
	clearTimeout(tipTimer);
	fadeouttip.fadeOut(); 			
}

function getPosition(element)
{
	alert(document.getElementById(element).style.left);
}

//END TESTING
function el(name)
{
  return document.getElementById( name );
}


function changedisplay(element,display)
{
  if (display=='on') 
  {  document.getElementById(element).style.display =''; }
  else
  { document.getElementById(element).style.display ='none';}
}


function highlight(itemid)
{
  rowid = 'row' + itemid;
  row = document.getElementById(rowid);
  
  if(row.className != 'marked') 
  {
    row.className = 'highlighted';
  }

}


function dehighlight(itemid)  
{
  rowid = 'row' + itemid;

  if (document.getElementById(rowid).className !='marked')
  {
	row.className = '';
  }
}


// Change style class on any object
function changeclass(id, newClass) {
identity=document.getElementById(id);
identity.className=newClass;
}


/* Currently unused:  Left her for example */
function newitemfade(itemid)  
{
  var row = document.getElementById( 'row' + itemid );
    
	var fade = new Fade(row, '#c8e9f1', '#e4f4ba', 150, 15, 0); 
    fade.init();	
  
}




//------------OPACITY FADE EFFECT------------------//


// Fade interval in milliseconds
// Make this larger if you experience performance issues
Fadomatic.INTERVAL_MILLIS = 50;

// Creates a fader
// element - The element to fade
// speed - The speed to fade at, from 0.0 to 100.0
// initialOpacity (optional, default 100) - element's starting opacity, 0 to 100
// minOpacity (optional, default 0) - element's minimum opacity, 0 to 100
// maxOpacity (optional, default 0) - element's minimum opacity, 0 to 100
function Fadomatic (element, rate, initialOpacity, minOpacity, maxOpacity) {
  this._element = element;
  this._intervalId = null;
  this._rate = rate;
  this._isFadeOut = true;

  // Set initial opacity and bounds
  // NB use 99 instead of 100 to avoid flicker at start of fade
  
  // I chose to use 100 to avoid a jagged text bug in Google Chrome. I have not seen a flicker issue. -ss
  this._minOpacity = 0;
  this._maxOpacity = 100;
  this._opacity = 100;

  if (typeof minOpacity != 'undefined') {
    if (minOpacity < 0) {
      this._minOpacity = 0;
    } else if (minOpacity > 99) {
      this._minOpacity = 99;
    } else {
      this._minOpacity = minOpacity;
    }
  }

  if (typeof maxOpacity != 'undefined') {
    if (maxOpacity < 0) {
      this._maxOpacity = 0;
    } else if (maxOpacity > 99) {
      this._maxOpacity = 99;
    } else {
      this._maxOpacity = maxOpacity;
    }

    if (this._maxOpacity < this._minOpacity) {
      this._maxOpacity = this._minOpacity;
    }
  }
  
  if (typeof initialOpacity != 'undefined') {
    if (initialOpacity > this._maxOpacity) {
      this._opacity = this._maxOpacity;
    } else if (initialOpacity < this._minOpacity) {
      this._opacity = this._minOpacity;
    } else {
      this._opacity = initialOpacity;
    }
  }

  // See if we're using W3C opacity, MSIE filter, or just
  // toggling visiblity
  if(typeof element.style.opacity != 'undefined') {

    this._updateOpacity = this._updateOpacityW3c;

  } else if(typeof element.style.filter != 'undefined') {

    // If there's not an alpha filter on the element already,
    // add one
    if (element.style.filter.indexOf("alpha") == -1) {

      // Attempt to preserve existing filters
      var existingFilters="";
      if (element.style.filter) {
        existingFilters = element.style.filter+" ";
      }
      element.style.filter = existingFilters+"alpha(opacity="+this._opacity+")";
    }

    this._updateOpacity = this._updateOpacityMSIE;
    
  } else {

    this._updateOpacity = this._updateVisibility;
  }

  this._updateOpacity();
}

// Initiates a fade out
Fadomatic.prototype.fadeOut = function () {
  this._isFadeOut = true;
  this._beginFade();
}

// Initiates a fade in
Fadomatic.prototype.fadeIn = function () {
  this._isFadeOut = false;
  this._beginFade();
}

// Makes the element completely opaque, stops any fade in progress
Fadomatic.prototype.show = function () {
  this.haltFade();
  this._opacity = this._maxOpacity;
  this._updateOpacity();
}

// Makes the element completely transparent, stops any fade in progress
Fadomatic.prototype.hide = function () {
  this.haltFade();
  this._opacity = 0;
  this._updateOpacity();
}

// Halts any fade in progress
Fadomatic.prototype.haltFade = function () {

  clearInterval(this._intervalId);
}

// Resumes a fade where it was halted
Fadomatic.prototype.resumeFade = function () {

  this._beginFade();
}

// Pseudo-private members

Fadomatic.prototype._beginFade = function () {

  this.haltFade();
  var objref = this;
  this._intervalId = setInterval(function() { objref._tickFade(); },Fadomatic.INTERVAL_MILLIS);
}

Fadomatic.prototype._tickFade = function () {

  if (this._isFadeOut) {
    this._opacity -= this._rate;
    if (this._opacity < this._minOpacity) {
      this._opacity = this._minOpacity;
      this.haltFade();
    }
  } else {
    this._opacity += this._rate;
    if (this._opacity > this._maxOpacity ) {
      this._opacity = this._maxOpacity;
      this.haltFade();
    }
  }

  this._updateOpacity();
}

Fadomatic.prototype._updateVisibility = function () {
  
  if (this._opacity > 0) {
    this._element.style.visibility = 'visible';
  } else {
    this._element.style.visibility = 'hidden';
  }
}

Fadomatic.prototype._updateOpacityW3c = function () {
  
  this._element.style.opacity = this._opacity/100;
  this._updateVisibility();
}

Fadomatic.prototype._updateOpacityMSIE = function () {
  
  this._element.filters.alpha.opacity = this._opacity;
  this._updateVisibility();
}

Fadomatic.prototype._updateOpacity = null;

//------------ END FADE EFFECT ------------------//






//------------ COLOR FADE EFFECT (Currently Unused)------------------//
/* 

Script to gradually change background colour of an element

References: 
   http://www.37signals.com/svn/archives/000558.php
   http://www.meyerweb.com/eric/tools/color-blend/

Future work: 
   Could change foreground, border colours
   Transparency

*/

function Fade(id, startColour, endColour, count, speed, delay ) {

  /* Properties */

  this.id = id;                    /* id/object ref of element to fade */
  this.startColour = startColour;  /* initial colour (3 or 6 digit) hex */
  this.endColour = endColour;      /* final colour (3 or 6 digit) hex */
  this.count = count;              /* No of steps to take during fade */
  this.speed = speed;              /* Delay in ms between steps */
  this.delay = delay;              /* Initial delay before fade begins */

  if (typeof this.id == "string") {
    this.obj = document.getElementById(id);  
  } else {
    this.obj = this.id;
  }
  this.colour = new Array();
  this.steps = 0;

  /* Methods */

  this.init = init;
  this.fade = fade;
  this.parseColour = parseColour;

  function init() {

    first = this.parseColour(this.startColour, 'hex');
    last = this.parseColour(this.endColour, 'hex');

    this.colour = new Array();
    this.colour[this.count] = this.startColour;
    for (i=0; i<this.count; i++) {
      temp = "rgb(";
      temp += parseInt(first[0]+(last[0]-first[0])/this.count*i);
      temp += ",";
      temp += parseInt(first[1]+(last[1]-first[1])/this.count*i);
      temp += ",";
      temp += parseInt(first[2]+(last[2]-first[2])/this.count*i);
      temp += ")";
      this.colour[this.count-i] = temp;
    }
    this.colour[0] = this.endColour;

    var thisObj = this;
    setTimeout( function() { thisObj.fade() }, this.delay);

  }

  function fade() {
      
    if (this.count >= 0) {

      this.obj.style.backgroundColor = this.colour[this.count--];

      // I want to do this:
      // setTimeout("this.fade()", init.speed);
      // but setTimeout runs in a different thread so 'this' 
      // is out of context. 
      // See: http://www.faqts.com/knowledge_base/view.phtml/aid/2311

      var thisObj = this;
      setTimeout( function() { thisObj.fade() }, this.speed);

    }
  }

  function parseColour(colour, t) {
    /* From: http://www.meyerweb.com/eric/tools/color-blend/ */
    var m = 1;
    col = colour.replace(/[\#rgb\(]*/,'');
    if (t == 'hex') {
      if (col.length == 3) {
        a = col.substr(0,1);
        b = col.substr(1,1);
        c = col.substr(2,1);
        col = a + a + b + b + c + c;
      }
      var num = new Array(col.substr(0,2),col.substr(2,2),col.substr(4,2));
      var base = 16;
    } else {
      var num = col.split(',');
      var base = 10;
    }
    if (t == 'rgbp') {m = 2.55}
    var ret = new Array(parseInt(num[0],base)*m,parseInt(num[1],base)*m,parseInt(num[2],base)*m);
    return(ret);
  }
}

//------------ END COLOR FADE EFFECT ------------------//

//------------ ToolTip code ---------------------------//
var showTp = 0;

function showToolTip(id)
{
   showTp = 1;
   var d = new Date();
   var t = d.getTime();
   var ajaxurl = '/ajaxserver/tooltips.php5?tooltip_id=' + id + '&time=' + t; 
   loadXMLDoc(ajaxurl);
}

function setToolTip(input, results, success)
{
   if (success == 1)
   {
      var szText = results[0].getElementsByTagName('tooltip')[0].firstChild.data;
      if (showTp == 1)
         overlib(szText, LEFT);
   }
}

function getPolls( search, searchdisp, userid )
{
   document.mysearch.advsearchoptions.value = search;
   document.mysearch.searchtxt.value = searchdisp;
   if( document.mysearch.userid )
     document.mysearch.userid.value = userid;
   document.mysearch.submit();
}

function addToNotify(topicid)
{
	var topicid = topicid;
	var postURI = '/ajaxserver/addtonotify.php5';
	
	// now prevent IE caching
	var d = new Date();
	var t = d.getTime();
	postString = 'topicid=' + topicid + '&TIME=' + t;

	// Now send the request away
	loadXMLDocPost(postURI, postString);
}

function addNotifyDone( input, results, success )
{
	var modmsg = document.getElementById( 'commentremovenotifymsg' );
	modmsg.style.display = 'none';
	
	var modmsg = document.getElementById( 'commentnotifymsg' );
	modmsg.style.display = 'none';
	
	var modmsg = document.getElementById( 'answernotifymsg' );
	modmsg.style.display = '';
	
	var modmsg = document.getElementById( 'answerremovenotifymsg' );
	modmsg.style.display = 'none';
	
	var notify = document.getElementById( 'notifymeanswers' );
	notify.style.display = 'none';
	
	var notifyoff = document.getElementById( 'notifymeanswersoff' );
	notifyoff.style.display = '';
}

function removeFromNotify(topicid)
{
	var topicid = topicid;
	var postURI = '/ajaxserver/removefromnotify.php5';
	
	// now prevent IE caching
	var d = new Date();
	var t = d.getTime();
	postString = 'topicid=' + topicid + '&TIME=' + t;

	// Now send the request away
	loadXMLDocPost(postURI, postString);
}

function removeFromNotifyDone( input, results, success )
{
	var modmsg = document.getElementById( 'commentremovenotifymsg' );
	modmsg.style.display = 'none';
	
	var modmsg = document.getElementById( 'commentnotifymsg' );
	modmsg.style.display = 'none';
	
	var modmsg = document.getElementById( 'answerremovenotifymsg' );
	modmsg.style.display = '';
	
	var modmsg = document.getElementById( 'answernotifymsg' );
	modmsg.style.display = 'none';
	
	var notify = document.getElementById( 'notifymeanswers' );
	notify.style.display = '';
	
	var notifyoff = document.getElementById( 'notifymeanswersoff' );
	notifyoff.style.display = 'none';
}

function commentNotify(contentid, contenttype, remove)
{
	var contentid = contentid;
	var contenttype = contenttype;
	var remove = remove;
	var postURI = '/ajaxserver/commentnotify.php5';
	
	// now prevent IE caching
	var d = new Date();
	var t = d.getTime();
	postString = 'contentid=' + contentid + '&contenttype=' + contenttype + '&remove=' + remove + '&TIME=' + t;

	// Now send the request away
	loadXMLDocPost(postURI, postString);
}

function commentNotifyDone( input, results, success )
{
  var removeaction = results[0].getElementsByTagName('actionremove')[0].firstChild.data;
  
  var modmsg = document.getElementById( 'answerremovenotifymsg' );
  if (modmsg != undefined)
     modmsg.style.display = 'none';
  var modmsg = document.getElementById( 'answernotifymsg' );
  if (modmsg != undefined)
     modmsg.style.display = 'none';
  
  if (removeaction == "0") // we removed the notification
  {
     var modmsg = document.getElementById( 'commentremovenotifymsg' );
     modmsg.style.display = 'none';
     var modmsg = document.getElementById( 'commentnotifymsg' );
     modmsg.style.display = '';
     var notify = document.getElementById( 'notifymecomment' );
     notify.style.display = 'none';
     var notifyoff = document.getElementById( 'notifymecommentoff' );
     notifyoff.style.display = '';
  }
  else
  {
     var modmsg = document.getElementById( 'commentremovenotifymsg' );
     modmsg.style.display = '';
     var modmsg = document.getElementById( 'commentnotifymsg' );
     modmsg.style.display = 'none';
     var notify = document.getElementById( 'notifymecomment' );
     notify.style.display = '';
     var notifyoff = document.getElementById( 'notifymecommentoff' );
     notifyoff.style.display = 'none';
  }
}

function modComment( id, mod )
{
  var ajaxurl = '/ajaxserver/modcomment.php5?id=' + id + '&mod=' + mod;
  loadXMLDoc(ajaxurl);
}

function modCommentDone( input, results, success )
{
  var id = results[0].getElementsByTagName('commentid')[0].firstChild.data;
  id = parseInt( id, 10 );
  var mod = results[0].getElementsByTagName('moderation')[0].firstChild.data;

  // first, turn them all on
  document.getElementById( 'modhelpful' + id ).className = '';
  document.getElementById( 'modunhelpful' + id ).className = '';
  document.getElementById( 'modinappropriate' + id ).className = '';

  // then, turn the selected one off
  document.getElementById( 'mod' + mod + id ).className = 'disabled';

  var modmsg = document.getElementById( 'commentmodmsg' + id );
  modmsg.style.display = '';
}

function modAnswer( id, mod, deleteme )
{
  var ajaxurl = '/ajaxserver/modanswer.php5?id=' + id + '&mod=' + mod;
  if (deleteme)
     ajaxurl += '&delete=1';
  // now prevent IE caching
   var d = new Date();
   var t = d.getTime();
   ajaxurl += '&TIME=' + t;
  loadXMLDoc(ajaxurl);
}

function modAnswerDone( input, results, success )
{
  var id = results[0].getElementsByTagName('answerid')[0].firstChild.data;
  id = parseInt( id, 10 );
  var mod = results[0].getElementsByTagName('moderation')[0].firstChild.data;
  var on = results[0].getElementsByTagName('on')[0].firstChild.data;

  // first, turn them all on
  //document.getElementById( 'modinappropriate' + id ).className = '';
  //document.getElementById( 'modadult' + id ).className = '';

  // then, turn the selected one off
  // document.getElementById( 'mod' + mod + id ).className = 'disabled';
  
  if (mod == 'adult')
  {
     var modadult = document.getElementById( 'modadult' + id);
     if (on == "1")
     {
        modadult.firstChild.data = 'Not Adult';
        modadulton = true;
     }
     else
     {
        modadult.firstChild.data = 'Adult';
        modadulton = false;
     }
  }
  else if (mod == 'inappropriate')
  {
     var modinap = document.getElementById( 'modinappropriate' + id);
     if (on == "1")
     {
        modinap.firstChild.data = 'Relevant';
        modinapon = true;
     }
     else
     {
        modinap.firstChild.data = 'Not Relevant';
        modinapon = false;
     }
  }

  var modmsg = document.getElementById( 'answermodmsg' + id );
  modmsg.style.display = '';
}

function modPoll( id, mod, deleteme )
{
  var ajaxurl = '/ajaxserver/modpoll.php5?id=' + id + '&mod=' + mod;
  if (deleteme)
     ajaxurl += "&delete=1";
  // now prevent IE caching
   var d = new Date();
   var t = d.getTime();
   ajaxurl += '&TIME=' + t;
  loadXMLDoc(ajaxurl);
}

function modPollDone( input, results, success )
{
  var id = results[0].getElementsByTagName('pollid')[0].firstChild.data;
  id = parseInt( id, 10 );
  var mod = results[0].getElementsByTagName('moderation')[0].firstChild.data;
  var on = results[0].getElementsByTagName('on')[0].firstChild.data;

  var pollmod = document.getElementById( 'pollmodadult' + id );
  if (on == "1")
  {
     pollmod.firstChild.data = "Not Adult";
     modadulton = true;
  }
  else
  {
     pollmod.firstChild.data = "Adult";
     modadulton = false;
  }

  var modmsg = document.getElementById( 'pollmodmsg' + id );
  modmsg.style.display = '';
}


function addToSessionAynom(key, value)
{
  var ajaxurl = '/ajaxserver/addtosession.php5?key=' + key + '&value=' + value;
  // now prevent IE caching
   var d = new Date();
   var t = d.getTime();
   ajaxurl += '&TIME=' + t;
   loadAynomXMLDoc(ajaxurl);
}

function addToSession(key, value)
{
  var ajaxurl = '/ajaxserver/addtosession.php5?key=' + key + '&value=' + value;
  // now prevent IE caching
   var d = new Date();
   var t = d.getTime();
   ajaxurl += '&TIME=' + t;
   loadXMLDoc(ajaxurl);
}

function genericAjaxSuccess( input, results, success )
{
  // call the overide function if it is defined
  if (self.genericOveride) 
     genericOveride();
}

//-------------------Positioning -------------------------//

function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

//------------------End Positioning ----------------------//

		/*********************************************************************
		 * No onMouseOut event if the mouse pointer hovers a child element 
		 * *** Please do not remove this header. ***
		 * This code is working on my IE7, IE6, FireFox, Opera and Safari
		 * 
		 * Usage: 
		 * <div onMouseOut="fixOnMouseOut(this, event, 'JavaScript Code');"> 
		 *		So many childs 
		 *	</div>
		 *
		 * @Author Hamid Alipour Codehead @ webmaster-forums.code-head.com		
		**/
		function is_child_of(parent, child) {
			if( child != null ) {			
				while( child.parentNode ) {
					if( (child = child.parentNode) == parent ) {
						return true;
					}
				}
			}
			return false;
		}
		function fixOnMouseOut(element, event, JavaScript_code) {
			var current_mouse_target = null;
			if( event.toElement ) {				
				current_mouse_target 			 = event.toElement;
			} else if( event.relatedTarget ) {				
				current_mouse_target 			 = event.relatedTarget;
			}
			if( !is_child_of(element, current_mouse_target) && element != current_mouse_target ) {
				eval(JavaScript_code);
			}
		}
		/*********************************************************************/
