//Font replacement

//IE Visible hack
Cufon.CSS.ready(function() {
  Cufon.CSS.addClass(Cufon.DOM.root(), 'cufon-replacing');
});

//Basic HTML
Cufon.replace("h1:not(.page):not(#sidebars h1):not(#sidebar_reports h1):not(.contact_form_heading h1)", { fontFamily: 'DinProRegular' });

//Navigation
Cufon.replace("#navigation_main ul li", { 
	fontFamily: 'DinProMedium',
	hover: {
		fontFamily: 'DinProMedium'
	}
});
Cufon.replace("#navigation_additional ul li", { fontFamily: 'DinProMedium' });
Cufon.replace("#header_links ul li", { fontFamily: 'DinProMedium' });
Cufon.replace("#languages ul li", { fontFamily: 'DinProMedium' });

//Home Info sidebar
Cufon.replace("#sidebar_home_info p", { fontFamily: 'DinProMedium' });

//Slider
Cufon.replace("#slider h1", { fontFamily: 'DinProMedium' });
Cufon.replace("#slider .slider_box_inner", { fontFamily: 'DinProMedium' });

//Stack info
Cufon.replace("#sidebar_stock_info", { fontFamily: 'DinProMedium' });

//Hone Info Sidebar
Cufon.replace("#sidebar_home_info h1", { fontFamily: 'DinProRegular' });

//Menu sidebar
Cufon.replace("#sidebar_inner_menu ul li:not(:first-child)", { fontFamily: 'DinProMedium' });
Cufon.replace("#sidebar_inner_menu ul li.current-menu-item:not(:first-child)", { fontFamily: 'DinProBold', color: "#333333" });
Cufon.replace("#sidebar_inner_menu ul li ul.sub-menu li", { fontFamily: 'DinProMedium' });
Cufon.replace("#sidebar_inner_menu ul li ul.sub-menu li.current-menu-item", { fontFamily: 'DinProBold', color: "#333333" });

//O nama page
Cufon.replace(".page_inner p.dotted a", { fontFamily: 'DinProRegular' });
Cufon.replace(".page_inner p.dotted_uppercase a", { fontFamily: 'DinProRegular' });
Cufon.replace(".page_inner p.dotted_normalcase", { fontFamily: 'DinProRegular' });

//Investors page
Cufon.replace(".investors_page_info", { fontFamily: 'DinProMedium', color: "#167ABE" });

//Sidebar video
Cufon.replace("#sidebar_video .generic_page_column", { fontFamily: 'DinProMedium'});
Cufon.replace("#sidebar_video_modernizacija .generic_page_column", { fontFamily: 'DinProMedium'});

//Followus menu
Cufon.replace(".sidebar_news_header_column ul.sidbar_news_follow_us li", { fontFamily: 'DinProMedium' });

//Sidebar counter
Cufon.replace("#sidebar_counter ul li div.investors_page_columns", { fontFamily: 'DinProRegular' });
Cufon.replace("#sidebar_counter ul li", { fontFamily: 'DinProMedium' });

//Sidebar stock info
Cufon.replace("#sidebar_stock_info_big .sidebar_stock_info_heading", { fontFamily: 'DinProMedium' });
Cufon.replace("#sidebar_stock_info_big table td", { fontFamily: 'DinProMedium' });

//Sidebar potrosacki sajt
Cufon.replace("#sidebar_potrosacki_sajt .generic_page_column", { fontFamily: 'DinProMedium'});

$(document).ready(function($)
{
	//SLIDER
	if($('#slider div').size() > 1){
		$('#slider').diapo({
			fx	: "simpleFade",
			loader 	: "none",
			barPosition	: "bottom",
			barStroke	: 5,
			thumbs: false,
			pauseOnClick: true,
			time: 5000,
			transPeriod: 1100,
			autoAdvance: true,
			commands: false,
			mobileCommands: false,
			pagination: true,
			slideOn: "next"
		});
	}
	
	//Main navigation
	$("#navigation_firstmenu, #navigation_brandmenu, .sidbar_news_follow_us").superfish({
		autoArrows:    false,
		animation:   {opacity:'show',height:'show'},
		delay:       500,
		dropShadows: false ,
		speed:   'fast'
	});
	
	$("#navigation_firstmenu ul li").hover(function()
	{
		var width = $(this).width() + 1;
		var subwidth;
		var id = $(this).attr("id");
		
		//Detect current language
		var current_language = $("#current_language").val();
		
		//Width of submenu fix
		if (current_language == "sr")
		{
			switch (id)
			{
				//Delatnosti
				case "menu-item-104" : subwidth = 215; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;
				//Istorija kompanije
				case "menu-item-105" : subwidth = 100; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;
				//Proizvodi
				case "menu-item-305" : subwidth = 180; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;			
				case "menu-item-311" : subwidth = 285; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;
				case "menu-item-108" : subwidth = 335; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;
				case "menu-item-107" : subwidth = 195; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;
				//Odrzivi razvoj
				case "menu-item-1536" : subwidth = 180; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;
				//Posao i karijera
				case "menu-item-1726" : subwidth = 305; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;				
				//Korporativno upravljanje
				case "menu-item-92" : subwidth = 255; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;				
				//Izvestavanje
				case "menu-item-91" : subwidth = 235; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;				
				//Pitanja i odgovori
				case "menu-item-94" : subwidth = 195; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;				
				//Korisne informacije za akcionare
				case "menu-item-1926" : subwidth = 145; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;				
				//Tri godine uspeha
				case "menu-item-106" : subwidth = 150;  $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;
			}
		}
		else if (current_language == "sh")
		{
			switch (id)
			{
				//O nama
				case "menu-item-104" : subwidth = 195; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;
				//Istorija kompanije	
				case "menu-item-105" : subwidth = 90; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;
				//Proizvodi
				case "menu-item-305" : subwidth = 170; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;			
				//Usluge
				case "menu-item-311" : subwidth = 265; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;
				//Modernizacija
				case "menu-item-108" : subwidth = 290; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;
				//Menadzment
				case "menu-item-107" : subwidth = 190; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;
				//Posao i karijera
				case "menu-item-1726" : subwidth = 290; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;	
				//Korporativno upravljanje
				case "menu-item-92" : subwidth = 255; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;				
				//Izvestavanje
				case "menu-item-91" : subwidth = 215; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;				
				//Pitanja i odgovori
				case "menu-item-94" : subwidth = 185; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;				
				//Korisne informacije za akcionare
				case "menu-item-1926" : subwidth = 140; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;											
				//Tri godine uspeha
				case "menu-item-106" : subwidth = 150;  $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;
			}
		}
		else if (current_language == "en")
		{
			switch (id)
			{
				//O nama
				case "menu-item-104" : subwidth = 220; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;
				//Istorija kompanije	
				case "menu-item-105" : subwidth = 75; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;
				//Proizvodi
				case "menu-item-305" : subwidth = 200; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;			
				//Usluge
				case "menu-item-311" : subwidth = 260; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;
				//Modernizacija
				case "menu-item-108" : subwidth = 330; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;
				//Menadzment
				case "menu-item-107" : subwidth = 180; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;
				//Posao i karijera
				case "menu-item-1726" : subwidth = 140; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;	
				//Korporativno upravljanje
				case "menu-item-92" : subwidth = 225; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;				
				//Izvestavanje
				case "menu-item-91" : subwidth = 215; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;				
				//Pitanja i odgovori
				case "menu-item-94" : subwidth = 205; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;				
				//Korisne informacije za akcionare
				case "menu-item-1926" : subwidth = 140; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;	
				//Odgovornost prema drustvu
				case "menu-item-1536" : subwidth = 260; $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;																									
				//Tri godine uspeha
                                case "menu-item-106" : subwidth = 180;  $(this).attr("style", "background: #F2F2F2 url('/wp-content/themes/nis/images/icon_navigation_arrow.png') no-repeat top right; "); break;
			}
		}
		

		$("ul.sub-menu", this).attr("style", "background: white; left: "+width+"px; position: absolute;  top: -12px; border-top: 1px dotted #59595C; width: "+subwidth+"px;");
	}, function()
	{
		$(this).removeAttr("style");
	});
	
	//Left navigation
	$("#sidebar_inner_menu ul li").each(function()
	{
		if ($(this).hasClass("current_page_item"))
		{
			var obj = $("ul.sub-menu", this);
 
			if (!(typeof obj === 'undefined'))
			{
				obj.show();
			}
			
		}
	});
	
	//Left subnav
	$("#sidebar_inner_menu ul.sub-menu li").each(function()
	{
		if ($(this).hasClass("current_page_item"))
		{
			$(this).parent().show();			
		}
	});
	
	//Margin fix
	$(".sidebar:last").css("margin-bottom", 0);
	
	//Gallery hack for Fancybox
	$(".gallery a").each(function()
	{
		$(this).attr("rel", "gallery_1");
	});
	
	//Gallery margin hack
	var a = 1;
	$(".gallery-item").each(function()
	{
		if (a % 3 == 0)
		{
			$(this).attr("style", "margin-right: 0;");
		}
		a++;
	});
	
	//Fancybox	
	$(".fbox, .gallery a").fancybox({
		maxWidth	: 800,
		maxHeight	: 600,
		fitToView	: true,
		width		: '70%',
		height		: '70%',
		autoSize	: true,
		closeClick	: true,
		padding		: 5,
		closeBtn	: true,
		openEffect	: 'fade',
		closeEffect	: 'fade',
		arrows		: true
	});
    
    //IE Last-child hacks
    $("#navigation_main ul li:last-child").addClass("ie_last_child");
    $("#sidebar_reports ul li:last-child").addClass("ie_last_child");
    $(".sidebar_news_content ul li:last-child").addClass("ie_last_child");
    $("#sidebar_campaigns ul li:last-child").addClass("ie_last_child");
	
});

Cufon.CSS.ready(function() {
  Cufon.CSS.removeClass(Cufon.DOM.root(), 'cufon-replacing');
});

