$.fn.single_double_click = function(single_click_callback, double_click_callback, timeout) {
return this.each(function() {
    var clicks = 0, self = this;
    if ($.browser.msie) { // ie triggers dblclick instead of click if they are fast
        $(this).bind("dblclick", function(event) {
            clicks = 2;
            double_click_callback.call(self, event);
        });
        $(this).bind("click", function(event) {
            setTimeout(function() {
                if (clicks != 2) {
                    single_click_callback.call(self, event);
                }
                clicks = 0;
            }, timeout || 300);
        });
    } else {
        $(this).bind("click", function(event) {
            clicks++;
            if (clicks == 1) {
                setTimeout(function() {
                    if (clicks == 1) {
                        single_click_callback.call(self, event);
                    } else {
                        double_click_callback.call(self, event);
                    }
                    clicks = 0;
                }, timeout || 300);
            }
        });
    }
});
}



 $(document).ready(function(){
    $("#modal").dialog({
        modal: true,
        resizable: false,
        draggable: true,
        autoOpen: false,
        width: 530
    });
    $("body").click(function(){
        $("#modal").dialog("close");
    });
    /*
    $(".products-modal").click(function(){
        var idProd = $(this).attr("title") ;
        $("#modal").html('<iframe src="/get_model/'+idProd+'/" width="520" height="455"  frameborder="0"></iframe>');
		$("#modal").dialog("open");
		return false;
	});	
	$(".products-modal").dblclick(function(){
        var idProd = $(this).attr("title") ;
        $("#modal").html('<iframe src="/get_model/'+idProd+'/" width="520" height="455"  frameborder="0"></iframe>');
		$("#modal").dialog("open");
		return false;
	});	
	*/
	$(".products-modal").single_double_click(function () {
        var idProd = $(this).attr("title") ;
        $("#modal").html('<iframe src="/get_model/'+idProd+'/" width="520" height="455"  frameborder="0"></iframe>');
		$("#modal").dialog("open");
		return false;
    }, function () {
        var idProd = $(this).attr("title") ;
        $("#modal").html('<iframe src="/get_model/'+idProd+'/" width="520" height="455"  frameborder="0"></iframe>');
		$("#modal").dialog("open");
		return false;
    })


});
