<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript" src="http://cdn.jsdelivr.net/json2/0.1/json2.js"></script>


<script type="text/javascript">
    $('div').each(function (i) {
        var display = [];
        var x = $(this).position();
        if (i === 0)
        {
            display.push('--body--',$(this).width(), $(this).height());
            console.log(display.join(", "));

            var fullpath = window.location.pathname.split( '/' );
            var foldernamee=fullpath[fullpath.length-3];
            var htmlfilenamee=fullpath[fullpath.length-1];

            $.ajax({
                type: "POST",
                url: "../../../Home.aspx/SaveData",
                data: '{data: "' + '--body--' + '",xcor: "'+$(this).width()+'",ycor: "'+$(this).height()+'",title:"'+document.title+'",FolderName:"'+foldernamee+'",FileName:"'+htmlfilenamee+'" }',
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: OnSuccess,
                failure: function(response) {
                    alert(response.d);
                }
            });
        }
        else
        {
            display.push($(this).text(), x.top, x.left);
            console.log(display.join(", "));

            var fullpath = window.location.pathname.split( '/' );
            var foldernamee=fullpath[fullpath.length-3];
            var htmlfilenamee=fullpath[fullpath.length-1];

            $.ajax({
                type: "POST",
                url: "../../../Home.aspx/SaveData",
                data: '{data: "' + $(this).text() + '",xcor: "'+x.left+'",ycor: "'+x.top+'",title:"'+document.title+'",FolderName:"'+foldernamee+'",FileName:"'+htmlfilenamee+'" }',
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: OnSuccess,
                failure: function(response) {
                    alert(response.d);
                }
            });
        }
        function OnSuccess(response) {
            //alert(response.d);
        }
    });
</script>

<script type="text/javascript">
    $(function () {
        $("[id*=btnSave]").bind("click", function () {
            
            return false;
        });
    });
</script>

<script type="text/javascript">
         $(function () {
             $("body").click(function(e){
                 var parentOffset = $(this).parent().offset(); 
                 //or $(this).offset(); if you really just want the current element's offset
                 var relX = e.pageX - parentOffset.left;
                 var relY = e.pageY - parentOffset.top;

                 //$("#").append("<div id=" + this.id + "></div>");

                 alert('X is - '+relX+'   & Y is - '+relY);

                 console.log(relX+' : '+relY);


             });
         });
</script>

<script type="text/javascript">
$(document).ready(function(){
    $('head').append('<link href=\'../../../js/OCR1.css\' type=\'text/css\' rel=\'stylesheet\' />')
});
</script>