<!--
//--Caricamento YouTube--
var options = jQuery.extend( {
  holderId: 'myVideosHtml',
  playerHeight: '300',
  playerWidth: '450',
  addThumbs: false,
  thumbSize: 'small',
  showInline: false,
  autoPlay: true,
  showRelated: true,
  allowFullScreen: false
},options);

var autoPlay = "";
var showRelated = "&rel=0";
var fullScreen = "";
if(options.autoPlay) autoPlay = "&autoplay=1"; 
if(options.showRelated) showRelated = "&rel=1"; 
if(options.allowFullScreen) fullScreen = "&fs=1"; 

play = function(id)	{
var html  = '';
	html += '<object height="'+options.playerHeight+'" width="'+options.playerWidth+'">';
	html += '<param name="movie" value="http://www.youtube.com/v/'+id+autoPlay+showRelated+fullScreen+'"> </param>';
	html += '<param name="wmode" value="transparent"> </param>';
	if(options.allowFullScreen) { 
		html += '<param name="allowfullscreen" value="true"> </param>'; 
	}
	html += '<embed src="http://www.youtube.com/v/'+id+autoPlay+showRelated+fullScreen+'"';
	if(options.allowFullScreen) { 
		html += ' allowfullscreen="true" '; 
	}
	html += 'type="application/x-shockwave-flash" wmode="transparent"  height="'+options.playerHeight+'" width="'+options.playerWidth+'"></embed>';
	html += '</object>';
return html;		   
};

youtubeid = function(url)	{
var ytid = url.match("[\\?&]v=([^&#]*)");
	ytid = ytid[1];
return ytid;
};	


//--Fine Caricamento YouTube--

$(document).ready(function()	{
	$.post('/write_user.asp', function(data) {
  		//alert(data);
		/*
		if(data=="")	{
			alert("vuoto"+data+"vuoto");	
		}else{
			alert("pieno"+data+"pieno");
		}
		*/
	});
	
	$(".contlastminute").jCarouselLite({
	  btnNext: ".su",
	  btnPrev: ".giu",
	  speed: 100,
	  vertical: true,
	  visible: 8,
	  circular: false,
	  scroll: 8
	});

	$("#myProfileAdmin").click( function()		{	
		document.location.href='user_register.asp';
	});
	
	$("#myFavoritesAdmin").click( function()		{	
		document.location.href='user_list.asp';
	});
	
	$("a.thickbox").click( function()		{	
		//Recupero l'id del messaggio e gli tolgo i 13 caratteri di "deleteButton_" o "youTubeVideo_", e glielo passo alla form modale
		var valueId = $(this).attr('id');
		var valueCategory = valueId.substring(0,13);
		if(valueCategory=="youTubeVideo_")	{
			var videoUrl = valueId.substring(13);
			$("#"+options.holderId+"").html(play(youtubeid(videoUrl)));
		} else if(valueCategory=="deleteButton_") {
			var deleteId = valueId.substring(13);
			$("#myDashboardAdminDeleteId").val(deleteId);
			$("#myVideosAdminDeleteId").val(deleteId);
			$("#myFarmAdminDeleteId").val(deleteId);
			$("#myFilesAdminDeleteId").val(deleteId);
		} else if(valueCategory=="readMoreDash_")	{
			var descr = $("#"+valueId+"_text").val();
			$("#readMoreContent").html(descr);
		}
 	});
	
    $(function() {
        $('#gallery a.gallery').lightBox();
    });
});

checkData = function(formName)	{
	var label = eval("document."+formName+".pLABEL");
	
	label.style.background=inputNormalColor;
	
	if (label.value=="")	{
		//alert ("Attenzione! Inserire la label.");
			label.focus();
			label.style.background=inputAlertColor;	
				return false;
	}
	vai = eval("document."+formName+".submit()");
	return true;
}

checkDataDescr = function(formName)	{
	var descr = eval("document."+formName+".pDESCR");
	
	descr.style.background=inputNormalColor;
	
	if (descr.value=="")	{
		//alert ("Attenzione! Inserire la descr.");
			descr.focus();
			descr.style.background=inputAlertColor;	
				return false;
	}
	vai = eval("document."+formName+".submit()");
	return true;
}

checkDataDescrEncode = function(formName)	{
	var descr = eval("document."+formName+".pDESCR");
	
	var descrReplaced = descr.value.replace(/\n/g,"<br/>");
	descr.value=descrReplaced;
	
	descr.style.background=inputNormalColor;
	
	if (descr.value=="")	{
		//alert ("Attenzione! Inserire la descr.");
			descr.focus();
			descr.style.background=inputAlertColor;	
				return false;
	}
	vai = eval("document."+formName+".submit()");
	return true;
}

checkDataMessage = function(formName)	{
	var bodyMail = eval("document."+formName+".pBODY");
	
	bodyMail.style.background=inputNormalColor;
	
	if (bodyMail.value=="")	{
		//alert ("Attenzione! Inserire la label.");
			bodyMail.focus();
			bodyMail.style.background=inputAlertColor;	
				return false;
	}
	vai = eval("document."+formName+".submit()");
	return true;
}

checkDataVideos = function(formName)	{
	//var label = eval("document."+formName+".pLABEL");
	var html = eval("document."+formName+".pHTML");
	
	//label.style.background=inputNormalColor;
	html.style.background=inputNormalColor;
	
	//if (label.value=="")	{
		//alert ("Attenzione! Inserire la label.");
			//label.focus();
			//label.style.background=inputAlertColor;	
				//return false;
	//}
	if (html.value=="")	{
		alert ("Attenzione! Inserire il link di youtube es:http://www.youtube.com/watch?v=nHL9yXimPkA .");
			html.focus();
			html.style.background=inputAlertColor;	
				return false;
	}
	vai = eval("document."+formName+".submit()");
	return true;
}

checkDataFarm = function(formName)	{	
	//var label = eval("document."+formName+".pLABEL");
	var img = eval("document."+formName+".pFILE");

	//label.style.background=inputNormalColor;
	img.style.background=inputNormalColor;
	
	//if (label.value=="")	{
		//alert ("Attenzione! Inserire la label.");
			//label.focus();
			//label.style.background=inputAlertColor;	
				//return false;
	//}
	if (img.value=="")	{
		alert ("Attenzione! Selezionare un'immagine.");
			img.focus();
			img.style.background=inputAlertColor;	
				return false;
	}
	if (img.value!="")	{
		imgExt = img.value.substr(img.value.lastIndexOf("."), img.value.length).toLowerCase();
		if ((imgExt!=".gif")&&(imgExt!=".jpg")&&(imgExt!=".jpeg")&&(imgExt!=".png"))	{
			alert ("Attenzione! Il formato " + imgExt + " non e' supportato. Usare solo immagini .gif, .jpg, .jpeg. e .png");
				img.focus();
				img.style.background=inputAlertColor;	
					return false;	
		}
	}
	vai = eval("document."+formName+".submit()");
	return true;
}

checkDataFile = function(formName)	{	
	var file = eval("document."+formName+".pFILE");

	file.style.background=inputNormalColor;
	
	if (file.value=="")	{
		alert ("Attenzione! Selezionare un file.");
			file.focus();
			file.style.background=inputAlertColor;	
				return false;
	}
	if (file.value!="")	{
		fileExt = file.value.substr(file.value.lastIndexOf("."), file.value.length).toLowerCase();
		if ((fileExt!=".doc")&&(fileExt!=".pdf")&&(fileExt!=".xsl")&&(fileExt!=".ods"))	{
			alert ("Attenzione! Il formato " + fileExt + " non e' supportato. Usare solo file .doc, .pdf, .xsl. e .ods");
				file.focus();
				file.style.background=inputAlertColor;	
					return false;	
		}
	}
	vai = eval("document."+formName+".submit()");
	return true;
}
// -->
