function SetLogoutField()
{
	document.forms[0].lblLogoutHidden.value = 'True';
	NoPostBack('Purchase.aspx');
	document.forms[0].submit();
}

function NoPostBack(sNewFormAction)
{
	document.forms[0].action = sNewFormAction;
	document.forms[0].target = '';
	document.forms[0].__VIEWSTATE.value = "";
	document.forms[0].__VIEWSTATE.name = "NOVIEWSTATE";
}

//usata solo per selectPriceRT.aspx in quanto, per l'ordinamento dei risultati
//è necessario avere le informazioni di stato all'interno del viewstate.
function NoPostBackWithViewState(sNewFormAction)
{
	document.forms[0].action = sNewFormAction;
	document.forms[0].target = '';
	if(document.forms[0].__EVENTTARGET != null)
	{
		document.forms[0].__EVENTTARGET.name = "NOEVENTTARGET";
	}
	document.forms[0].__VIEWSTATE.name = "NOVIEWSTATE";
}
function NoPostBackChatCallmeBack(sNewFormAction,Target)
{
	document.forms[0].action = sNewFormAction;
	document.forms[0].target = Target;
	document.forms[0].__VIEWSTATE.value = "";
	document.forms[0].__VIEWSTATE.name = "NOVIEWSTATE";
}

function RouteToNextPage(pRadioButton, pRoute1, pRoute2)
{
	if (pRadioButton.checked)
	{
		NoPostBack(pRoute1);
	}
	else
	{
		NoPostBack(pRoute2);
	}
}

//usato solo per SelectPrice.aspx, non più usato da SelectSchedule.aspx
function RouteSelection(pSelJ, pPage1)
{
	//Write the number of the selected journey in the hidden field SelJ.
	document.getElementById("SelJ").value = pSelJ;
	NoPostBack(pPage1);
}

//usata solo per selectPriceRT.aspx in quanto, per l'ordinamento dei risultati
//è necessario avere le informazioni di stato all'interno del viewstate.
function RouteSelectionWithViewState(pSelJ, pPage1)
{
	//Write the number of the selected journey in the hidden field SelJ.
	document.getElementById("SelJ").value = pSelJ;
	NoPostBackWithViewState(pPage1);
}
/*function RouteBackPart(pPage)
{
	//Set hidden field ModifyJ to True
	document.all("SelJ").value = "";
	document.all("ModifyJ").value = "BackPart";

	//Post to itself.
	NoPostBack(pPage);
}*/

/*function RoutePanelSearch()
{
	//Set hidden field ModifyJ to True.
	//TODO - Inutile, rimuovere. No! Non inutile! Il ViewState lo reimposta al valore precedente!
	document.getElementById("SelJ").value = ""; 

	try
	{
		//TODO - Questo è sicuramente inutile in Schedule, verificare in Price
		document.getElementById("ModifyJ").value = "PanelSearch";
	}
	catch(ex)
	{
	}
	
	 
	//Post to search type.
	var sSearchType = document.getElementById("SearchType").value;
	NoPostBack("Select" + sSearchType + ".aspx");
}*/

function SaveCheckBoxValue(ctrl, hiddenName)
{
	var h = document.getElementById(hiddenName);
	if(ctrl.checked)
		h.value = "True";
	else
		h.value = "False";
}

/* function winOpComunicatiStampa() {
 window.open('comunicati_stampa_popup.html','', 'toolbar=no,scrollbars=yes,resizable=no,height=563,width=518');
}

function winOpRicevuta() {
 window.open('pop_ricevuta.htm','', 'toolbar=no,scrollbars=yes,resizable=no,height=563,width=518');
}

function winOpRicevuta2() {
 window.open('pop_ricevuta2.htm','', 'toolbar=no,scrollbars=yes,resizable=no,height=563,width=518');
}

function torna() {
history.back();
}

function chiudi() {
window.close();
}

function stampa(){  
if (NS) {
    window.print() ;  
} else {
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    WebBrowser1.ExecWB(6, 2);
  WebBrowser1.outerHTML = "";  
}
}  **/


function PresetSelect(pSelect, pVal)
{
	pSelect.value = pVal;
}

function PresetSelectItem(pSelect, pVal, pNum)
{
	pSelect[pNum].value = pVal;
}

function PresetRadioButton(pRadioButton, pVal)
{
	for(var i=0; i<pRadioButton.length; i++)
	{
		if (pRadioButton[i].value == pVal)
			pRadioButton[i].checked = true;
		else
			pRadioButton[i].checked = false;
	}
}

function PresetCheckBox(pCheckBox, pVal)
{
	if (pVal == "True")
		pCheckBox.checked = true;
	else		
		pCheckBox.checked = false;
}

function PresetTextBox(pTextBox, pVal)
{
	pTextBox.value = pVal;
}

function PresetTextBoxItem(pTextBox, pVal, pNum)
{
	pTextBox[pNum].value = pVal;
}


function RoutePanelSearchSpecialClass(panelSearchType, sardiniaCustomers)
{
	//Set hidden field ModifyJ to True.
	//TODO - Inutile, rimuovere. No! Non inutile! Il ViewState lo reimposta al valore precedente!
	document.getElementById("SelJ").value = ""; 
	try
	{
		//TODO - Questo è sicuramente inutile in Schedule, verificare in Price
		document.getElementById("ModifyJ").value = "PanelSearch";
	}
	catch(ex)
	{
	}
	if(sardiniaCustomers){
	//OW-->ONE WAY | RT--> ROUND TRIP | OO--> OTHER OPTION
	if(panelSearchType=='OW'){
	
	var From1 = document.getElementById("pageOneWay_From1_cboAptList").value;
	var To1 = document.getElementById("pageOneWay_To1_cboAptList").value;
		if(From1 && To1) {
			var flCT = false;
			if(From1 == 'CAG' && To1 == 'FCO')			 
				{flCT = true;}
			if(From1 == 'FCO' && To1 == 'CAG')
				{flCT = true;}
		}
	}
	if(panelSearchType=='RT'){
	var From1 = document.getElementById("pageRoundTrip_From1_cboAptList").value;
	var To1 = document.getElementById("pageRoundTrip_To1_cboAptList").value;
		if(From1 && To1) {
			var flCT = false;
			if(From1 == 'CAG' && To1 == 'FCO')			 
				{flCT = true;}
			if(From1 == 'FCO' && To1 == 'CAG')
				{flCT = true;}
		}
	}
if(panelSearchType=='OO'){
From4=document.getElementById("pageOtherOptions_From4_cboAptList");
if(From4==null){
		From3=document.getElementById("pageOtherOptions_From3_cboAptList")
		if(From3==null){

			var From1 = document.getElementById("pageOtherOptions_From1_cboAptList").value;
			var To1 = document.getElementById("pageOtherOptions_To1_cboAptList").value;
			if(From1 && To1) 
			{
				if(From1 == "CAG" && To1 == "FCO")
					flCT = true;
				if(From1 == "FCO" && To1 == "CAG")
					flCT = true;
				if(flCT)
				{
					var From2 = document.getElementById("pageOtherOptions_From2_cboAptList").value;
					var To2 = document.getElementById("pageOtherOptions_To2_cboAptList").value;
					if(From2 && To2) 
					{
						flCT = false;
						if(From2 == "CAG" && To2 == "FCO")
							flCT = true;
						if(From2 == "FCO" && To2 == "CAG")
							flCT = true;
					
					}
				}
			}
		}
		else
		{
			flCT = false;
		}
	}
	else
	{
		flCT = false;
	}
}

		
		if (flCT)  {
			var confString;
			confString =  'toolbar=no,';
			confString += 'location=no,';
			confString += 'alwaysRaised=yes,';
			confString += 'z-lock=yes,';
			confString += 'resizable=no,';
			confString += 'status=no,';
			confString += 'menubar=no,';
			confString += 'scrollbars=yes,';
			confString += 'width=520,';
			confString += 'height=420,';
			confString += 'left=50,';
			confString += 'top=150';
			window.open('static_item/popup_sardinia.htm', 'SC', confString); 	
			return false;
		}
		}
	
	//END SIMONA
	
	
	//Post to search type.
	var sSearchType = document.getElementById("SearchType").value;
	NoPostBack("Select" + sSearchType + ".aspx");
	var a = 1 ;
	return a;
}

function openSendMailToFriend()
{
      var confString;

      confString =  "toolbar=no,";
      confString += "location=no,";
      confString += "alwaysRaised=yes,";
      confString += "z-lock=yes,";
      confString += "resizable=no,";
      confString += "status=yes,";
      confString += "menubar=no,";
      confString += "scrollbars=yes,";
      confString += "width=520,";
      confString += "height=415,";
      confString += "left=50,";
      confString += "top=150";

	  //var w = window.open("SendToFriend.aspx","STF",confString);
      window.open("SendToFriend.aspx","STF",confString);
      //return false;
}//openSendMailToFriend

function openAirportHelp(bookingType, target, targetlist)
{
      var confString;

      confString =  "toolbar=no,";
      confString += "location=no,";
      confString += "alwaysRaised=yes,";
      confString += "z-lock=yes,";
      confString += "resizable=no,";
      confString += "status=yes,";
      confString += "menubar=no,";
      confString += "scrollbars=yes,";
      confString += "width=520,";
      confString += "height=420,";
      confString += "left=50,";
      confString += "top=150";

      var w = window.open("AirportHelp.aspx?bookingType=" + bookingType + "&target=" + target + "&targetlist=" + targetlist, "APT", confString);
      
      return false;
}//openAirportHelp

function winOp(link,width,height,scrollbars)
{window.open(link,'popup','toolbar="no",scrollbars='+scrollbars+',resizable="no",height='+height+',width='+width+'');
}

 