function showImage(imgLink,imgWidth,imgHeight){
	imgHeight=imgHeight+32;
	imgWidth=imgWidth+32;
        var userAgent = navigator.userAgent.toLowerCase();
	if (userAgent.indexOf('firefox') != -1){
		imgHeight=imgHeight-13;
		imgWidth=imgWidth-12;
	}
	var lf = Math.floor((screen.width-imgWidth)/2);
	var tp = Math.floor((screen.height-imgHeight)/2);
	if (userAgent.indexOf('opera') != -1){
		lf = 100;
		tp = 100;
	}
	var tmp='toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,copyhistory=0,left='+lf+',top='+tp+',width='+imgWidth+',height='+imgHeight;
	var ind = imgLink.lastIndexOf('/');
	var fn=imgLink;
	if (ind>-1) fn=imgLink.substring(ind+1,imgLink.length);
	imageWindow=window.open("","","'"+tmp+"'");
	imageWindow.focus;
	imageWindow.document.writeln('<html><head><title>' + fn + '</title></head><body bgcolor=\"#ffffff\">');
	imageWindow.document.writeln('<center><img src=\"' + imgLink + '\" border=\"1\"></center></body></html>');
	imageWindow.focus;
	imageWindow.document.close();
	imageWindow.focus;
}

$(function() {
    
    $("#thumb").click(function() {
        $.ajax( {
            type: "GET",
            url: "change",
            data: { p: 3 },
            dataType: "json",
            success: function(data) {
                $("#width").html( data.width )
                $("#img0").html( data.img0 )
                $("#img1").html( data.img1 )
                $("#img2").html( data.img2 )
                $("#pagTop").html( data.pagTop )
                $("#pagBot").html( data.pagTop )
                $("#table").html( data.table )
            }
        })
    })
    
    $("#dateCr").click(function() {
        $.ajax( {
            type: "GET",
            url: "change",
            data: { p: 0 },
            dataType: "json",
            success: function(data) {
                $("#width").html( data.width )
                $("#img0").html( data.img0 )
                $("#img1").html( data.img1 )
                $("#img2").html( data.img2 )
                $("#pagTop").html( data.pagTop )
                $("#pagBot").html( data.pagTop )
                $("#table").html( data.table )
            }
        })
    })
    
    $("#dateAd").click(function() {
        $.ajax( {
            type: "GET",
            url: "change",
            dataType: "json",
            data: { p: 1 },
            success: function(data) {
                $("#width").html( data.width )
                $("#img0").html( data.img0 )
                $("#img1").html( data.img1 )
                $("#img2").html( data.img2 )
                $("#pagTop").html( data.pagTop )
                $("#pagBot").html( data.pagTop )
                $("#table").html( data.table )
            }
        })
    })

    $("#hits").click(function() {
        $.ajax( {
            type: "GET",
            url: "change",
            data: { p: 2 },
            dataType: "json",
            success: function(data) {
                $("#width").html( data.width )
                $("#img0").html( data.img0 )
                $("#img1").html( data.img1 )
                $("#img2").html( data.img2 )
                $("#pagTop").html( data.pagTop )
                $("#pagBot").html( data.pagTop )
                $("#table").html( data.table )
            }
        })
    })
    
    $("#button").click(function() {
        $.ajax( {
            type: "POST",
            url: "add",
            data: { node: $("#node").html(), author: $("#author").val(), city: $("#city").val(), email: $("#email").val(), site: $("#site").val(), text: $("#text").val()},
            dataType: "json",
            success: function(data) {
                $("#error").html(data.error);
                if (data.error=='') {
                    $("#comments").html(data.comments);
                    $("#author").val('');
                    $("#city").val('');
                    $("#email").val('');
                    $("#site").val('');
                    $("#text").val('');
                }
            }
        })
    })

    $("#dbutton").click(function() {
        $.ajax( {
            type: "POST",
            url: "add",
            data: { node: $("#node").html(), code: $("#code").val(), author: $("#author").val(), text: $("#text").val()},
            dataType: "json",
            success: function(data) {
                $("#error").html(data.error);
                if (data.error=='') {
                    $("#comments").html(data.comments);
                    $("#error").val('');
                    $("#author").val('');
                    $("#text").val('');
                }
            }
        })
    })
})

