	function openPopVideoEsterno(code,titolo,w,h){
		removePopup();
		//*** Ajax.Request per html popup
		var url = '/videoPop/esterno.asp?code='+ code + '&titolo=' + encodeURIComponent(titolo) + '&w=' + w + '&h=' + h;
		//window.open(url);
		new Ajax.Request(
			url, {method: 'get', 
			onSuccess:function(requester){										
				strRet = requester.responseText;
				idErr = strRet.substring(0, strRet.indexOf(':'));
				if (idErr=='200'){								
					htmlRet = strRet.split('|')[1];						
					getPopup(htmlRet);
				}else{
					alert('Al momento non è possibile visualizzare il video.');
				}					
			}, onFailure:function(requester){
				alert('Al momento il video non è disponibile.');			
			}} 
		);
	}


	function openPopVideoVimeo(code,titolo,w,h){
		removePopup();
		//*** Ajax.Request per html popup
		var url = '/videoPop/vimeo.asp?code='+ code + '&titolo=' + encodeURIComponent(titolo) + '&w=' + w + '&h=' + h;
	
		new Ajax.Request(
			url, {method: 'post', 
			onSuccess:function(requester){										
				strRet = requester.responseText;
				idErr = strRet.substring(0, strRet.indexOf(':'));
				if (idErr=='200'){								
					htmlRet = strRet.split('|')[1];						
					getPopup(htmlRet);
				}else{
					alert('Al momento non è possibile visualizzare il video.');
				}					
			}, onFailure:function(requester){
				alert('Al momento il video non è disponibile.');			
			}} 
		);
	}



	function openPopVideoInterno(code,titolo,w,h){
	
		removePopup();
		//*** Ajax.Request per html popup
		var url = '/videoPop/interno.asp?code='+ code + '&titolo=' + titolo + '&w=' + w + '&h=' + h;

		new Ajax.Request(
			url, {method: 'post', 
			onSuccess:function(requester){										
				strRet = requester.responseText;
				idErr = strRet.substring(0, strRet.indexOf(':'));
				if (idErr=='200'){								
					htmlRet = strRet.split('|')[1];						
					getPopup(htmlRet);
				}else{
					alert('Al momento non è possibile visualizzare il video.');
				}					
			}, onFailure:function(requester){
				alert('Al momento il video non è disponibile.');			
			}} 
		);
	}


	function removePopup(){
		if ($('videoPopUp')!=null){
			$('videoPopUp').remove();
		}
	}	
	
	
	function chiudiPopup(){
		removePopup();	
	}


	function getPopup(htmlTxt){
		removePopup();
		new Insertion.Top($('videoPack'),htmlTxt);
		posMyPack();
		return(document.body.down());		
	}





function posMyPack(){
		var myScrollTop = 0
		if (document.documentElement.scrollTop > 0){
			myScrollTop = document.documentElement.scrollTop;
		}else{
			myScrollTop = document.body.scrollTop;
		}
		$('videoPack').style.top = 0
		$('videoPack').style.left = 0
		$('videoPack').style.top = (((tellMeTheHeight() - $('videoPopUp').getDimensions().height)/ 4) + myScrollTop - 87) + 'px';
		$('videoPack').style.left = (((tellMeTheWidth() - $('videoPopUp').getDimensions().width)/ 2)) + 'px';

}

//SCROLL POPUP DIV
window.onscroll = function()
{
	var myScrollTop = 0
	if (document.documentElement.scrollTop > 0){
		myScrollTop = document.documentElement.scrollTop;
	}else{
		myScrollTop = document.body.scrollTop;
	}
	
	//Scroll su box video
	if ($('videoPopUp')){
		if ($('videoPopUp').style.display != 'null'){
			if ($('videoPack')){
				$('videoPack').style.top = (((tellMeTheHeight() - $('videoPopUp').getDimensions().height)/ 4) + myScrollTop) + 'px';
				$('videoPack').style.left = (((tellMeTheWidth() - $('videoPopUp').getDimensions().width)/ 2)) + 'px';
			}
		}
	}
	
}


//HEIGHT WINDOW
function tellMeTheHeight() {
        w = window;
        var height = w.innerHeight || (w.document.documentElement.clientHeight || w.document.body.clientHeight);
        return height
}

//WIDTH WINDOW
function tellMeTheWidth() {
        w = window;
        var width = w.innerWidth || (w.document.documentElement.clientWidth || w.document.body.clientWidth);
        return width
}

////////////////////////////////////////////////////



