
		$(function(){
			$("#latest").serialScroll({
				items:'li',
				duration:800,
				force:true,
				cycle:true,
				axis:'y',
				lazy:true,// NOTE: it's set to true, meaning you can add/remove/reorder items and the changes are taken into account.
				interval:6000, // yeah! I now added auto-scrolling
				step:1 // scroll 2 news each time
			});

			$("#slider").serialScroll({
				target:'#imgbraket',
				items:'li',
				navigation:'#switcher ul li',
				duration:0,
				interval:5200,
				force:true,
				axis:'x',
				onBefore:function(){
					//$("#imgbraket ul li").fadeOut();
				},
				onAfter:function(){				
					$("#imgbraket ul li").fadeIn(800);
				}
			});

		});
		sfHover = function()
{
	var sfEls = document.getElementById( "nav" ).getElementsByTagName( "LI" );
	for ( var i = 0; i < sfEls.length; i++ )
	{
		sfEls[i].onmouseover = function()
		{
			this.className += " sfhover";
		}
		sfEls[i].onmouseout = function()
		{
			this.className = this.className.replace(new RegExp( " sfhover\\b"), "" );
		}
	}
}
if ( window.attachEvent ) window.attachEvent( "onload", sfHover );

function initMenus() {
	$('ul.menu ul').hide();
	$.each($('ul.menu'), function(){
	$('.lit').next('ul').show();
	//$('.lit').parent('ul').siblings().show();
	$('.lit').parent().parent().show();
		//$('#' + this.id + '.expandfirst ul:first').show();
	});
	$('.lit').next('ul').show();
	$('.lit').parent('ul').siblings().show();
	$('ul.menu li').click(
		function() {
			$('.lit').next('ul').show();
			$('.lit').parents().show();
			var checkElement = $(this).next();
			var parent = this.parentNode.parentNode.id;

			if($('#' + parent).hasClass('noaccordion')) {
				$('.lit').next('ul').show();
				$('.lit').parents().show();
				$(this).next().slideToggle('normal');
				
				return false;
			}
			if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
				$('.lit').next('ul').show();
				$('.lit').parents().show();
				if($('#' + parent).hasClass('collapsible')) {
					$('#' + parent + ' ul:visible').slideUp('normal');
				}
				
				return false;
			}
			if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
				$('.lit').next('ul').show();
				$('.lit').parents().show();
				$('#' + parent + ' ul:visible').slideUp('normal');
				checkElement.slideDown('normal');
				
				return false;
			}
			
			$('.lit').next('ul').show();
			$('.lit').parents().show();
		}
	);
}
$(document).ready(function() {initMenus();});

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupContact").fadeIn("slow");
		popupStatus = 1;
	}
}

//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupContact").fadeOut("slow");
		popupStatus = 0;
		$("#popupContact").hide()
		$("#backgroundPopup").hide();
	}
}

//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = $(window).width()/*document.documentElement.clientWidth*/;
	var windowHeight = $(window).height()/*document.documentElement.clientHeight*/;
	var popupHeight = $("#popupContact").height();
	var popupWidth = $("#popupContact").width();
	//centering
	$("#popupContact").css({
		"position": "absolute",
		"top": (windowHeight/2-popupHeight/2),
		"left": (windowWidth/2-popupWidth/2)
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}


//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){

	

	//LOADING POPUP
	//Click the button event!
	//$("#xbutton4").click(function(){
	$("#qlambass").click(function(){
		loadPopup();
		//centering with css
		centerPopup();
		//load popup
		
	});
	
	$(".button").click(function(){
		//centering with css
		centerPopup();
		//load popup
		loadPopup();
	});
				
	//CLOSING POPUP
	//Click the x event!
	$("#popupContactClose").click(function(){
		disablePopup();
	});
	$("#entersite").click(function(){
		disablePopup();
	});
	//Click out event!
	
	$("#backgroundPopup").click(function(){
		disablePopup();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});

});
