/*
   ClickMap jQuery Plugin
   By Jay Salvat
   http://www.jaysalvat.com/
*/

(function($) { 

$.fn.saveClicks = function() { 
    $(this).bind('mousedown.clickmap', function(evt) { 
		if (screen.width > 1280) {
			actualx = ((screen.width - 1280) / 2);
			actualxx = evt.pageX - actualx;
		}
		else if (screen.width < 1280) {
			actualx = ((1280 - screen.width) / 2);
			actualxx = evt.pageX + actualx;
			
		}
		else if (screen.width == 1280) {
			actualxx = evt.pageX;
		}
		
        $.post('clickmap.php', {  
			   
            x:actualxx,  
            y:evt.pageY,
			width:screen.width,
			height:screen.height,
            l:escape(window.location) 
        }); 
    }); 
}; 
 
$.fn.stopSaveClicks = function() { 
     $(this).unbind('mousedown.clickmap'); 
}; 

$.displayClicks = function(settings) { 
    $('<div id="clickmap-overlay"></div>').appendTo('body'); 
 
    $('<div id="clickmap-loading"></div>').appendTo('body'); 
 
    $.get('clickmap.php', { l:settings },  
        function(html) { 
            $(html).appendTo('body');     
            $('#clickmap-loading').remove(); 
        } 
    ); 
}; 
 
$.removeClicks = function() { 
    $('#clickmap-overlay').remove(); 
    $('#clickmap-container').remove(); 
}; 
         
})(jQuery); 