	startslide = function(container){
		$('.slidecontainer').hide();
		$(container).show();
		$(container+' .carousel').hide();
		$(container+' .carousel:first').show();
		
		$('#titleslide').html($('#img1').attr("title"));
		$('#zona').html($('#img1').attr("zn"));
		$('#suprafata').html($('#img1').attr("sup"));
		$('#anul').html($('#img1').attr("an"));
		$('#tipof').html($('#img1').attr("tip"));
		$('#pret').html($('#img1').attr("pret"));
		$('#linkchange').attr('href','anunt/eil'+$('#img1').attr("rel"));

		
		$('#pagination').empty();
		$(container+" img").each(function(index) {
			i=index+1;
			if(i==1)cls='active';else cls='';
			$("#pagination").append($('<a>'+i+'</a>')
				.attr({ href : '#',rel: i })
				.addClass(cls)
			)
		  });
		  
		changeslide = function(){
				$("#pagination a").removeClass('active');
				$active.addClass('active');		
				$(container+' .carousel').fadeOut(800);
			    $(container+" .carousel:nth-child("+$active.attr("rel")+")").fadeIn(800);
				
				$('#titleslide').html($(container+" .carousel:nth-child("+$active.attr("rel")+")").attr("title"));
				$('#zona').html($(container+" .carousel:nth-child("+$active.attr("rel")+")").attr("zn"));
				$('#suprafata').html($(container+" .carousel:nth-child("+$active.attr("rel")+")").attr("sup"));
				$('#anul').html($(container+" .carousel:nth-child("+$active.attr("rel")+")").attr("an"));
				$('#tipof').html($(container+" .carousel:nth-child("+$active.attr("rel")+")").attr("tip"));
				$('#pret').html($(container+" .carousel:nth-child("+$active.attr("rel")+")").attr("pret"));
				$('#linkchange').attr('href','anunt/eil'+$(container+" .carousel:nth-child("+$active.attr("rel")+")").attr("rel"));
		}
		
		newslide = function(){
			clearinterval(play);
			autoslide();
		}
		
		autoslide = function(){
			play = setInterval(function(){
				nextslide=parseInt($('.active').attr('rel'))+1;	
				
					if(nextslide>$('#pagination a').length)
					{
						nextslide=1;
					}

				$(container+' .carousel').fadeOut(800);
			    $(container+" .carousel:nth-child("+nextslide+")").fadeIn(800);

				$('#titleslide').html($(container+" .carousel:nth-child("+nextslide+")").attr("title"));
				$('#zona').html($(container+" .carousel:nth-child("+nextslide+")").attr("zn"));
				$('#suprafata').html($(container+" .carousel:nth-child("+nextslide+")").attr("sup"));
				$('#anul').html($(container+" .carousel:nth-child("+nextslide+")").attr("an"));
				$('#tipof').html($(container+" .carousel:nth-child("+nextslide+")").attr("tip"));
				$('#pret').html($(container+" .carousel:nth-child("+nextslide+")").attr("pret"));
				$('#linkchange').attr('href','anunt/eil'+$(container+" .carousel:nth-child("+nextslide+")").attr("rel"));				
		  
				$("#pagination a").removeClass('active');
				$("#pagination a:nth-child("+nextslide+")").addClass('active');	
			}, 5000);	
		}
		
		$(".leftslider").hover(function() {
			clearInterval(play); //Stop the rotation
		}, function() {
			autoslide(); //Resume rotation
		});
		  
		$("#pagination a").click(function() {	
			lastactive=$('.active').attr('rel');
				if(lastactive!= $(this).attr('rel')){
					$active = $(this);
					changeslide();
					autoslide();
					clearInterval(play)
				}
			return false;
		}); 
		
			autoslide();
	};
	

function bigradios(){
	$(".bigradio input[type=radio]").hide();
	$(".bigradio").hover(
	  function () {
		if(!$(this).hasClass('bigradio_checked')){
			$(this).addClass('bigradio_hovered');
		}
	  }, 
	  function () {
		$(this).removeClass('bigradio_hovered');
	  }
	);

	$(".bigradio").click(function(){
		$('.bigradio').removeClass('bigradio_checked');
		$('input[type=radio]',this).attr('checked', 'checked');
		$(this).removeClass('bigradio_hovered');
		$(this).addClass('bigradio_checked');
	});
}

function otherradios(){
	$(".secondmenu input[type=radio]").hide();
	$(".secondmenu").hover(
	  function () {
		if(!$(this).hasClass('secondmenu_checked')){
			$(this).addClass('secondmenu_hovered');
		}
	  }, 
	  function () {
		$(this).removeClass('secondmenu_hovered');
	  }
	);

	$(".secondmenu").click(function(){
		$('.secondmenu').removeClass('secondmenu_checked');
		$('input[type=radio]',this).attr('checked', 'checked');
		$(this).removeClass('secondmenu_hovered');
		$(this).addClass('secondmenu_checked');
	});
}
	
showzona = function(){
		$(".letter").hide();
		$(".letter:first").show();
		$("#alegezona").fadeIn();
		show_orase_com_buc();
		show_zone_buc();
		$(".NFSelectTarget").hide();
		$(".darkbg").fadeTo('slow',0.6);
		return false;
};

showsearchid = function(){
		$("#cautaid").fadeIn();
		$(".darkbg").fadeTo('slow',0.6);
		return false;
}
showoferta = function(){
		$("#adoferta").fadeIn();
		$(".darkbg").fadeTo('slow',0.6);
		return false;
}
showcerere = function(){
		$("#adcerere").fadeIn();
		$(".darkbg").fadeTo('slow',0.6);
		return false;
}
showcariere = function(){
		$("#cariere").fadeIn();
		$(".darkbg").fadeTo('slow',0.6);
		return false;
}
showfacebook = function(){
		$("#facebook").fadeIn();
		$(".darkbg").fadeTo('slow',0.6);
		return false;
}
showfavorite = function(){
		$("#favorite").fadeIn();
		$(".darkbg").fadeTo('slow',0.6);
		return false;
}
shownewsletter = function(){
		$("#newsletter").fadeIn();
		$(".darkbg").fadeTo('slow',0.6);
		return false;
}



showmap = function(){
		$("#harta").show();
		initialize();
		$(".darkbg").fadeTo('slow',0.6);
		return false;
};

show_zone_buc = function(){
		$(".letter").hide();
		$("#zone_buc").show();
$(this).removeClass('zonachecked');		
		return false;		
};

show_orase_com_buc = function(){
		$(".letter").hide();
		$("#orase_com_buc").show();
				$('#check42').attr('checked','checked');
$(this).removeClass('zonachecked');		
		return false;
};

reset_zona = function(){
		$(".letter").hide();
		$(".letter:first").show();
};

closezona = function(){
		$(".darkbg").fadeOut(); 
		$(".alegezona").fadeOut(); 
		$("#harta").fadeOut();
		$("#loader").fadeOut();
};

getcurs = function(){
		$.ajax({
		  url: 'inc/ajax/get_curs.php',
		  success: function(data) {
			$('#importcurs').html(data);
		  }
		});
}

minimizebar = function(){
	$.cookie("minimized", "1", { expires: 7 });
	$('#minimizetab').fadeOut();
	$('#meniujos').fadeOut();
	$('#spacerjos').fadeOut();
	$('#minimizebar').fadeOut();
				 
	 $("#bottombar").animate({
		width: "160px",
		height: "35px"
	}, 800,function(){
		$('#minimized').fadeIn();
		$('#maximizetab').fadeIn();
		$('#bottombar').fadeOut();
	});	
}

maximizebar = function(){
	$.cookie("minimized", null);
	$('#maximizetab').fadeOut();
	$('#minimized').fadeOut();
	$('#bottombar').fadeIn();
	$('#spacerjos').fadeIn();
	 $("#bottombar").animate({
		width: "100%",
		height: "40px"
	}, 800,function(){
				 
		$('#meniujos').fadeIn();
		$('#minimizebar').fadeIn();
		$('#minimizetab').fadeIn();
	});	
}

//Add events
var existingLoadEvent = window.onload || function () {};
var existingResizeEvent = window.onresize || function() {};
window.onload = function () {
	
	startslide('#container1');		  
	bigradios();	  
	otherradios();		
    existingLoadEvent();
    NFInit();
	
	$('.darkbg').css("height",$(document).height());
	$(".darkbg").click(function () { 
      closezona();
    });	
	
	$("#inchidezona").click(function () { 
      closezona();
    });		
	
	$(".literazona").click(function () { 
		$(".letter").hide();
		$("#preloader").fadeIn('fast');
					$('.literazona').removeClass('literaselected');
			$(this).addClass('literaselected');
		$.ajax({
		  type: "POST",
		  data: "litera="+$(this).html()+"&type=zone",
		  url: 'inc/ajax/getzone.php',
		  success: function(data) {
			$('#preloader').html(data);
					
		$(".locatiezona").click(function () { 
			if(!$('#check'+$(this).attr('id')).is(':checked')){
			  $('#check'+$(this).attr('id')).attr('checked', true);
			  $(this).addClass('zonachecked');
			}else{
			  $('#check'+$(this).attr('id')).attr('checked', false);
			  $(this).removeClass('zonachecked');
			} 
		});		
		
		$(".locatiezona input:checkbox").click(function () { 
			if(!$('#check'+$(this).parent().attr('id')).is(':checked')){
			  $('#check'+$(this).parent().attr('id')).attr('checked', true);
			  $(this).parent().addClass('zonachecked');
			}else{
			  $('#check'+$(this).parent().attr('id')).attr('checked', false);
			  $(this).parent().removeClass('zonachecked');
			} 
		});	

		  }
		});

    });		
	
	
	$("#butoncauta").hover(function () { 
      $(this).attr('src','style/img/cauta-blue.png');
    },function () { 
      $(this).attr('src','style/img/cauta.png');
    });	
	
	$(".locatiezona").click(function () { 
		if(!$('#check'+$(this).attr('id')).is(':checked')){
		  $('#check'+$(this).attr('id')).attr('checked', true);
		  $(this).addClass('zonachecked');
		}else{
		  $('#check'+$(this).attr('id')).attr('checked', false);
		  $(this).removeClass('zonachecked');
		} 
    });		
	
	$(".locatiezona input:checkbox").click(function () { 
		if(!$('#check'+$(this).parent().attr('id')).is(':checked')){
		  $('#check'+$(this).parent().attr('id')).attr('checked', true);
		  $(this).parent().addClass('zonachecked');
		}else{
		  $('#check'+$(this).parent().attr('id')).attr('checked', false);
		  $(this).parent().removeClass('zonachecked');
		} 
    });	
	
			$('.notification').hover(function() {
 				$(this).css('cursor','pointer');
 			}, function() {
 					$(this).css('cursor','auto');
				});

			$('.notification span').click(function() {
                $(this).parents('.notification').fadeOut(800);
            });
			
			$('.notification').click(function() {
                $(this).fadeOut(800);
            });
		

	
	
			closenotify = setInterval(function(){
				$('.notification').fadeOut();
			}, 3000);
			
	
}

window.onresize = function() {
	if(resizeTest != document.documentElement.clientHeight) {
		existingResizeEvent();
		NFFix();
	}
	resizeTest = document.documentElement.clientHeight;
}	


jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
	
