function shimImage(img){ img.src = "http://www.horchow.com/store/catalog/images/shim.gif" }

/*
  onloadDelegate can be used to specify the use of the window.onload function
  after the body declaration. 
 */
function onloadDelegate(function1, function2){
  return function(){
    if(function1){ function1(); }
    if(function2){ function2(); }
  }
}

/*
  HeightSpan, HeightSpanOnLoad, and HeightSpanTimeout can be used to set
  the height of a specific element equal to the height of a reference element 
*/
function HeightSpan( sRefElement, sAdjElement, sPixAdj ){
	this.refElem = document.getElementById(sRefElement);
  this.adjElem = document.getElementById(sAdjElement);  
  if( sPixAdj ){ this.pixAdj = new Number(sPixAdj) }
  else{ this.pixAdj = new Number(0); }
}
function HeightSpanOnLoad( sRefElement, sAdjElement, sPixAdj ){   
  HeightSpan.call( this, sRefElement, sAdjElement, sPixAdj );  
  window.onload = onloadDelegate(window.onload, HeightSpan.adjust(this));  
}HeightSpanOnLoad.prototype=new HeightSpan();

function HeightSpanTimeout( sRefElement, sAdjElement, sPixAdj ){   
  HeightSpan.call( this, sRefElement, sAdjElement, sPixAdj );
  HeightSpan.adjust(this);
  var callFunc = function(){ HeightSpan.adjust(this); }
  var checkInterval = window.setInterval( callFunc,500 );
  window.setTimeout( function(){clearInterval(checkInterval);}, 1000);  
}HeightSpanTimeout.prototype=new HeightSpan();

HeightSpan.adjust = function(obj){	
	if(obj.refElem && obj.adjElem){
		adjSize = new Number(obj.refElem.offsetHeight) -1 + obj.pixAdj;
		elemSize = new Number( obj.adjElem.offsetHeight);				
		if(elemSize < adjSize){ obj.adjElem.style.height = new String(adjSize)+"px";	}	
	}
}

RowHeightEval = function(){	
	this.rowElements = new Array();
	this.maxRowHeight = new Number(0);
	
	RowHeightEval.prototype.add = function( elemId ){
		var elem = document.getElementById(elemId);
		this.rowElements[this.rowElements.length] = elem;				
		elemH = new Number(elem.offsetHeight);
		if(elemH > this.maxRowHeight){ 			
			elem.style.paddingTop=0;
			padTop = elemH - elem.offsetHeight;
			elem.style.paddingBottom=0;
			padBottom = elemH - padTop - elem.offsetHeight;			
			this.maxRowHeight = elemH - (padTop+padBottom); 
			elem.style.paddingTop = padTop+"px";
			elem.style.paddingBottom= padBottom+"px";			
		}
	};
	
	RowHeightEval.prototype.adjust = function(){
		for(i=0; i<this.rowElements.length; i++){
			if(this.rowElements[i].offsetHeight < this.maxRowHeight){
				this.rowElements[i].style.height = new String(this.maxRowHeight)+"px";
			}
		}		
		this.maxRowHeight = new Number(0);
		this.rowElements = new Array();
	};
};

function replaceWithText( idRefElement, strText ){
	var refElem = document.getElementById(idRefElement);

	if(refElem.hasChildNodes()){
		domUtil.removeChildNodes(refElem);
	}
	
	var replacementTextNode = document.createTextNode(strText);
   refElem.appendChild(replacementTextNode);

}

function domUtil(){}

domUtil.removeChildNodes = function(node) {
	while (node.childNodes.length > 0) {
		node.removeChild(node.childNodes[0]);	
	}	
}

function overlayimage(sImgId, sOverlayId, sContent){
	
	var refImg = document.getElementById(sImgId);
	var product = document.getElementById(sOverlayId);	
	var children = product.childNodes;
	var postLinkNode;
	if( children.length != 0 ){
		for(i=0; i<children.length; i++){
			var node = children[i];			
			if( node.className == "prodImgLink" ){
				var nextNodeNum = ((new Number(i))+1)
				if( nextNodeNum < children.length){
					postLinkNode=children[nextNodeNum];break;
				}
			}
		}
	}
	if(postLinkNode){		
		var oDiv = document.createElement("div");
		oDiv.className="overlay";
		var oImg = document.createElement("img");
		oImg.src=sContent; oImg.className="flagimg";
		oDiv.appendChild(oImg);
		product.insertBefore(oDiv, postLinkNode);
	}
}

  function getCSSRule( s_sheet, s_rule ){        
    var o_rule;
    for(var s=0; s< document.styleSheets.length; s++){        
	    if(document.styleSheets[s].href.indexOf(s_sheet)> 0){   
	      var o_rules;      
	      if(document.styleSheets[s].cssRules){ o_rules = document.styleSheets[s].cssRules; }
	      if(document.styleSheets[s].rules){ o_rules = document.styleSheets[s].rules; }            
	      if(o_rules){
	        for( var r=0; r<o_rules.length; r++){          
	          if( o_rules[r].selectorText.toLowerCase() == s_rule.toLowerCase() ){
							o_rule = o_rules[r];
	          }
	        }
	      }
	    }    
    }        
    return o_rule;
  }
