﻿function addToCart(productID, productName) {
        
        var txt = productName +
					'<div class="field"><label for="editfname">Price:</label>Contact</div>' +
					'<div class="field"><label for="editlname">Qty:</label><input id="qty" name="qty" value="1" width="100px"  /></div>';
        

        $.prompt(txt, {
            buttons: [{title: 'Add To Cart',value:true}],
            submit: function(v, m, f) {
                var flag = true;
                if (v) {

                    if ($.trim(f.qty) == '') {
                        m.find('#qty').addClass('error');
                        flag = false;
                    }
                    else m.find('#qty').removeClass('error');

                }
                return flag;
            },            

            callback: function(v, m, f) {

                if (v) {

                    $.ajax({
                        type: "POST",
                        url: "AddCart.aspx",
                        data: "productid=" + productID + "&qty=" + f.qty,
                        error: function() {
                            alert("Error");
                        },
                        success: function(data) {                            
                            $("#cartItem").html(data);                                         
                        }                        
                    });
                }
                else { }
            }
        });  
        
    }

function resizeImg(proid) {
    var imgWidth = $('#img' + proid).width();
    var imgHeight = $('#img' + proid).height();
    var check = imgWidth/imgHeight;
    
    if(check > 1.8)
    {
        $('#img' + proid).css('width', '165');  
    }
    else
    {
        $('#img' + proid).css('height', '116');
    }
}	


