function outLinks() {
  var outLink;
  if (document.getElementsByTagName('a')) {
    for (var i = 0; (outLink = document.getElementsByTagName('a')[i]); i++) {
      if (outLink.href.indexOf(location.host) == -1) {
        outLink.setAttribute('target', '_blank');
      }
    }
  }
}

function show_counter() {
	if(location.host=="director.lucian0308.com" || location.host=="localhost"){
	 if(document.getElementById('counter')){
		$.get('counter.php', function(data){
			$('#counter').html(data);
		});

		
	 }
	}
}


$(document).ready(function() {
	$(".bottom1").append('<a href="http://validator.w3.org/check?uri=http%3A%2F%2Fdirector.lucian0308.com%2F"><img src="img/xhtml.jpg" width="80" height="15" border="0" style="margin:5px;" /></a>');
	$(".bottom1").append('<a href="http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fdirector.lucian0308.com%2F"><img src="img/css.jpg" width="80" height="15" border="0" style="margin:5px;" /></a>');
	
	$("input#cauta")
		.mouseover(function(){
			this.src='img/search-input2o.jpg';
		})
		.mouseout(function(){
			this.src='img/search-input2.jpg';
		})
	
	$(".dir_table").not(".dir_table2")
		.mouseover(function(){
			this.style.backgroundColor='#E7F7FE';
		})
		.mouseout(function(){
			this.style.backgroundColor='';
		})
	;
	
	$.getJSON('include/categorii.php', function(data) {
		$.each(data, function(entryIndex, entry) {
			
			$("a[href='"+entryIndex.replace(/ /g,'-')+"/']").each( function(){
				nr = parseInt(entry['nr_total']);
				$(this).append("<span>("+nr+")</span>");
			});
			 
		});
	});
	
	
	outLinks();
	show_counter();
	
	$("#counter").ajaxStop(function(){
		setTimeout('show_counter();',30000);
 	});
	
	$("#counter").ajaxStart(function(){
		$(this).html('<img src="img/ajax_loader.gif" style="margin-top:8px; margin-bottom:9px;"/>');
 	});
	
});

