/*
jQuery(function()
	{
		jQuery('#pane').jScrollPane({scrollbarWidth:5, showArrows:false});
	});
jQuery(function()
	{
		jQuery('#pane2').jScrollPane({scrollbarWidth:5, showArrows:false});
	});
	*/


		// run the currently selected effect

	
		
		// callback function to bring a hidden box back

	
		// set effect from select menu value
		/*
		$( "#button" ).click(function() {
			runEffect();
			return false;
		});
		*/

$(function() {
//	jQuery("body").css("display", "none");		
	  jQuery(".pageWrapper").css("display", "none");		
//	  jQuery("#KrisBg").css("display", "none");		
//	    jQuery("body").fadeIn(1000);
	   jQuery(".pageWrapper").fadeIn(3000);
//	   jQuery("#KrisBg").fadeIn(1000);
var bgImage = $('#KrisBg');      
if($('#pane4').length){
	//$('#pane4').jScrollPane({scrollbarOnLeft:true});
}
    if($('#bottom_c1').length){
		 $("#bottom_c1").toggle(
      function () {
		
		//$(this).removeClass('closed');
		//$(this).addClass('opened');
		  $(this).fadeIn(1000).css({'background-image' : 'url(\'images/panel_down-min.png\')','height' : '36px'});
       $('.center_p').fadeIn(1000).css({"display":"none"});
       $('.bottom_p').css({"display":"none"});
      },
      function () {
	
	//	$(this).removeClass('opened');
	//	$(this).addClass('closed');
	$(this).fadeIn(1000).css({'background-image' : 'url(\'images/pb1.png\')','height' : '10px'});
       $('.center_p').fadeOut(1000).css({"display":"block"});
       $('.bottom_p').css({"display":"block"});
      }
    );

		$(".center_p").click(function () {
			$('.center_p').toggleClass("highlight");
		});

	/*	$('#bottom_c1').click(function () {
			$('.center_p').css({"display":"block"});
		},
		function () {
			$('.center_p').css({"display":"none"});
		});
		*/
	}
		function runEffect() {
		
			//var effects = ['','','','','','','',];
		
			// get effect type from 
			var selectedEffect = 'explode';
			
			// most effect types need no options passed by default
			var options = {};
			// some effects have required parameters
			if ( selectedEffect === "scale" ) {
				options = { percent: 0 };
			} else if ( selectedEffect === "transfer" ) {
				options = { to: "#button", className: "ui-effects-transfer" };
			} else if ( selectedEffect === "size" ) {
				options = { to: { width: 200, height: 60 } };
			}

			// run the effect
			$( "#KrisBg" ).effect( selectedEffect, options, 1000, callback );
				$( "#KrisBg" ).css({ 'display':'block' }).fadeIn();
		};

		function callback() {
			
			var options = {};
		//		$( "#effect" ).removeAttr( "style" ).hide().fadeIn();
		
				runEffect();
			//	bounce
				
				$( "#KrisBg" ).effect( 'bounce', options, 1000, callback );
				
			};
	if($('.imageGroup').length){
	/*	$(".imageGroup").colorbox({transition:"none", height:"80%"});*/
	$("a[rel=example_group]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'opacity':'false',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});	}
	if($('.VideoGroup').length){
		$(".VideoGroup").fancybox({
				'width'				: '75%',
				'height'			: '75%'
			});					
	}
	
	var $winheight = $(window).height();
		$(".source-image").attr({
			height: $winheight
		});
		$(window).bind("resize", function(){
			var $winheight = $(window).height();
			$(".source-image").attr({
				height: $winheight
			});
		 });
	
	
	if($('.menu_element').length){
		$('.menu_element').animate({opacity: 0.5}, 1000);
		$(".link_menu").hover(
			
			function () {				
				var id = $(this).attr('id');				
				$('#menu_element_'+id).addClass("hover");
				
				$('#menu_element_'+id).animate({opacity: 1.0}, 1000);
			/*	
				$("#OpenMenu").removeClass("OpenMenuNotActive");
			
				$("#OpenMenu").addClass("OpenMenuActive");
				
				$("#OpenMenu").fadeIn(100);
			*/

			},
			function () {
				var id = $(this).attr('id');	
				
				$('#menu_element_'+id).animate({opacity: 0.5}, 1000);
				
				$('#menu_element_'+id).removeClass("hover");
			/*	
				$("#OpenMenu").fadeOut(100);
				
				$("#OpenMenu").removeClass("OpenMenuActive");
				
				$("#OpenMenu").addClass("OpenMenuNotActive");
			*/	
			}
		);
	}
	if($('#MainLogo').length){
		alert(13);
	}
	/*
	$('.link_bg').click(function(){
	var bg = $(this).attr('rel');
		
		$('body').animate({opacity: 0.5}, 1000,function(){
			$('body').css({'background-color' : '#'+bg});
		});
		$('body').animate({opacity: 1.0}, 1000);
		//$('body').fadeIn(500);
		
		//alert('change Bg:'+bg);
	});
	*/
	$(".MainLogo").hover(
	
	  function () {
		$("#OpenMenu").removeClass("OpenMenuNotActive");
		$("#OpenMenu").addClass("OpenMenuActive");
		$("#OpenMenu").fadeIn(500);
	  },
	  function () {
		//$("#OpenMenu").fadeOut(500);
		$("#OpenMenu").removeClass("OpenMenuActive");
		$("#OpenMenu").addClass("OpenMenuNotActive");
	  }
	);
	if($('.body_menu').length){
		$('.link_bg').animate({opacity: 0.9}, 500);
		$(".link_bg").hover(
			
			function () {				
				var ids = $(this).attr('id');
					
				$('#elem_'+ids).addClass("hoverMenuBg");
				
				$('#elem_'+ids).animate({opacity: 1.0}, 500);

			},
			function () {
				var ids = $(this).attr('id');	
				
				$('#elem_'+ids).animate({opacity: 0.5}, 500);
				$('#elem_'+ids).removeClass("hover");
				
			}
		);
	}
	if($('.news_block').length){
		$(".news_block a").hover(function() {
                $(this).css({'z-index' : '10'});
                $(this).find('img').stop()
                .animate({
			
                    width: '130px',
                    height: '130px'
                }, 400);
                
                
            }, function() {
                $(this).css({'z-index' : '0'});
                $(this).find('img').stop()
                .animate({
                    top: '5px',
                    left: '5px',
                    width: '126px',
                    height: '126px'
                }, 250);
                $(this).find('span').remove();
            });
	}
	
	$('#tf_loading').hide()
}); 
var step = 1;	 
	var current = 1;	 
//	var array = ['shake','explode','bounce','explode'];
	var array = ['shake'];
	var x = 0;
	var options = {};	
	function scrollBg(){
		
		
		
		
		
		
			//$('#KrisBg').css({'background-image' : 'url("images/loader.gif")','background-position:' : "middle center"});
			
				
			
			if(countBgImages > current){
				current = current + step;	
			} else {
				current = 0;	
			}
				
				
				
			
			if(x >1){
				x=0;
			}
			
		//	$( "#KrisBg" ).effect( 'shake', options, 2000);	
			$('#KrisBg').css({'background-image' : 'url("images/backgrounds/textures/'+images_bg[current]+'")'});
			$( "#KrisBg" ).css({ 'display':'block' }).fadeIn(1000);
			x = x + 1;
			}
	setInterval("scrollBg()", 18000);
//	$( "#KrisBg" ).effect( 'shake', options, 2000);

