

	
		$(document).ready(function(){
			
			// ie stuff
			if($.browser.msie) $(".homepage_person_box_bg").addClass('ie');

			//------------- lightbox links ------------
			$("A.text-img-left-lightbox").append('<div class="plus"><div><!----></div></div>');
			$("A.text-img-right-lightbox").append('<div class="plus"><div><!----></div></div>');
			$("A.text-img-left-lightbox").addClass('text-img-left lightbox').removeClass('text-img-left-lightbox');
			$("A.text-img-right-lightbox").addClass('text-img-right lightbox').removeClass('text-img-right-lightbox');
			//------------- /lightbox links ------------
			
			//------------- select ------------
			$('select.site_select_menu')
				.selectmenu({
					style:  'dropdown',
					width: 333
				});
			//------------- /select ------------
			
			//------------- lightbox ------------
			$(".lightbox, .img_container A, .image A").lightbox();
			//------------- /lightbox ------------
			
			
			
			//------------ right menu 2 rows link ----------------
			line_height = 20;
			$("UL.content_right_menu LI A").each(function(){
				if( $(this).height() > line_height ){ $(this).addClass('rows_2'); }
			});
			//------------ /right menu 2 rows link ----------------
			
			
			
			//------------- right switcher ------------
			num_items 		= $("#panel_move UL LI").length;
			page_width		= $("#panel_move UL LI").width();
			current_page	= rand(num_items);
			slideshow_speed	= 3000; // in ms
			
		
				// generate nav links
				inner_li_html = "";
				for( i = 1; i <= num_items; i++ ){ i2 = ""; if( i < 10 ){ i2 = "0"; } inner_li_html += '<li><a href="#">' + i2 + i + '</a></li>'; }
				$("#right_switcher_nav").html('<ul>'+inner_li_html+'</ul>');
				
				// attach events
				$("#right_switcher_nav A").bind('click', function(){
					clearTimeout(efx_slideshow_timer);
					$("#right_switcher_nav A").removeClass('active');
					$(this).addClass('active');
					current_selected_pic 		= $( $("#right_switcher_nav UL LI A") ).index( $("#right_switcher_nav UL LI A.active") );
					efx_slideshow_timer = setTimeout( "efx_slideshow( current_selected_pic + 1 )", 0 );
					return false;	
				});
				
				// activate selected link + move panel to that pos
				$("#right_switcher_nav A").eq(current_page-1).addClass('active');
				first_left = -1 * (current_page-1) * page_width;
				$('#panel_move').css('left', first_left + 'px');
				
				// start slideshow
				efx_slideshow_timer = setTimeout( "efx_slideshow( efx_find_next_pic() )", slideshow_speed );
			//------------- /right switcher ------------
			
			
			
			// news box - left
			$(".news_box_column:even").addClass('left');
			$(".news_box_column:odd").addClass('right');
			
			if( $(".dont_wrap").length == 0 ){
				
				$(".news_box_column:not(.no_wrap):even:first").addClass('for_wrap');
				$(".news_box_column:not(.no_wrap):even:first").next('.right').addClass('for_wrap');
	
				inner_html = "";
				$(".for_wrap").each(function(){
					if( $(this).hasClass('left') ){ inner_html += '<div class="news_box_column left no_wrap">'+ $(this).html() + '</div>'; }
					if( $(this).hasClass('right') ){ 
						inner_html += '<div class="news_box_column right no_wrap">'+ $(this).html() + '</div>'; 
						$(this).after('<div class="news_box team_box">'+inner_html+'</div>'); 
						inner_html=""; 
						$(".for_wrap").remove(); 
					}
				});
				
				
				$(".news_box_column:not(.no_wrap):even:first").addClass('for_wrap');
				$(".news_box_column:not(.no_wrap):even:first").next('.right').addClass('for_wrap');
	
				inner_html = "";
				$(".for_wrap").each(function(){
					if( $(this).hasClass('left') ){ inner_html += '<div class="news_box_column left no_wrap">'+ $(this).html() + '</div>'; }
					if( $(this).hasClass('right') ){ 
						inner_html += '<div class="news_box_column right no_wrap">'+ $(this).html() + '</div>'; 
						$(this).after('<div class="news_box team_box">'+inner_html+'</div>'); 
						inner_html=""; 
						$(".for_wrap").remove(); 
					}
				});
				if( inner_html != "" ){ 
					$(".for_wrap.left").after('<div class="news_box team_box">'+inner_html+'</div>');
					$(".for_wrap").remove();  
				}
				
				
				$(".news_box_column:not(.no_wrap):even:first").addClass('for_wrap');
				$(".news_box_column:not(.no_wrap):even:first").next('.right').addClass('for_wrap');
	
				inner_html = "";
				$(".for_wrap").each(function(){
					if( $(this).hasClass('left') ){ inner_html += '<div class="news_box_column left no_wrap">'+ $(this).html() + '</div>'; }
					if( $(this).hasClass('right') ){ 
						inner_html += '<div class="news_box_column right no_wrap">'+ $(this).html() + '</div>'; 
						$(this).after('<div class="news_box team_box">'+inner_html+'</div>'); 
						inner_html=""; 
						$(".for_wrap").remove(); 
					}
				});
				if( inner_html != "" ){ 
					$(".for_wrap.left").after('<div class="news_box team_box">'+inner_html+'</div>');
					$(".for_wrap").remove();  
				}
				
				
				
			}
			

			
			//---------------- accordion ----------------
			$('#acc_list A.switch_link:first').addClass('first_top');
			$('#acc_list').accordion({});
			//---------------- /accordion ----------------



			
			//-------------- top menu generate --------------
			$("DIV#menu UL LI A").each(function(index){
				this_id = $(this).attr('id');
				$(this).parent('LI').attr('class', this_id);
			});
			//-------------- /top menu generate --------------
			
			
			
			// top menu add double links
			$("LI.tm_homepage").after('<li class="tm_homepage-1"><a href="' + $("DIV#menu UL LI A#tm_homepage").attr('href') + '">' + $("DIV#menu UL LI A#tm_homepage").text() + '</a></li>');
			$("LI.tm_news").after('<li class="tm_news-1"><a href="' + $("DIV#menu UL LI A#tm_news").attr('href') + '">' + $("DIV#menu UL LI A#tm_news").text() + '</a></li>');
			$("LI.tm_services").after('<li class="tm_services-1"><a href="' + $("DIV#menu UL LI A#tm_services").attr('href') + '">' + $("DIV#menu UL LI A#tm_services").text() + '</a></li>');
			$("LI.tm_showcase").after('<li class="tm_showcase-1"><a href="' + $("DIV#menu UL LI A#tm_showcase").attr('href') + '">' + $("DIV#menu UL LI A#tm_showcase").text() + '</a></li>');
			$("LI.tm_contact").after('<li class="tm_contact-1"><a href="' + $("DIV#menu UL LI A#tm_contact").attr('href') + '">' + $("DIV#menu UL LI A#tm_contact").text() + '</a></li>');
			
			
			// top menu - attach events
			$("LI.tm_homepage A, LI.tm_homepage-1 A").bind('mouseenter', function(){ $("DIV#menu").attr('class', ''); $("DIV#menu").addClass('active_homepage'); });
			$("LI.tm_news A, LI.tm_news-1 A").bind('mouseenter', function(){ $("DIV#menu").attr('class', ''); $("DIV#menu").addClass('active_news'); });
			$("LI.tm_about A").bind('mouseenter', function(){ $("DIV#menu").attr('class', ''); $("DIV#menu").addClass('active_about'); });
			$("LI.tm_services A, LI.tm_services-1 A").bind('mouseenter', function(){ $("DIV#menu").attr('class', ''); $("DIV#menu").addClass('active_services'); });
			$("LI.tm_showcase A, LI.tm_showcase-1 A").bind('mouseenter', function(){ $("DIV#menu").attr('class', ''); $("DIV#menu").addClass('active_showcase'); });
			$("LI.tm_contact A, LI.tm_contact-1 A").bind('mouseenter', function(){ $("DIV#menu").attr('class', ''); $("DIV#menu").addClass('active_contact'); });
			$("DIV#menu UL LI A").bind('mouseleave', function(){ $("DIV#menu").attr('class', ''); topmenu_active_page(); });
			
			// top menu - find active state
			topmenu_active_page();




			//------------------ border hover on images ------------------	
			$(".text-img-left , .text-img-right")
			.bind('mouseenter', function(){
				this_width 	= $(this).width();
				this_height = $(this).height();
				$(this).find('div.plus').css('width', (this_width - 8) + 'px');
				$(this).find('div.plus').css('height', (this_height - 8) + 'px'); 	
			})			
			.bind('mouseleave', function(){
				this_width 	= $(this).width();
				this_height = $(this).height();
				$(this).find('div.plus').css('width', this_width + 'px');
				$(this).find('div.plus').css('height', this_height + 'px'); 	
			});
			//------------------ /border hover on images ------------------
			
			// right switcher nav + align nav
			m_left = parseInt(($("#right_switcher_nav").width() - $("#right_switcher_nav UL").width()) / 2);
			$("#right_switcher_nav UL").css('margin-left', m_left + "px");
			
			
			// company credits - align nav
			m_left = 0;
			m_backlink = 0;
			m_explorelink = 0;
			if( $(".backlink").length ){ m_backlink = $(".backlink").width() - 80;  }
			if( $(".page_photogallery_nav .sitelink").length ){ m_explorelink = $(".page_photogallery_nav .sitelink").width() + 210;  }
			m_left = parseInt(($(".page_photogallery_nav").width() - 20 - m_backlink - m_explorelink - $("UL.pp_nav").width()) / 2);
			$("UL.pp_nav").css('margin-left', m_left + "px");
			
			
			// .last
			$(".footer_mainmenu LI:last, DIV.news_box:last ,DIV.credits_box:last, DIV#top UL LI:last").addClass('last');
			$("DIV.news_box.last").prepend('<div class="shadow_top"><!----></div><div class="shadow_right"><!----></div>');
			
			
			// odd ,even
			$("DIV.credits_box:even").addClass('box_left');
			$("DIV.credits_box:odd").addClass('box_right');
			
			
			// back
			$(".backlink").click(function(){
				history.go(-1);
				return false;	
			});
			
			
			
			// about page - photogallery
			photos_per_page = 12;
			$("UL.short_photogallery LI").each(function(index){
				page_num = 1;
				if( index < 12 ){ page_num = 1; }
				else if( index < 16 ){ page_num = 2; }
				else if( index < 24 ){ page_num = 3; }
				else if( index < 32 ){ page_num = 4; }
				else if( index < 40 ){ page_num = 5; }
				else if( index < 48 ){ page_num = 6; }
				else if( index < 56 ){ page_num = 7; }
				else if( index < 64 ){ page_num = 8; }
				else if( index < 72 ){ page_num = 9; }
				else if( index < 80 ){ page_num = 10; }
				$(this).addClass('page_' + page_num);
				$("UL.about_switcher LI A:first").addClass('active');
			});
			$("UL.short_photogallery LI").hide();
			$("UL.short_photogallery LI.page_1").show();
			
			$("UL.about_switcher LI A").bind('click', function(){
				
				$("UL.about_switcher LI A").removeClass('active');
				$(this).addClass('active');
				
				//page = parseInt($(this).html());
				page = parseInt( ($(this).html()).replace("0", "") );

							
				$("UL.short_photogallery LI").hide();
				$("UL.short_photogallery LI.page_" + page).show();
				
				return false;
			});
			
			
			// works photogallery
			photos_per_page = 4;
			$("UL.works_photogallery LI").each(function(index){
				page_num = 1;
				if( index < 4 ){ page_num = 1; }
				else if( index < 8 ){ page_num = 2; }
				else if( index < 12 ){ page_num = 3; }
				else if( index < 16 ){ page_num = 4; }
				else if( index < 20 ){ page_num = 5; }
				else if( index < 24 ){ page_num = 6; }
				else if( index < 28 ){ page_num = 7; }
				else if( index < 32 ){ page_num = 8; }
				else if( index < 36 ){ page_num = 9; }
				else if( index < 40 ){ page_num = 10; }
				$(this).addClass('page_' + page_num);
				$("UL.pp_nav LI A:first").addClass('active');
			});
			$("UL.works_photogallery LI").hide();
			$("UL.works_photogallery LI.page_1").show();
			
			$("UL.works_switcher LI A").bind('click', function(){
				
				$("UL.works_switcher LI A").removeClass('active');
				$(this).addClass('active');
				
				page = parseInt($(this).html());			
				$("UL.works_photogallery LI").hide();
				$("UL.works_photogallery LI.page_" + page).show();
				
				return false;
			});
			
			
			// odd , even
			$(".homepage_news_box_jq:even").addClass('news_left');
			$(".homepage_news_box_jq:odd").addClass('news_right');
			
			
			
			// input
			$("DIV.f_input INPUT")
			.bind('focus' , function(){
				$(this).parent("DIV.f_input").addClass('active');	
			})			
			.bind('blur' , function(){
				$("DIV.f_input").removeClass('active');	
			});
			
			$("DIV.f_ta TEXTAREA")
			.bind('focus' , function(){
				$(this).parent("DIV.f_ta").addClass('active');	
			})			
			.bind('blur' , function(){
				$("DIV.f_ta").removeClass('active');	
			});
			
			
			// submit contact
			$("#contact_submit").bind('click', function(){
				
				form_empty = "";
				
				if( $("#jqf_name").val() == "" ){ form_empty += "\n- Your name & surname"; }
				if( $("#jqf_email").val() == "" ){ form_empty += "\n- Your email address"; }
				//if( $("#jqf_company").val() == "" ){ form_empty += "\n- Company name:"; }
				if( $("#jqf_cell").val() == "" ){ form_empty += "\n- Telephone / Cell Phone"; }
				if( $("#jqf_subject OPTION:selected").val() == "" ){ form_empty += "\n- Subject of your contact"; }
				if( $("#jqf_message").val() == "" ){ form_empty += "\n- Message / Comment / Feedback / Inquiry"; }
				
				if( form_empty != "" ){
					form_empty = "Please enter:\n" + form_empty;
					alert( form_empty );	
				}
				else $("#contact_form").submit();
				
				return false;	
			});
			
			
			
			$("A.read_more_link").bind('click', function(){
				location.href = $(this).attr('href');
				return false;	
			});
			
			
			if( $("A.backlink").size() && $("DIV.page_photogallery UL.works_photogallery LI").size() == 0 ){
				$("DIV.page_photogallery , .pp_nav, .no_bottom_bg").remove();
			}
			
			
		});
