/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	dynamically create a "suspended" cover for passed ID
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function BN_SuspLayer(sID) {
	//	create hiding iFrame object
	var sTemplateID = "Susp" + sID;
	var oDiv = document.getElementById(sTemplateID);
	
	if (!oDiv) {
		var sTemplateHolderID = "th" + sID.substring(1);
		var oCont = document.getElementById(sTemplateHolderID);

		var oBO = document.getElementById(sID);
		
		if (!oBO) return null;
		if ( oBO.className.indexOf("BOsusp") == -1 )
			oBO.className += " BOsusp";

/*
		
	alert(oCont);
		if (oCont) {			
			var nLeft = xLeft(oBO);
			var nTop = xTop(oBO);
	alert(nLeft);
		} else {//	this market is in the coupon. find the parent to insert it
			oCont = oBO;
			var nLeft = 0;
			var nTop = 0;
			while (oCont) {
				if (oCont.tagName.toUpperCase() == "BODY") break;
				nLeft += oCont.offsetLeft;
				nTop += oCont.offsetTop;
				//alert(xDef(oCont.offsetParent));
				
				if (xDef(oCont.offsetParent)) oCont = oCont.offsetParent;
				else break;
				
			}
	alert(nLeft);
			
		}
*/

		oCont = document.getElementsByTagName("body")[0];

		nTop = xTop(oBO);
		nLeft = xLeft(oBO);

//		alert(nTop + "|" + nLeft);
		
		if (oCont) {
			oCont.insertAdjacentHTML("afterBegin", '<div id="' + sTemplateID + '" class="susp">&nbsp;Suspended</div>');
			oDiv = document.getElementById(sTemplateID);
			
			var nWidth = xWidth(oBO);
			var nHeight = xHeight(oBO);

			xWidth(oDiv, nWidth-2);
			xHeight(oDiv, nHeight-2);
			xLeft(oDiv, nLeft);
			xTop(oDiv, nTop);
		}
	}
	
	return oDiv;
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	move cover over the template
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function BN_Suspend(sID) {

	if (sID.substring(0,1) != 't') sID = 't' + sID;
	
	var oLayer = BN_SuspLayer(sID);
	if (oLayer)
		xShow(oLayer);
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	move cover away from template
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function BN_Unsuspend(sID) {
	
	if (sID.substring(0,1) != 't') sID = 't' + sID;
	
	var oLayer = BN_SuspLayer(sID);
	if (oLayer)
		xHide(oLayer);

	var oBO = document.getElementById(sID);
	oBO.className.replace(" BOsusp", "");
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	reposition layer when child coupon template is collapsed
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function BN_SuspRepos(oLayer) {
	if (typeof(oLayer) == "object") {
		if ( !xIsOn(oLayer) ) return;

		var sID = oLayer.id.substring(4);
		oCont = document.getElementById(sID);
		var nTop = 0;

		while (oCont) {
			if (oCont.className.indexOf("cpntemplateholder") != -1 ) break;
			nTop += oCont.offsetTop;
			if (xDef(oCont.offsetParent)) oCont = oCont.offsetParent;
			else break;
		}

		if (oCont) {
			xTop(oLayer, nTop);
		}
	}
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	global function that calls suspending onload
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function BN_SuspendList() {
	var aTmp = xGetElementsByClassName("BOsusp");
	for (var i=0;i<aTmp.length;i++) {
		BN_Suspend(aTmp[i].id);
	}
}



/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Variables
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
var xOp7 = false, xIE = false, xUA = navigator.userAgent.toLowerCase();
if (window.opera) {
	xOp7 = ( xUA.indexOf("opera 7") != -1 || xUA.indexOf("opera/7") != -1 );
} else {
	xIE = ( xUA.indexOf("msie") != -1 );
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Appearance
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function xOn(e, sV) {
	if ( !(e = xGetElementById(e)) ) return;
	if ( xDef(sV) )
		e.style.display = sV;
	else
		e.style.display = "block";
}
function xOff(e) {
	if ( !(e = xGetElementById(e)) ) return;
	e.style.display = "none";
}
function xIsOn(e) {
	if ( !(e = xGetElementById(e)) ) return;
	var bRet = true;
	if (e.style.display == "") {
		bRet = !(xGetAnyCS(e, "display") == "none");
	} else {
		bRet = !(e.style.display == "none");
	}
	return bRet;
}
function xShow(e) {
	if ( !(e = xGetElementById(e)) ) return;
	e.style.visibility = "visible"; // v3.12, e.style.visibility='inherit';
}
function xHide(e) {
	if ( !(e = xGetElementById(e)) ) return;
	e.style.visibility = "hidden";
}
function xIsShown(e) {
	if ( !(e = xGetElementById(e)) ) return;
	var bRet = true;
	if (e.style.visibility == "")
		bRet = !(xGetAnyCS(e, "visibility") == "hidden");
	else
		bRet = !(e.style.visibility == "hidden");
	return bRet;
}
function xZIndex(e, uZ) {
	if ( !(e = xGetElementById(e)) ) return 0;
	if ( xDef(uZ) )
		e.style.zIndex = uZ;
    else
		uZ = e.style.zIndex;
	return uZ;
}
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Position
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function xMoveTo(e, iX, iY) {
	xLeft(e,iX);
	xTop(e,iY);
}
function xLeft(e, iX) {
	if ( !(e = xGetElementById(e)) ) return 0;
    if ( xDef(iX) )
		e.style.left = iX + "px";
	else {
			iX = DL_GetElementLeft(e);
	}
	return iX;
}
function xTop(e, iY) {
	if ( !(e = xGetElementById(e)) ) return 0;
    if ( xDef(iY) )
		e.style.top = iY + "px";
	else {
			iY = DL_GetElementTop(e);
	}
	return iY;
}
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Size
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function xResizeTo(e, uW, uH) {
	xWidth(e,uW);
	xHeight(e,uH);
}
function xWidth(e, uW) {
	if ( !e || (uW && uW<0) ) return 0;
	if ( xDef(uW) ) {
		uW = Math.round(uW);
		xSetCW(e, uW);
	}
	uW = e.offsetWidth;
	return uW;
}
function xHeight(e, uH) {
	if ( !e || (uH && uH<0) ) return 0;
	if ( xDef(uH) ) {
		uH = Math.round(uH);
		xSetCH(e, uH);
	}
	uH=e.offsetHeight;
	return uH;
}
function xGetCS(ele,sP){
	return parseInt(document.defaultView.getComputedStyle(ele,"").getPropertyValue(sP));
}
function xSetCW(ele,uW){
	if (uW < 0) return;

	var pl=0, pr=0, bl=0, br=0;
	if ( xDef(document.defaultView) && xDef(document.defaultView.getComputedStyle) ) {
		pl = xGetCS(ele, "padding-left");
		pr = xGetCS(ele, "padding-right");
		bl = xGetCS(ele, "border-left-width");
		br = xGetCS(ele, "border-right-width");
	} else if ( xDef(ele.currentStyle, document.compatMode) ) {
		if(document.compatMode == "CSS1Compat"){
			pl = parseInt(ele.currentStyle.paddingLeft);
			pr = parseInt(ele.currentStyle.paddingRight);
			bl = parseInt(ele.currentStyle.borderLeftWidth);
			br = parseInt(ele.currentStyle.borderRightWidth);
		}
	} else if ( xDef(ele.offsetWidth, ele.style.width) ) {
		ele.style.width = uW + "px";
		pl = ele.offsetWidth - uW;
	}
	if ( isNaN(pl) ) pl=0;
	if ( isNaN(pr) ) pr=0;
	if ( isNaN(bl) ) bl=0;
	if ( isNaN(br) ) br=0;
	var cssW = uW - (pl+pr+bl+br);
	if ( isNaN(cssW) || cssW<0 )
		return;
	else
		ele.style.width = cssW + "px";
}
function xSetCH(ele, uH){
	if (uH < 0) return;

	var pt=0, pb=0, bt=0, bb=0;
	if ( xDef(document.defaultView) && xDef(document.defaultView.getComputedStyle) ) {
		pt = xGetCS(ele,"padding-top");
		pb = xGetCS(ele,"padding-bottom");
		bt = xGetCS(ele,"border-top-width");
		bb = xGetCS(ele,"border-bottom-width");
	}
	else if (xDef(ele.currentStyle,document.compatMode)) {
		if (document.compatMode == "CSS1Compat"){
			pt=parseInt(ele.currentStyle.paddingTop);
			pb=parseInt(ele.currentStyle.paddingBottom);
			bt=parseInt(ele.currentStyle.borderTopWidth);
			bb=parseInt(ele.currentStyle.borderBottomWidth);
		}
	}
	else if ( xDef(ele.offsetHeight, ele.style.height) ) {
		ele.style.height = uH + "px";
		pt = ele.offsetHeight - uH;
	}
	if ( isNaN(pt) ) pt=0;
	if ( isNaN(pb) ) pb=0;
	if ( isNaN(bt) ) bt=0;
	if ( isNaN(bb) ) bb=0;
	var cssH = uH - (pt+pb+bt+bb);
	if ( isNaN(cssH) || cssH<0 )
		return;
	else
		ele.style.height = cssH + "px";
}
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Object
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function xGetElementById(e) {
	if (typeof(e) != "string") return e;
	if (document.getElementById)
		e = document.getElementById(e);
	else
		e = null;
	return e;
}
function xParent(e){
	if ( !(e = xGetElementById(e)) ) return null;

	var p = null;
	if ( xDef(e.parentNode) )
		p = e.parentNode;
	else if ( xDef(e.parentElement) )
		p = e.parentElement;
	else if ( xDef(e.offsetParent) )
		p = e.offsetParent;

	return p;
}
function xDef() {
	for (var i=0; i<arguments.length; ++i) {
		if ( typeof(arguments[i]) == "undefined" )
			return false;
	}
	return true;
}
function xGetAnyCS(oEle, sProp) {
	var p = "";
	if(document.defaultView && document.defaultView.getComputedStyle){
		p = document.defaultView.getComputedStyle(oEle,'').getPropertyValue(sProp)
	} else if(oEle.currentStyle) {
		// convert css property name to object property name for IE
		var a = sProp.split('-');
		sProp = a[0];
		for (var i=1; i<a.length; ++i) {
			c = a[i].charAt(0);
			sProp += a[i].replace(c, c.toUpperCase());
		}   
		p = oEle.currentStyle[sProp];
	}
	return p;
}
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Window
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function xScrollLeft() {
	var offset = 0;
	if ( xDef(window.pageXOffset) )
		offset = window.pageXOffset;
	else if ( document.documentElement && document.documentElement.scrollLeft )
		offset = document.documentElement.scrollLeft;
	else if ( document.body && xDef(document.body.scrollLeft ) )
		offset = document.body.scrollLeft;
	return offset;
}
function xScrollTop() {
	var offset = 0;
	if ( xDef(window.pageYOffset) )
		offset = window.pageYOffset;
	else if ( document.documentElement && document.documentElement.scrollTop )
		offset = document.documentElement.scrollTop;
	else if ( document.body && xDef(document.body.scrollTop ) )
		offset = document.body.scrollTop;
	return offset;
}
function xClientWidth() {
	var w=0;
	if ( !window.opera && document.documentElement && document.documentElement.clientWidth ) // v3.12
		w=document.documentElement.clientWidth;
	else if ( document.body && document.body.clientWidth )
		w = document.body.clientWidth;
	return w;
}
function xClientHeight() {
	var h=0;
	if ( !window.opera && document.documentElement && document.documentElement.clientHeight ) // v3.12
		h = document.documentElement.clientHeight;
	else if ( document.body && document.body.clientHeight )
		h = document.body.clientHeight;
	return h;
}

function xGetElementsByClassName(clsName, parentEle, tagName, fn)
{
  var found = new Array();
  var re = new RegExp('\\b'+clsName+'\\b', 'i');
  var list = xGetElementsByTagName(tagName, parentEle);
  for (var i = 0; i < list.length; ++i) {
    if (list[i].className.search(re) != -1) {
      found[found.length] = list[i];
      if (fn) fn(list[i]);
    }
  }
  return found;
}
function xGetElementsByTagName(tagName, parentEle)
{
  var list = null;
  tagName = tagName || '*';
  parentEle = parentEle || document;
  if (xIE) {
    if (tagName == '*') list = parentEle.all;
    else list = parentEle.all.tags(tagName);
  }
  else if (parentEle.getElementsByTagName) list = parentEle.getElementsByTagName(tagName);
  return list || new Array();
}


/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	InsertElement.js - implements IE's insertAdjacentHTML and insertAdjacentText to DOM-based browsers
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	(c) Copyright Thor Larholm (thor@jscript.dk)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
if ( typeof(HTMLElement) != "undefined" ) {
	if ( !(HTMLElement.prototype.insertAdjacentElement) ) {
		HTMLElement.prototype.insertAdjacentElement = function(where,parsedNode) {
			switch (where) {
				case "beforeBegin":
					this.parentNode.insertBefore(parsedNode,this);
					break;
				case "afterBegin":
					this.insertBefore(parsedNode,this.firstChild);
					break;
				case "beforeEnd":
					this.appendChild(parsedNode);
					break;
				case "afterEnd":
					if (this.nextSibling) {
						this.parentNode.insertBefore(parsedNode, this.nextSibling);
					} else {
						this.parentNode.appendChild(parsedNode);
					}
					break;
			}
		};
		HTMLElement.prototype.insertAdjacentHTML = function(where,htmlStr) {
			var r = this.ownerDocument.createRange();
			r.setStartBefore(this);
			var parsedHTML = r.createContextualFragment(htmlStr);
			this.insertAdjacentElement(where,parsedHTML);
		};
		HTMLElement.prototype.insertAdjacentText = function(where,txtStr) {
			var parsedText = document.createTextNode(txtStr);
			this.insertAdjacentElement(where,parsedText);
		};
	}
}



function DL_GetElementLeft(eElement)
{
   if (!eElement && this)                    // if argument is invalid
   {                                         // (not specified, is null or is 0)
      eElement = this;                       // and function is a method
   }                                         // identify the element as the method owner

   var DL_bIE = document.all ? true : false; // initialize var to identify IE

   var nLeftPos = eElement.offsetLeft;       // initialize var to store calculations
   var eParElement = eElement.offsetParent;  // identify first offset parent element

   while (eParElement != null)
   {                                         // move up through element hierarchy

      if(DL_bIE)                             // if browser is IE, then...
      {
         if( (eParElement.tagName != "TABLE") && (eParElement.tagName != "BODY") )
         {                                   // if parent is not a table or the body, then...
            nLeftPos += eParElement.clientLeft; // append cell border width to calcs
         }
      }
      else                                   // if browser is Gecko, then...
      {
         if(eParElement.tagName == "TABLE")  // if parent is a table, then...
         {                                   // get its border as a number
            var nParBorder = parseInt(eParElement.border);
            if(isNaN(nParBorder))            // if no valid border attribute, then...
            {                                // check the table's frame attribute
               var nParFrame = eParElement.getAttribute('frame');
               if(nParFrame != null)         // if frame has ANY value, then...
               {
                  nLeftPos += 1;             // append one pixel to counter
               }
            }
            else if(nParBorder > 0)          // if a border width is specified, then...
            {
               nLeftPos += nParBorder;       // append the border width to counter
            }
         }
      }
      nLeftPos += eParElement.offsetLeft;    // append left offset of parent
      eParElement = eParElement.offsetParent; // and move up the element hierarchy
   }                                         // until no more offset parents exist
   return nLeftPos;                          // return the number calculated
}

function DL_GetElementTop(eElement)
{
   if (!eElement && this)                    // if argument is invalid
   {                                         // (not specified, is null or is 0)
      eElement = this;                       // and function is a method
   }                                         // identify the element as the method owner

   var DL_bIE = document.all ? true : false; // initialize var to identify IE

   var nTopPos = eElement.offsetTop;         // initialize var to store calculations
   var eParElement = eElement.offsetParent;  // identify first offset parent element

   while (eParElement != null)
   {   
                                         // move up through element hierarchy
      if(DL_bIE)                             // if browser is IE, then...
      {
         if( (eParElement.tagName != "TABLE") && (eParElement.tagName != "BODY") )
         {                                   // if parent a table cell, then...
            nTopPos += eParElement.clientTop; // append cell border width to calcs
         }
      }
      else                                   // if browser is Gecko, then...
      {
         if(eParElement.tagName == "TABLE")  // if parent is a table, then...
         {                                   // get its border as a number
            var nParBorder = parseInt(eParElement.border);
            if(isNaN(nParBorder))            // if no valid border attribute, then...
            {                                // check the table's frame attribute
               var nParFrame = eParElement.getAttribute('frame');
               if(nParFrame != null)         // if frame has ANY value, then...
               {
                  nTopPos += 1;              // append one pixel to counter
               }
            }
            else if(nParBorder > 0)          // if a border width is specified, then...
            {
               nTopPos += nParBorder;        // append the border width to counter
            }
         }
      }
      
      nTopPos += eParElement.offsetTop;      // append top offset of parent
      
      eParElement = eParElement.offsetParent; // and move up the element hierarchy
   }                                         // until no more offset parents exist
   return nTopPos;                           // return the number calculated
}



