/*#######################################











#########################################*/

jQuery.fn.pixelpointer = function(){
	this.append('<span id="tooltip"></span><div id="vertical"></div><div id="horizontal"></div>');
	
	
    var bShow = false;
 	$('#vertical').hide();
    $('#horizontal').hide();
    $('#tooltip').hide();

	$(document).keypress(function(event) {
	   // ctrl + shift + v
	   if ((event.which == '86' || event.which=='22') && event.ctrlKey==true && event.shiftKey==true) {
	     if(bShow == false){
	                bShow = true;
	 	         $('#vertical').show();
	                 $('#horizontal').show();
	                 $('#tooltip').show();
	       }else{
	              bShow = false;
	 	      $('#vertical').hide();
	              $('#horizontal').hide();
	              $('#tooltip').hide();
	       }
	    }
	});

 	$(document).mousemove(function(e){   
 		var docWidth = $(window).width();
 		var docHeight = $(window).height();
	 	var cssObj = {
	 	  'float': 'left',
	 	  'position': 'absolute',
	 	  'clear': 'none',
	      'background-color' : 'red',
	      'margin-left' : e.pageX,
	      'width': '1px',
	      'height': docHeight
	    }
    	$('#vertical').css(cssObj);
    	var cssObj = {
	 	  'float': 'left',
	 	  'position': 'absolute',
	 	  'clear': 'none',
	      'background-color' : 'blue',
	      'margin-top' : e.pageY,
	      'width': docWidth,
	      'height': '1px'
	    }
    	$('#horizontal').css(cssObj);

        var posLeft = 0;
        var posTop = 0;
		// Repositions the tooltip when clipping the edges of the screen
        if( (e.pageX + 125) > $(window).width() ){
             posLeft = e.pageX - 130;
        }else{
             posLeft = e.pageX+15;
        }
        if( (e.pageY + 50) > $(window).height() ){
        	posTop = e.pageY - 40; 
        }else{
        	posTop = e.pageY + 15;
        }
	    $('#tooltip')
	           .text("x:" + e.pageX + "   y:" + e.pageY)
	           .css({
                       'margin-top':posTop,
                       'float':'left',
                       'position':'absolute',
                       'margin-left':posLeft,
                       'clear':'none',
                       'background-color':'#ccc',
                       'border':'1px solid silver',
                       'padding':'3px',
                       'width':'105px',
                       'height':'20px'
	                  });
	    }); 
};

