

	Cufon.replace('h1', {
		textShadow: '#333 1px 1px'
	});
	
	Cufon.replace('h2', {
		textShadow: '#666 1px 1px'
	});
	
	Cufon.replace('.violet h2', {
		textShadow: '#222 1px 1px'
	});
	
	Cufon.replace('.ffff');
	

	Cufon.replace('h3,a.more,#nav-listen a, .cufon');

	$(window).load(function() {
		/*
		*	Load main background image after others to prevent flickering
		*/
		if ( $('body').css('background-image') == 'none' ) {
			//var max = 4; // Number of images
			//$('body').css('background-image', 'url("/images/bg/bg' + ( Math.floor(Math.random() * max + 1) ) + '.jpg")');
			//$('body').css('background-image', 'url("/images/bg/bg.jpg")');
		}
	});
	
	$(document).ready(function() {
		
		/*
		*	Top menu
		*/

		$("ul.nav-sub").each(function() {
			var sub = $(this);
	
			if ($("li.active", sub).length) { //sub.parent().hasClass('active') || 
				sub.show();
			} else {
				sub.hide();
				
				sub.parent().hover(function() {
					sub.show();
				}, function() {
					sub.hide();
				});
			}
		});
	
		/*
		*	Headings
		*/
		
		$(".heading").addClass('png_bg').wrapInner('<div class="inner png_bg"></div>');
		
		/*
		*	Events pop-up
		*/
		
		function reposition(e) {
			var popup = $("#event-popup");
			
			var wh = $(window).height();
			var ww = $(window).width();
			var st = $(document).scrollTop();
			var sl = $(document).scrollLeft();
			
			var left	= e.clientX + sl + 10;
			var top		= e.clientY + st + 10;
			
			var w = popup.width();
			var h = popup.height();
			
			if (top  > ( wh + st - h - 10)) {
				top = wh + st - h - 10;
			}
			
			if (left  > ( ww + sl - w )) {
				left = left - w - 15;
			}

			popup.css({
				'top'	: top,
				'left'	: left
			})
		}
		
		$(".event-popup").mouseenter(function(e) {
			$("#event-popup").remove();

			var el = $(this);

			if (el.attr('article')) {
				window.location = '/news/?id=' + el.attr('article');

			} else if (el.attr('event')) {

				$.get("/event.php?id=" + el.attr('event'), function(data) {
					$('<div id="event-popup" style="display:none">' + data + '</div>' ).appendTo('body');
					
					var popup = $("#event-popup");
					
					Cufon.replace('h2', {
						textShadow: '#666 1px 1px'
					});
					
					popup.css('width', popup.width()).show();
					
					reposition(e );
					
					el.mousemove(function(e) {
						reposition(e );
					})
					.mouseleave(function() {
						el.unbind('mousemove');
						$("#event-popup").remove();
					});
				});
			}
		})
		

		$('.FacebookBtn').click(function () {
	        signinWin = window.open(this.href + '&display=popup', "SignIn", "width=600,height=388,toolbar=0,scrollbars=0,status=0,resizable=0,location=0,menuBar=0, left="+(screen.width?(screen.width-600)/2:0)+", top="+(screen.height?(screen.height-388)/2:0)+"");
	        signinWin.focus();
	        return false;
	    });
	    
	    $('.TwitterBtn').click(function () {
	        signinWin = window.open(this.href, "SignIn", "width=800,height=400,toolbar=0,scrollbars=0,status=0,resizable=0,location=0,menuBar=0, left="+(screen.width?(screen.width-800)/2:0)+", top="+(screen.height?(screen.height-400)/2:0)+"");
	        signinWin.focus();
	        return false;
	    });
	    
	     $('.GoogleBtn').click(function () {
	        signinWin = window.open(this.href, "SignIn", "width=800,height=400,toolbar=0,scrollbars=0,status=0,resizable=0,location=0,menuBar=0, left="+(screen.width?(screen.width-800)/2:0)+", top="+(screen.height?(screen.height-400)/2:0)+"");
	        signinWin.focus();
	        return false;
	    });

	    
	    $("#newsletter_wrap").submit(function() {
	    	$.post('/newsletter.php', {
	    		'val' : $("#newsletter_val").val()
			}, function(rez) {
				
				if (rez == 1) {
					$("#newsletter_wrap").html('<span class="cufon">Subscribed succesffully!</span>');
					
					Cufon.replace('#newsletter_wrap span');
				}
			});
			
			return false;
		});
		
		$("#newsletter_val").bind('focus', function() {
			if ($(this).val() == 'Subscribe to newsletter') {
				$(this).val('');
			}
		}).bind('blur', function() {
			if ($(this).val() == '') {
				$(this).val('Subscribe to newsletter');
			}
		});
	});
	

			

