//Function to add hover properties to the touchpanel product line thickbox images
$(document).ready(
    function addTouchpanelProductLineImageListeners() {
        $(".touchpanelProductLine").hover(
            //hover over actions
            function(){
                $(this).find(".tplImage").hide();          //hide the non-hover touchpanel product line image
                $(this).find(".tplHoverImage").show();     //show the hover touchpanel product line image
            },
            //hover out actions
            function(){
                $(this).find(".tplHoverImage").hide();     //hide the hover touchpanel product line image
                $(this).find(".tplImage").show();          //show the non-hover touchpanel product line image
            }
        );
    }
);
$(document).ready(   
    function addTouchPanelProductLinePopupListeners(e) {
        $(".tplLink").click(
            //click action
            function(){
                var tplUrl = $(this).attr("href");                                          //grab the url we want to do our ajax call to
                var tplPopupDiv = $(this).attr("rel") + "Popup";                            //grab the div id and append Popup to it, to make the popup windows id
                $("#" + tplPopupDiv).load(tplUrl, function(){
                    attachTPLButtonListeners();                                               //attach button listners for the popup window  
                });                                          //fill the popup window with the ajax content              
                if ( jQuery.browser.msie && (jQuery.browser.version < 7) )
                {
                    $(".touchpanelProductLineContainer").width(600);        //set the width of the product line container to fit the popup    
                }
                $("#" + tplPopupDiv).show();                                                //show the popup window             
                return false;
            }
        );
    }
);

function attachTPLButtonListeners()
{
    $(".tplActionClose").click(
        function(){
            var tplPopupToHide = $(this).attr("rel");                           //grab the id of the popup window from the rel attribute in our close tag
            $("#" + tplPopupToHide).hide();                                        //hide the popup window
            if ( jQuery.browser.msie && (jQuery.browser.version < 7) )
            {
                $(".touchpanelProductLineContainer").width(150);        //reset the width of the product line container to normal size    
            }
            return false;
        }
    );  
}