var last_displayed = 'logo';

function set_opacity(obj, opacity){
	opacity = (opacity == 100) ? 99.999 : opacity;
	
	// IE
	if(navigator.appName == 'Microsoft Internet Explorer')
		obj.filters.alpha.opacity = opacity;
	else {
		// Safari<1.2, Konqueror
		obj.style.KHTMLOpacity = opacity/100;
		// Older Mozilla and Firefox
		obj.style.MozOpacity = opacity/100;
		// Safari 1.2, newer Firefox and Mozilla, CSS3
		obj.style.opacity = opacity/100;
	}
}

// visualizza pian piano un elemento
function fade_in(obj_to_display, opacity) {
	if(navigator.appName == 'Microsoft Internet Explorer')
		obj_to_display.style.display = 'block';
	else
		obj_to_display.style.display = 'table';
	if(opacity <= 100) {
		set_opacity(obj_to_display, opacity);
		opacity+= 10;
		window.setTimeout("fade_in(obj_to_display, "+opacity+")", 100);
	}
	else
		last_displayed = obj_to_display.getAttribute('id');
}

// fa spatire pian piano un elemento
function fade_out(obj_to_hide, opacity, obj_to_display) {
	if(opacity >= 0) {
		set_opacity(obj_to_hide, opacity);
		opacity-= 10;
		window.setTimeout("fade_out(obj_to_hide, "+opacity+", obj_to_display)", 100);
	}
	else {
		obj_to_hide.style.display = 'none';
		fade_in(obj_to_display, 0);
	}
}

// nasconde il l'ultimo contenuto centrale visualizzato e mostra la fiera
function display_fair(fair) {
	obj_to_hide = document.getElementById(last_displayed);
	obj_to_display = document.getElementById('fair_box_'+fair);
	
	fade_out(obj_to_hide, 100, obj_to_display);
}

// nasconde il l'ultimo contenuto centrale visualizzato e mostra la fiera
function display_office(office) {
	obj_to_hide = document.getElementById(last_displayed);
	obj_to_display = document.getElementById('office_box_'+office);
	
	fade_out(obj_to_hide, 100, obj_to_display);
}

// torna all'home page normale con il logo
function display_logo() {
	obj_to_hide = document.getElementById(last_displayed);
	obj_to_display = document.getElementById('logo');
	
	fade_out(obj_to_hide, 100, obj_to_display);
}

// login forzato sul main server per gli owner
function towers_login() {
	if(document.getElementById('actor').value.substring(0,4)=='alba')
	{
		var ap = document.loginform.action.replace('www2','www');
        	ap = ap.replace('www1','www');
        	ap = ap.replace('www3','www');
		document.getElementById('loginform').setAttribute('action',ap);
	}
	document.loginform.submit();
}


function show_remember_box(){
    if(document.getElementById('remember_box')){
        document.getElementById('rem_load').style.display = 'none';
        document.getElementById('rem_load').innerHTML = js_dic_LOADING;
        document.getElementById('userclient').value='';
        document.getElementById('remember_mail').value='';
        document.getElementById('rem_form').style.display = 'block';
        document.getElementById('remember_box').style.display = 'block';
    }
}
function check_email(){
    if(document.getElementById('userclient').value==''){
        print_error(js_dic_ERRORNOCODE);
        return false;
    }
    var email = Trim(get_value('remember_mail'));
    if(email == '' || !emailControl(email)){
        print_error(js_dic_NOEMAIL);
        return false;
    }
    else{
        var url_xml_rpc_=js_global_root_url+'xml_rpc/call.php';
        var struct_param_=new Array();
        var iso_encoding_='utf-8';
        struct_param_['header']=new Array();
        struct_param_['query']=new Array();
        struct_param_['header']['version']='1.0.0';
        struct_param_['header']['product']='customers';
        struct_param_['header']['sessid']=sessid;
        struct_param_['header']['type']='remember_password';
        struct_param_['query']['client'] = Trim(get_value('userclient'));
        struct_param_['query']['email'] = email;
        
        document.getElementById('rem_form').style.display = 'none';
        document.getElementById('rem_load').style.display = 'block';
        xml_request(struct_param_,url_xml_rpc_,iso_encoding_,mail_sent);
    }
}
function mail_sent(response){
    if(response=='ok')
        document.getElementById('rem_load').innerHTML = js_dic_SENTMAILOK;
    else
        document.getElementById('rem_load').innerHTML = js_dic_SENTMAILKO;
}