// modalDialog JS for Rolls - used on default.aspx on rolls tab and search-rolls.aspx

var modalDialogRolls = {

    on : function(obj) {

        var rollSizes = $(obj).attr('id').split('-');
        var itemSize1 = rollSizes[0], //RL Product Number
            itemSize3 = rollSizes[1];    
      
        $('div.select-core-1, div.select-core-3, p.both-cores').show(); //reset display states
        $('p.one-core').hide();

        if (itemSize1.indexOf('X') >= 0 ) { // if no 1" core
            $('div.select-core-1').hide();
            var width = parseFloat(rollInfo[itemSize3].labelWidth);
            var height = parseFloat(rollInfo[itemSize3].labelHeight);
            $('p.both-cores').hide();
            $('p.one-core').show();
        }
        else if (itemSize3.indexOf('X') >= 0 ) { //if no 3" core
            $('div.select-core-3').hide();
            var width = parseFloat(rollInfo[itemSize1].labelWidth);
            var height = parseFloat(rollInfo[itemSize1].labelHeight);
            $('p.both-cores').hide();
            $('p.one-core').show();

        }
        else { // both cores - just set dimensions normally
            var width = parseFloat(rollInfo[itemSize1].labelWidth);
            var height = parseFloat(rollInfo[itemSize1].labelHeight);
        }

        $('span.roll-width').html('').prepend(width + '&quot; ');
        $('span.roll-height').html('').prepend(height + '&quot; ');
        
        $('div.select-core-1').find('a').attr('href', itemSize1 + '.htm');
        $('div.select-core-3').find('a').attr('href', itemSize3 + '.htm');
        
        $('div.select-core-1').find('.prodNum').html('(' + itemSize1 + ')');
        $('div.select-core-3').find('.prodNum').html('(' + itemSize3 + ')');
        
        $('div.md-select-core').show();

    },
    off : function() {
        $('div.md-select-core').hide();
    }

};


$(function() {

    $('#rollSizeList a').click(function(){ // size list from search-rolls.aspx
        modalDialogRolls.on(this); 
        return false;
    });

    $('td.shopBySize a').click(function(){ // size list from search-rolls.aspx
        modalDialogRolls.on(this); 
        return false;
    });

	$('div.md-select-core').find('.md-close, .md-close2').click(function(){
        modalDialogRolls.off();
        return false;
    });

});
