////globali////
if (screen.width > 1024)
{
var maxLung = 1024 - 150;
}
else
{
var maxLung = parseInt(screen.width) - 150;
}

var maxAlt = parseInt(screen.height) - 250;

document.cookie="maxLung="+maxLung ;
document.cookie="maxAlt="+maxAlt ;

/////////////

function check_login()
{
if ( $('user').value == "" || $('pwd').value == "" )
	{
	alert('login or password are not complete');			
	return false;	
	}
	
if ( $('pwd').value.length < 6 )

	{
	alert(' password must be at least 6 character ');			
	return false;	
	}

var re;
re=/^[a-zA-Z0-9]*$/ 
if(!re.test( $('pwd').value ))
	{
	alert('Password cannot contain special symbols');			
	return false;	
	}

}
/////////////

function call_slide(page,param)
{
if ($('aInd'))
{
alert('Please wait few seconds more...');
return false;
}
	var myHorizontalSlide = new Fx.Slide('internal', {mode: 'horizontal',
	onComplete: function()
	{
     call_ajax(page,param);
    }
    });
myHorizontalSlide.toggle(); 
 }

function call_ajax(page,param)
{

        var req = new Request({  
             method: 'get',  
             url: '/ajax/lista.film.asp?page='+page+'&param='+param ,   
             onRequest: function() {$('browsenew').set('html', '<img src="/images/ajax_indicators.gif" id="aInd" >');},  
             onComplete: function(response)
             {
             $('browsenew').set('html',response);
             add_event('mba');  
 			}, 
             onFailure: function(response) {$('browsenew').set('html',url+'An error has occurred'); } 
}).send();  
}

function call_generic(strurl,target,classe)
{

if ($('aInd'))
{
alert('Please wait few seconds more...');
return false;
}

         var req = new Request({  
             method: 'get',  
             url: strurl ,
             evalScripts: true,
             urlEncoded: true,
             onRequest: function() {$(target).set('html', '<img src="/images/ajax_indicators.gif" id="aInd" >');},  
             onComplete: function(response) 
             
             {$(target).set('html',response);
             
             	if (classe != "" )
             	{
             
			 		add_event(classe); 
			 		if ($('morex0'))
			 		{
			 		add_event('morex'); 
					}
			
			if (document.getElementsByName('tipG').length > 0 )
			{
				//
	window.addEvent('domready', function(){
   $$('.tips').each(function(item){
      item.store('tip:title', '');
      item.store('tip:text', '<img src="'+item.get('title')+'" class="tipGallery" />');
      new Tips(item, {onShow : function(tip){
           tip.fade('in');
         }, onHide : function(tip){
            tip.fade('out');
         }
      });
   });
});
				
				//
				
			}
				}

             }, 
             onFailure: function(response) {$(target).set('html',url+'An error has occurred'+ strurl ); } 
 
}).send();    
}


	function add_event(classe)
	{
		var box = {};
			window.addEvent('domready', function(){
				box = new MultiBox(classe, {descClassName: 'multiBoxDesc', useOverlay: false,showControls: false,fixedTop:0});
			});
	}


function call_slide2(page,target,target2,strurl)
{
	var myHorizontalSlide = new Fx.Slide(target, {mode: 'horizontal',
	onComplete: function()
	{
    call_generic(strurl,target2);
    }
    });
myHorizontalSlide.toggle(); 
 }


/////controllo form///

function check_form()
{
var form = document.getElementById('form1');
if (form.keywords.value == "" && form.year.selectedIndex == 0 && form.genere.selectedIndex == 0 && form.filtri.selectedIndex == 0 &&  form.language.selectedIndex == 0 )
	{
		alert('No value selected\n Please Choose at least one field !');
		return false;
	}
	else
	{
form.submit();
	}

}

////
function swap2(img,id) 
{
if ( $('browse')  )
{ 
$('browse').style.height = 205;
}

if ( $('browsenew')  )
{ 
resize_browse2(200,'browsenew')
}

var menu = document.getElementById('menu');
var li_menu = menu.getElementsByTagName('li') ;
var imgok = '' ;
var imgTemp = '' ;

for (i=0; i<6; i++) 
	{ 
	imgok = document.getElementById("x"+(i+1)).src ;

	limg = imgok.length ;
	imgok = imgok.substring(27,limg)
	imgok = imgok.replace(".gif","")
	limg2 = imgok.length ;
	imgok = imgok.substring(0,limg2-1) ;

	
	imgok = "/images/"+imgok+"1.gif" ;
	$("x"+(i+1)).src = imgok;
	}

$("x"+id).src = '/images/'+img+'.gif' ; 

if (id < 6)
{ 
call_slide(0,id);
}
else
{ 
call_generic('/ajax/search.form.asp','internal','');
}
}
////

function send_form(url,classe)
{
var form = $('form1');

if (form.keywords.value == "" && form.year.selectedIndex == 0 && form.genere.selectedIndex == 0 &&  form.language.selectedIndex == 0 )
	{
		alert('No value selected\n Please Choose at least one field !');
		return false;
	}
	else
	{
	check_form_ok('browsenew',form,url,classe);
	resize_browse2(1200,'browsenew');
	}
}

////

function send_form2(url,classe)
{
var form = $('form1');
if (form.keywords.value == "" && form.year.selectedIndex == 0 && form.genere.selectedIndex == 0 &&  form.language.selectedIndex == 0 && form.filtri.selectedIndex == 0 )
	{
		alert('No value selected\nPlease Choose at least one field !');
		return false;
	}
	else
	{
resize_browse2(1000,'browsenew');
check_form_ok('browsenew','form1',url,classe)
}

 
}

///

function send_key(url,classe)
{
var keywords = $('keywords').value ;

if (keywords == "" )
{
alert('keywords field is empty. Please define it !')
return false;
}

resize_browse2(900,'browsenew');
check_form_ok('browsenew','form1',url,classe) 
 
}
////

function resize_browse(val)
{
var browse = $('browse');
		browse.tween('height', val);
		return false; // alternative syntax to stop the event
}

function resize_browse2(val,div)
{

var browse = $(div);
browse.tween('height',val);
return false; 
}

function resize_div(val,div,url,tab)
{

var top = $(div);

if ($('tab').value != tab && $('tab').value > 0 )
{
call_ajax2(div,url,val);
$('tab').value = tab;
return false;
}

$('tab').value = tab ;
if (top.style.height == "1px" || top.style.height.length == 0  )
{
val = "250" ;
call_ajax2(div,url,val);
}
else
{
top.innerHTML = '' ;
val = "1" ;
top.tween('height', val);
$('tab').value = tab ;
}
}

function call_ajax2(target,url,val)
{
var top = $(target);
         var req = new Request({  
             method: 'get',  
             url: url ,   
             onRequest: function() {$(target).set('html', '<img src="/images/ajax_indicators.gif" id="aInd" >');
    	     top.tween('height', val);
             },  
             onComplete: function(response)                         
            {
     $(target).set('html',response);
 			}, 
             onFailure: function(response) {$(target).set('html',url+'An error has occurred'); } 
}).send();  
}

/////

function swap(img,id) 
{
var menu = document.getElementById('menu');
var li_menu = menu.getElementsByTagName('li') ;
var imgok = '' ;
var imgTemp = '' ;

for (i=0; i<li_menu.length; i++) 
	{ 
	imgok = document.getElementById("m"+(i+1)).src ;
	limg = imgok.length ;
	imgok = imgok.substring(40,limg)
	imgok = imgok.replace(".gif","")
	limg2 = imgok.length ;
	imgok = imgok.substring(0,limg2-1) ;
	imgok = "/images/"+imgok+"1.gif" ;
	document.getElementById("m"+(i+1)).src = imgok ;
	}

document.getElementById("m"+id).src = '/images/'+img+'.gif' ; 
}

function swap_img(img,id,cur)
{ 
if (cur == "")
{ 
id = 1;
}

if ( id != cur )
{ 
{ 
var id = $("m"+id)
id.src = "/images/"+ img ;
}
}
}

function swap_over(id,img)
{ 
var cur = $(id).src;
var seg = cur.split("/");
var segLast = seg[5];

if (segLast == "all1.gif" || segLast == "dma1.gif") 
{
$(id).src = "/images/"+img ;
}

if (segLast == "search1.gif" || segLast == "dma1.gif" ) 
{
$(id).src = "/images/"+img ;
}
}


function swap_out(id,img)
{ 

var cur = $(id).src;
var seg = cur.split("/");
var segLast = seg[5];

if (segLast == "all_over.gif") 
{
$(id).src = "/images/"+img ;
}

if (segLast == "search_hover.gif") 
{
$(id).src = "/images/"+img ;
}

}

function swap_img3(n,img)
{ 
$('p1').src = '/images/dossier_normal.gif' ;
$('p2').src = '/images/article_normal.gif' ;
$('p3').src = '/images/interview_normal.gif';

$('p'+n).src = '/images/'+ img +'_active.gif' ;
}

function swap4_img(id,img)
{ 
var id = $("p"+id)
var str = id.src;
var test = str.indexOf("active");

if (parseInt(test) > 0 )
{ 
return false;
}
id.src = "/images/"+ img ;
}

function swap_img5(id,img)
{ 
var id =  $("t"+id);
if ($('t0'))
{ 
$('t0').src = '/images/reg_normal.gif' ;
}

$('t1').src = '/images/contact_normal.gif' ;
$('t2').src = '/images/credits_normal.gif' ;
$('t3').src = '/images/sitemap_normal.gif' ;

var str = id.src;
var test = str.indexOf("active");

if (parseInt(test) > 0 )
{ 
return false;
}

id.src = "/images/"+ img + "_active.gif" ;
}


function swap_img7(n,img)
{ 
$('u1').src = '/images/myprofile_normal.gif' ;
$('u2').src = '/images/myreviews_normal.gif' ;
$('u3').src = '/images/myrate_normal.gif';
$('u'+n).src = '/images/'+ img +'_active.gif' ;
}

//
function contact_form()
{ 
var form = $('contact')

if (form.nome.value == "")
{ 
alert('Name field is  mandatory !') 
form.nome.focus();
return false;
}

if (form.email.value == "")
{ 
alert('Email field is mandatory !') 
form.email.focus();
return false;
}

if (!form.email.value.match(/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/)) 
	{
	alert('Email value is not correct !') 
	form.email.focus();
	return false;
	}
	
if (form.corpo.value.length == ""  )
{ 
alert('Message field is empty !') 
form.corpo.focus();
return false;
}

if (form.corpo.value.length > 300  )
{ 
alert('Message field can contais max 300 characters !') 
form.corpo.focus();
return false;
}

if (form.securitycode.value == "" )
{ 
alert('Security code is empty !') 
form.securitycode.focus();
return false;
}

check_form_ok('box3','contact','/comandi/contatti.asp')

}


function contact_form2(strurl)
{ 

var form = $('contact')
	
if (form.corpo.value.length == ""  )
{ 
alert('Message field is empty !') 
form.corpo.focus();
return false;
}

if (form.corpo.value.length > 600  )
{ 
alert('Message field can contains max 600 characters !') 
form.corpo.focus();
return false;
}

if (form.securitycode.value == "" )
{ 
alert('Security code is empty !') 
form.securitycode.focus();
return false;
}

check_form_ok('browsenew','contact',strurl)

}


function check_form_ok(target,form,strurl,classe)
{
var myHTMLRequest = new Request(
   {
      url:strurl,
        method: 'post',  
       onRequest: function() {$(target).set('html', '<img src="/images/ajax_indicators.gif" id="aInd" >');},  
       onComplete: function(response)
      {
      $(target).set('html',response);
      add_event(classe); 
       
    if (document.getElementsByName('tipG').length > 0 )
			{
	//
	window.addEvent('domready', function(){
   $$('.tips').each(function(item){
      item.store('tip:title', '');
      item.store('tip:text', '<img src="'+item.get('title')+'" class="tipGallery" />');
      new Tips(item, {onShow : function(tip){
           tip.fade('in');
         }, onHide : function(tip){
            tip.fade('out');
         }
      });
   });
});

//
	
}

      
      
      
	},
 onFailure: function(response) {$(target).set('html',strurl+'An error has occurred'); } 
 }
).post($(form));
}

////

function swap_img2(img,id)
{ 
var id = $("x"+id)
var str = id.src;

var okstr = str.substring(str.length-5,str.length-4)
if (okstr == "2")
{ 
return false;
}

id.src = "/images/"+ img ;
}


function check_user()
{

var form = document.getElementById('form1'); 
var conta = 0;

	if( form.nome.value == "" )
	{
	 conta = conta + 1 ;
	 form.nome.style.background = 'yellow' ;	
	}
	else
	{
	 form.nome.style.background = '' ;	
	}
	
	
	if (form.cognome.value == "")
	{
	 conta = conta + 1 ;
	 form.cognome.style.background = 'yellow' ;	
	}
	else
	{
	 form.cognome.style.background = '' ;	
	}
	
	if (form.email.value == "" )
	{
	 conta = conta + 1 ;
	 form.email.style.background = 'yellow' ;	
	}
	else
	{
	 form.email.style.background = '' ;	
	}
	
	if (!form.email.value.match(/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/)) 
	{
	 conta = conta + 1 ;
	 form.email.style.background = 'yellow' ;	
	}
	else
	{
	 form.email.style.background = '' ;	
	}
	
	if (form.nazione.selectedIndex == 0 )
	{
	 conta = conta + 1 ;
	 form.nazione.style.background = 'yellow' ;	
	}
	else
	{
	 form.nazione.style.background = '' ;	
	}	
	
	if (form.localita.value == "" )
	{
	 conta = conta + 1 ;
	 form.localita.style.background = 'yellow' ;	
	}
	else
	{
	 form.localita.style.background = '' ;	
	}
	
	if (form.tel.value == "" || isNaN(form.tel.value) )
	{
	 conta = conta + 1 ;
	 form.tel.style.background = 'yellow' ;	
	}
	else
	{
	 form.tel.style.background = '' ;	
	}
	
	
	if (form.nick.value == ""  )
	{
	 conta = conta + 1 ;
	 form.tel.style.background = 'yellow' ;	
	}
	else
	{
	 form.nick.style.background = '' ;	
	}

	if (form.nick.value.length < 6 )
	{
	alert('Nickname value must contain at least 6 characters');
	form.nick.style.background = 'yellow' ;	
	return false;
	}
	else	
	{
	 form.nick.style.background = '' ;	
	}
	
	if (form.pwd1.value == "" )
	{
	 conta = conta + 1 ;
	 form.pwd1.style.background = 'yellow' ;	
	}
	else
	{
	 form.pwd1.style.background = '' ;	
	}
	
	if (form.pwd2.value == "" )
	{
	 conta = conta + 1 ;
	 form.pwd2.style.background = 'yellow' ;	
	}
	else
	{
	 form.pwd2.style.background = '' ;	
	}
	
	if (form.pwd1.value.length < 6 || form.pwd2.value.length < 6  )
	{
	 form.pwd1.style.background = 'yellow' ;
	 form.pwd2.style.background = 'yellow' ;	
	 
	 alert('Password minimum length is 6 characters !');
	 return false;
	}
	else
	{
	 form.pwd1.style.background = '' ;
	 form.pwd2.style.background = '' ;	
	}
	
	if (form.pwd1.value != form.pwd2.value  )
	{
	 alert('Password seems different !');
	 return false;
	}
	
var re ;
re=/^[a-zA-Z0-9]*$/ 
if(!re.test(form.pwd1.value,form.pwd2.value))
{
alert('Password can\'t contain speacial symbols !')
return false;
}

if (conta > 0 )
{
alert('Some fields are not complete or not defined\nPlease check it!')
return false;
}
if (form.securitycode.value == "")
{
alert('Security code is empty!')
form.securitycode.style.background = 'yellow' ;	
return false;
}
}



function check_user2()
{

var form = document.getElementById('form1'); 
var conta = 0;

	if( form.nome.value == "" )
	{
	 conta = conta + 1 ;
	 form.nome.style.background = 'yellow' ;	
	}
	else
	{
	 form.nome.style.background = '' ;	
	}
	
	
	if (form.cognome.value == "")
	{
	 conta = conta + 1 ;
	 form.cognome.style.background = 'yellow' ;	
	}
	else
	{
	 form.cognome.style.background = '' ;	
	}
	
	if (form.email.value == "" )
	{
	 conta = conta + 1 ;
	 form.email.style.background = 'yellow' ;	
	}
	else
	{
	 form.email.style.background = '' ;	
	}
	
	if (!form.email.value.match(/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/)) 
	{
	 conta = conta + 1 ;
	 form.email.style.background = 'yellow' ;	
	}
	else
	{
	 form.email.style.background = '' ;	
	}
	
		
	if (form.localita.value == "" )
	{
	 conta = conta + 1 ;
	 form.localita.style.background = 'yellow' ;	
	}
	else
	{
	 form.localita.style.background = '' ;	
	}
	
	if (form.tel.value == "" || isNaN(form.tel.value) )
	{
	 conta = conta + 1 ;
	 form.tel.style.background = 'yellow' ;	
	}
	else
	{
	 form.tel.style.background = '' ;	
	}
	
if (form.pwd1.value != "" || form.pwd1.value != "" )
{
	if (form.pwd1.value == "" )
	{
	 conta = conta + 1 ;
	 form.pwd1.style.background = 'yellow' ;	
	}
	else
	{
	 form.pwd1.style.background = '' ;	
	}
	
	if (form.pwd2.value == "" )
	{
	 conta = conta + 1 ;
	 form.pwd2.style.background = 'yellow' ;	
	}
	else
	{
	 form.pwd2.style.background = '' ;	
	}
	
	if (form.pwd1.value.length < 6 || form.pwd2.value.length < 6  )
	{
	 form.pwd1.style.background = 'yellow' ;
	 form.pwd2.style.background = 'yellow' ;	
	 
	 alert('Password minimum length is 6 characters !');
	 return false;
	}
	else
	{
	 form.pwd1.style.background = '' ;
	 form.pwd2.style.background = '' ;	
	}
	
	if (form.pwd1.value != form.pwd2.value  )
	{
	 alert('Password seems different !');
	 return false;
	}
	
var re ;
re=/^[a-zA-Z0-9]*$/ 
if(!re.test(form.pwd1.value,form.pwd2.value))
{
alert('Password can\'t contain speacial symbols !')
return false;
}

}

if (conta > 0 )
{
alert('Some fields are not complete or not defined\nPlease check it!')
return false;
}
}

////

function if_opera(url){
    if(is_opera()){
        AddCss(url)
    }
}
function is_opera(version, param){
    if (version == null){
      var version = '';
    }
    var agt = navigator.userAgent.toLowerCase();
    if (param == null){
        return (agt.indexOf("opera "+version) != -1 || agt.indexOf("opera/"+version) != -1);
    } else {
        var vers = parseInt(agt.charAt(agt.indexOf("Opera")+7));
        if (param == 'gte'){
            return (vers >= version);
        }
        else if (param == 'gt'){
            return (vers > version);
        }
        else if (param == 'lte'){
            return (vers <= version);
        }
        else if (param == 'lt'){
            return (vers < version);
        }
    }
}
function AddCss(url){
    var l=document.createElement("link");
    l.setAttribute("type","text/css");
    l.setAttribute("rel","stylesheet");
    l.setAttribute("href",'/css/'+url);
    document.getElementsByTagName("head")[0].appendChild(l);
}



function jump_page()
{
var page = document.getElementsByName('page');
var obj = "" ;
for (i=0; i<page.length; i++) 
	{
	obj = page[i].value ;
if (obj > 0 )	
 {
 page[i].value = obj-1 ;
 }
	}
}