function imgWin(imgSrc) {
	margin = 20;
	win = open("/tools/image.php?img="+escape(imgSrc), "win", "resizable,width=100,height=100,top=0,left=0");
	img = new Image();
	img.onload = function() {
		win.resizeTo(w = img.width + margin, h = img.height + margin*3);
	}
	img.src = imgSrc;
}

Shadowbox.init({
    SkipInit: true
});
function imgWin(src){
    Shadowbox.open({
        content:    src,
        player:     "img",
        title: '',
        options: {
            handleOversize: 'resize'
        }
    })
}

	$(document).ready(function(){
//			var cookie =  $.cookie("answered");
//			if (cookie) {
				$("a[rel='colorbox']").colorbox({loop:false, top: true});
//			}
//			else {
//				$("a[rel='colorbox']").colorbox({
//					width: "50%",
//					inline: true,
//					href: "#poll", 
//	                                current: "",
//					rel: "nofollow",
//					top: true,
//				});
	
	
				
//			}
	 
	});
	

//(function($){

	$('input#submit-poll').live('click', function(){
                var formData = $('#poll-form').serialize();
		$('.poll-buttons').css('display', 'none');
		$('#cboxLoadingGraphic').css('display', 'block');
	 	$.ajax({
		  url: '/poll/poll.php',
		  type: 'post',
		  data: (formData),
		  dataType: 'json',
		  success: function(response){
			if (response.error) {
                                $('#error').html(response.message);
				 $.colorbox.resize();
			}else {
				$.cookie("answered", true, { expires: 365});
				$('#poll').html(response.message);
				$.colorbox.resize();
				setTimeout(function(){ 
				   restart(); 
				  }, 2000 ); 
	
				 
			}
		  },
                  error: function(xhr, type, exception) { alert("Error: " + exception); }
		});
		$('#cboxLoadingGraphic').css('display', 'none');
		$('.poll-buttons').css('display', 'block');
		
		
		 });
		
function restart() {
	$.colorbox.remove();
	$.colorbox.init();
	$("a[rel='colorbox']").colorbox({
	 	href: false,
	 	open: true,
	 	top: true,
		photo: true,
	    loop: false,
	}); 
	$('#cboxOverlay').css('display', 'block');
	$.colorbox.resize();
}
//})(jQuery);
