$(document).ready(function(){


	var taglines = ["Dacă dansul tău latino preferat e corida, avem ceva pentru tine", "Dacă echipa ta favorită de fotbal e o echipă de rugby, avem ceva pentru tine", "Dacă filmul tău de dragoste preferat conține tancuri și elicoptere, avem ceva pentru tine", "Dacă nu consideri alpinism urcatul într-un SUV, avem ceva pentru tine","Dacă televizorul tău se stinge automat la emisiunea de patinaj artistic, avem ceva pentru tine", "Dacă îți petreci mai mult timp pe munte decât urmărind documentare cu munți, avem ceva pentru tine"];
	var count = taglines.length; 
	var win = Math.floor(Math.random() * (count - 1));
	$('body.inactive #header #logo #slogan').html(taglines[win]);
	
	//init	
	stejar.init();

	var v_height = $(document).height();
	var height = $('#main').height();
	if (v_height > height) {
		var margin = parseInt((v_height - height)/2) - 60;
		$('#main').css('margin-top',margin);
	}

	$(window).resize(function(){			
		var v_height = $(document).height();			
		var height = $('#main').height();
		if (v_height > height) {
			var margin = parseInt((v_height - height)/2) - 60;
			$('#main').css('margin-top',margin);
		}
	});

	$(window).click(function(e){		
		var section = $('#map div.open');
		stejar.closeSection(section);
	});


	$('.inputSidebar').each(function(i, el){
		var initial_value = $(el).val();
		$(el).focus(function(){			
			var current_value = $(this).val();
			if (initial_value == current_value) {
				$(this).val('');
			}			
		})
			.blur(function(){			
			var current_value = $(this).val();
			if (!current_value) {
				$(this).val(initial_value);
			}
		});
	});

	//tooltip		
	$('#map div.box div.boxContent ul.items li').each(function(i, el){
		var markup = $(el).html();
		$(el).tooltip({
			track: true,
			delay: 0,
			showURL: false,
			bodyHandler: function() { 
				return markup; 
			}
		});
	});

	$("#map div.box").click(function(e){		
		if (!$('sectionContent', this).is(':visible')) {
			stejar.loadSection($(this));			
		} 		
		e.stopPropagation();
		return false;
	});

	//esc key to close pop-up // ESCAPE key pressed
	$(document).keydown(function(e) {
		//check if section opened
		var section = '';
		$('#map div.box').each(function(i, el){			
			if ($('div.sectionContent', el).is(':visible')) { 
				section = $(el);
			}
		});	
		
		
		if (e.keyCode == 27) {
			stejar.closeSection(section);
		}
	});		

});
	
			












