/*
Funzioni di supporto al file pezzo.asp | poggiano su framework jQuery 1.2 
*/
	$(document).ready(function(){
	 //Date dei commenti in modo friendly [http://timeago.yarp.com/]
		$('abbr[class*=timeago]').timeago();
		//Limit Textarea Chars | http://www.unwrongest.com/projects/limit/#demo 
		$('#CommentComment').limit('2000','#charcounter');
		
		//MultiMedia embedded | Examples and documentation at: http://malsup.com/jquery/media/
		//$.fn.media.mapFormat('mp3','winmedia');
	 $('a.media').media({width: 200, height: 200, params: {wmode: 'transparent', showControls: 1, enableContextMenu: 1, ShowStatusBar: 0, DisplaySize:0, AnimationAtStart: 1, uiMode: 'mini'}});
		$('a.mediamp3').media({width: 300, height: 20, bgColor: 'f0dcb3', flashvars: {backColor: "333333", frontColor: "eac880", showDownload: "true"}, params : {wmode: 'transparent', allowfullscreen:"false", allowscriptaccess:"always"}});

		//riferimento NOTE | evidenzia paragrafo che contiene la nota
		$("a[href^='#nota-']").click(function(){
		$(".entry-content p").removeClass("noteref");
		var noteRef=$(this).attr("href").split('#').join('');
		$("a[id="+noteRef+"]").parent("p").addClass("noteref");
		});
		
		//-------------------------------------SEZIONE COMMENTI 
		// nasconde  div.infograph
		$("div.infograph").hide();
		//slide ALL commenti
		$("#flipcomments").click(function () { 
			$("div.blog_text").slideToggle("slow");
			$("h5.blog_header span").toggleClass("expand");		
		});
		//slide SINGLE commento
		$("h5.blog_header span").click(function () {
			$(this).parent().next("div.blog_text").slideToggle("slow");
			$(this).toggleClass("expand");
		});
		//slide P suggest HTML code
		$("#suggest").click(function () {
		$(this).next("div.infograph").slideToggle("slow");
		});
		
		//-------------------------------Validazione FORM
		$("#invio").validate({
			rules: {
				nick: {minlength: 2},
				captcha: {minlength: 6},
				email: {email: true},
				sito: {url:true}
		}
		//,submitHandler: function(){alert("Submitted!")}
		});
		// a custom method making the default value for companyurl ("http://") invalid, without displaying the "invalid url" message
		jQuery.validator.addMethod("defaultInvalid", function(value, element) {
		return value != element.defaultValue;}, "");
		//new method for CAPTCHA error display | only numbers and letters
		jQuery.validator.addMethod("getcaptcha", function(value, element) {
		return this.optional(element) || /^[a-z0-9]+$/i.test(value);}, "solo lettere (a-z) e cifre (0-9)");
});
