﻿
function showPack(imgSrc) {
    url = "PackByID/1?image="+ imgSrc;
    pack = window.open(url, "pack", "width=500,height=500,tollbar=0,resizable=1,scrollbars=1");
    pack.focus();
}

function openWin(id, item_type, item_url) {
       switch (item_type) {
        // regular news item
        case 'Link to News Item': url = "NewsItem/NewsByID/?id=" + id
            window.open(url, "news", "width=492,height=420,scrollbars=1");
            break;

        // link to internal page 
        case 'Link to Internal Page': location.href = item_url;
            break;

        // link to pdf file 
        case 'Link to File': url = "item.asp?id=" + id;
            window.open(url, "news", "width=500,height=400,resizable=1");
            break;
       
    }
}

$(document).ready(function() {

    $('#Menu1 li').bind('mouseover', function(event) {
        $(this).find('ul').css({ display: 'block', top: '20px' });
    });
    $('#Menu1 li').bind('mouseout', function(event) {
        $(this).find('ul').css({ display: 'none', top: '-9999px' });
    });







    $('#dropDown').bind('change', function() {
        changeTable($(this).val());
    });

    function changeTable(sort) {
        var date = new Date();
        $.getJSON('productsByType/' + sort + '?time=' + date.getTime(), function(data) {

            var row = '';
            var allRows = '';
            $('#table-data').html('');
            for (i = 0; i < data.length; i++) {
                row = '';
                row = row + '<div class=\"table_1\" style=\"background-color:#ffeaaf\" >' + data[i].Product_Name + '</div>';
                row = row + '<div class=\"Line1\">' + data[i].Unit_Net_weight + '</div>';
                row = row + '<div class=\"Line1\">' + data[i].Number_Of_Units + '</div>';
                row = row + '<div class=\"Line1\">' + data[i].Carttons_Per_Pallete + '</div>';
                row = row + '<div class=\"ViewLine2\">' + '<a href="javascript:showPack(\'' + data[i].View + '\');"><img src="/Images/pic.gif" /></a></div>';
                row = row + '<div class=\clear\"></div>';
                allRows = allRows + row;
            }
            $('#table-data').html(allRows);

        });

    }








});


