﻿// Video Center Java Scripts
 //Brouser detection------------------------------------------------------------

 
		if (window.ActiveXObject) 
				{
				req = new ActiveXObject("Microsoft.XMLHTTP");
				}
				else if (window.XMLHttpRequest) 
				{
				req = new XMLHttpRequest();
				}
  
//-- Session Image Value --------------------------------------------------
AntispamImg ='<%= Session("antispam").ToString() %>'
       
//---Ajax Search  ----------------------------------------------------------

		 function MFSearch(form) {
		  var tipo = $F('mf_tipo'); 		
				//var sot = $F('mf_sot');
				
				//if(sot == "tgflash" | sot == "videonews"){tipo = "news";}
				//if(sot == "moda" | sot == "viaggi" | sot == "motori" | sot == "nautica" | sot == "wellness" ){tipo = "life";}
				//if(sot == "design" | sot == "hightech" | sot == "cinema" | sot == "sapori" | sot == "arte" | sot == "leader" | sot == "lusso" ){tipo = "life";}
				
				AjaxMenu(tipo,'menuVideo','tipo','VideoMenu.asp');
				
				var targ ='CanaliFormat'; 
				var url = 'videoGrid.asp';  
				
				
				var testo = sostituisciDoppioApice($F('testoCerca'));							
			    var params = 'cerca=true&tipo=' + tipo + '&testo=' + testo;
			    //var params = 'cerca=true&tipo=' + tipo + '&SOT=' + sot + '&testo=' + testo;
			
				//alert(params);
			
			var MyAjax = new Ajax.Updater(
					{success: targ},
					url,
					{method: 'get', 
					parameters: params, 
					onFailure: reportError});
					
					 return false;
					}
						function reportError(request) {
						$F(targ) = "Error";
						return false;
					}

//Alex  Utility Scripts ----------------------------------------------------------------------------------------------------
			 
function ShowDiv(MyDiv){
				document.getElementById(MyDiv).style.visibility='visible';
				}
				
function hideDiv(arr){
				for (i=0; i<arr.length; i++){
				document.getElementById(arr[i]).style.visibility='hidden';
				}
				}

// Style display ---------------------------------------------------------------------------------------------
function ShowDivStyle(MyDiv){
			
				document.getElementById(MyDiv).style.display='';
				}
			
				
function HideDivStyle1(MyDiv){
				document.getElementById(MyDiv).style.display='none';
				}
								
function hideDivStyle(arr){
				for (i=0; i<arr.length; i++){
				document.getElementById(arr[i]).style.display='none';
				}
				}
//-- Select Deselect------------------------------------------------------------------	

function SelectStyle(tabID){
							
				var currTabElem = document.getElementById(tabID);
				currTabElem.setAttribute("className", "tab_sel");      //IE
				currTabElem.setAttribute("class", "tab_sel");          //Firefox
       
				}
function UnSelectStyle(arr)
				{
				for (i=0; i<arr.length; i++){	
				var currTabElem = document.getElementById(arr[i]);
				currTabElem.setAttribute("className", "tab_notSel");
				currTabElem.setAttribute("class", "tab_notSel");
        
				}
				}

function SelectStyle_large(tabID){
							
				var currTabElem = document.getElementById(tabID);
				currTabElem.setAttribute("className", "tab_sel_large");      //IE
				currTabElem.setAttribute("class", "tab_sel_large");          //Firefox
       
				}
function UnSelectStyle_large(arr)
				{
				for (i=0; i<arr.length; i++){	
				var currTabElem = document.getElementById(arr[i]);
				currTabElem.setAttribute("className", "tab_notSel_large");
				currTabElem.setAttribute("class", "tab_notSel_large");
        
				}
				}

//---Ajax Record Nav Comments ----------------------------------------------------------

		AjaxMove = function (Variabile,targ,NameVar,url) {
			var params = NameVar + '=' + Variabile;
			//alert(params);
			//alert(url);
			 
			
			var MyAjax = new Ajax.Updater(
					{success: targ},
					url,
					{method: 'get', 
                      parameters: params, 
                      evalScripts: true,
                      onFailure: reportError,
                      asynchronous: false
                      });
                      
					}
						function reportError(request) {
						$F(targ) = "Error";
					}
//--AJAX Global Splash Screen image display div "splash" -------------------
					
		var myGlobalHandlers = {
		onCreate: function(){
			Element.show('splash');
		},

		onComplete: function() {
			if(Ajax.activeRequestCount == 0){
				Element.hide('splash');
			}
		}
	};

	Ajax.Responders.register(myGlobalHandlers);

//---Ajax Menu1 ----------------------------------------------------------

		AjaxMenu = function (Variabile,targ,NameVar,url) {
			
			var params = NameVar + '=' + Variabile;
			
			
			//alert(NameVar);
			//alert(url);
			
			var MyAjax = new Ajax.Updater(
					{success: targ},
					url,
					{method: 'get', parameters: params, onFailure: reportError});
					}
						function reportError(request) {
						$F(targ) = "Error";
					}
				
//--- Ajaxc Menu2 ------------------------------------------------------------

		AjaxMenu2 = function (targ,url,NameVar1,Var1,NameVar2,Var2,NameVar3,Var3,NameVar4,Var4,NameVar5,Var5,NameVar6,Var6) {
			
			var params = NameVar1 + '=' + Var1 + '&' + NameVar2 + '=' + Var2 + '&' + NameVar3 + '=' + Var3 + '&' + NameVar4 + '=' + Var4 + '&' + NameVar5 + '=' + Var5 + '&' + NameVar6 + '=' + Var6;
			
			
			//alert(params);
			//alert(url);
			
			var MyAjax = new Ajax.Updater(
					{success: targ},
					url,
					{method: 'get', parameters: params, onFailure: reportError, evalScripts: true});
					}
						function reportError(request) {
						$F(targ) = "Error";
					}
								
//-- Pulizia dell testo da charatteri indesiderati / \ " < > ---------------------
	
	function sostituisciDoppioApice(param){

				 risultato = param;
				 lunghezza = param.length;
				 risultato = risultato.replace(/\"/g,''); 
				 risultato = risultato.replace(/\</g,'minore');
				 risultato = risultato.replace(/\>/g,'maggiore');
				 risultato = risultato.replace(/\//g,'');
				 risultato = risultato.replace(/\\/g,'');
				 risultato = risultato.replace(/\%/g,'percento');

				 return risultato;
			}
			
// Email Check-----------------------------------------------------------------
    function emailcheck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   // alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   // alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   // alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		   // alert("Invalid E-mail ID")
		    return false
		 }
		 
		return true	
	}



// Comments ---------------------------------------------------------------------			

	AjaxFormComments = function()
	{
				//Works after the validate function
				//alert('Ci Sono in AjaxForm CommentiAdd');
				
				var NameVar = $F('NameVar');         // Variable Name
				var Variabile = $F('Variabile');     // Variable
				var targ =$F('targ');                // The terget Div on the same Page
				var url = $F('url');                 // Dove e la pajina da inserire in Continer
				
				//alert(NameVar + Variabile + targ  + url );
				
				var Subject = sostituisciDoppioApice($F('Subject'));
				var CommentText = sostituisciDoppioApice($F('CommentText'));
				var antiSpam = sostituisciDoppioApice($F('antiSpam'));
				var talk_alias = $F('talk_alias');
				var step = $F('step');
				var ContentID = $F('com_content_id');
				var CategoryID = $F('CategoryID');
				var Title = $F('Title');
				var ContentInfo = $F('ContentInfo');
				var t = $F('t');
				var strUrl = $F('strUrl');

				var params = NameVar + '=' + Variabile + '&Subject=' + Subject + '&CommentText=' + CommentText + '&antiSpam=' + antiSpam + '&talk_alias=' + talk_alias + '&step=' + step + '&ContentID=' + ContentID + '&CategoryID=' + CategoryID + '&Title=' + Title + '&ContentInfo=' + ContentInfo + '&t=' + t + '&strUrl=' + strUrl;

				//alert(params +' ' + url + ' ' + targ);
				
			var MyAjax = new Ajax.Updater(
					{success: targ},
					url,
					{method: 'get', parameters: params, onFailure: reportError});
					
					}
						function reportError(request) {
						$F(targ) = "Error";
					}
					
//--ajax_offensive_comments---------------------------------------

  function offvalidate(form){	
    //alert('sto valorizzando')
	if(form.off_comment_text.value == ""){
      alert("Attenzione !\nIl campo \"Aggiungi il tuo commento\" non puo\' essere vuoto");
      return false;
    }	
	if(form.of_anti_spam.value == ""){
		alert("Attenzione !\nNon hai digitato i numeri dell\'immagine");
		return false;
    }
     //alert(' EXIT validation')
			ajax_off_comments();	
			return false;
   }
    ajax_off_comments = function(){
	//Works after the validate function
	//alert('Ci Sono in Ajax  off CommentiAdd');
				
	 var NameVar = $F('off_name_var');  // Variable Name
		var Variabile = $F('off_var');     // Variable
		var targ =$F('off_container');     // The terget Div on the same Page
		var url = $F('off_url');           // Dove e la pajina da inserire in Continer
		
		//alert(NameVar + Variabile + targ  + url );
		
		
		var CommentText = sostituisciDoppioApice($F('off_comment_text'));
		//alert(CommentText)
		var antiSpam = sostituisciDoppioApice($F('of_anti_spam'));
		var talk_alias = $F('talk_alias');
		var step = $F('off_step');
		var ContentID = $F('off_content_id');
		var CategoryID = $F('CategoryID');
		var Title = $F('off_tittle');
		var ContentInfo = $F('off_content_info');
		var t = $F('off_t');
		var strUrl = $F('off_strurl');

		var params = NameVar + '=' + Variabile + '&id=' + Variabile + '&message=' + CommentText + '&antiSpam=' + antiSpam + '&talk_alias=' + talk_alias + '&step=' + step + '&ContentID=' + ContentID + '&CategoryID=' + CategoryID + '&Title=' + Title + '&ContentInfo =' + ContentInfo + '&t=' + t + '&strUrl=' + strUrl;

		//alert(params +' ' + url + ' ' + targ);
		
	var MyAjax = new Ajax.Updater(
			{success: targ},
			url,
			{method: 'get', parameters: params, onFailure: reportError});
			AntispamImg ='<%= Session("antispam").ToString() %>'
			}
				function reportError(request) {
				$F(targ) = "Error";
			}



//EFFECTS----------------------------------------------------------
		
	
  function applyScrollLeft(targ)
	{
		new Effect.Move($(targ), {y:0, x:-468, mode: 'relative'});
		new Effect.Appear($(targ), {from:0.2, to:1.0});
	}
	function applyScrollRight(targ)
	{
		new Effect.Move($(targ), {y:0, x:468, mode: 'relative' });
		new Effect.Appear($(targ), {from:0.2, to:1.0});
	}
	
	function applyEffectError(targ)
	{
		new Effect.Appear($(targ), {from:0.0, to:0.1});
	}
	
	function applyEffect(targ)
	{
		new Effect.Appear($(targ), {from:0.0, to:1.0});
	}
	
	function applyHideArr(arr)
	{
 		for (i=0; i<arr.length; i++) {
			new Effect.Fade($(arr[i]), {from:0.1, to:0.0});
		}
  }

//---------------------------------------------------------
	function CopyToClipboard()
		{
		  var CopiedTxt
				document.Form1.txtArea.focus();
				document.Form1.txtArea.select(); 
				CopiedTxt = document.selection.createRange();
				CopiedTxt.execCommand("Copy");
		}

//-------------------------------------------------------------------------------

function validate(form)
{	

	if(form.Subject.value == "")
    {
      alert("Attenzione !\n Il campo \"Titolo\" non puo\' essere vuoto");
      return false;
    }
	if(form.CommentText.value == "")
    {
      alert("Attenzione !\n Il campo \"Aggiungi il tuo commento\" non puo\' essere vuoto");
      return false;
    }	
		else 
	if(form.antiSpam.value == "")
    {
		alert("Attenzione !\n Non hai digitato i numeri dell\'immagine");
		return false;
    }
		AjaxFormComments();	
		return false;
}
	 
// INVIA a UN Amico ***************************************	
	 
 function validateInvio(form){	
	
	if(form.amico_subject.value == ""){
      alert("Attenzione !\n Il campo \"Oggetto\" non puo\' essere vuoto");
      return false;
    }	
	
	if (emailcheck(form.amico_destinatario.value) != true){
	    alert("Attenzione !\n Non hai inserito correttamente la mail del destinatario");
	    return false
	}
	
	if (emailcheck(form.amico_mittente.value) != true){
	   alert("Attenzione !\n Non hai inserito correttamente il Tuo indirizzo email");
	    return false
	}
	
	if(form.amico_antiSpam.value == ""){
      alert("Attenzione !\n Non hai digitato i numeri dell\'immagine");
      return false;
    }
    
	//alert('Sto Uscendo da Check in');
	AjaxFormAmico();
	return false;
   }
	 
AjaxFormAmico = function(){
				//Works after the validate function
				//alert('Ci Sono in AjaxForm Amico');
				
				var targ =$F('amico_targ');                // The terget Div on the same Page
				var url = $F('amico_url');                 // Dove e la pajina da inserire in Continer
				
				//alert(targ  + url );
				
				var destinatario = sostituisciDoppioApice($F('amico_destinatario'));
				var mittente = sostituisciDoppioApice($F('amico_mittente'));
				var current_sezione = 'video';
				var subject = sostituisciDoppioApice($F('amico_subject'));
				var message = sostituisciDoppioApice($F('amico_message'));
				var antiSpam = sostituisciDoppioApice($F('amico_antiSpam'));
				var strurl = $F('amico_strurl');
				var params = 'subject=' + subject + '&message=' + message + '&destinatario=' + destinatario + '&mittente=' + mittente + '&antiSpam=' + antiSpam + '&current_sezione=video&step=2&strURL=' + strurl;
				//alert(strurl );
				//alert('Link = ' + params);			
			var MyAjax = new Ajax.Updater(
					{success: targ},
					url,
					{method: 'get', parameters: params, onFailure: reportError});
					
					}
						function reportError(request) {
						$F(targ) = "Error";
					}

 // -- Creazione Alias (Nik Name)--------------------------------
   
   function validateAlias(form)
{	
	if(form.a_talk_alias.value == "")
    {
      alert("Attenzione !\nNon hai inserito l\'alias");
      return false;
    }
 //alert("Exit Validate");
 AjaxFormAlias();	
 return false;
}
   
   AjaxFormAlias = function(){
				//Works after the validate function
				//alert('Ci Sono in AjaxForm Alias');
				
				var NameVar = $F('a_name_var');        // Variable Name
				var Variabile = $F('a_var');           // Variable
				var targ =$F('a_targ');                // The terget Div on the same Page
				var url = $F('a_url');                 // Dove e la pajina da inserire in Continer
				
				//alert(NameVar + Variabile + targ  + url );
    var talk_alias = sostituisciDoppioApice($F('a_talk_alias'));
				var step = $F('a_step');
				var ContentID = $F('a_content_id');
				var CategoryID = $F('a_category_id');
				var ContentInfo = $F('a_contentInfo');
				var strUrl = $F('a_strurl');

				var params = NameVar + '=' + Variabile + '&talk_alias=' + talk_alias + '&step=' + step + '&ContentID=' + ContentID + '&CategoryID=' + CategoryID + '&ContentInfo =' + ContentInfo + '&strUrl=' + strUrl;

				//alert(params +' ' + url + ' ' + targ);
				
			var MyAjax = new Ajax.Updater(
					{success: targ},
					url,
					{method: 'get', parameters: params, onFailure: reportError});
					return false;
					}
						function reportError(request) {
						$F(targ) = "Error";
					}
//-- Log In -----------------------------------------------------------------------------------
  
//-------------------------------------------------------------------------------------
