//This variable has been declared as 1 so that when the user hits the enter button on entering the pag for
//the first time, the page is sumbitted. However if he presses tab and moves the focus to some other link
//this variable is set to 0 thus disabling the function for handling enter key press.
var valEnter="1";
var valDropdown="0";

//This funtion sets the IBE_FCN value depending on the value of the stage variable
function fLoadPage(FormObj,stage)
{
FormObj.action = CONTROLLER;
if(stage==0)
{
	FormObj.IBE_FCN.value=AIRSEARCH_BREADCRUMB;
}
else if(stage==1)
{
	FormObj.IBE_FCN.value=AIRSEARCH_REDEMPTION_BREADCRUMB;
}
else if(stage==2)
{
	FormObj.IBE_FCN.value=AIRSEARCH_CLICKABLEFARE_BREADCRUMB;
}
else if(stage==3)
{
	FormObj.IBE_FCN.value=AIRAVAIL_BREADCRUMB;
}
else if(stage==4)
{
	FormObj.IBE_FCN.value=STOPOVER_BREADCRUMB;
}
else if(stage==5)
{
	FormObj.IBE_FCN.value=MDSEARCH_BREADCRUMB;
}
else if(stage==6)
{
	FormObj.IBE_FCN.value=APSELECTDESTINATION_BREADCRUMB;
}
else if(stage==7)
{
	FormObj.IBE_FCN.value=WPSELECTDESTINATION_BREADCRUMB;
}
//Purvi's code starts...
else if(stage==8)
{
	FormObj.IBE_FCN.value=FC_BREADCRUMB;
}
else if(stage==9)
{
	
	FormObj.IBE_FCN.value=MDAVAIL_BREADCRUMB;
} else if(stage==10) {
	FormObj.IBE_FCN.value=DDFAIRSEARCH_BREADCRUMB;
} else if(stage==11) {
	FormObj.IBE_FCN.value=DDFAIRAVAIL_BREADCRUMB;
}
//Purvi's code ends...
document.forms[0].target = "";
loadingMssgOnSubmit( );
FormObj.submit();
}

//This funtion disables the return date dropdowns if the award ID selected supports one way.
//Also this function makes a call to the functions that set the proper values in the adult and children
//dropdown depending on whether the award ID supports First cabin class or not.
//imtcwc 20070810 enhancement for pax # for Business class in ka.com (add brand name as parameter)
function disableReturnDateDropdown(brand)
{
    var x = document.forms[0].r_day;
    var y = document.forms[0].r_month;
    var z = document.forms[0].rAwardType.value;
    
    if (z == '1_OW_E' || z=='1_OW_B' || z=='1_OW_F' || z=='2_OW_B' || z=='2_OW_F' || z == '24_OW_E')  //CPPTOS: Added for Priority Award
    {
		x.disabled = true;
        y.disabled = true;
		// start Added the folling code to provide handling for the following-- awardID selection to oneway then no change in the return date in calendar -Chithra
        // changes for new one way handling.On change of award id to one way value should be reset to One way.
		x.selectedIndex=0;
        y.selectedIndex=0;
        
		document.forms[0].tripType.value=1;
        //document.forms[0].radioDepRet.disabled = true;
		document.forms[0].radioDepRet[0].checked=true;
        var currentCalForm=document.forms[0].currentCalForm.value;
        if(currentCalForm=="return")
        {
        	document.forms[0].currentCalForm.value = "departure";
		dep1.className = "selectdepdated";
		dep2.className = "selectdepdater";
        }
		// end Added the folling code to provide handling for the following-- awardID selection to oneway then no change in the return date in calendar -Chithra
    }
    else if(z =='3_RT_B' || z == '3_RT_F')
    {
        document.forms[0].IBE_FCN.value = MYITINERARYSUMMARY;

        document.forms[0].action= CONTROLLER;
		loadingMssgOnSubmit( );
        document.forms[0].submit();
    }
    else
    {
        x.disabled = false;
        y.disabled = false;
    }
    if(z!="")
    {
		//imtcwc 20070810 enhancement for pax # for Business class in ka.com
	    if ((z=='1_OW_F'|| z == '1_RT_F'||z=='2_OW_F'||z=='2_RT_F')||((z=='1_OW_B'||z=='1_RT_B'||z=='2_OW_B'||z=='2_RT_B')&& brand=='KA'))
	    {
		changeSelect2();
	    }
	    else
	    {
		//alert("Inside restore....");
		restore(document.forms[0]);
	    }
    }
}

//This funtion basically sets the IBE_FCN value. It also checks whether the stopover checkbox has been
//checked by the user.
function checkBoxClick(FormObj,stage)
{
	//alert(stage);
	FormObj.action = CONTROLLER;
	if(FormObj.buttonType.value=="Search")
	{
		FormObj.IBE_FCN.value=AIRAVAIL;
	} else if(FormObj.buttonType.value=="DDFSearch") {
		FormObj.IBE_FCN.value=DDFAIRAVAIL;
	}
	else if(FormObj.buttonType.value=="LogIn")
	{
		if(stage==AIRSEARCH_REV)
		{
		FormObj.IBE_FCN.value=AIRSEARCH_LOGIN;
		}
		else if(stage==AIRSEARCH_RED)
		{
		FormObj.IBE_FCN.value=AIRSEARCH_REDEMPTION_LOGIN;
		}
		else if(stage==AIRSEARCH_CLK)
		{
		FormObj.IBE_FCN.value=AIRSEARCH_CLICKABLEFARE_LOGIN;
		}
		else if((stage==AIRAVAIL_REV)||(stage==AIRAVAIL_RED)||(stage==AIRAVAIL_CLK))
		{
		FormObj.IBE_FCN.value=AIRAVAIL_LOGIN;
		}
		else if((stage==AIRFARE_REV)||(stage==AIRFARERED_RED)||(stage==AIRFARE_CLK)
		||(stage==STOPOVER_FARE_REV)||(stage==STOPOVER_FARE_CLK))
		{
		FormObj.IBE_FCN.value=AIRFARE_LOGIN;
		}
		else if(stage==APSEARCH_CLK)
		{
		FormObj.IBE_FCN.value=APSEARCH_LOGIN;
		}
		else if(stage==APSELECTDESTINATION_CLK)
		{
		FormObj.IBE_FCN.value=APSELECTDESTINATION_LOGIN;
		}
		else if(stage==APSUMMARY_CLK)
		{
		FormObj.IBE_FCN.value=APSUMMARY_LOGIN;
		}
		else if(stage==WPSELECTDESTINATION_CLK)
		{
		FormObj.IBE_FCN.value=WPSELECTDESTINATION_LOGIN;
		}
		else if(stage==WPSUMMARY_CLK)
		{
		FormObj.IBE_FCN.value=WPSUMMARY_LOGIN;
		}
		else if(stage==MDSEARCH_REV)
		{
		FormObj.IBE_FCN.value=MDSEARCH_LOGIN;
		}
		else if(stage==TARGETFAREUSERSLANDINGPAGE_REV) {
			FormObj.IBE_FCN.value=TARGETFARESUSERS;
		}

		//26-Sep-05 Mukesh comment as the flow type on Fare Calendar page will be revenue
		//else if(stage==FARESSEARCH_CLK)

		else if(stage==FARESSEARCH_REV)

		{
		FormObj.IBE_FCN.value=FC_LOGIN;
		}
		else if(stage==MDAVAIL_CLK)
		{
		FormObj.IBE_FCN.value=MDAVAIL_LOGIN;
		}
		else if(stage==MDAVAIL_REV)
		{
		FormObj.IBE_FCN.value=MDAVAIL_LOGIN;
		}
		else if(stage==STOPOVERAVAIL_REV)
		{
		FormObj.IBE_FCN.value=MDAVAIL_LOGIN;
		}
		else if(stage==STOPOVERAVAIL_CLK)
		{
		FormObj.IBE_FCN.value=MDAVAIL_LOGIN;
		}
		else if(stage==STOPOVERAVAILCLK_CLK)
		{
		FormObj.IBE_FCN.value=MDAVAIL_LOGIN;
		}
		else if(stage==MDFARES_CLK)
		{
		FormObj.IBE_FCN.value=AIRFARE_LOGIN;
		}
		else if(stage==MDFARES_REV)
		{
		FormObj.IBE_FCN.value=AIRFARE_LOGIN;
		}
		else if(stage==FARECALENDARGETFARES_CLK)
		{
		FormObj.IBE_FCN.value=AIRFARE_LOGIN;
		} else if(stage==DDFAIRSEARCH_REV) {
			FormObj.IBE_FCN.value=DDFAIRSEARCH_LOGIN;
		} else if(stage==DDFAIRAVAIL_REV) {
			FormObj.IBE_FCN.value=DDFAIRAVAIL_LOGIN;
		}
	}
	else if(FormObj.buttonType.value=="LogOut")
	{
		FormObj.FROM_MLC.value="0";
		if(stage==AIRSEARCH_REV)
		{
		FormObj.IBE_FCN.value=AIRSEARCH_LOGOUT;
		}
		else if(stage==AIRSEARCH_RED)
		{
		FormObj.IBE_FCN.value=AIRSEARCH_REDEMPTION_LOGOUT;
		}
		else if(stage==AIRSEARCHMILES_RED)
		{
		FormObj.IBE_FCN.value=AIRSEARCH_REDEMPTION_LOGOUT;
		}
		else if(stage==SELECTDESTINATION_RED)
		{
		FormObj.IBE_FCN.value=AIRSEARCH_REDEMPTION_LOGOUT;
		}
		else if(stage==SEARCHAVAILFORDESTINATION_RED)
		{
		FormObj.IBE_FCN.value=AIRSEARCH_REDEMPTION_LOGOUT;
		}
		else if(stage==MYITINERARYSUMMARY_RED)
		{
		FormObj.IBE_FCN.value=AIRSEARCH_REDEMPTION_LOGOUT;
		}
		else if(stage==MYITINERARYDETAIL_RED)
		{
		FormObj.IBE_FCN.value=AIRSEARCH_REDEMPTION_LOGOUT;
		}
		else if(stage==AIRSEARCH_CLK)
		{
		FormObj.IBE_FCN.value=AIRSEARCH_CLICKABLEFARE_LOGOUT;
		}
		else if((stage==AIRAVAIL_REV)||(stage==AIRAVAIL_RED)||(stage==AIRAVAIL_CLK))
		{
		FormObj.IBE_FCN.value=AIRAVAIL_LOGOUT;
		}
		else if((stage==AIRFARE_REV)||(stage==AIRFARE_CLK)
		||(stage==STOPOVER_FARE_REV)||(stage==STOPOVER_FARE_CLK))
		{
		FormObj.IBE_FCN.value=AIRFARE_LOGOUT;
		}
		else if(stage==AIRFARERED_RED)
		{
		FormObj.IBE_FCN.value=AIRFARERED_LOGOUT;
		}
		else if(stage==GETCONFIRMATIONRED_RED)
		{
		FormObj.IBE_FCN.value=CONFIRMATION_REDEMPTION_LOGOUT_FCN;
		}
		else if(stage==GETCONFIRMATION_REV || stage==GETCONFIRMATION_CLK )
		{
		FormObj.IBE_FCN.value=CONFIRMATION_REVENUE_LOGOUT_FCN;
		}
		else if(stage==MYTRIPS_REV)
		{
		FormObj.IBE_FCN.value=MYTRIPS_LOGOUT;
		}		
		else if(stage==TRIPDETAILS_REV)
		{
		FormObj.IBE_FCN.value=TRIPDETAILS_LOGOUT;
		}
		//added now - chithra for logout functionality
		//else if(stage==CUG_REV)
		//{
			//FormObj.IBE_FCN.value=AIRSEARCH_REDEMPTION_LOGOUT;
			//if(FormObj.FORHEADERACTION)
			//{
				//FormObj.TYPE.value="RED";
				//FormObj.action = "hidden2.jsp";
			//}
		//}//added now - chithra for logout functionality
		else if(stage==CUG_LANDINGPAGE_REV)
		{
			//FormObj.IBE_FCN.value=AIRSEARCH_REDEMPTION_LOGOUT;
			FormObj.IBE_FCN.value=CUGLANDINGPAGELOGOUT;
			if(FormObj.NAM)
			{
				//FormObj.TYPE.value="REV";
				FormObj.FROM_NAM.value="1";
			}
			//else
			//{
			//FormObj.TYPE.value="RED";
			//}
			//FormObj.action = "hidden2.jsp";
		}
		//else if(stage==CUG_LANDINGPAGE_RED)
		//{
			//FormObj.IBE_FCN.value=AIRSEARCH_REDEMPTION_LOGOUT;
			//FormObj.TYPE.value="RED";
			//FormObj.action = "hidden2.jsp";
	//	}
		else if(stage==CUG_BOOKINGUSERREGISTRATIONCONFIRMATION_REV)
		{
			FormObj.IBE_FCN.value=CUGBOOKINGUSERREGISTERDONELOGOUT;
			if(FormObj.NAM)
			{
				//FormObj.TYPE.value="REV";
				FormObj.FROM_NAM.value="1";
			}
			//else
			//{
			//FormObj.TYPE.value="RED";
			//}
		}
		else if(stage==APSEARCH_CLK)
		{
			FormObj.IBE_FCN.value=APSEARCH_LOGOUT;
		}
		else if(stage==APSELECTDESTINATION_CLK)
		{
			FormObj.IBE_FCN.value=APSELECTDESTINATION_LOGOUT;
		}
		else if(stage==APSUMMARY_CLK)
		{
			FormObj.IBE_FCN.value=APSUMMARY_LOGOUT;
		}
		else if(stage==WPSELECTDESTINATION_CLK)
		{
			FormObj.IBE_FCN.value=WPSELECTDESTINATION_LOGOUT;
		}
		else if(stage==WPSUMMARY_CLK)
		{
			FormObj.IBE_FCN.value=WPSUMMARY_LOGOUT;
		}
		else if(stage==MDSEARCH_REV)
		{
			FormObj.IBE_FCN.value=MDSEARCH_LOGOUT;
		}
		
		//26-Sep-05 Mukesh comment as the flow type on Fare Calendar page will be revenue
		//else if(stage==FARESSEARCH_CLK)

		else if(stage==FARESSEARCH_REV)

		{
			FormObj.IBE_FCN.value=FC_LOGOUT;
		}
		else if(stage==MDAVAIL_CLK)
		{
			FormObj.IBE_FCN.value=MDAVAIL_LOGOUT;
		}
		else if(stage==MDAVAIL_REV)
		{
			FormObj.IBE_FCN.value=MDAVAIL_LOGOUT;
		}
		else if(stage==STOPOVERAVAIL_REV)
		{
			FormObj.IBE_FCN.value=MDAVAIL_LOGOUT;
		}
		else if(stage==STOPOVERAVAIL_CLK)
		{
			FormObj.IBE_FCN.value=MDAVAIL_LOGOUT;
		}
		else if(stage==STOPOVERAVAILCLK_CLK)
		{
			FormObj.IBE_FCN.value=MDAVAIL_LOGOUT;
		}
		else if(stage==MDFARES_CLK)
		{
			FormObj.IBE_FCN.value=AIRFARE_LOGOUT;
		}
		else if(stage==MDFARES_REV)
		{
			FormObj.IBE_FCN.value=AIRFARE_LOGOUT;
		}
		else if(stage==FARECALENDARGETFARES_CLK)
		{
			FormObj.IBE_FCN.value=AIRFARE_LOGOUT;
		}
		//25-MAY-2006_MOD_Start:Amey Kanade:Target fare Users CR
		else if(stage==TARGETFAREUSERSLANDINGPAGE_REV)
		{
			FormObj.IBE_FCN.value=TARGETFARESUSERSLOGOUT;
		} else if (stage==DDFAIRSEARCH_REV) {
			FormObj.IBE_FCN.value=DDFAIRSEARCH_LOGOUT;
		} else if (stage==DDFAIRAVAIL_REV) {
			FormObj.IBE_FCN.value=DDFAIRAVAIL_LOGOUT;
		}
		//25-MAY-2006_MOD_End:Amey Kanade:Target fare Users CR
	}
	if(document.getElementById("stopOverCheckbox"))
	{
	if((FormObj.stopOverCheckbox!=null)&&(FormObj.buttonType.value=="Search"))
	{
		if(FormObj.stopOverCheckbox.checked)
		{
			FormObj.IBE_FCN.value=STOPOVER;
		}
	}
	}
    FormObj.target = "";
	if(FormObj.buttonType.value!="LogOut")
	{
    loadingMssgOnSubmit( );
	}
	FormObj.submit();

}

//This funtion sets the IBE_FCN values to search when the user clicks on the start again link on
//any page.
function startAgain(FormObj,flowType)
{
    FormObj.action = CONTROLLER;

	//start : added for logging event on click of the start again link
    FormObj.eventStatus.value="startOver";
    //end : added for logging event on click of the start again link
    if(flowType=="REV")
    {
    	//FormObj.IBE_FCN.value=AIRSEARCH_BREADCRUMB;
    	//FormObj.IBE_FCN.value=AIRSEARCH;
		FormObj.IBE_FCN.value=AIRSEARCH_STARTAGAIN
    }
    else if(flowType=="RED")
    {
    	//FormObj.IBE_FCN.value=AIRSEARCH_REDEMPTION_BREADCRUMB;
    	//FormObj.IBE_FCN.value=AIRSEARCH_REDEMPTION;
		FormObj.IBE_FCN.value=AIRSEARCH_REDEMPTION_STARTAGAIN

    }
    else
    {
    	//FormObj.IBE_FCN.value=AIRSEARCH_CLICKABLEFARE_BREADCRUMB;
    	//FormObj.IBE_FCN.value=AIRSEARCH_CLICKABLEFARE;
		FormObj.IBE_FCN.value=AIRSEARCH_CLICKABLEFARE_STARTAGAIN;
    }
	//alert("FormObj.IBE_FCN.value"+FormObj.IBE_FCN.value);
	FormObj.target = "";
	loadingMssgOnSubmit( );
	FormObj.submit();
}


//This funtion sets the IBE_FCN values to search when the user clicks on the start again link on
//any page.
function startAgainNew(FormObj,flowType,subFlowType)
{
 //   alert("Hello Mukss");
    FormObj.action = CONTROLLER;

	//start : added for logging event on click of the start again link
   // FormObj.eventStatus.value="startOver";
    //end : added for logging event on click of the start again link
 //  alert( " Mukss in startAgainNew Fn subFlowType::" + subFlowType );
    if(subFlowType=="APS")
    {
    	//FormObj.IBE_FCN.value=AIRSEARCH_BREADCRUMB;
    	//FormObj.IBE_FCN.value=AIRSEARCH;
		FormObj.IBE_FCN.value=APSELECTDESTINATION_STARTAGAIN;
    }
    else if(subFlowType=="WPS")
    {
    	//FormObj.IBE_FCN.value=AIRSEARCH_REDEMPTION_BREADCRUMB;
    	//FormObj.IBE_FCN.value=AIRSEARCH_REDEMPTION;
		FormObj.IBE_FCN.value=WPSELECTDESTINATION_STARTAGAIN;

    }
    else if(subFlowType == "FCS")
    {
    	//FormObj.IBE_FCN.value=AIRSEARCH_CLICKABLEFARE_BREADCRUMB;
    	//FormObj.IBE_FCN.value=AIRSEARCH_CLICKABLEFARE;
		FormObj.IBE_FCN.value=AIRSEARCH_STARTAGAIN;
    }
    else if(subFlowType == "MDS")
    {
    	//FormObj.IBE_FCN.value=AIRSEARCH_CLICKABLEFARE_BREADCRUMB;
    	//FormObj.IBE_FCN.value=AIRSEARCH_CLICKABLEFARE;
	FormObj.IBE_FCN.value=MDSEARCH_STARTAGAIN;
    }
	//alert("FormObj.IBE_FCN.value"+FormObj.IBE_FCN.value);
	FormObj.target = "";
	loadingMssgOnSubmit( );
	FormObj.submit();
}

  var childWin;

    //Added by bhupi to get fare rules window more in width then the normal popup window.
  function fnPopUpFareRules(url)
  {
   if(childWin && !(childWin.closed))
   { 
    childWin.location=url;
   }
   else
   {
	eval("childWin = window.open(url, \"NewWin\", \"toolbar=no,locationbar=no,status=no,menubar=no,scrollbars=yes,width="+(window.screen.width/1.4)+",height="+(window.screen.height/2)+",resizable\")");
   }
   childWin.focus();
  }

  
  //This funtion is used to show the popup window.
  function fnPopUp(url)
  {
   if(childWin && !(childWin.closed))
   { 
    childWin.location=url;
   }
   else
   {
    //childWin = window.open(url, "NewWin", "toolbar=no,locationbar=no,status=no,menubar=no,scrollbars=yes,width=580,height=500,resizable");
//	Apoorve changed to make the new window 1/4 size of screen 6/11/2004 start
	//alert("inside header popupwindow open abcdefgi");
	eval("childWin = window.open(url, \"NewWin\", \"toolbar=no,locationbar=no,status=no,menubar=no,scrollbars=yes,width="+(window.screen.width/2)+",height="+(window.screen.height/2)+",resizable\")");
//	Apoorve changed to make the new window 1/4 size of screen 6/11/2004 end

   }
   childWin.focus();
  }

//This funtion is used to set the Value of the variable valEnter to 0.
function setVal(val)
{
	valEnter=val;
}

//This funtion is used to set the Value of the variable valDropdown to 1 when focus is on dropdown
//and its value to 0 if focus is moved away from the dropdown.
function setValDropDown(val)
{
	valDropdown=val;
}

//This block of code is written to provide handling for enter key press.
if (document.all)
{
   document.onkeydown = function TabkeyPress()
   {
      if(event.keyCode==9)
      {
		valEnter="0";
      }
   }
	document.onkeypress=function callKeyPress()
	{
		//alert("I am here2");
		//alert(event.keyCode);
		//alert("valEnter"+ valEnter);
		//alert("valDropdown"+valDropdown);
	  var tempvalDropdown=valDropdown;
      //The above line has been added because the value of valDropdown variable
      //changes to "0" after the first line

	  //Added to deactivate enter after pressed once
	  var actaulPageLayer = document.getElementById("fullBody");
	  var actaulPageLayerVisible = actaulPageLayer.style.visibility;
//	  alert(" actaulPageLayerVisible : [" + actaulPageLayerVisible+"]");
//	  alert(" actaulPageLayerVisible : " + (actaulPageLayerVisible == "visible"));
      if ((event.keyCode ==13)&&(valEnter=="1")&&(tempvalDropdown=="0") &&(actaulPageLayerVisible == "visible"))

      {
      	    FormObj=window.document.forms[0];
      	    document.forms[0].action = CONTROLLER;
      	    var stage = document.forms[0].stageForEnterKey.value;
      	    var flowType = document.forms[0].flowTypeForEnterKey.value;
      	    var stageFlow=stage+"_"+flowType;
	      	if(stage==AIRSEARCH)
		    {
				if(((document.forms[0].member!=null)&&(document.forms[0].member.value!=""))||((document.forms[0].pin!=null)&&(document.forms[0].pin.value!="")))
				{
				   logIn(FormObj,stageFlow);
				}
				else
				{
				       setButtonType(FormObj,"Search",stage);
				}
		    }
		    else
		    {
			    if(flowType=="RED")
			    {
				    if(stage==AIRAVAIL)
				    {
					if(((document.forms[0].member!=null) && (document.forms[0].member.value!=""))||((document.forms[0].pin!=null)&&(document.forms[0].pin.value!="")))
					{
					    document.forms[0].IBE_FCN.value=AIRAVAIL_LOGIN;
						loadingMssgOnSubmit( );
		    			document.forms[0].submit();
					 }		
					else
					{
						document.forms[0].IBE_FCN.value=AIRFARERED;
						loadingMssgOnSubmit( );
						document.forms[0].submit();
					}
				    }
				    else if (stage==AVCALREDEMPTION)
					{
						//document.forms[0].IBE_FCN.value=AIRAVAIL;
						//document.forms[0].submit();
						fnIBE_FCNAVCal("AirAvail");
					}
				    
				    else if((stage==AIRFARERED))
				    //||(stage==AIRFARERED_ITIN)||(stage==AIRFARERED_TOPUP))
				    {
				    		//fnSubmitPayment();
				    }
				    
				    else if((stage==AIRSEARCHMILES)||(stage==SELECTDESTINATION))
				    {
						 fnIBE_FCNAirSearchMiles();
				    }
				    else if(stage==SEARCHAVAILFORDESTINATION)
				    {
						 setButtonType(FormObj,"Search",stage);
				    }
	
			    }
			    else if(flowType=="REV"||flowType=="CLK")
			    {
			    	//alert ("Here");
			    	if(stage==AIRAVAIL)
				    {
						if(((document.forms[0].member!=null) && (document.forms[0].member.value!=""))||((document.forms[0].pin!=null)&&(document.forms[0].pin.value!="")))
						{
						    document.forms[0].IBE_FCN.value=AIRAVAIL_LOGIN;
							loadingMssgOnSubmit( );
						    document.forms[0].submit();
						 }		
						else
						{
							document.forms[0].IBE_FCN.value=AIRFARE;
							loadingMssgOnSubmit( );
							document.forms[0].submit();
						}
				    }
				    else if(stage==AIRFARE ||stage==STOPOVER_FARE)
				    {
						if(((document.forms[0].member!=null) && (document.forms[0].member.value!=""))||((document.forms[0].pin!=null)&&(document.forms[0].pin.value!="")))
						{
						    document.forms[0].IBE_FCN.value=AIRFARE_LOGIN;
							loadingMssgOnSubmit( );
						    document.forms[0].submit();
						}
						else if (document.forms[0].LOGINUserID)
						{
							if(((document.forms[0].LOGINUserID!=null) && (document.forms[0].LOGINUserID.value!=""))||((document.forms[0].LOGINPassword!=null)&&(document.forms[0].LOGINPassword.value!="")))
							{
								    document.forms[0].IBE_FCN.value=AIRFARE_LOGIN;
								    //document.forms[0].submit();
									submit1();
							}
							else if (((document.forms[0].UserID!=null) && (document.forms[0].UserID.value!="")))
							{
								    //document.forms[0].IBE_FCN.value=REGISTER_PROFILE;
								    //document.forms[0].submit();
							}
						}
						else
						{
							//fnSubmit();
						}
				    }
				    else if(stage==STOPOVER_SEARCH)
				    {
						 submitStopOver();
				    }
				    else if(stage==STOPOVER_AVAIL)
				    {
						 submitCombine();
				    }
				    else if(stage==STOPOVER_PROGRESS)
				    {
						 submitProgress();
				    }
				    else if (stage==AVCALREVENUE)
					{
						//alert ("Here1");
						//document.forms[0].IBE_FCN.value=AIRAVAIL;
						//document.forms[0].submit();
						fnIBE_FCNAVCal("AirAvail");
					}
				    else if (stage==APSEARCH)
					{
						if(((document.forms[0].member!=null) && (document.forms[0].member.value!=""))||((document.forms[0].pin!=null)&&(document.forms[0].pin.value!="")))
						{
						    document.forms[0].IBE_FCN.value=APSEARCH_LOGIN;
							loadingMssgOnSubmit( );
						    document.forms[0].submit();
						 }		
						else
						{
							fnSubmitSearch(APSELECTDESTINATION);
						}
					}
				    else if (stage==APSELECTDESTINATION)
					{
						if(((document.forms[0].member!=null) && (document.forms[0].member.value!=""))||((document.forms[0].pin!=null)&&(document.forms[0].pin.value!="")))
						{
						    document.forms[0].IBE_FCN.value=APSELECTDESTINATION_LOGIN;
							loadingMssgOnSubmit( );
						    document.forms[0].submit();
						 }		
						else
						{
							fnSubmitSel(APSUMMARY);
						}
					}
				    else if (stage==APSUMMARY)
					{
						if(((document.forms[0].member!=null) && (document.forms[0].member.value!=""))||((document.forms[0].pin!=null)&&(document.forms[0].pin.value!="")))
						{
						    document.forms[0].IBE_FCN.value=APSUMMARY_LOGIN;
							loadingMssgOnSubmit( );
						    document.forms[0].submit();
						 }		
						else
						{
							fnSubmitSum(APAVAIL);
						}
					}
				    else if (stage==MDAVAIL)
					{
						if(((document.forms[0].member!=null) && (document.forms[0].member.value!=""))||((document.forms[0].pin!=null)&&(document.forms[0].pin.value!="")))
						{
						    document.forms[0].IBE_FCN.value=MDAVAIL_LOGIN;
							loadingMssgOnSubmit( );
						    document.forms[0].submit();
						 }		
						else
						{
							fnCheckFlightsFull(document.forms[0].fullOND.value, document.forms[0].totalOND.value, document.forms[0].ibeFcnGetFares.value);
						}
					}
				    else if (stage==WPSELECTDESTINATION)
					{
						if(((document.forms[0].member!=null) && (document.forms[0].member.value!=""))||((document.forms[0].pin!=null)&&(document.forms[0].pin.value!="")))
						{
						    document.forms[0].IBE_FCN.value=WPSELECTDESTINATION_LOGIN;
							loadingMssgOnSubmit( );
						    document.forms[0].submit();
						 }		
						else
						{
							fnCallSubmit();
						}
					}
				    else if (stage==WPSUMMARY)
					{
						if(((document.forms[0].member!=null) && (document.forms[0].member.value!=""))||((document.forms[0].pin!=null)&&(document.forms[0].pin.value!="")))
						{
						    document.forms[0].IBE_FCN.value=WPSUMMARY_LOGIN;
							loadingMssgOnSubmit( );
						    document.forms[0].submit();
						 }		
						else
						{
							callSubmit(WPAVAIL);
						}
					}
				    else if (stage==MDSEARCH)
					{
						if(((document.forms[0].member!=null) && (document.forms[0].member.value!=""))||((document.forms[0].pin!=null)&&(document.forms[0].pin.value!="")))
						{
						    document.forms[0].IBE_FCN.value=MDSEARCH_LOGIN;
							loadingMssgOnSubmit( );
						    document.forms[0].submit();
						 }		
						else
						{
							fnSubmitMD(MDAVAIL);
						}
					}
			   }
//			   else if(flowType=="CLK")
//			   {
//			   		alert ("Here");
//			   		if (stage==AVCALREVENUE)
//					{
//						//document.forms[0].IBE_FCN.value=AIRAVAIL;
//						//document.forms[0].submit();
//						fnIBE_FCNAVCal("AirAvail");
//					}
//			    }
		    }
       }
   }
}	  
 function fnForgotPin(url,formObj)
  {
	//alert( formObj );
	url = url+ formObj.member.value;
	fnPopUp(url);
  }
 function fnForgotPinCUG(url,formObj)
  {
	url = url+ formObj.txtUserID.value;
	fnPopUp(url);
  }
  function fnForgotPinRegister(url,formObj)
  {
	 // alert( formObj );
    url = url+ formObj.LOGINUserID.value;
	fnPopUp(url);
  }



	function checkbrowser()
	{
		if(!(isvalidBrowser()))
		{
			//alert('Not a valid browser');
			document.location.href="DownLoad.jsp";
		}

	}

	function isvalidBrowser()
	{
		return detectBrowser();
		
	}

	function detectBrowser()
	{
		// convert all characters to lowercase to simplify testing
		    var agt=navigator.userAgent.toLowerCase();

	    // *** BROWSER VERSION ***
	    // Note: On IE5, these return 4, so use is.ie5up to detect IE5.
		this.major = parseInt(navigator.appVersion);
		this.minor = parseFloat(navigator.appVersion); // - this.major;

		//alert(this.major);			alert(this.minor);		alert(agt);	

		this.nav  = (((agt.indexOf('mozilla')!=-1) || (agt.indexOf('netscape')!=-1)) && (agt.indexOf('spoofer')==-1)
			&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
			&& (agt.indexOf('webtv')==-1));

		this.nav2 = (this.nav && (this.major == 2));
		this.nav3 = (this.nav && (this.major == 3));
		this.nav4 = (this.nav && (this.major == 4));
		this.nav4up = (this.nav && (this.minor > 4));
	    
		this.navonly = (this.nav && ((agt.indexOf(";nav") != -1) ||   (agt.indexOf("; nav") != -1)) || agt.indexOf('netscape')!=-1);

		this.nav5 = (this.nav && (this.major == 5));
		this.nav5up = (this.nav && (this.minor >= 5));

		this.nav7 = (agt.indexOf('netscape')!=-1);	

		this.ie   = (agt.indexOf("msie") != -1);
		this.ie3  = (this.ie && (this.major < 4));
		this.ie4  = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")==-1) );
		this.ie4up  = (this.ie  && (this.minor > 4));
		this.ie5  = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")!=-1) );
		this.ie5up  = (this.ie  && (this.minor > 5)); 
		this.ie55 = (agt.indexOf("msie 5.5")!=-1); 
		this.ie5up  = (this.ie  && (this.minor > 5)); 
		this.ie6 = (agt.indexOf("msie 6.0")!=-1); 

		this.firefox1 = (agt.indexOf("firefox/1")!=-1); 
		this.safari = (agt.indexOf("safari/125.9")!=-1); 
		//alert(agt.indexOf('netscape'));		alert(" NAV 7 " + this.nav7);		alert(" IE 6 " + this.ie6);		alert(" ie5up " + this.ie5up);


		//alert(" this.firefox1 " + this.firefox1);
		if(this.ie55 || this.ie6 || this.nav7 || this.firefox1 || this.safari)
		{
			return true;
		}
		else
		{
			return false;
		}
		
	}
function fnExit()
{
//    document.forms[0].action= CONTROLLER;
//	document.forms[0].IBE_FCN.value=EXIT;
//	document.forms[0].submit();
fReturnToHomePage();
	}

function fReturnToUSA()
{
	document.forms[0].target = "";
	document.forms[0].action= CONTROLLER;
	document.forms[0].IBE_FCN.value=RETURNTONAM;
	loadingMssgOnSubmit();
	document.forms[0].submit();
}
function startAgainToUSA()
{
    document.forms[0].action= CONTROLLER;
	document.forms[0].IBE_FCN.value=RETURNTONAM;
	document.forms[0].isStartAgain.value="Y";
	document.forms[0].target = "";
	loadingMssgOnSubmit( );
	document.forms[0].submit();
}
function fReturnToHomePage()
{
	document.forms[0].target = "";
	document.forms[0].action= CONTROLLER;
	document.forms[0].IBE_FCN.value=RETURNTOHOMEPAGE;
	if(document.forms[0].returnToHomePage)
	{
	document.forms[0].returnToHomePage.value="Y";
	}
	loadingMssgOnSubmit();
	document.forms[0].submit();
}
//Begin Rakesh 7-Jun-2005 Added methods for Account Locking implementation
 function fnForgotPinMLC()
  {
	//alert( formObj );
	url = forgotPinURL+ window.document.forms[0].member.value;
	fnPopUp(url);
  }
function fnContactUsAclock( url )
{
	//alert( formObj );
	url = url+ window.document.forms[0].member.value;
	fnPopUp(url);
}


// START -- Added by BHUPI for handling of customised error messages and debugging alerts

var errorArgs = new Array();
	function alertDebug(msg)
	{
		alert(" alert debug :" + msg);
	}

	function fnErrorHandler(errorMessage)
	{
		//alertDebug(errorArgs[0]);
		var sIndex = 0;
		var count = 0;
		var finalString = "";
		
		while(0 <= errorMessage.indexOf("~"))
		{
			//alertDebug(errorMessage.indexOf("~"));
			eIndex = errorMessage.indexOf("~");
			var tempString = errorMessage.substring(sIndex, eIndex);
			//alertDebug("temp string : " + tempString);
			finalString = finalString + tempString + errorArgs[count++];
			//alertDebug("message so far : " + finalString);
			errorMessage = errorMessage.substring(eIndex + 1);
			//alertDebug("errorMessage : " + errorMessage);
		}
		if(errorMessage.length > 0)
		{
			finalString = finalString + errorMessage;
		}
		alert(finalString);		
	}

// END -- Added by BHUPI for handling of customised error messages and debugging alerts
function setFCIBEFCN()
{
	if(document.forms[0].BFButtonEnabled.value=="1")



	{
		document.forms[0].target = "";
		document.forms[0].action= CONTROLLER;
		document.forms[0].IBE_FCN.value=FARESSEARCH;
		loadingMssgOnSubmit();
		document.forms[0].submit();
	}
}

function startAgainToDDF() {
    document.forms[0].action= CONTROLLER;
	document.forms[0].IBE_FCN.value=DDFAIRSEARCH_STARTAGAIN;
	document.forms[0].isStartAgain.value="Y";
	document.forms[0].target = "";
	loadingMssgOnSubmit( );
	document.forms[0].submit();
}