// Console

if (typeof console == 'undefined') {
	console = new Object;
	console.trace = function() {};
	console.log = function() {};
	console.debug = function() {};
	console.info = function() {};
	console.warn = function() {};
	console.error = function() {};
	console.time = function() {};
	console.timeEnd = function() {};
	console.count = function() {};
} else if (typeof console.time === 'undefined') {
	console.trace = function() {};
	console.time = function() {};
	console.timeEnd = function() {};
	console.count = function() {};	
}


// Funzione di notifica all'utente, al posto dell'alert. 
function message(s){
	alert(s);
}


/* SITE CENSUS DA SWF */
function count_ajax_m_flash(nome_flash){
		var o = {
			rsPath: "/"+nome_flash
		}
		$('.box_white embed').ajaxMetrics(o);
}


/*FUNCTION LE LA RICERCA*/
function cercaNelSitoBottom() {
 var argomento = (self.document.forms['cerca2'].q.value);
 document.siteSearch1.ricerca_par.value=argomento;
 document.siteSearch1.submit();
}
// cerca in testata
function cercaNelSito() {
 var argomento = (self.document.forms['cerca'].q.value);
 document.siteSearch1.ricerca_par.value=argomento;
 document.siteSearch1.submit();
}


/***********************************************************************
**************              DOCUMENT.READY                **************
***********************************************************************/

$(document).ready(function() {
						   
	var cookie = $.cookie("rcsLogin");
	if (cookie != null) {
		//var posizioneFinale = nomeUtente.indexOf("|");
		//nomeUtente = nomeUtente.substring(0, posizioneFinale);
		var cookieVal = cookie.split("|");

		document.communityUser = new Object();
		communityUser = {
			userName        : cookieVal[0]
		};

		$("#header form.input-green").html('<a class="logout" href="http://gazzaspace.gazzetta.it/user/logout">Logout</a>Bentornato <a href="http://gazzaspace.gazzetta.it"> ' + communityUser.userName + '</a>');
	} else {
		$("#header form.input-green").html('<input type="hidden" class="destination" name="edit[destination]" value="'+document.URL+'" /><input type="text" class="formfield" title="GazzaSpace Username" taborder="1" name="edit[name]" /><input type="password" class="shortfield" title="Password" taborder="2" name="edit[pass]" /><a href="#" class="button-bold bt-green submit_form">Login</a>');
	}						   

	$("#speciali select").change(function(){
		var value_selected = $(this).val();
		window.location = value_selected;
	});

	
	$('.in-text input, .in-text textarea, #keywords-photo').example(function() {
	 	return $(this).attr('title'); 
	});
	
	
	

/*CONTROLLO OAS - SE UN BOX CONTIENE SOLO UN ELEMENTO VIENE NASCOSTO*/		
 $(".check-oas, .banner750x90").each(function(){
 	if(($(this).html()).indexOf("empty.gif")>-1 || $(this).children().length<=1) {
		if($(this).attr("class")=="banner750x90") {
          $("#header .infospace").css("display","none");
					$("#header a.menu-linx").css("top","237px");
					$("#header a.menu-town").css("top","161px");
					$("#header a.menu-mobile").css("top","106px");
					$("#header a.menu-forum").css("top","306px");
                }
		$(this).css("display","none");
	}
 });

  $(".submit_form").click(function(){
	$(this).parent("form:eq(0)").submit();
	return false;
  });
	
}); // CHIUSURA document.ready
