function $get(object){return document.getElementById(object);}
function getElementsByClassName(strClass, strTag, objContElm) {
  strTag = strTag || "*";
  objContElm = objContElm || document;
	
  var objColl = objContElm.getElementsByTagName(strTag); 
  
  if (!objColl.length &&  strTag == "*" &&  objContElm.all) objColl = objContElm.all;
  var arr = new Array();
  var delim = strClass.indexOf('|') != -1  ? '|' : ' ';
  var arrClass = strClass.split(delim);
  for (var i = 0, j = objColl.length; i < j; i++) {
	var arrObjClass = objColl[i].className.split(' ');
	if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
	var c = 0;
	comparisonLoop:
	for (var k = 0, l = arrObjClass.length; k < l; k++) {
	  for (var m = 0, n = arrClass.length; m < n; m++) {
		if (arrClass[m] == arrObjClass[k]) c++;
		if (( delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
		  arr.push(objColl[i]);
		  break comparisonLoop;
		}
	  }
	}
  }
  return arr;
}
var test;
/***********************************************************************************************************************/
function showVariation(object, pvid){  
    var parentNode = object.parentNode;   
    while(parentNode.tagName != 'FIELDSET' )
    {parentNode = parentNode.parentNode;}
	
	var descriptions = getElementsByClassName('productDesc','div',parentNode);
	var prices = getElementsByClassName('productPrice','span',parentNode);
    var images = getElementsByClassName('productImage','img',parentNode);         
    var partpayments = getElementsByClassName('ddlPart','select',parentNode); 
    var promotionInfos = getElementsByClassName('promotionInfo','span',parentNode);    		    		   		
    var buttons = getElementsByClassName('hiddenButton','input',parentNode);     
 	
    var ppDescs = getElementsByClassName('ppDesc','span',parentNode);     
    var lblPartPayments = getElementsByClassName('lblPartPayment','span',parentNode);    	
	
    for (var i=0;i<prices.length;i++)
	{
	    if(descriptions[i] != null)
		    descriptions[i].style.display = "none";
		if(prices[i] != null)
		    prices[i].style.display = "none";		
		if(images[i] != null)		
		    images[i].style.display = "none";			
		if(promotionInfos[i] != null)		
		    promotionInfos[i].style.display = "none";	
		if(ppDescs[i] != null)		
		    ppDescs[i].style.display = "none";	
		if(lblPartPayments[i] != null)		
		    lblPartPayments[i].style.display = "none";	
		    
		if(partpayments[i] != null)
		{
		    partpayments[i].style.display = "none";		        
		    partpayments[i].selectedIndex = 0;
		    //getElementsByClassName('hiddenPart','input',parentNode)[0].value = "false"; //Reset part payment
		    getElementsByClassName('hiddenPart','input',parentNode)[0].value = partpayments[i].value; //Reset part payment -- modified by TT on 08-07-2011 to reset part payment based on the first option of the part payment dropdownlist
		}		
	}
	
	var description = getElementsByClassName('productDesc'+pvid,'div',parentNode);
	var price = getElementsByClassName('productPrice'+pvid,'span',parentNode);
    var image = getElementsByClassName('productImage'+pvid,'img',parentNode);        
    var partpayment = getElementsByClassName('ddlPart'+pvid,'select',parentNode);
    var promotionInfo = getElementsByClassName('promotionInfo'+pvid,'span',parentNode);    		    		
    var buttonss = getElementsByClassName('hiddenButton'+pvid,'input',parentNode);   
     		
    //var button = getElementsByClassName('button','input',parentNode);  
    
    var button1 = getElementsByClassName('rightContainerButton', 'div', parentNode); // for ProductDisplay_01 and ProductDisplay_03.
    var button2 = getElementsByClassName('leftContainerButton', 'div', parentNode); // for ProductDisplay_02.
    var button3 = getElementsByClassName('dvButton', 'div', parentNode); // for ProductDisplay_04.   
   
    var button4 = getElementsByClassName('out_of_stock', 'div', parentNode); // for out of stock button.
 
    var lblPartPayment = getElementsByClassName('lblPartPayment'+pvid,'span',parentNode);  		
    
    if(description[0])
        description[0].style.display = "block";
    if(price[0])
        price[0].style.display = "block";
    if(image[0])
        image[0].style.display = "block";    
    if(partpayment[0])
        partpayment[0].style.display = "block";
    if(promotionInfo[0])
        promotionInfo[0].style.display = "block";        
     if(lblPartPayment[0])
        lblPartPayment[0].style.display = "block";
        
    if(buttonss[0].value == 'True')
    {
        //if(button[0])
        //    button[0].style.display = "none";
       
        if(button1[0])       
            button1[0].style.display = "none";      
        else if(button2[0])
            button2[0].style.display = "none";
        else if(button3[0])
            button3[0].style.display = "none";
            
        if(button4[0])
        {
            button4[0].style.display = "block";
        }
    }
    else
    {
        //if(button[0])
        //    button[0].style.display = "inline";
        
        if(button1[0])       
            button1[0].style.display = "block";      
        else if(button2[0])
            button2[0].style.display = "block";
        else if(button3[0])
            button3[0].style.display = "block";
            
       if(button4[0])
       {
           button4[0].style.display = "none";
       }
    }      
}


/***********************************************************************************************************************/
function showVariation2(object_id){ 
   
    var object = document.getElementById(object_id);
    var parentNode = object.parentNode;  
    var pvid = object.value;
    while(parentNode.tagName != 'FIELDSET' )
    {parentNode = parentNode.parentNode;}
	
	var descriptions = getElementsByClassName('productDesc','div',parentNode);
	var prices = getElementsByClassName('productPrice','span',parentNode);
    var images = getElementsByClassName('productImage','img',parentNode);
    //var images2 = getElementsByClassName('productImage','input',parentNode);    
    var partpayments = getElementsByClassName('ddlPart','select',parentNode); 
    //var variations = getElementsByClassName('ddlVariation','select',parentNode); 
    var promotionInfos = getElementsByClassName('promotionInfo','span',parentNode);    	
    var promotionInfoLines = getElementsByClassName('promotionInfoLine','div',parentNode);    		    		   		
    var buttons = getElementsByClassName('hiddenButton','input',parentNode);    	
    var ppDescs = getElementsByClassName('ppDesc','span',parentNode);   
    var lblPartPayments = getElementsByClassName('lblPartPayment','span',parentNode);         	
	
    for (var i=0;i<prices.length;i++)
	{
	    if(descriptions[i] != null)
		    descriptions[i].style.display = "none";
		if(prices[i] != null)
		    prices[i].style.display = "none";		
		if(images[i] != null)		
		    images[i].style.display = "none";	
		//if(images2[i] != null)
		//    images2[i].style.display = "none";	
		if(promotionInfos[i] != null)		
		    promotionInfos[i].style.display = "none";	
		    
		if(promotionInfoLines[i] != null)		
		    promotionInfoLines[i].style.display = "none";	
		if(ppDescs[i] != null)		
		    ppDescs[i].style.display = "none";	
	    if(lblPartPayments[i] != null)		
		    lblPartPayments[i].style.display = "none";	
		    
		if(partpayments[i] != null)
		{
		    partpayments[i].style.display = "none";
		    partpayments[i].selectedIndex = 0;
		    //getElementsByClassName('hiddenPart','input',parentNode)[0].value = "false"; //Reset part payment
		    getElementsByClassName('hiddenPart','input',parentNode)[0].value = partpayments[i].value; //Reset part payment -- modified by TT on 08-07-2011 to reset part payment based on the first option of the part payment dropdownlist
		}		
	}
	
	var description = getElementsByClassName('productDesc'+pvid,'div',parentNode);
	var price = getElementsByClassName('productPrice'+pvid,'span',parentNode);
    var image = getElementsByClassName('productImage'+pvid,'img',parentNode);
    //var image2 = getElementsByClassName('productImage'+pvid, 'input', parentNode);
    var partpayment = getElementsByClassName('ddlPart'+pvid,'select',parentNode);
    var promotionInfo = getElementsByClassName('promotionInfo'+pvid,'span',parentNode);    		    	
    var promotionInfoLine = getElementsByClassName('promotionInfoLine'+pvid,'div',parentNode); 	
    var buttonss = getElementsByClassName('hiddenButton'+pvid,'input',parentNode);  
      		
    //var button = getElementsByClassName('button','input',parentNode);   
    
    var button1 = getElementsByClassName('rightContainerButton', 'div', parentNode); // for ProductDisplay_01 and ProductDisplay_03.
    var button2 = getElementsByClassName('leftContainerButton', 'div', parentNode); // for ProductDisplay_02.
    var button3 = getElementsByClassName('dvButton', 'div', parentNode); // for ProductDisplay_04.
    
     var button4 = getElementsByClassName('out_of_stock', 'div', parentNode); // for out of stock button.
    
    var lblPartPayment = getElementsByClassName('lblPartPayment'+pvid,'span',parentNode);  		 		
    
    if(description[0])
        description[0].style.display = "block";
    if(price[0])
        price[0].style.display = "block";
    if(image[0])
        image[0].style.display = "block";
    //if(image2[0])
    //    image2[0].style.display = "block";  
    if(partpayment[0])
        partpayment[0].style.display = "block";
    if(promotionInfo[0])
        promotionInfo[0].style.display = "block";
    if(promotionInfoLine[0])
        promotionInfoLine[0].style.display = "block";
    if(lblPartPayment[0])
        lblPartPayment[0].style.display = "block";    
    
    if(buttonss[0].value == 'True')
    {
        //if(button[0])
        //    button[0].style.display = "none";
       
        if(button1[0])       
            button1[0].style.display = "none";      
        else if(button2[0])
            button2[0].style.display = "none";
        else if(button3[0])
            button3[0].style.display = "none";
            
        if(button4[0])
        {
            button4[0].style.display = "block";
        }
    }
    else
    {
        //if(button[0])
        //    button[0].style.display = "inline";
        
        if(button1[0])       
            button1[0].style.display = "block";      
        else if(button2[0])
            button2[0].style.display = "block";
        else if(button3[0])
            button3[0].style.display = "block";
            
       if(button4[0])
       {
           button4[0].style.display = "none";
       }
    }      
    
    //setTimeout("setProductDisplayHeight()", 1000);
    
    setProductDisplayHeight();
}

function setProductDisplayHeight()
{
     var maxHeightProductDisplay01Inner = 0;
    
    $(".productDisplay04Inner").css('height', '');    
    $(".productDisplay04Inner").each(function(i)
        {   
            var tdHeight = $(this).parents("td").height();
            test = $(this).parents("td");
            if(maxHeightProductDisplay01Inner < tdHeight)
            {
                //maxHeightProductDisplay01Inner = tdHeight - 13;
                maxHeightProductDisplay01Inner = tdHeight;
                //alert("greater -> maxHeightProductDisplay01Inner = " + maxHeightProductDisplay01Inner + "px");
            }            
            //else
            //{
            //    alert("not greater -> maxHeightProductDisplay01Inner = " + maxHeightProductDisplay01Inner + "px");
            //}
        }
    );
    
    //alert("maxHeightProductDisplay01Inner = " + maxHeightProductDisplay01Inner + "px");
    //alert("maxHeightProductDisplay01Inner = " + maxHeightProductDisplay01Inner + "px");
    
    $(".productDisplay04Inner").each(function(i)
        {   
            $(this).css({height:maxHeightProductDisplay01Inner+"px"});
        }
    ); 
}

/***********************************************************************************************************************/
function passPartPayment(object)
{    
    var parentNode = object.parentNode;   
    while(parentNode.tagName != 'FIELDSET' )
    {parentNode = parentNode.parentNode;}
    
    var pvId = null;  
    var rblVariations = null;
    
    if(getElementsByClassName('rblVariation','div',parentNode)[0])
    {
        rblVariations = getElementsByClassName('rblVariation','div',parentNode)[0].getElementsByTagName('input');  
    }  
    var ppDescs = getElementsByClassName('ppDesc','span',parentNode);        
    var partpayment = getElementsByClassName('hiddenPart','input',parentNode)[0];   
    
    //Hide all first
    for (var i=0;i<ppDescs.length;i++)
	{
	    //alert(ppDescs[i].innerHTML);
	    if(ppDescs[i] != null)
		    ppDescs[i].style.display = "none";		
	}
	
	if(rblVariations)
	{
	    //Find out pvId
        for (var j = 0; j < rblVariations.length; j ++)
        {
            if(rblVariations[j].checked)
                pvId = rblVariations[j].value;
        }   
    }     
    
    //show the selected one
    if(pvId && object.value == "true")
    {    
        var ppDesc = getElementsByClassName('ppDesc'+pvId,'span',parentNode);
        if(ppDesc[0])
            ppDesc[0].style.display = "block";
    }
    
    partpayment.value = object.value;       

}


/***********************************************************************************************************************/
function passPartPayment2(object, ddlVariationId)
{    
    var parentNode = object.parentNode;   
    while(parentNode.tagName != 'FIELDSET' )
    {parentNode = parentNode.parentNode;}
    
    var pvId = null;  
    var rblVariations = null;
    
    if(getElementsByClassName('rblVariation','div',parentNode)[0])
    {
        rblVariations = getElementsByClassName('rblVariation','div',parentNode)[0].getElementsByTagName('input');  
    }  
    var ppDescs = getElementsByClassName('ppDesc','span',parentNode);        
    var partpayment = getElementsByClassName('hiddenPart','input',parentNode)[0];   
    
    //Hide all first
    for (var i=0;i<ppDescs.length;i++)
	{
	    //alert(ppDescs[i].innerHTML);
	    if(ppDescs[i] != null)
		    ppDescs[i].style.display = "none";		
	}
	
	if(rblVariations)
	{
	    //Find out pvId
        for (var j = 0; j < rblVariations.length; j ++)
        {
            if(rblVariations[j].checked)
                pvId = rblVariations[j].value;
        }   
    }   
    
    var ddlVariation = document.getElementById(ddlVariationId);    
   
    if(ddlVariation !== undefined && ddlVariation != null && ddlVariation != "")
    {
        //alert("Hello World, ddlVariation is not null. Value = " + ddlVariation.options[ddlVariation.selectedIndex].value);
        //alert("Hello World, ddlVariation is not null. Value = " + ddlVariation.value);
        pvId = ddlVariation.value;
    }    
    
    //show the selected one
    if(pvId && object.value == "true")
    {    
        var ppDesc = getElementsByClassName('ppDesc'+pvId,'span',parentNode);
        if(ppDesc[0])
            ppDesc[0].style.display = "block";
    }
    
    partpayment.value = object.value;    
    //alert("partpayment.value = " + partpayment.value);
    
    setProductDisplayHeight();
}


/***********************************************************************************************************************/
function navigationFix() {
    var _top = getElementsByClassName('topNav');
    for (var c=0;c<_top.length; c++)
    {    
     var ieULs = _top[c].getElementsByTagName('ul');
     if ($.browser.msie){
        for (j=0; j<ieULs.length; j++) {
            ieULs[j].innerHTML = ('<iframe src="about:blank" scrolling="no" frameborder="0" height="0"></iframe>' + ieULs[j].innerHTML);
            var ieMat = ieULs[j].firstChild;
            ieMat.style.width="0px";
            ieMat.style.height="0px";
            ieULs[j].style.zIndex="99";
        }
     }

     var sfEls = _top[c].getElementsByTagName("LI");
     for (var i=0; i<sfEls.length; i++) {
        var extraRight = 0-sfEls[i].offsetWidth-5;
        
        if ($.browser.msie && $.browser.version < 7 && sfEls[i].offsetWidth !=0) {
            if (sfEls[i].childNodes[1] != undefined){
               //var _margin="0px 0px 0px " + extraRight + "px";
			   var _margin="0px 0px 0px 0px";
               sfEls[i].getElementsByTagName('ul')[0].style.margin=_margin;
            }
         }  
        sfEls[i].onmouseover=function() {
            this.className+=(this.className.length>0? " ": "") + "onHover";
        }
        sfEls[i].onMouseDown=function() {
            this.className+=(this.className.length>0? " ": "") + "onHover";
        }
        
        sfEls[i].onMouseUp=function() {
            this.className+=(this.className.length>0? " ": "") + "onHover";
        }
        sfEls[i].onmouseout=function() {
            this.className=this.className.replace(new RegExp("( ?|^)onHover\\b"), "");
        }
      } 
   }
}
/***********************************************************************************************************************/
TextSize = {
 increment: 1.1875, currentPercent: null, defaultPercent: 100, defaultSize: 16, originalPercent: null, minSize: null, maxSize: null, 
 inited: false,

 init: function(){
 if(!this.inited){
     this.inited = true;
     var element = $('body');
     var origSize = element.css("font-size");
     
     if(origSize.indexOf("%")!=-1){
         this.originalPercent = parseInt(origSize);
     }else if(origSize.length>0){
            var size = parseInt(origSize);
            if(!isNaN(size) && size>0){
                this.originalPercent = (size/this.defaultSize)*this.defaultPercent;
            }
     }else{
            this.originalPercent = this.defaultPercent;
     }
     element.css('font-size', this.originalPercent+"%");
     this.currentPercent = this.originalPercent;
    }
 },
 limit: function(min, max){
        this.minSize = min;
        this.maxSize = max;
 },
 reset: function(tween){
        this.init();
        this.adjust(this.originalPercent, tween);
 },
 increase: function(tween){
        this.init();
        this.adjust(this.currentPercent*this.increment, tween);
 },
 decrease: function(tween){
        this.init();
        this.adjust(this.currentPercent*(1/this.increment), tween);
 },
 adjust: function(to, tween){
        if(tween==null)tween = false;
        if(to>0){
            var old = this.currentPercent;
            if(this.maxSize)to = Math.min(to,this.maxSize);
            if(this.minSize)to = Math.max(to,this.minSize);
            this.currentPercent = to;
            if(tween && Fx!=null && old!=null){
                var myEffect = $('body').effect('font-size', {duration: 500, unit: "%"});
                myEffect.start(to+"%");
            }else{
                $('body').css("font-size",to+"%");
            }
        }
    }
};

// function btnAddToCart OnMouseOver
function btnAddToCart_OnMouseOver(btnID)
{
    var myButton = document.getElementById(btnID);  
    myButton.style.color = '#333333';
}

//function btnAddToCart OnMouseOut
function btnAddToCart_OnMouseOut(btnID)
{
    var myButton = document.getElementById(btnID);  
     myButton.style.color = '#333333';
}





