// PLACEHOLDER:
	$(function(){
		placeholder_crossbrowser(); //comportamento crossbrowser per i placeholder
		$("#annuncio-lista-categorie li").click(function(){
			$("#annuncio-lista-categorie").hide();
		});
		
		//gestione placeholder delle select del form pubblicazione:
		$("#box_form_annuncio select").live("change", function () {
			if($(this).val() == "") $(this).addClass("select_placeholder");
				else $(this).removeClass("select_placeholder")
		});
		$("#box_form_annuncio select").change();
		
		//Gestione text-overflow nei browser che non supportano il css3
		try{
			$(".text-overflow").textOverflow('...', true); //text-overflow in firefox <= 6.x
		}catch(err){
		}
		
	});

	function supports_input_placeholder() {
		var i = document.createElement('input');
		return 'placeholder' in i;
	}//function placeholder_crossbrowser()
	
	function placeholder_crossbrowser(){
		if(!supports_input_placeholder()){
			$('[placeholder]').focus(function() {
			  var input = $(this);
			  if (input.val() == input.attr('placeholder')) {
				input.val('');				
				input.removeClass('placeholder');
				if(input.attr("id")=="pwd"){
					try{	document.getElementById('pwd').type="password"; }catch(err){}
				}//if(input.attr("id")=="pwd")
			  }
			}).blur(function() {
			  var input = $(this);
			  if (input.val() == '' || input.val() == input.attr('placeholder')) {
				input.addClass('placeholder');
				if(input.attr("id")=="pwd"){ 
					try{ document.getElementById('pwd').type="text";}catch(err){}
				}//f(input.attr("id")=="pwd")
				input.val(input.attr('placeholder'));
			  }
			}).blur();
			$('[placeholder]').parents('form').submit(function() {
			  $(this).find('[placeholder]').each(function() {
				var input = $(this);
				if (input.val() == input.attr('placeholder')) {
				  input.val('');
				}
			  })
			});
		}
	}//function placeholder_crossbrowser()
// -- fine placeholder -- //
	
//Gestione text-overflow
/*
 * jQuery Text Overflow v0.7
 *
 * Licensed under the new BSD License.
 * Copyright 2009-2010, Bram Stein
 * All rights reserved.
 */
(function(c){var b=document.documentElement.style,d=("textOverflow" in b||"OTextOverflow" in b),a=function(f,i){var h=0,e=[],g=function(j){var l=0,k;if(h>i){return}for(l=0;l<j.length;l+=1){if(j[l].nodeType===1){k=j[l].cloneNode(false);e[e.length-1].appendChild(k);e.push(k);g(j[l].childNodes);e.pop()}else{if(j[l].nodeType===3){if(h+j[l].length<i){e[e.length-1].appendChild(j[l].cloneNode(false))}else{k=j[l].cloneNode(false);k.textContent=c.trim(k.textContent.substring(0,i-h));e[e.length-1].appendChild(k)}h+=j[l].length}else{e.appendChild(j[l].cloneNode(false))}}}};e.push(f.cloneNode(false));g(f.childNodes);return c(e.pop().childNodes)};c.extend(c.fn,{textOverflow:function(g,e){var f=g||"&#x2026;";if(!d){return this.each(function(){var l=c(this),m=l.clone(),p=l.clone(),k=l.text(),h=l.width(),n=0,o=0,j=k.length,i=function(){if(h!==l.width()){l.replaceWith(p);l=p;p=l.clone();l.textOverflow(g,false);h=l.width()}};l.after(m.hide().css({position:"absolute",width:"auto",overflow:"visible","max-width":"inherit"}));if(m.width()>h){while(n<j){o=Math.floor(n+((j-n)/2));m.empty().append(a(p.get(0),o)).append(f);if(m.width()<h){n=o+1}else{j=o}}if(n<k.length){l.empty().append(a(p.get(0),n-1)).append(f)}}m.remove();if(e){setInterval(i,200)}})}else{return this}}})})(jQuery);
