  $(document).ready(function(){

  	//disabilita il controllo MyFormat se seleziono 'Other Version' on load window
	if ($("#IdReleased option:selected").text() == 'Other Version...')
		{$("#MyFormat").attr('disabled', 'disabled');
		 $("#ov").val(1);}
	else
		{$("#MyFormat").removeAttr('disabled'); $("#ov").val(0);}

	 //controlla se ci sono altre review della stessa version già scritte
	    	idr = $("select option:selected").val();
	    	idrev = $("#IdReview").val();
    		ov = $("#ov").val();
    		c = $("#comment").val();
    		mv = $("#myversion").val();
				//alert("IdReview: " + idrev);
			    if ( idrev == "" )
			    {
    		    	//alert("myversion: " + mv + " idreleased: " + idr + " ov: " + ov);
			    	$.getJSON("index.php?option=com_musicadvisor&view=checkrevrat&format=json",
			    	{IdReleased: idr, c: c, ov: ov}, function(n){

			    		if (n.value == "1" && c == 0 && (mv != idr || ov == 1))
			    		{
			    		$("#checkresult").css({'color': '#FF0000', 'text-align': 'center', 'font': 'Arial', 'font-size': 'x-small'});
			    		$("#checkresult").text("You've already written a review for this version, you are able to write a review for another version of this album!");
		    		}
		    		else if (n.value == "1" && c == 1 && (mv != idr || ov == 1))
		    		{
			    		$("#checkresult").css({'color': '#FF0000', 'text-align': 'center', 'font': 'Arial', 'font-size': 'x-small'});
			    		$("#checkresult").text("You've already rated this version, you are able to rated another version of this album!");
			    		}
			    		else
			    		{
				    		$("#checkresult").css({'color': '#626200', 'text-align': 'center'});
				    		$("#checkresult").text("..:::::..");
			    		}
			    	 });

			    }




   //cambia il tasto Modify in Save abilita gli attributi in My Detail
	   $("#submitDetail").click(function () {
		  $("#userform input").removeAttr("disabled");
		  $("#submitDetail").text("Save");
		});

	//hyphenate
     $('.p_review p').hyphenate();
     $('.p_review a').hyphenate();
     $('.p_rate p').hyphenate({oWidth : 150});
          $('.t_rate p').hyphenate({oWidth : 100});
          $('.p_rate a').hyphenate({oWidth : 150});
	 $('.scroll p').hyphenate({oWidth : 350});
	 $('.class10 p').hyphenate({oWidth : 650});

	//timeago
	jQuery("span.timeago").timeago();




  });
