﻿
// File JScript

// BOX di Conferma per passare allo step successivo
function newindow(url,width,height)
{
egenskaper="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,top=0,left=0";
egenskaper+=",width="+width;
egenskaper+=",height="+height;
unik=new Date();
unik=unik.getSeconds()+"_"+unik.getMinutes()+"_"+unik.getHours();
window.open(url,unik,egenskaper);
}

function showPopUp(strId, strMe) {
    var popup = document.getElementById(strId);
    var helper = document.getElementById(strMe);
    setLyr(helper, strId, 25, 5);
    popup.style.display="block";
}

function hidePopUp(strId) {
    var popup = document.getElementById(strId);
    popup.style.display="none";
}

function setLyr(obj,lyr,offsetX,offsetY)
{
	var newX = findPosX(obj);
	var newY = findPosY(obj);
	var x = new getObj(lyr);
	x.style.top = newY+offsetY + 'px';
	x.style.left = newX+offsetX + 'px';
}


function ShowVehPopup(href) {
	window.open(href,'CF_Vehicule','width=420,height=200,directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no').focus();
}



function conferma_step()
{
var agree=confirm("Sicuro di continuare?");
if (agree)
	return true ;
else
	return false ;
}

var visibile = false;

// Mostra/Nascondi DIV Sidebar

function nascondi_mostra_div(ID_sidebar,ID_maincopy){
	if (visibile==false){		
		document.getElementById(ID_sidebar).style.display='none';
		document.getElementById(ID_maincopy).style.marginLeft='0px';
        document.getElementById(ID_maincopy).style.borderLeft = '0px';
		visibile=true;
	}else{
		document.getElementById(ID_sidebar).style.display='';
	    document.getElementById(ID_maincopy).style.marginLeft='15em';
        document.getElementById(ID_maincopy).style.borderLeft = '1px solid rgb(153,153,153)';	
		visibile=false;
	}
    }		
function MostraDiv(ID_sidebar,ID_maincopy){
	document.getElementById(ID_sidebar).style.display='';
	document.getElementById(ID_maincopy).style.marginLeft='15em';
    document.getElementById(ID_maincopy).style.borderLeft = '1px solid rgb(153,153,153)';
    }
    


function findPos(e, pos_type, move_val)
{
	var tipo_browser = navigator.appName;
	var pos_x = 0;
	var pos_y = 0;
	if (tipo_browser == 'Netscape')
	{
		pos_x = parseInt(self.pageXOffset) + e.clientX + document.body.scrollLeft;
		pos_y = parseInt(self.pageYOffset) + e.clientY + document.body.scrollTop;
		pos_x = pos_x + move_val;
		pos_y = pos_y + move_val;
		pos_x = pos_x + "px";
		pos_y = pos_y + "px";
	}
	else
	{
		if (e.pageX) return e.pageX;
		else if (e.clientX)
			pos_x = e.clientX + (document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
		else return null;
		if (e.pageY) return e.pageY;
		else if (e.clientY)
			pos_y = e.clientY + (document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
		else return null;
		pos_x = pos_x + move_val;
		pos_y = pos_y + move_val;
	}
	if (pos_type == 'x')
	{
		return pos_x;
	}
	else
	{
		return pos_y;
	}
}

function info_box_image(e, id)
{
	if (document.getElementById(id))
	{
		if (document.getElementById(id).style.display == 'block')
		{
			document.getElementById(id).style.display = 'none';
		}
		else
		{
			document.getElementById(id).style.left = findPos(e, 'x', -400);
			document.getElementById(id).style.top = findPos(e, 'y', -100);
			document.getElementById(id).style.display = 'block';
		}
	}
}	

function info_data(e, id)
{
	if (document.getElementById(id))
	{
		if (document.getElementById(id).style.display == 'block')
		{
			document.getElementById(id).style.display = 'none';
		}
		else {

		    
			document.getElementById(id).style.left = findPos(e, 'x', 0);
			document.getElementById(id).style.top = findPos(e, 'y', 0);
			document.getElementById(id).style.display = 'block';
		}
	}
}

function info_miglior_prezzo_andata(e, id) {
    if (document.getElementById(id)) {
        if (document.getElementById(id).style.display == 'block') {
            document.getElementById(id).style.display = 'none';
        }
        else {


            document.getElementById(id).style.left = findPos(e, 'x', -210);
            document.getElementById(id).style.top = findPos(e, 'y', -65);
            document.getElementById(id).style.display = 'block';
        }
    }
}


function info_miglior_prezzo_ritorno(e, id) {
    if (document.getElementById(id)) {
        if (document.getElementById(id).style.display == 'block') {
            document.getElementById(id).style.display = 'none';
        }
        else {


            document.getElementById(id).style.left = findPos(e, 'x', -210);
            document.getElementById(id).style.top = findPos(e, 'y', -65);
            document.getElementById(id).style.display = 'block';
        }
    }
}

function info_data_steps(id) {
    if (document.getElementById(id)) {
        if (document.getElementById(id).style.display == 'block') {
            document.getElementById(id).style.display = 'none';
        }
        else {
            document.getElementById(id).style.left = '865px';
            document.getElementById(id).style.top = '1310px';
            document.getElementById(id).style.display = 'block';
        }
    }
}	


function info_partenze_andata(e, id)
{
	if (document.getElementById(id))
	{
		if (document.getElementById(id).style.display == 'block')
		{
			document.getElementById(id).style.display = 'none';
		}
		else
		{
			document.getElementById(id).style.left = findPos(e, 'x',-120);
			document.getElementById(id).style.top = findPos(e, 'y', -184);
			document.getElementById(id).style.display = 'block';
		}
	}
}	


function info_partenze_ritorno(e, id)
{
	if (document.getElementById(id))
	{
		if (document.getElementById(id).style.display == 'block')
		{
			document.getElementById(id).style.display = 'none';
		}
		else
		{
			document.getElementById(id).style.left = findPos(e, 'x', -120);
			document.getElementById(id).style.top = findPos(e, 'y', 10);
			document.getElementById(id).style.display = 'block';
		}
	}
}	


  //**************************************************
 //     controlli oggetti steps
//**************************************************

function copiasuritorno(id_oggetto_andata,id_oggetto_ritorno){
    if (document.getElementById(id_oggetto_ritorno)){
        //alert(id_oggetto_andata);
        document.getElementById(id_oggetto_ritorno).value=document.getElementById(id_oggetto_andata).value;
    }
}

function nascondioggetto(id_oggetto){
    if (document.getElementById(id_oggetto)){
        //alert(valore_andata);
        document.getElementById(id_oggetto).style.display = 'none';
    }
}

function mostraoggetto(id_oggetto){
    if (document.getElementById(id_oggetto)){
        //alert(id_oggetto);
        document.getElementById(id_oggetto).style.display = '';
    }
}

function copiasuritorno_check(id_oggetto_andata,id_oggetto_ritorno){
    if (document.getElementById(id_oggetto_ritorno)){
        //alert(valore_andata);
        document.getElementById(id_oggetto_ritorno).checked=document.getElementById(id_oggetto_andata).checked;
    }
}

var max_img=3; //SE IL NUMERO DI FOTO AUMENTA ... AUMENTARE IL VALORE DELLA VARIABILE



function displayImg(id){
    for (a=1; a<=max_img; a++){
        if(a==id){
            if (document.getElementById("img"+a)){
                document.getElementById("img"+a).style.display="";
            }
        
        }else{
            if (document.getElementById("img"+a)){
                document.getElementById("img"+a).style.display="none";
            }
		}
    }
	return true;
}


function displayRandom(){
	myrandom=Math.round(Math.random()*3)
	myrandom++;
	 if(myrandom>3){
	 myrandom=3;
	 }
	displayImg(myrandom);
}

function F_redirect_poste(http_path)
{
    var mpcode = document.getElementById('mpcode');
    var mpdate = document.getElementById('mpdate');
    window.open(http_path + 'poste.aspx?' + 'mpcode=' + mpcode.value + '&' + 'mpdate=' + mpdate.value);
}

//INIZIO - funzioni per la selezione della riga
var checkbox_precedente_andata = "";
var checkbox_precedente_ritorno = "";
var compagnia_id_selezionata_andata = "";
var compagnia_id_selezionata_ritorno = "";
var andata = "";
var ritorno = "";
var iframe_presente;

//andata
function selezionaRigaAndata(obj) {
    if (checkbox_precedente_andata != "") {
        $("#" + checkbox_precedente_andata).parent().parent().css("background-color", "");
    }

    $(obj).parent().parent().css("background-color", "#FFCC00");
    checkbox_precedente_andata = obj.id;

    obj.checked = true;

    compagnia_id_selezionata_andata = $(obj).attr("compagnia_id");
    andata = $(obj).attr("value");
    iframe_presente = $(obj).attr("iframe_presente");
    //settaPulsanteAvanti()
}

function onmouseoutRigaAndata(obj) {
    if (obj.checked == false) {
        $(obj).parent().parent().css("background-color", "");
    }
}

function onmouseoverRigaAndata(obj) {
    $(obj).parent().parent().css("background-color", "#FFCC00");
}


//ritorno
function selezionaRigaRitorno(obj) {
    if (checkbox_precedente_ritorno != "") {
        $("#" + checkbox_precedente_ritorno).parent().parent().css("background-color", "");
    }

    $(obj).parent().parent().css("background-color", "#FFCC00");
    checkbox_precedente_ritorno = obj.id;

    obj.checked = true;

    compagnia_id_selezionata_ritorno = $(obj).attr("compagnia_id");
    ritorno = $(obj).attr("value");
    window.scrollTo(3000, 3000);

    //settaPulsanteAvanti()

}

function onmouseoverRigaRitorno(obj) {
    $(obj).parent().parent().css("background-color", "#FFCC00");
}

function onmouseoutRigaRitorno(obj) {
    if (obj.checked == false) {
        $(obj).parent().parent().css("background-color", "");
    }
}
//FINE - funzioni per la selezione della riga
