	//this function is to be used from other JS files. Look at its usages for examples.
	function showHideReturnDate(thevalue)
	{
		if(document.getElementById("retCH"))
		{
			if(thevalue!="R")
			{
				document.getElementById("retCH").style.display = "none";
			}
			else
			{
				document.getElementById("retCH").style.display = "block";
			}
		}	
	}
	
	// Modified by MilindG jun-23 for Calendar Change as per Bug : 208

	function pageRefresh()
	{
		window.location.reload(true);
	}

	function GetDate(day,month,dayControlName,monthControlName)
	{	
		 dayControl = window.opener.document.getElementById(dayControlName) ;
		 dayControl.selectedIndex = day;
			 
		 monthControl = window.opener.document.getElementById(monthControlName) ;

		 for(i=0;i<monthControl.length;i++)
		 {
			if(trim(monthControl.options[i].value) != '' && parseInt(monthControl.options[i].value, 10) == parseInt(month, 10))
			{
				monthControl.selectedIndex = i ;
				break ;
			}
		 }

		window.close();  
	}
	
	function trim(theString)
	{
	    while (theString.substring(0,1) == ' '){
    	        theString = theString.substring(1, theString.length);
    	    }
	    while (theString.substring(theString.length-1,theString.length) == ' '){
    	        theString = theString.substring(0, theString.length-1);
    	    }
    	    return theString;
    	}

	/*
	Get which radio button of Today/Tomorrow is checked. Control of type
	textbox.
	*/
	function GetSelectedDateForTextBox( radioButtonListName, dateControlId )
	{	
		//Get the Today/Tomorrow radio button list, date control.
		var RadioButtonList = document.getElementsByName( radioButtonListName );
		var DateControl = document.getElementById( dateControlId );
		var Index;
		var CheckedItem;

		//Check which radio button is checked. 
		for( Index = 0; Index < RadioButtonList.length ; Index++ )
		{
			if( RadioButtonList[Index].checked )
			{
				CheckedItem = RadioButtonList[Index];
				break;
			}
		}//End of traversing radiolist

		if( DateControl.type == 'text')
			DateControl.value = CheckedItem.value;
	}//End of GetSelectedDate


	/*
	Get which radio button of Today/Tomorrow is checked. Set the passed date
	and month in the controls.
	*/
	function GetSelectedDateMonth( radioButtonListName, dateControlId, monthControlId )
	{
		//Get the Today/Tomorrow radio button list, date control.
		var RadioButtonList = document.getElementsByName( radioButtonListName );
		var DateControl = document.getElementById( dateControlId );
		var MonthControl = document.getElementById( monthControlId );
		var Index;
		var CheckedItem;

		//Check which radio button is checked. 
		for( Index = 0; Index < RadioButtonList.length ; Index++ )
		{
			if( RadioButtonList[Index].checked )
			{
				CheckedItem = RadioButtonList[Index];
				break;
			}
		}//End of traversing radiolist

		var Value = CheckedItem.value;
		var Pos = Value.indexOf( "/" );
		var DateValue = Value.substr( 0, 2 );
		var MonthValue = Value.substr( Pos+1, 2 );

		//select the checked date in the drop down
		for( Index = 0; Index < DateControl.length; Index++)
		{
			if( DateControl.options[Index].value == DateValue)
			{
				DateControl.selectedIndex = Index ;
				break ;
			}
		}//End of traversing the datecontrol

		//select the month in the drop down
		for( Index = 0; Index < MonthControl.length; Index++)
		{
			if( MonthControl.options[Index].value == MonthValue)
			{
				MonthControl.selectedIndex = Index ;
				break ;
			}
		}//End of traversing the datecontrol

	}//End of GetSelectedDateMonth

	/*
	Get which radio button of Today/Tomorrow is checked. Set the date in the control.
	Control of type Dropdown
	*/
	function GetSelectedDateForDropDown( radioButtonListName, dateControlId )
	{	
		//Get the Today/Tomorrow radio button list, date control.
		var RadioButtonList = document.getElementsByName( radioButtonListName );
		var DateControl = document.getElementById( dateControlId );
		var Index;
		var CheckedItem;

		//Check which radio button is checked. 
		for( Index = 0; Index < RadioButtonList.length ; Index++ )
		{
			if( RadioButtonList[Index].checked )
			{
				CheckedItem = RadioButtonList[Index];
				break;
			}
		}//End of traversing radiolist

		//select the checked date in the drop down
		for( Index = 0; Index < DateControl.length; Index++)
		{
			if( DateControl.options[Index].value == CheckedItem.value)
			{
				DateControl.selectedIndex = Index ;
				break ;
			}
		}//End of traversing the datecontrol

	}//End of GetSelectedDate

		
	function windowNewOpen(url,myHeight,myWidth)
	{

		var myLeft = (screen.width-myWidth)/2;
		var myTop = (screen.height-myHeight)/2;
		var dayControl;
		var monthControl;
		
			
		var urlstring = url; 
	
		var features = 'scrollbar=no,width=' + myWidth +  ',height=' + myHeight + ',left=' + myLeft + ',top=' + myTop;
		var openedWindow =  window.open(urlstring,'test',features);
	//	openedWindow.moveTo(screen.availWidth/2-(235/2),screen.availHeight/2-(250/2));

		return false;
	}
	
	//function windowOpen(url,dayValue,monthValue,defaultModuleDate)
	function windowOpen(url, journeytype, OPreviousDaydayValue, OPreviousMonth, RPreviousDay, RPreviousMonth, defaultModuleDate)
	{
		var myHeight = 330;
		var myWidth = 260;
		var myLeft = (screen.width-myWidth)/2;
	    var myTop = (screen.height-myHeight)/2;
		var dayControl;
		var monthControl;

		OdayControl = document.getElementById(OPreviousDaydayValue);
		
		OmonthControl  = document.getElementById(OPreviousMonth);
	
		RdayControl = document.getElementById(RPreviousDay);
		
		RmonthControl  = document.getElementById(RPreviousMonth);
			
		if (OPreviousDaydayValue =='' || OPreviousMonth =='' )
		{
			 var urlstring = url + '?JourneyType=' + journeytype 
					+ '&OdayControl=' + '&OmonthControl=' 
					+ '&OPreviousDay=' + '&OPreviousMonth=' 
					+ '&RdayControl=' + RPreviousDay + '&RmonthControl=' + RPreviousMonth
					+ '&RPreviousDay=' + RdayControl.value + '&RPreviousMonth=' + RmonthControl.value
					+ '&DefaultModuleDate=' +defaultModuleDate; 
					
			
		}
		else
		{
			 var urlstring = url + '?JourneyType=' + journeytype 
					+ '&OdayControl=' + OPreviousDaydayValue + '&OmonthControl=' + OPreviousMonth 
					+ '&OPreviousDay=' + OdayControl.value + '&OPreviousMonth=' + OmonthControl.value
					+ '&RdayControl=' + RPreviousDay + '&RmonthControl=' + RPreviousMonth
					+ '&RPreviousDay=' + RdayControl.value + '&RPreviousMonth=' + RmonthControl.value
					+ '&DefaultModuleDate=' +defaultModuleDate; 
			
		}	
		var features = 'scrollbars=no,resizable=yes,status=no,width=' + myWidth +  ',height=' + myHeight + ',left=' + myLeft + ',top=' + myTop;
		var openedWindow =  window.open(urlstring,'test',features);
		return false;
	}

	function OpenPopUpWindowCentered(theURL,winName,features, myWidth, myHeight, isCenter) {
		var re = /%26/g;
		theURL = theURL.replace(re, "&")
		if(window.screen)if(isCenter)if(isCenter=="true"){
		var myLeft = (screen.width-myWidth)/2;
		var myTop = (screen.height-myHeight)/2;
		features+=(features!='')?',':'';
		features+=',left='+myLeft+',top='+myTop;
		}
	var new_win = 		window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
	new_win.focus();
	}

        // Following function is added as a part of Implementation of SMS functionality
	function TextMeSMS(ddt1,ol1,tm1,adt1,dl1)
	{
		var leftPosition = (screen.width) ? (screen.width-520)/2 : 0; 
		var topPosition = (screen.height) ? (screen.height-480)/2 : 0;
		var settings = 'height=480,width=520,top=' + topPosition +',left=' + leftPosition +',scrollbars=no,resizable=no';
 		var vurl ='http://thetrainline.textme.kizoom.co.uk/?ddt1=' + ddt1 + '&ol1=' + ol1 + '&tm1=' + tm1 + '&adt1='+ adt1 +'&dl1='+dl1;
 		//var vurl ='http://localhost/SMS_test/SampleSite/WebForm1.aspx/?ddt1=' + ddt1 + '&ol1=' + ol1 + '&tm1=' + tm1 + '&adt1='+ adt1 +'&dl1='+dl1 ;
		var win = window.open(vurl,'SampleTest',settings);
		win.focus();
	}

	function SubmitToAcsUrl(){
        window.onload = doActualSubmit;
	}
    
    function doActualSubmit(){
		var formVar = document.createElement("form");
		var paReq = document.getElementById("PaReq");
		var md = document.getElementById("MD");
		var termUrl = document.getElementById("TermUrl");
		formVar.appendChild(paReq);
		formVar.appendChild(md);
		formVar.appendChild(termUrl);
		formVar.method= "post";
	    formVar.action = document.getElementById("AcsUrl").value;
	    document.body.appendChild(formVar);
	    formVar.submit();        
    }
	
	function LoadPageInParentWindow(){
		    top.location = document.getElementById("ConfirmationPage").value;
	}

	function LoadCurrentPageInTopmostWindow(){
		//~ if(self != top)
		    //~ top.location = self.location;
	}


	/*For TTL Leisure 
	Added Hexaware - Satyam B, Used in CreditCardDetailsUIProvider */
	function FetchCCTypeFromCreditCardTypeDD()
        {
            var objInput = document.getElementsByTagName("select");	
	        for (var i=0;i<objInput.length;i++)
	        {
		        if (objInput[i].id.indexOf("CreditCardDetailsModule.CreditCardTypeDropdown")>=0)
		        {			        
	                var myindex  = objInput[i].selectedIndex
	                var hiddinCCC = document.getElementById("updateCCC");
	                hiddinCCC.value=objInput[i].options[myindex].value;
	             }
	        }
			return true;
        }
	/*For TTL Leisure 
	Added Hexaware - Satyam B, Used in CreditCardDetailsUIProvider */
	function FetchCCTypeFromChooseCardDD()
        {
            var objInput = document.getElementsByTagName("select");	
	        for (var i=0;i<objInput.length;i++)
	        {
		        if (objInput[i].id.indexOf("CreditCardDetailsModule.ChooseCardDropdown")>=0)
		        {			        
	                var myindex  = objInput[i].selectedIndex
	                var hiddinCCC = document.getElementById("updateCCC");
	                hiddinCCC.value=objInput[i].options[myindex].value;
	             }
	        }
			return true;
        }
        
        function SubmitFormWithHiddenField(name)
        {
           var editAddress = document.createElement('input');
           editAddress.setAttribute('type','hidden');
           editAddress.setAttribute('name',name);
           editAddress.setAttribute('value',name);
           document.forms[0].appendChild(editAddress);
           document.forms[0].submit();
        }
        
        function RefreshAllElementVisibilities(eventSender, pattern) {
            var RefreshElementVisibility = UpdateVanishingElementCssFromPattern(eventSender,pattern);
            return function(elementCollection) {
                elementCollection.ForEach(RefreshElementVisibility);
            }
        }
                       
        function RefreshVisibilitiesWith(eventSender, pattern){
           ElementCollections('div','legend','p').ForEach(RefreshAllElementVisibilities(eventSender,pattern));
        }
                
        function UpdateVanishingElementCssFromPattern(eventSender, pattern)
       {
          return function(element) {
              var match = element.id.match(/vanishing.*CaresAbout#(.*)-Match#(.*)-.*CssClass#(.*)-/); 
              if (match == null || eventSender != match[1] ) return;
              var patternToMatchAgainst = match[2];
              var DefaultCssClass = match[3];
              var setCssClass = CssClassSetter(isSelected(patternToMatchAgainst,pattern)? DefaultCssClass : 'hidden');   
              setCssClass(element);
           }
       }
       
       function isSelected(patternToMatchAgainst,pattern)
       {
            var elements = patternToMatchAgainst.split("|");
            for(var i=0;i<elements.length; i++)
            {
               if(elements[i] == pattern)
                    return true;
            }
            return false;
       }
                             
       function ElementCollections() {            
            var elementsOfType = function(elementTagName) {
                return document.getElementsByTagName(elementTagName);
            }                          
            var getCollection = function(elementTagName) {
                return new CollectionWithDelegates(elementsOfType(elementTagName));
            }
            return new CollectionWithDelegates(arguments).ConvertAll(getCollection);
       }
       
       function CollectionWithDelegates(collection) {          
          this.ForEach = function(action) {
               for (var i = 0; i < collection.length; i++) {
                  action(this.item(i));         
               } 
           }
           
          this.ConvertAll = function(converter) {
             var returnArr = new Array();
             for (var i = 0; i < collection.length; i++) {
                  returnArr[i] = converter(this.item(i)); 
               }
             return new CollectionWithDelegates(returnArr);   
          }           
          
          this.length = collection.length;
          ithHTMLItem = function(i) {return collection.item(i);}
          ithArrayItem = function(i) {return collection[i];}
          this.item = (typeof collection.item != 'undefined') ? ithHTMLItem : ithArrayItem;           
       }
        
       function CssClassUpdater(cssClass)
       {
          return CssClassSetter(cssClass);
       }
       
       function RemoveCssClass(element)
       {
          return CssClassSetter('')(element);
       }
       
       function CssClassSetter(cssClass)
       {
          return function(element){
             element.className = cssClass;
          }
       }               

function submit_form()
{
  document.forms[0].submit();
}

function suppressEnterKey(e){
  var keynum;
  if(window.event) { keynum = e.keyCode;} else if(e.which){keynum = e.which;} 
  if(keynum == 13) return false;
  return true;
}
