//pass isModal to set masterpage
$(document).ready(function() 
{
        var theHref;
        $(".thickbox").each(
            function()
            {
              theHref = this.href;
              
 theHref += "?isModal=modal&KeepThis=true&TB_iframe=true";
              $(this).attr("href",theHref);
            }
        );
});




$(document).ready(function(){
    $("table.altrows tr:even").addClass("");
    $("table.altrows tr:odd").addClass("alt");
    $("#static-content table tr:even").addClass("");
    $("#static-content table tr:odd").addClass("alt");
    $('img[@src$=.png],.logo-link').ifixpng(); 
  //  showPrintButton();
    changeButtons();
    defaultCheckoutButtons();
    popUps()
    });
    
    
function showPrintButton() 
{
    $('#final-box').append(
    
        $('<ul class="buttons"></ul>').append(
    
            $('<li></li>').append(
            
                '<a href="javascript:window.print();"><img src="/assets/racinggreen/images/btn-print.gif" alt="print"></a>'
                
            )
        )
    );
}


function changeButtons() 
{

    $(".linkbutton").each
    (
         function()
         {
            var btn = this;
            $("<a></a>").attr("href","#").append(this.value).bind
			(
	            "click",
                function()
                {
                  btn.click()
                }	
            ).insertBefore(this)
           $(this).hide(); 		   
	    }
	);
}



function defaultCheckoutButtons()
{
    
    $("#checkout .textfield").each
    (
        function()
        {
         $(this).keydown
         (
            function(e)
            {
               
               if (e.keyCode == 13){
               $(".buttons").children("li").children(".button").click()
               }
                
            }
         )
        }   
    );
}


function popUps()
{

    
    
    $("a[@rel='external']").click(function()
    {
        window.open($(this).attr("href"), null, "height=520,width=520,status=yes,toolbar=no,menubar=no,location=no");
        return false;
    });
}
/*
Dynamically load jqzoom and set up simple image zooming
HT:	On all product pages.
==========================================================================================================================================
*/

$(document).ready(function(){

    if ($(".jqzoom").length > 0) {        
    // var biggestImageSuffix = "_l";       // uncomment this line if we're not getting the suffix from the back-end in the aspx file        
    // var biggestAvailableImageTest = "/content/products/products/1/1/4/1142011_A_p.jpg";       // test only	
    //var biggestImageSuffix = "";	
    var testImageSuffix = biggestImageSuffix || null;        
    if (testImageSuffix != (null && "")) { 
	//console.log(testImageSuffix +' step 3');
             $("#product-detail #product-imagery p").css("visibility","visible");

            var biggestAvailableImage = $(".jqzoom img")
                .eq(0)
                .attr("src")
                .replace(/_p.jpg/i, biggestImageSuffix + '.jpg');

            $("#product-right-col").css("opacity",.9999); // fix for IE opacity issues
            $(".jqzoom").jqueryzoom({
                xzoom: 499, //zooming div default width (default width value is 200)
                yzoom: 367, //zooming div default height (default height value is 200)
                offset: 0, //zooming div default offset(default offset value is 10)
                position: "right", //zooming div position(default position value is "right")
                preload: 0, // by default preload of big images is 1
                lens: 1, // by default the lens is 1
                positionTop: 3,
                positionLeft: 299,
                bigimage: biggestAvailableImage,
                hideElement: "#product-right-col"
              });
           }
          }

});