// JavaScript Document

		   
function init(){
	
	$("a[href$='.pdf']").attr("target","_blank");
	$("a[href^='http://']").attr("target","_blank");
	
	// Limba si butonul de schimbare al limbii
	//$("a").live("click", function(e){e.preventDefault();
	$("a","#alege-limba").click(function(e){e.preventDefault();
		var lang = "ro"; var langOpus = "en";
		var amEN = window.location.pathname.search("/en/");
		lang = (amEN == -1)?"ro":"en";
		
		langOpus = (amEN == -1)?"en":"ro";
		langOpus = (langOpus=="ro")?"":langOpus;
	
		var adr = document.URL
		var adr = (lang=="en")?adr.replace(".ro/website/en/","/"):adr.replace(".ro/website/",".ro/website/en/");
		window.location.replace(adr);
	});

	
	
	$("#buton-meniu-float").hover(
      function () {$("#zona-meniu-float").fadeIn('fast');$("#logo-over").fadeOut('slow');$("#mapContainer").fadeOut('fast');
	  }, 
      function () {});
	$("#zona-meniu-float").hover(
      function () {}, 
      function () {$(this).fadeOut('slow');});


 	$("#logo").hover(
      function () {$("#logo-over").fadeIn('slow');$("#zona-meniu-float").fadeOut('slow');}, 
      function () {});
 	$("#logo-over").hover(
      function () {}, 
      function () {$(this).fadeOut('fast');});	
	
	
	$("#bt_harta").click(function(event){
								  event.preventDefault();
								  doRenderMap(44.441286, 26.119733, 5, "Str. Dimitrie Onciul, Nr. 23-25");
								  $("#mapContainer").fadeIn('fast');
								 
		});
	$("#bt_harta2").click(function(event){
								  event.preventDefault();
								  doRenderMap(44.214442,28.641873, 6, "Blv. Mamaia, Nr. 304");
								  $("#mapContainer").fadeIn('fast');					 
		});
	$(".bt_harta_link").click(function(){$("#bt_harta").click();});
	$(".bt_harta_link2").click(function(){$("#bt_harta2").click();});


	$(".bt_pano_link").click(function(){
									  event.preventDefault();
									  $("#mapContainer >#map").html("<iframe src='http://www.norc.ro/embed.aspx?id=2f9a936ea07c4567e3fc0ac635b215a9&ppa=256.3&r=127.48&vla=-26.92&lz=80&acc=8419d2ef-0622-41ac-8fe1-7fdc54fbcf15' frameborder='0' scrolling='no' width='100%' height='100%'></iframe>");
									  $("#mapContainer").fadeIn('fast');
									  });
	$(".bt_pano_link2").click(function(){
									  event.preventDefault();
									  $("#mapContainer >#map").html("<iframe src='http://www.norc.ro/embed.aspx?id=4536da46872de3fe380447332ea71fa1&ppa=277.4&r=276.2&vla=-7.3&lz=28&acc=8419d2ef-0622-41ac-8fe1-7fdc54fbcf15' frameborder='0' scrolling='no' width='100%' height='100%'></iframe>");
									  $("#mapContainer").fadeIn('fast');
									   });





	$("#bt_close_harta").click(function(event){$("#mapContainer").fadeOut('fast');event.preventDefault();
		});
	$(".proiect").click(function(event){
								 $("ul.detalii:visible").not( $(this).parent().children(".detalii")).slideUp('slow')
								 $(this).parent().children(".detalii").slideToggle('slow');
								 event.preventDefault();

		});

	$(".bt_detalii").live("click",function(event){
									//$(".BT_detalii").slideDown("slow",function(){$(this).parent().children(".info").slideUp("slow");});;
									$(".info:visible").slideUp("slow",function(){$(this).parent().children(".BT_detalii").slideDown("slow");});
									//$("BT_detalii").focus();
									$(this).parent().slideUp("slow");
									$(this).parent().parent().children(".info").slideDown("slow");
									$(this).parent().parent().children(".info").children(".bt_inchide").click(
																			function () { 
																			$(this).parent().parent().children(".BT_detalii").slideDown("slow"); 
																			$(this).parent().slideUp("slow");
																			});
									event.preventDefault();
									 });

	$(".bt_cuprins").click(function(event){
								 $(this).parent().parent().children(".cuprins").slideToggle('slow');
								 event.preventDefault();

		});


		
		// Create a map object 
		
		//doRenderMap(44.441286, 26.119733,1,"-");
		
	function doRenderMap($x, $y, $nr, $adr){
		$("#mapContainer > #map").remove();
		$("#mapContainer").append('<div id="map">&nbsp;</div>');

		delete map, latlon, myMarker, myMarkerContent;
		var map = new YMap(document.getElementById('map'), YAHOO_MAP_REG, new YSize(680, 460));  
		map.addZoomLong();  
		map.addPanControl();  
		map.setMapType();
		var latlon = new YGeoPoint($x, $y);
		var myMarker = new YMarker(latlon);
		var myMarkerContent = "<div style='padding:20px; width:180px; height:60px;'><h2><strong>INCD GeoEcoMar</strong></h2><p>" + $adr + "</p></div>";
		YEvent.Capture(myMarker, EventsList.MouseClick,
		function() {myMarker.openSmartWindow(myMarkerContent);});
		map.addOverlay(myMarker);
		map.drawZoomAndCenter(latlon, $nr);
		myMarker.addAutoExpand("INCD GeoEcoMar");
		myMarker.openSmartWindow(myMarkerContent);
		}


		// functie pentru "Stiri"
	function doRollStiri(){
		
		$('#block-modul-lista-stiri li:first').animate({opacity: 1.0}, 3000);
		$('#block-modul-lista-stiri li:first').animate(
					//start animate				
					{marginTop: "-75px"}, 
					{duration: 2000, queue: true, complete: function(){
						//start functionComplete
						$('#block-modul-lista-stiri li:first').insertAfter($('#block-modul-lista-stiri li:last'));
						$('#block-modul-lista-stiri li:last').css("margin-top","0px");
						$('#block-modul-lista-stiri li:first').animate({opacity: 1.0}, 3000);
						doRollStiri();
						//end functionComplete
						}
					}
					//end animate
					);
	}
	
	// apelarea functiei
	doRollStiri();
	

		$(".grupa-titlu").each(function(i){
										$obj_this = $(this);
										    $("#bt"+i).click(function (event) {	
															  event.preventDefault();
															  apeleazaAfisarea(i);
															   });
								});
		function apeleazaAfisarea(t){
			$(".grupa-titlu").each(function(i){
											
								if (i == t) {
									$(this).slideDown('slow');
									$("#" + i + " + .grupa-proiecte").slideDown('slow');
								} else{
									$(this).slideUp('fast');
									$("#" + i + " + .grupa-proiecte").slideUp('fast');
									}
								});	
		}
		apeleazaAfisarea(0);


/*$('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
    && location.hostname == this.hostname) {
      var $target = $(this.hash);
      $target = $target.length && $target
      || $('[name=' + this.hash.slice(1) +']');
      if ($target.length) {
        var targetOffset = $target.offset().top;
        $('html,body')
		.animate({opacity: 1.0}, 1000)
        .animate({scrollTop: targetOffset}, 1000);
       return false;
      }
    }
  });*/

	$(document).bind("DOC_READY", incarcare);
	
	function incarcare(){
		var $getDEP = $(".coloanaX").attr("dep");
		
		$(".coloanaX").html("");
		
		$.ajax({
			   type: "POST",
			   url: "admin/cod/php/genereaza-dep.php",
			   dataType: "html",
			   data: "dep=" + $getDEP,
			   error: function(data){
				  alert(data);
				   },
			   success: function(data){
				   $(".coloanaX:first").html(data);
				   $(".coloanaX").css('background','none');
				   }
			});
		
		}
		
	$(document).trigger({type:"DOC_READY"});	

	var mod = true;
	$("#bt_anunt-maimult").click(function(e){
									if (mod) $(this).text("mai putin [-]");
									else $(this).text("mai mult [+]");
									mod = !mod;
									  $("#anunt-maimult").slideToggle("fast");
									  //alert("click");
									  e.preventDefault()
									  });
	
	var mod2 = true;
	$("#bt_anunt-maimult2").click(function(e){
									if (mod2) $(this).text("mai putin [-]");
									else $(this).text("mai mult [+]");
									mod2 = !mod2;
									  $("#anunt-maimult2").slideToggle("fast");
									  //alert("click");
									  e.preventDefault()
									  });
	$("#bt_anunt-maimult3").click(function(e){
									if (mod2) $(this).text("mai putin [-]");
									else $(this).text("mai mult [+]");
									mod2 = !mod2;
									  $("#anunt-maimult3").slideToggle("fast");
									  //alert("click");
									  e.preventDefault()
									  });
	$("#bt_anunt-maimult4").click(function(e){
									if (mod2) $(this).text("mai mult [+]");
									else $(this).text("mai putin [-]");
									mod2 = !mod2;
									  $("#anunt-maimult4").slideToggle("fast");
									  //alert("click");
									  e.preventDefault()
									  });
	//$("#bt_anunt-maimult4").click();
	
	$('.bt-mai-mult').toggle(
	function(e){e.preventDefault();
		$('.mai-mult').slideDown('fast');
		$(this).text('Mai putin');
		},
	function(e){e.preventDefault();
		$('.mai-mult').slideUp('slow');
		$(this).text('Mai mult');
		});
}


		

$(document).ready(init);

function laValidare(){
	//alert('Va multumim! \n\nIn cazul in care sunt campuri cu fundal rosu va rugam sa revizuiti informatia introdusa in acele campuri.\n\nEchipa GeoEcoMar.');
}
