$(document).ready(function() {
		
		//$(document).mousemove(function(e){
		//	$('#status').html(e.pageX +', '+ e.pageY);
		//});
		
		var lang = $("body").attr("id");
		
		if (lang == "serbian") {
			var tooltips = new Array(
				"",
				"<div class=\"normalText\"><b>Nagrada reformator godine ’09</b></div>",
				"<div class=\"normalText\"><b>Okrugli sto o planiranju i izgradnji ‘09</b></div>",
				"<div class=\"normalText\"><b>Reformator '10</b></div>",
				"<div class=\"normalText\"><b>Radna večera sa ambasadorom SAD ‘08</b></div>",
				"<div class=\"normalText\"><b>Inauguracija NALED-a ‘06</b></div>",
				"<div class=\"normalText\"><b>Inauguracija NALED-a ‘06</b></div>",
				"<div class=\"normalText\"><b>Inauguracija NALED-a ‘06</b></div>",
				"<div class=\"normalText\"><b>Promocija Kalkulatora '10</b></div>",
				"<div class=\"normalText\"><b>Konferencija Iz Lavirinta ‘08</b></div>",
				"<div class=\"normalText\"><b>Radni ručak sa ambasadorom SAD ‘08</b></div>",
				"<div class=\"normalText\"><b>Sporazum o certifikaciji ‘09</b></div>",
				"<div class=\"normalText\"><b>Konferencija o municipalnim obveznicama ‘09</b></div>",
				"<div class=\"normalText\"><b>Radni ručak sa ambasadorkom SAD ‘10</b></div>",
				"<div class=\"normalText\"><b>Promocija - Aerodrom '10</b></div>",
				"<div class=\"normalText\"><b>Sporazum o certifikaciji ‘09</b></div>",
				"<div class=\"normalText\"><b>Sporazum o certifikaciji ‘09</b></div>",
				"<div class=\"normalText\"><b>Nagrada reformator godine ’09</b></div>",
				"<div class=\"normalText\"><b>Nagrada reformator godine ’09</b></div>",
				"<div class=\"normalText\"><b>Nagrada reformator godine ’09</b></div>",
				"<div class=\"normalText\"><b>Radni ručak sa direktorom Svetske banke ‘09</b></div>",
				"<div class=\"normalText\"><b>Radni ručak sa direktorom Svetske banke ‘09</b></div>",
				"<div class=\"normalText\"><b>Radni ručak sa direktorom Svetske banke ‘09</b></div>",
				"<div class=\"normalText\"><b>Radni ručak sa ambasadorom Nemačke ‘10</b></div>",
				"<div class=\"normalText\"><b>Okrugli sto - Vršac'10</b></div>",
				"<div class=\"normalText\"><b>Okrugli sto - FIAT'10</b></div>",
				"<div class=\"normalText\"><b>Okrugli sto - Javno privatna partnerstva '10</b></div>",
				"<div class=\"normalText\"><b>Okrugli sto - Vršac '10</b></div>",
				"<div class=\"normalText\"><b>Okrugli sto - Izmene zakona o planiranju i izgradnji, NBS '10</b></div>",
				"<div class=\"normalText\"><b>Nacionalne veletržnice '10</b></div>",
				"<div class=\"normalText\"><b>Konferencija Sajam Investexpo '10</b></div>",
				"<div class=\"normalText\"><b>Dom Narodne Skupštine - Certifikacija '10</b></div>",
				"<div class=\"normalText\"><b>Banke i privreda '10</b></div>",
				"<div class=\"normalText\"><b>Regulatorna reforma Srbije - Kako iz lavirinta '10</b></div>",
				"<div class=\"normalText\"><b>Radni ručak sa direktorom NSZ-a '11</b></div>",
				"<div class=\"normalText\"><b>EFG Expo Serbia '11</b></div>",
				"<div class=\"normalText\"><b>Skupština NALED '11</b></div>",
				"<div class=\"normalText\"><b>Okrugli sto SEWEA '11</b></div>",
				"<div class=\"normalText\"><b>Radni ručak sa Ministrom Ekonomije '11</b></div>",
				"<div class=\"normalText\"><b>Radni ručak sa portugalskim ambasadorom i zamenikom šefa delegacije EU '11</b></div>",
				"<div class=\"normalText\"><b>Okrugli sto - Nacrt uredbe o konverziji prava korišćenja građevinskog zemljišta '11</b></div>",
				"<div class=\"normalText\"><b>Svečana dodela certifikata '11</b></div>",
				"<div class=\"normalText\"><b>Ambasadorska inicijativa '11</b></div>",
				"<div class=\"normalText\"><b>Upoznaj državu Srbiju '11</b></div>");
		}
		
		if (lang == "english") {
			var tooltips = new Array(
				"",
				"<div class=\"normalText\"><b>Reformer of the year award ’09</b></div>",
				"<div class=\"normalText\"><b>Round table - Law on planning and construction ’09</b></div>",
				"<div class=\"normalText\"><b>Top reformer '10</b></div>",
				"<div class=\"normalText\"><b>Business dinner with US Ambassador ’08</b></div>",
				"<div class=\"normalText\"><b>NALED inauguration ceremony ’06</b></div>",
				"<div class=\"normalText\"><b>NALED inauguration ceremony ’06</b></div>",
				"<div class=\"normalText\"><b>NALED inauguration ceremony ’06</b></div>",
				"<div class=\"normalText\"><b>Calculator promotion '10</b></div>",
				"<div class=\"normalText\"><b>Conference „Out of the maze“ ’08</b></div>",
				"<div class=\"normalText\"><b>Business luncheon with US Ambassador ’08</b></div>",
				"<div class=\"normalText\"><b>MoU on certification ’09</b></div>",
				"<div class=\"normalText\"><b>Conference of municipal bonds ’09</b></div>",
				"<div class=\"normalText\"><b>Business luncheon with US Ambassador ’10</b></div>",
				"<div class=\"normalText\"><b>Promotion - Airport '10</b></div>",
				"<div class=\"normalText\"><b>MoU on certification ’09</b></div>",
				"<div class=\"normalText\"><b>MoU on certification ’09</b></div>",
				"<div class=\"normalText\"><b>Reformer of the year award ’09</b></div>",
				"<div class=\"normalText\"><b>Reformer of the year award ’09</b></div>",
				"<div class=\"normalText\"><b>Reformer of the year award ’09</b></div>",
				"<div class=\"normalText\"><b>Business luncheon with Head of World Bank ’09</b></div>",
				"<div class=\"normalText\"><b>Business luncheon with Head of World Bank ’09</b></div>",
				"<div class=\"normalText\"><b>Business luncheon with Head of World Bank ’09</b></div>",
				"<div class=\"normalText\"><b>Business luncheon with German Ambassador ’10</b></div>",
				"<div class=\"normalText\"><b>Round table - Vrsac '10</b></div>",
				"<div class=\"normalText\"><b>Round table - FIAT '10</b></div>",
				"<div class=\"normalText\"><b>Round table - Public-Private Partnership '10</b></div>",
				"<div class=\"normalText\"><b>Round table - Vrsac '10</b></div>",
				"<div class=\"normalText\"><b>Round table - Amendments to Law on Planning and Construction, NBS '10</b></div>",
				"<div class=\"normalText\"><b>National Wholesale market '10</b></div>",
				"<div class=\"normalText\"><b>Conference InvestExpo Fair '10</b></div>",
				"<div class=\"normalText\"><b>National assembly hall - Certification '10</b></div>",
				"<div class=\"normalText\"><b>Banks and Economy '10</b></div>",
				"<div class=\"normalText\"><b>Regulatory Reform in Serbia - Out of the maze? '10</b></div>",
				"<div class=\"normalText\"><b>Business luncheon with director of NES '11</b></div>",
				"<div class=\"normalText\"><b></b>EFG Expo Serbia '11</div>",
				"<div class=\"normalText\"><b>NALED assembly '11</b></div>",
				"<div class=\"normalText\"><b>Round table SEWEA '11</b></div>",
				"<div class=\"normalText\"><b>Working luncheon with the Minister of Economy ‘11</b></div>",
				"<div class=\"normalText\"><b>Working luncheon with the Ambassador of Portugal and the Deputy Chief of the Delegation of EU ‘11</b></div>",
				"<div class=\"normalText\"><b>Round table - The Draft Decree on Conversion of the Right to Use Land ‘11</b></div>",
				"<div class=\"normalText\"><b>Certification of business friendly municipalities '11</b></div>",
				"<div class=\"normalText\"><b>Ambassadors initiative '11</b></div>",
				"<div class=\"normalText\"><b>Meet the state of Serbia '11</b></div>");
		}
		
		$("#tooltip").css("width", "890px");
		$("#tooltip").css("height", "20px");
		$("#tooltip").css("padding", "5px");		
		$("#tooltip").css("background", "url(js/pics/blankwhite.png) 0 0");
		//$("#tooltip").css("opacity", ".3");
		$("#tooltip").css("position", "absolute");
		$("#tooltip").css("z-index", "200000");
		$("#tooltip").css("top", "420px");
		$("#tooltip").css("left", "50%");
		$("#tooltip").css("margin", "0 0 0 -450px");
		$("#tooltip").hide();
		
		$(".imgHeader").mousemove(function() {
			$("#tooltip").html(tooltips[$(this).attr("id").substr(6)]);
			//alert(tooltips[$(this).attr("id").substr(6)]);
			if ($("#tooltip").is (':visible')) {}	
			else {$("#tooltip").show();}
		});
		
		$(document).mousemove(function(e) {
			if((e.pageX < 260) || (e.pageX > 1160) || (e.pageY < 150) || (e.pageY > 450)) {
				$("#tooltip").hide();
			}
		});

		$("#back").css("background", "black");
		$("#back").css("opacity", "0.6");
		$("#back").css("width", "100%");
		$("#back").css("min-height", "100%");
		$("#back").css("top", "0");
		$("#back").css("left", "0");
		$("#back").css("z-index", "499999");
		$("#back").hide();

		$("html").css("overflow-x", "hidden");
		
		var browserName=navigator.appName;

		var browserVer=parseInt(navigator.appVersion);
		if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
			 var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		}

		if (browserName=="Microsoft Internet Explorer" && ieversion<7)	{
			//alert(browserVer);
			$("#back").css("width", "102%");
			$("#back").css("height", "150%");
			$("#back").css("position", "absolute");
			$("#showImage").css("position", "absolute");
			$("#showFond").css("position", "absolute");
			$("#showMedia").css("position", "absolute");
		} else {
			$("#back").css("position", "fixed");
			$("#showImage").css("position", "fixed");
			$("#showFond").css("position", "fixed");
			$("#showMedia").css("position", "fixed");
		}
 
		$("#showImage").css("top", "50%"); $("#showImage").css("left", "50%"); 
		$("#showImage").css("margin", "-300px 0 0 -400px");
		$("#showImage").css("width", "800px");
		$("#showImage").css("height", "600px");
		$("#showImage").css("background", "white");
		$("#showImage").css("z-index", "600000");
		$("#showImage").css("border", "1px solid black");

		$("#showImage").hide();
		
		$("#showFond").css("top", "50%");
		$("#showFond").css("left", "50%");	
		$("#showFond").css("margin", "-300px 0 0 -400px");
		$("#showFond").css("width", "800px");
		$("#showFond").css("height", "600px");
		$("#showFond").css("background", "url(js/pics/ajaxHandlerBack.png) no-repeat 0 0");
		$("#showFond").css("z-index", "510000");
		$("#showFond").hide();
		
		
		$("#showMedia").css("top", "50%");
		$("#showMedia").css("left", "50%");	
		$("#showMedia").css("margin", "-228px 0 0 -260px");
		$("#showMedia").css("width", "520px");
		$("#showMedia").css("height", "456px");
		$("#showMedia").css("background", "url(js/pics/ajaxMediaBack.png) no-repeat 0 0");
		$("#showMedia").css("z-index", "520000");
		$("#showMedia").hide();
		
		

		// FUNKCIJE
		
		function showMessageWindow() { 
			$("#showMessage").empty(); $("#showMessage").css("background", "white url(js/ajax-loader.gif) no-repeat center"); $("#showMessage").css("padding", "0"); $("#showMessage").fadeIn("slow"); $("html").css("overflow-y", "hidden"); $("#back").toggle();
		}
		
		function hideMessageWindow() {
			$("#showMessage").hide(); $("#back").hide(); $("html").css("overflow-y", "auto");
		}
		
		function ieScroll() {
			if (browserName=="Microsoft Internet Explorer" && ieversion<7)	{ window.scrollTo(0,0); }
		}
		
		$(".fond").click(function(e) {
			//var path = "pics/galerija/" + $(this).children().attr("class") + ".jpg";
			e.preventDefault();
			$("#showFond").load('js/php/ajaxCitajFond.php', {'id': $(this).attr("id"), 'lang': lang}, function() {
				$("#zatvoriFond").click(function(e) {
					e.preventDefault();
					$("#showFond").fadeOut("slow");
					$("#back").fadeOut("slow");
					$("html").css("overflow-y", "auto");
				});
				
				$("#stampajFond").click(function() {
				});
				
				
			});
			$("#showFond").css("width", "800px");
			$("#showFond").css("height", "600px");
			$("#showFond").css("margin", "-300px 0 0 -400px");
			$("#showFond").css("padding", "20px 0 5px 20px");
			$("#showFond").css("background", "url(js/pics/ajaxHandlerBack.png) no-repeat 0 0");
			//$("#showFond").css("cursor", "pointer");
			$("#showFond").fadeIn("slow");
			$("html").css("overflow-y", "hidden");
			$("#back").toggle();
			
		});
		
		
		
		$(".pressclipping").click(function(e) {
			e.preventDefault();
			//var path = "pics/galerija/" + $(this).children().attr("class") + ".jpg";
			$("#showFond").load('js/php/ajaxCitajPressclipping.php', {'id': $(this).attr("id")}, function() {
				$("#zatvoriPressclipping").click(function(e) {
					e.preventDefault();
					$("#showFond").fadeOut("slow");
					$("#back").fadeOut("slow");
					$("html").css("overflow-y", "auto");
				});
				
				$("#stampajPressclipping").click(function() {
				});
				
				
			});
			$("#showFond").css("width", "800px");
			$("#showFond").css("height", "600px");
			$("#showFond").css("margin", "-300px 0 0 -400px");
			$("#showFond").css("padding", "20px 0 5px 20px");
			$("#showFond").css("background", "url(js/pics/ajaxHandlerBack.png) no-repeat 0 0");
			//$("#showFond").css("cursor", "pointer");
			$("#showFond").fadeIn("slow");
			$("html").css("overflow-y", "hidden");
			$("#back").toggle();
			
		});
		
		
		
		
		$(".trening").click(function(e) {
			e.preventDefault();
			//var path = "pics/galerija/" + $(this).children().attr("class") + ".jpg";
			$("#showFond").load('js/php/ajaxCitajTrening.php', {'id': $(this).attr("id"), 'lang': $("body").attr("id")}, function() {
				$("#zatvoriTrening").click(function(e) {
					e.preventDefault();
					$("#showFond").fadeOut("slow");
					$("#back").fadeOut("slow");
					$("html").css("overflow-y", "auto");
				});
				
				$("#stampajTrening").click(function() {
				});
				
				
			});
			$("#showFond").css("width", "800px");
			$("#showFond").css("height", "600px");
			$("#showFond").css("margin", "-300px 0 0 -400px");
			$("#showFond").css("padding", "20px 0 5px 20px");
			$("#showFond").css("background", "url(js/pics/ajaxHandlerBack.png) no-repeat 0 0");
			//$("#showFond").css("cursor", "pointer");
			$("#showFond").fadeIn("slow");
			$("html").css("overflow-y", "hidden");
			$("#back").toggle();
			
		});		
	
		
		
		
		
		$('a.showOffer').click(function(e) {
			e.preventDefault();
			id=$(this).attr('id');
			//var path = "pics/galerija/" + $(this).children().attr("class") + ".jpg";
			$("#showFond").load('js/php/ajaxCitajBerzu.php', {'offerID': id}, function() {
				$("#zatvoriFond").click(function(e) {
					e.preventDefault();
					$("#showFond").fadeOut("slow");
					$("#back").fadeOut("slow");
					$("html").css("overflow-y", "auto");
				});
				
				$("#mailBerza").click(function(e) {
					e.preventDefault();
					$.post('js/php/emailForm.php', function(data) {

						
						jPrompt('Unesite e-mail adresu na koju želite da pošaljete preporuku:', 'Email...', 'Slanje preporuke', function(r) {
							if(r) {
								$.post('js/php/emailRecommendation.php', {'id': id, 'toemail' : r}, function(data2) {
									if(data2=="OK") {
										jAlert('Vaša preporuka je uspešno poslata. Hvala Vam.', 'Slanje preporuke');
									} else {
										jAlert('Vaša preporuka nije poslata. Pokušajte ponovo.', 'Slanje preporuke');
									}
								});

							} else {
								jAlert('Vaša preporuka nije poslata. Pokušajte ponovo.', 'Slanje preporuke');
							}
						});
					});
				});
				
				
			});
			$("#showFond").css("width", "800px");
			$("#showFond").css("height", "600px");
			$("#showFond").css("margin", "-300px 0 0 -400px");
			$("#showFond").css("padding", "20px 0 5px 20px");
			$("#showFond").css("background", "url(js/pics/ajaxHandlerBack.png) no-repeat 0 0");
			//$("#showFond").css("cursor", "pointer");
			$("#showFond").fadeIn("slow");
			$("html").css("overflow-y", "hidden");
			$("#back").toggle();

		});
		
		
		
		
		
		
		
		$("#companyDiv").load("js/php/dodajBanerKompanije.php", function() {
			$('#slider').cycle({
				fx:     'fade',
				speed:   300,
				timeout: 3000,
				next:   '#slider',
				pause:   1
			});
		});
			
		
		$("#partnersDiv").load("js/php/dodajBanerPartnera.php", function() {
			$('#slider2').cycle({
				fx:     'fade',
				speed:   300,
				timeout: 3000,
				next:   '#slider2',
				pause:   1
			});
		});
		
		
		
		/*
		$(".galleryThumbImage").click(function() {
			if (browserName=="Microsoft Internet Explorer" && ieversion<7)	{
				window.scrollTo(0,0);
			}
			
			var path = "pics/galerija/" + $(this).children().attr("class") + ".jpg";
			$("#showImage").css("background", "white url(pics/content/ajax-loader.gif) no-repeat center");
			$("#showImage").load('js/php/ajaxShowImage.php', {'path' : path}, function() {
				$(this).click(function() {
					$(this).fadeOut("slow");
					$("#back").fadeOut("slow");
					$("html").css("overflow-y", "auto");
				});
			});

			$("#showImage").css("padding", "0");
			//$("#showImage").css("cursor", "pointer");
			$("#showImage").fadeIn("slow");
			$("html").css("overflow-y", "hidden");
			$("#back").toggle();
			
		});
		*/
		
		$("#gallery-thumbs a").lightBox();
		
		
		// member service handlers
		$(".member_service > div").toggle();
		
		$(".member_service > li > a").click(function() {
				var div = $(this).attr("id");
				//alert (div+"-content");
				$("#"+div+"-content").toggle();
		});
		
		// LTS sidebar right handlers
		$(".LTS").toggle();
		$(".LTSgroup").click(function() {
			var attr = $(this).attr("id");
			$("."+attr+"-content").toggle();
		});
		
		
		$("area").each(function () {
			$(this).click(function() {
			
				if($(this).attr("href") == "#") {
			
					$("#showFond").load('js/php/ajaxCitajCertOpstinu.php', {'id': $(this).attr("id"), 'lang': $("body").attr("id")}, function() {
						$("#zatvoriCertOpstinu").click(function() {
							$("#showFond").fadeOut("slow");
							$("#back").fadeOut("slow");
							$("html").css("overflow-y", "auto");
						});
					
					});
					$("#showFond").css("width", "800px");
					$("#showFond").css("height", "600px");
					$("#showFond").css("margin", "-300px 0 0 -400px");
					$("#showFond").css("padding", "20px 0 5px 20px");
					$("#showFond").css("background", "url(js/pics/ajaxHandlerBack.png) no-repeat 0 0");
					//$("#showFond").css("cursor", "pointer");
					$("#showFond").fadeIn("slow");
					$("html").css("overflow-y", "hidden");
					$("#back").toggle();
				}
			});
		});
		
		
		
		$("#vv").load("js/php/videocomponent.php", function() {
		$("#videobox").load('js/php/showvideo.php');
		$("#videoname").load('js/php/showvideoname.php');
	
		$("#videolinks a").each(function() {
				
			$(this).click(function() {	

				$("#videobox").load('js/php/showvideo.php', {'id': $(this).attr('id')});
				$("#videoname").load('js/php/showvideoname.php', {'id': $(this).attr('id')});
			});
		});
	});
		
});
