windowFocus = true;

$(document).ready(function()
{
	$(".latest-video").colorbox({iframe:true, transition:"fade", innerWidth:640, innerHeight:480});
	$(".gallery a").colorbox({transition:"fade", maxWidth:"75%", maxHeight:"75%"});
	$("#view-tables").colorbox({transition:"fade", maxWidth:"75%", maxHeight:"75%"});
	$(".upcoming-event a.colorbox").colorbox({transition:"fade", maxWidth:"75%", maxHeight:"75%"});
});


$(window).blur(function(){
	if(windowFocus === true)
		windowFocus = false;

		clearInterval(sliderInterval);
		clearInterval(switcherInterval);
		clearInterval(partysliderInterval);

});

$(window).focus(function(){
	if(windowFocus === false){
		windowFocus = true;

	    $('#party-slider').switcher();	
		$('#news-slider').fader();
		$('#latest-photos-slider').partySlider();
	}
})

$(document).ready(function() {


if($('#phone_input').length > 0)
$('#phone_input').keypress(function(e) {
	if(isNaN(String.fromCharCode(e.keyCode)) || String.fromCharCode(e.keyCode) == ' ' || e.keyCode == 160 )
	{
		return false;
	}
									
});


/*
 * Footer Fade Effect on hover
 */
 
	$(function() {
		$("#partners a").css("opacity","0.4");
		$("#partners a").hover(
			function() {
				$(this).stop().animate({opacity: 1.0}, "fast");
			},
			function() {
				$(this).stop().animate({opacity: 0.5}, "fast");
			}
		);
	});

/* 
 * Slider Initiation 
 */

	$('#news-slider').fader();
	$('#party-slider').switcher();
	$('#latest-photos-slider').partySlider();
	
	
/* 
 * Menu v2- light version 
 */
 
 	$('#page-header ul > li').hover(
		function() {
			$(this).addClass('hover');
			$('ul', this).stop(true,true).slideDown(300);
		}, 
		function() {
			$(this).removeClass('hover');
			$('ul', this).slideUp(300);
		}
	);
 
});

/*
 * BEGIN OF Main Site Left Top Slider 
 */

(function($) {	
		
	sliderInterval = null;
	currentSlideI = 0;
	switchTime = 10000;
	sliderReady = false;
	faderInit = false;

	$.fn.fader = function() {
		if(faderInit == false) {
			faderInit = true;
		
		$('#latest-news,#news-slider-navigation').hover(
			function() {	
				$('#news-slider-navigation').stop(true,true);
				clearInterval(sliderInterval);
				sliderInterval = null;
			}, 
			function() {
				clearInterval(sliderInterval);
				sliderInterval = null;
				if(childcount.length > 0) {
					sliderInterval = setInterval("fade.fadermove();",switchTime);
				}
			}
		);
		
		$('#news-slider-navigation a').click(function() {
			if(sliderReady && !$(this).hasClass('current')) {
				$('#news-slider > li').stop(true,true);
				sliderReady = false;			

				$.each($('#news-slider li'),
					function() {
						if($(this).css('opacity') == '1') {
	 						$(this).animate({opacity:0},800,
	 							function() {
	 								$(this).css('display','none'); 
	 							}
	 						);
 						} 
 					}
 				);
 			
 				currentSlideI = $(this).parent().index();	
 			
				$(childs[currentSlideI]).delay(1200).css('display','block').animate({opacity:1},1200, 
					function() {					
						sliderReady = true;
						if(currentSlideI < childcount) {
							currentSlideI++;
						} else {
							currentSlideI = 0;
						}
					}
				);
				
				$('#news-slider-navigation .current').removeClass('current');
				$('#news-slider-navigation li:nth-child('+parseInt(currentSlideI+1)+') a').addClass('current');
			}
			return false;
		});
		
		childs = Array(); 
		childsNodes = $(this).children();
		childcount = childsNodes.length-1; 	
		
		$.each(childsNodes,
			function(i,v) {
				childs[i] = v;		
			}
		);	
		
		}
		fade = new fader();
		fade.fadermove();
		if(childcount > 0) {
			sliderInterval = setInterval("fade.fadermove()",switchTime);
		}
		
	}

	var fader = function() {
		this.fadermove = function() {
			
			fadeDelay = 0;
			sliderReady = false;
 			$.each(childs,
 				function() {
 					if($(this).css('opacity') == '1') {
 						$(this).animate({opacity:0},800, 
 							function() {
								$(this).css('display','none'); 						
 							}
 						);
 						fadeDelay = 1200;	
 					}
 				}
 			);
 			
			$(childs[currentSlideI]).css('display','block').delay(fadeDelay).animate({opacity:1},1200,
				function() {
					sliderReady = true;
				}
			);
			
			$('#news-slider-navigation .current').removeClass('current');
			$('#news-slider-navigation li:nth-child('+parseInt(currentSlideI+1)+') a').addClass('current');
			
			if(currentSlideI < childcount){
				currentSlideI++;
			} else {
				currentSlideI = 0;
			}
		} 
	}
})(jQuery);

/*
 * END OF Main Site Left Top Slider 
 */


/*
 * BEGIN OF Main Site Right Top Slider 
 */
 
(function($) {	
		
	switcherInterval = null;
	currentSlidexI = 0;
	switchxTime = 9000;
	switcherReady = false;
	switcherInit = false;
	
	$.fn.switcher = function() 
	{
		if(switcherInit == false){
			switcherInit = true;
		
		$('#latest-party,#party-slider-navigation').hover(function(){	
			$('#party-slider-navigation').stop(true,true);
			//$('#latest-news ul li').stop(true,true);
			clearInterval(switcherInterval);
			switcherInterval = null;
		}, function(){
			clearInterval(switcherInterval);
			switcherInterval = null;
			if(childcountx > 0) {
				switcherInterval = setInterval("switche.switchmove();",switchxTime);
			}
		});
		
		$('#party-slider-navigation a').click(function(){
		if(switcherReady && !$(this).hasClass('current')) {
			switcherReady = false;
			$('#latest-party #party-slider > ul li').stop(true,true);

			$.each($('#latest-party #party-slider li'),function(){
			
				if($(this).css('opacity') == '1'){
	 				$($(this)).animate({opacity:0},1200, function(){
						$(this).css('display','none');
						$(this).find('.first-line').css('opacity','0');
						$(this).find('.second-line').css('opacity','0');
						$(this).find('.third-line').css('opacity','0');
						$(this).find('.badge').css('opacity','0');
 					});
 				} 
 			});
 			
 			currentSlidexI = $(this).parent().index();	
			
			$(childsx[currentSlidexI]).delay(1500).css('display','block').animate({opacity:1},1200,function(){
				
					$(this).find('.first-line').animate({opacity:1},800);
					$(this).find('.second-line').delay(800).animate({opacity:1},800);
					$(this).find('.third-line').delay(1600).animate({opacity:1},800);
					$(this).find('.badge').delay(2400).animate({opacity:1},800, function(){
						
					});
					setTimeout("switcherReady = true;", 2400);
			});
				

			
			$('#party-slider-navigation .current').removeClass('current');
			$('#party-slider-navigation li:nth-child('+parseInt(currentSlidexI+1)+') a').addClass('current');
			
			
				if(currentSlidexI < childcountx) {
					currentSlidexI++;
				} else {
					currentSlidexI = 0;
				}

			}
			return false;
		});
		
		childsNodesx = $(this).children();
		childcountx = childsNodesx.length-1; 
		childsx = Array(); 
		
		$.each(childsNodesx, function(i,v){
			childsx[i] = v;
		});	
		
		}
		switche = new switchthis();
		switche.switchmove();
	
		if(childcountx > 0) {
			switcherInterval = setInterval("switche.switchmove()",switchxTime);
		}	
	}
	
	
	
	var switchthis = function(){
		this.switchmove = function(){
			
			prevNr = 0;
			if(currentSlidexI == 0){
				prevNr = childcountx;
			} else{
				prevNr = currentSlidexI - 1;
			}
			delay = 0;
			switcherReady = false;
			switcherDelay = 0;
			$.each(childsx, 
				function(i,v) {
					if($(v).css('opacity')=='1') {
						switcherDelay = 1500;
						$(v).animate({opacity:0},1200, 
							function() {
								$(this).css('display','none');
								$(this).find('.first-line').css('opacity','0');
								$(this).find('.second-line').css('opacity','0');
								$(this).find('.third-line').css('opacity','0');
								$(this).find('.badge').css('opacity','0');
								
							}	
						);
					}
				}
			);

			$(childsx[currentSlidexI]).delay(switcherDelay).css('display','block').animate({opacity:1},1200,function(){
				
					$(this).find('.first-line').animate({opacity:1},800);
					$(this).find('.second-line').delay(800).animate({opacity:1},800);
					$(this).find('.third-line').delay(1600).animate({opacity:1},800);
					$(this).find('.badge').delay(2400).animate({opacity:1},800, function(){
						switcherReady = true;
					});
					setTimeout("switcherReady = true;",2400);
			})

			$('#party-slider-navigation .current').removeClass('current');
			$('#party-slider-navigation li:nth-child('+parseInt(currentSlidexI+1)+') a').addClass('current');
			
			if(currentSlidexI < childcountx){
				currentSlidexI++;
			} else currentSlidexI = 0;
		} 
	}

})(jQuery);
	
/*
 * END OF Main Site Right Top Slider 
 */	
	

/* main site right slider bottom */

(function($) {	
		
	partysliderInterval = null;
	partycurrentSlideI = 0;
	partyswitchTime = 10000;
	partysliderReady = false;
	partySliderInited = false;

	classes = Array('photo-third','photo-second','photo-first','photo-fifth' ,'photo-fourth');
	if($(window).width() > 1024) {
		animations = Array( {'index':16,'animation':{top: -55, left:137, rotate:'0deg'}},{'index':15,'animation':{ top: -85, left: 10, rotate:'-6deg'}},{'index':14,'animation':{top: -45, left: -60, rotate:'-12deg'}}, {'index':12,'animation':{top: -50, left: 320, rotate:'14deg'}},{'index':15,'animation':{top: -80, left:260,rotate:'8deg'}});
	} else {
		animations = Array( {'index':16,'animation':{top: -55, left:137, rotate:'0deg'}},{'index':15,'animation':{ top: -85, left: 40, rotate:'-6deg'}},{'index':14,'animation':{top: -45, left: 10, rotate:'-12deg'}}, {'index':12,'animation':{top: -50, left: 250, rotate:'14deg'}},{'index':15,'animation':{top: -80, left:230,rotate:'8deg'}});
	}
	console.log($(window).width());
	console.log('asdasd');
	
	$.fn.partySlider = function() {
		if(partySliderInited == false){
			partySliderInited = true;
		
		partychilds = Array(); 
		partychildsNodes = $(this).children();
		partychildcount = partychildsNodes.length-1; 	
		
		$('#latest-photos-container, #latest-photos-slider li').hover(
			function() {
				clearInterval(partysliderInterval);
				partysliderInterval = null;
			},
			function() {
				clearInterval(partysliderInterval);
				partysliderInterval = null;
				partysliderInterval = setInterval("partySliderf.partySlide()",partyswitchTime);
			}
		);
		
		$('#latest-photos-navigation a').click(
			function(e) {
				if(partysliderReady && !$(this).hasClass('current')) {
					$('#latest-photos-slider > li').stop(true,true);
					sliderReady = false;			
 					partySelectedSlideI = $(this).parent().index();	
 				
 					classPointer = 0;
					pointer = partycurrentSlideI;
					while(partycurrentSlideI != partySelectedSlideI ) {
						classPointer = 0;
						pointer = partycurrentSlideI;
	 					while(classPointer <= 4) {
 				
 							$(partychilds[pointer]).attr('class','').addClass(classes[classPointer]).css('z-index',animations[classPointer]['zindex']).animate(animations[classPointer]['animation'], 300, 
 								function()	{
		 							partysliderReady = true;
	 							}
	 						);
	 			
 							classPointer++;
 							if(pointer < partychildcount) {
								pointer++;
							} else {
								pointer = 0;
							}
 						}
 						
 						if(partycurrentSlideI < partychildcount) {
							partycurrentSlideI++;
						} else {
							partycurrentSlideI = 0;
						}
 					}
 				
					$('#latest-photos-navigation  .current').removeClass('current');
					$('#latest-photos-navigation  li:nth-child('+parseInt(partycurrentSlideI+1)+') a').addClass('current');
				}
			
				return false;
			}
		);
		
		$.each(partychildsNodes,
			function(i,v) {
				partychilds[i] = v;		
			}
		);	
		}
		partySliderf = new partySlider();
		partySliderf.partySlide();
		partysliderInterval = setInterval("partySliderf.partySlide()",partyswitchTime);
		
	}

	var restartSlider = function() {
		partySliderf = new partySlider();
		partySliderf.partySlide();
		partysliderInterval = setInterval("partySliderf.partySlide()",partyswitchTime);
	}
	
	var partySlider = function() {
		this.partySlide = function() {
			

			partysliderReady = false;

			classPointer = 0;
			pointer = partycurrentSlideI;
 			while(classPointer <= 4){

 					$(partychilds[pointer]).animate(animations[classPointer]['animation'], 1500, 
 						function()	{
		 					partysliderReady = true;
						}
	 				)
	 				setTimeout("$(partychilds["+pointer+"]).attr('class','').css('z-index',animations["+classPointer+"]['zindex']).addClass(classes["+classPointer+"])",550);
	 				/* .delay(1500).css('z-index',animations[classPointer]['zindex']); */

/*
 					$(partychilds[pointer]).attr('class','').addClass(classes[classPointer]).css('z-index',animations[classPointer]['zindex']).animate(animations[classPointer]['animation'], 800, 
 						function(){
	 						partysliderReady = true;
	 					}
	 				);
*/
	 			
	 			

	 			//$(partychilds[pointer]).delay(810).addClass(classes[classPointer]);
	 			
 				classPointer++;
 				if(pointer < partychildcount){
					pointer++;
				} else {
					pointer = 0;
				}
 			}
		
			//$(partychilds[partycurrentSlideI]).addClass('photo-first');


			$('#latest-photos-navigation .current').removeClass('current');
			$('#latest-photos-navigation li:nth-child('+parseInt(partycurrentSlideI+1)+') a').addClass('current');
			
			if(partycurrentSlideI < partychildcount){
				partycurrentSlideI++;
			} else {
				partycurrentSlideI = 0;
			}
		} 
	}
})(jQuery);
