// JScript File
///Date format evaulate
///It can consist of 0-9 and / or - or .
///this don't parse for current culture it does only server side
function ClientDateValidate(source, arguments) {
    re = /^([0-9]{2,4})?([/-])+([0-9]{2,4})?([/-])+([0-9]{2,4})$/;
    if (re.test(arguments.Value)) {
        arguments.IsValid=true;
    }
    else {
        arguments.IsValid=false;
    }
}

function CurrencyPopup(sBookedAmount) {
	targetURL = 'Currency.ascx?amt='+sBookedAmount;
	CurrencyWindow = window.open (targetURL, 'CurrencyWindow', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,height=400,width=410', borders=0);
	CurrencyWindow.focus();
}

function CurrencyPopup1() {
	targetURL = 'CurrencyConverter.aspx';
	CurrencyWindow = window.open (targetURL,'CurrencyConverter', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,height=380,width=380', borders=0);
	CurrencyWindow.focus();
}

function CurrencyPopupCA(pCurrency,pAmount,pHotelCode,pLanguage) {
	targetURL = 'CurrencyConverter.aspx?currency='+pCurrency +'&amount='+pAmount+'&property='+pHotelCode+'&language='+pLanguage;
	CurrencyWindow = window.open (targetURL,'CurrencyConverter', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,height=355,width=355', borders=0);
	CurrencyWindow.focus();
}

function HotelMapPopup(pHotelCode,pLanguage,pAddress) {
	targetURL = 'HotelMap.aspx?property='+pHotelCode+'&language='+pLanguage+'&address='+pAddress;
	HotelMapWindow = window.open (targetURL,'HotelMap','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,titlebar=0,height=340,width=540', borders=0);
	HotelMapWindow.focus();
}

function HotelInfoPopup(pHotelCode,pLanguage) {
	targetURL = 'HotelInformation.aspx?property='+pHotelCode+'&language='+pLanguage;
	//HotelInfoWindow = window.open (targetURL,'HotelInformation','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,height=355,width=355', borders=0);
	HotelInfoWindow = window.open (targetURL,'HotelInformation','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,height=355,width=355', borders=0);
	HotelInfoWindow.focus();
}

function HotelGalleryPopup(pHotelCode) {
	targetURL = 'HotelPictureGallery.aspx?property='+pHotelCode;
	HotelGalleryWindow = window.open (targetURL,'HotelPictureGallery', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,height=355,width=355', borders=0);
	HotelGalleryWindow.focus();
}

function TermsPopup(pHotelCode, pLanguage, pExtenstion) {
    if(pHotelCode=='*')
	    targetURL = 'I/hotels/'+pLanguage+'_terms' + pExtenstion;
	else
	    targetURL = 'I/hotels/'+pHotelCode+'/'+pLanguage+'_terms'+pExtenstion;
	TermsWindow = window.open (targetURL, 'Terms', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,height=455,width=800', borders=0);
	TermsWindow.focus();
}

function showBiggerImage(closeText, imageURL, width,height) {
    height = parseInt(height) + 50;
    width = parseInt(width) + 40;
	TermsWindow = window.open ('', 'Image', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,height='+height+',width='+width, borders=0);
	TermsWindow.document.writeln('<html><body><div align=center><img src=\''+imageURL+'\' border=0></div></html></body>');
	TermsWindow.document.close();
}

function changePictureSrc(TargetImageID,SrcPath) {
    var MainImg=document.getElementById(TargetImageID);
    MainImg.src=SrcPath;
}
    
///little trickery if we want to appear a question box when the button was pressed and don't want to cause 2 times postback 
///So we need 1 button and 1 hiddenfield wich has a ValueChanged event (sample in the SubmitCancel.ascx). this event will substitute the button's event
///we have to bind the MsgOkCancel() to the onClick event of button (in the behind code)
///
///msg ->this will appear in the message box
///controlID -> Hiddenfield id 
function MsgOkCancel(msg, controlID) { 
    var fRet; 
    fRet = confirm(msg); 
    var con = document.all ? document.all[controlID] : document.getElementById(controlID);

    if(fRet) {
        con.value = "true";
    } 
}

//var startTimeStamp = 0;
//var isArrivalSelected = false;
//var selectedArrivalID = 0;
//var selectedDepartureID = 0;
//*Async*
//var tmparid= 'ctl00_LeftContentHolder_ctlCalendar_tmpar'; 
//var tmpdpid = 'ctl00_LeftContentHolder_ctlCalendar_tmpdp';
//var startid = 'ctl00_LeftContentHolder_ctlCalendar_tmpstart';
//*Async*
var tmparid= 'ctlCalendar_tmpar'; 
var tmpdpid = 'ctlCalendar_tmpdp';
var tmpserialid = 'ctlCalendar_tmpserial';
var startid = 'ctlCalendar_tmpstart';
var tmpoffset = 'ctlCalendar_tmpoffset';

var calendarStatus = new Array();
var calendarStatusIDs = new Array();
var onMouseOverSelected = 0;
var nroOfDays = 42;
var isReloaded = 0;
var tmID;

function isArrivalSelected() {
    var selectedArrivalID = document.getElementById(tmparid); 
    var selectedDepartureID = document.getElementById(tmpdpid);
    //alert(selectedArrivalID.value);
    return parseInt(selectedArrivalID.value)>0 && parseInt(selectedDepartureID.value)==0;
}

function saveItem(Id,cssClass) {
    if (calendarStatus['E'+Id]== null || calendarStatus['E'+Id]=='') {
        calendarStatus['E'+Id] = cssClass;
    }
    calendarStatusIDs.push(Id);
}
   

function __changeSelections() {
    
    var selectedArrivalID = document.getElementById(tmparid); 
    var selectedDepartureID = document.getElementById(tmpdpid);


    for (var i = 0;i<calendarStatusIDs.length;i++) {

        serial = calendarStatusIDs[i];
        var el = document.getElementById(serial);
        if (el!=null) {
            if (calendarStatus['E'+serial]!='') {
                el.className=calendarStatus['E'+serial];
            } 
            else {
                el.className='CalendarNotAvailable';
            }
            if (serial==parseInt(selectedArrivalID.value)) {
                el.className = 'CalendarSelected';
            } 
            else {
                if (el.className!='Calendar_closed' && serial>=parseInt(selectedArrivalID.value) && serial<=parseInt(selectedDepartureID.value)) {
                    el.className = 'CalendarSelected';
                }
            }
        }
    }
}
    
function reloadCalendar(calendar_id, is_postback) {
    if(is_postback)
        isReloaded = 1;
    //alert('reload');
    if (isReloaded == 0) {
        isReloaded=1;
        if(calendar_id!=null)
            setTimeout("__doPostBack('"+calendar_id+"','V0')", 3000);
    } 
    else {
        isReloaded=0;
        var selectedArrivalID = $get(tmparid); 
        var selectedDepartureID = $get(tmpdpid);
        var selectedSerialID = $get(tmpserialid);
        var startTimeStamp = $get(startid);
        var dayDistinct = $get(tmpoffset);
        //alert(selectedArrivalID.value +'-'+selectedDepartureID.value+' start'+ startTimeStamp.value +' offset :'+ dayDistinct.value);
        var depOffset=0;
        var Offset = parseInt(startTimeStamp.value);
        var oStart = 0;
        var oEnd = 0;
        var bStartFound = false;
        var bEndFound = false;
        var serial = 0;
        var el = null;
        
        for (var i=0;i<nroOfDays;i++) { 
            serial = parseInt(startTimeStamp.value)+i;
            el = document.getElementById(serial);
            
            if (el!=null) {
                var currentDay = document.getElementById(serial);
                var curDay = parseInt(currentDay.innerHTML);            
                if((curDay == parseInt(selectedArrivalID.value)) && 
                   (serial>=parseInt(selectedSerialID.value)) &&
                   (!bStartFound))
                {
                    oStart = serial;
                    //alert(oStart);
                    bStartFound = true;
                }
                if((curDay == parseInt(selectedDepartureID.value)) && 
                   (serial>=parseInt(selectedSerialID.value)) && 
                   (!bEndFound))
                {
                    oEnd = serial;
                    //alert(oEnd);
                    bEndFound = true;
                }
            }
        }   
             
        for (var i=0;i<nroOfDays;i++) 
        { 
            serial = parseInt(startTimeStamp.value)+i;
            el = document.getElementById(serial);
            
            if (el!=null) 
            {   //check the month over e.g. jan30.-feb2. 
                if(parseInt(selectedArrivalID.value) > parseInt(selectedDepartureID.value))
                {
                    depOffset = parseInt(selectedArrivalID.value) + parseInt(dayDistinct.value);
                } 
                else
                {
                    depOffset = parseInt(selectedDepartureID.value);
                }

                if (el.className!='Calendar_closed' && el.className!='CalendarPassedDate' && (serial>=oStart && serial<=oEnd) && (oStart<=parseInt(selectedSerialID.value) && parseInt(selectedSerialID.value)<=oEnd)) 
                {
                    //alert('serial22222 : ' + serial +' - ' + startTimeStamp.value + ' - ' + oStart+' - '+oEnd+' - '+ depOffset); 
                    saveItem(serial,el.className);
                    el.className = 'CalendarSelected';
                }
            }
        }
    }
}


function __calMOver(start,id,status) {
 
    if (isArrivalSelected()) {
        
        var selectedArrivalID = document.getElementById(tmparid); 
        var selectedDepartureID = document.getElementById(tmpdpid);
                
        __changeSelections();
        
        var el = document.getElementById(id);
        if (status=='i') {
            var SelArID = parseInt(selectedArrivalID.value);
            if (id>SelArID) {    
                var StartIndex = SelArID;
                if (start>SelArID) {
                    StartIndex = start;
                }
                    
                for (var k=SelArID;k<=id;k++) {
                    var el = document.getElementById(k);
                    if (el!=null && el.className!='Calendar_closed') {
                        // save the status before changing it 
                           
                        saveItem(k,el.className);
                        el.className='CalendarSelected';
                    }
                }
            }  
        }
    }
}   

// changed to work with combined year/month - sacha, 2007-07-06
function __changeDateLocale(start,selfID,sDateDay,sDateMonth,sDateYear,eDateDay,eDateMonth,eDateYear) { 
    var aDateBoxDay=parent.window.document.getElementById('Arrival_day');
    var aDateBoxYearMonth=parent.window.document.getElementById('Arrival_yearmonth');
    
    var dDateBoxDay=parent.window.document.getElementById('Departure_day');
    var dDateBoxYearMonth=parent.window.document.getElementById('Departure_yearmonth');
    
    var selectedArrivalID = document.getElementById(tmparid); 
    var selectedDepartureID = document.getElementById(tmpdpid);
        
    if (!isArrivalSelected() || selfID<parseInt(selectedArrivalID.value)) {
        selectedArrivalID.value = selfID;
        selectedDepartureID.value = 0;
               
        aDateBoxDay.value=sDateDay;
        aDateBoxYearMonth.value=sDateYear+""+sDateMonth;
    } 
    else 
    {
        if (selfID==parseInt(selectedArrivalID.value)) 
        {
            // if clicking the arrival date again
            selectedArrivalID.value = 0;
            selectedDepartureID.value = 0;
        } 
        else 
        {     
            if (selfID>parseInt(selectedArrivalID.value)) 
            {
                selectedDepartureID.value = selfID;
            }
        }   
    }
            
    __changeSelections();
       
    if (parseInt(selectedDepartureID.value)==0) {
        dDateBoxDay.value=eDateDay;
        dDateBoxYearMonth.value=eDateYear+""+eDateMonth;
    } 
    else {
        dDateBoxDay.value=sDateDay;
        dDateBoxYearMonth.value=sDateYear+""+sDateMonth;
    }
    
    var DateCell=document.getElementById(selfID);
    saveItem(selfID,DateCell.className);
    DateCell.className = 'CalendarSelected';
}

///Shows the bytes amount of the ViewState of the Page
///made for only test
function ShowViewStateSize() {
    var buf = document.aspnetForm["__VIEWSTATE"].value ;
    alert("View Sate is " + buf.length + "bytes");
}

function DoCollapseGuarantees(guaranteeTypeCC, guaranteeTypeEditID, CollapsePanelID) {
   var bbb = document.getElementById(guaranteeTypeEditID); //at the modifycancel                                      
   if (bbb) 
   {
      if(guaranteeTypeCC!=null)
      {
          var ss = guaranteeTypeCC.split("|");
          for (i = 0; i < ss.length; i++)
          {
              if (bbb.options[bbb.selectedIndex].value == ss[i])
              {
                  ChangeAll(true, CollapsePanelID);
              }
              else
              {
                  ChangeAll(false, CollapsePanelID);
              }
          }
      }
   }
}

function DoCollapseExpandUsers(sw1, existingID, sw2, registerID) {
  if (sw1)
  {
      ChangeAll(true, existingID);
      ChangeAll(false, registerID);
  }
  if(sw2)
  {
      ChangeAll(true, registerID);
      ChangeAll(false, existingID);
  }
}

function ChangeAll(open, CollapsePanelId) {
    var behavior = $find(CollapsePanelId);
    
    if(behavior!=null) {
        // Open or close the panel
        if (open)
        {
            behavior._doOpen.call(behavior);
        }
        else
        {
            behavior._doClose.call(behavior);
        }        
    }
}   

var gAutoPrint = false; // Flag for whether or not to automatically call the print function 
function printPopup(hotelCSS, rowButtons) 
{ 
    if (document.getElementById != null) 
    { 
        // 2006-12-21 CD: Added the notes javascript
        var html = '<HTML>\n<HEAD>\n'; 
        html += '<LINK id=\"ctl00_commonstyle\" media=\"screen\" href=\"'+hotelCSS+'\" type=\"text/css\" rel=\"stylesheet\"/>';
        html += '<LINK id=\"ctl00_printingstyle\" media=\"print\" href=\"CSS/printing.css\" type=\"text/css\" rel=\"stylesheet\"/>';
        html += '<SCRIPT language=\"javascript\" src=\"Scripts/tooltip.js\" type=\"text/javascript\"></SCRIPT>';
        html += '<SCRIPT language=\"javascript\" src=\"Scripts/Utils.js\" type=\"text/javascript\"></SCRIPT>';
        
        if (gAutoPrint) { 
            if (navigator.appName == "Microsoft Internet Explorer") { 
                html += '\n</HEAD>\n<'
                html += 'BODY style="padding-left:80px; padding-right:80px;" onLoad="PrintCommandObject.ExecWB(6, -1);">\n'; 
            } 
            else { 
                html += '\n</HEAD>\n<BODY style="padding-left:80px; padding-right:80px;">\n'; 
            } 
        } 
        else { 
            html += '\n</HEAD>\n<BODY style="padding-left:80px; padding-right:80px;">\n'; 
        } 
        
        //html += '\n<table><tr><td>&nbsp;</td><td>'; //Zsolt 21/12/06 fit in left margo
            
        var rowButtons = document.getElementById(rowButtons);
        if(rowButtons!=null)
            rowButtons.style.display = 'none';
                    
        var printReadyElem = document.getElementById("maincontent");
        
        if (printReadyElem != null) { 
            html += printReadyElem.innerHTML; 
            
            //21/12/06 Zsolt removes the question mark on the preview
            if (navigator.appName == "Microsoft Internet Explorer")
            {
                html = html.replace(/class=HelpButton/g,"class=PrintHelpButton");
                html = html.replace(/class=menuTable/g,"class=menuPrintTable");                
                html = html.replace(/class=headerStyleTable/g,"class=headerStyle"); 
            }
            else
            {
                html = html.replace(/class=\"HelpButton\"/g,"class=\"PrintHelpButton\"");
                html = html.replace(/class=\"menuTable\"/g,"class=\"menuPrintTable\"");
                html = html.replace(/class=\"headerStyleTable\"/g,"class=\"headerStyle\"");                
            }
        } 
        else { 
            alert("Could not find the maincontent section in the HTML"); 
            return; 
        }
        
        if(rowButtons!=null)
            rowButtons.style.display = 'block';
            
        //html += '\n</td></tr></table>'; //Zsolt 21/12/06 fit in left margo (end)
            
        if (gAutoPrint) { 
            if (navigator.appName == "Microsoft Internet Explorer") { 
                html += '<OBJECT ID="PrintCommandObject" WIDTH=0 HEIGHT=0 '
                html += 'CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>\n</BODY>\n</HTML>'; } 
            else { 
                html += '\n</BODY>\n</HTML>'; 
            } 
        } 
        else { 
            html += '\n</BODY>\n</HTML >'; 
        } 
        var printWin = window.open("","printPopup"); 
        printWin.resizeTo(800,850);

        printWin.document.open(); 
        printWin.document.write(html); 
        printWin.document.close();
        printWin.print(); 
    } 
    else { 
        alert("Sorry, the print ready feature is only available in modern browsers.");
    }
    return false;
} 

// Move an element directly on top of another element (and optionally
// make it the same size)
function Cover(bottom, top, ignoreSize) {
    if(bottom)
    {
        if(top)
        {
            var location = Sys.UI.DomElement.getLocation(bottom);
            top.style.position = 'absolute';
            top.style.top = location.y + 'px';
            top.style.left = location.x + 'px';
            if (!ignoreSize) {
                top.style.height = bottom.offsetHeight + 'px';
                top.style.width = bottom.offsetWidth + 'px';
            }
        }
    }
}

var infoElement;
var flyOutElement;
var imgElement;
var cellElement;
var popupElement;
    
function CloseDetailWindow(popupObj, infoObj, flyOutObj, cellObj) {
  
    if(popupElement)
    {
        popupElement._behaviors[0].hide();
    }     
    if(infoElement)
    {   
        infoElement.style.display = "none";
    }
    if(flyOutElement)
    {
        flyOutElement.style.display = "none";
    }      
    if(cellElement)
    {
        cellElement.style.display = "none";
    }     
}

function OpenDetailWindow(popupObj, loadingObj, displayUrl, infoObj, flyOutObj, imgObj, cellObj) {
    
    CloseDetailWindow();
    
    if(infoObj) infoElement = $get(infoObj);
    if(flyOutObj) flyOutElement = $get(flyOutObj);
    if(imgObj) imgElement = $get(imgObj);
    if(cellObj) cellElement = $get(cellObj);
    if(popupObj) popupElement = $get(popupObj);
    
    if(infoElement)
    {
        Cover(imgElement, flyOutElement);
        flyOutElement.style.display = "block";
        var documentWidth = self.innerWidth ? self.innerWidth : document.documentElement.clientWidth;
        if (!documentWidth) {
            documentWidth = document.body.clientWidth;
        }        
        if(documentWidth<flyOutElement.offsetLeft+150+250)
        {
            flyOutElement.style.left = flyOutElement.offsetLeft - 150 + "px";
            flyOutElement.style.top = flyOutElement.offsetTop - 50 + "px";                       
        }
        else
        {
            flyOutElement.style.left = flyOutElement.offsetLeft + 150 + "px";
            flyOutElement.style.top = flyOutElement.offsetTop - 50 + "px";
        }
        flyOutElement.style.width = "250px";
        
        Cover(flyOutElement, infoElement, true);      
        infoElement.style.display = "block";   
        
        Cover(flyOutElement, cellElement, true);      
                 
        cellElement.style.display = "block";     
        cellElement.style.top = flyOutElement.offsetTop + flyOutElement.offsetHeight + "px";    
    }
    MakeWebRequest(popupObj, loadingObj, displayUrl);
}

function hideLoading() {
    var loading = $get('LoadingPanel');
    loading.style.visibility = 'hidden';
}    

function onInputSubmit() {
    var step = document.getElementById("ctl00$step");
    var i = new Number(step.value);
    i = i + 1;
    step.value = i.toString(10);
    i = null;
}

function countryChange(country_id, state_id, default_selection) {
    var ddl_country = $get(country_id);
    var ddl_state = $get(state_id);
    
    if(ddl_country)
    {
        if(ddl_country.selectedIndex>0)
        {
            var selected_country_value = ddl_country.options[ddl_country.selectedIndex].value;

            ddl_state.length = 0;
            if((default_selection) && (default_selection.length>0)) {
                //alert(default_selection);
                stateOption = new Option(default_selection,"");
                ddl_state.options[ddl_state.length] = stateOption;
            }
	        for (i=0;i<_values.length;i++){
		        if (_country_values[i]==selected_country_value) {
		            //alert(selected_country_value);
			        stateOption = new Option(_names[i], _values[i]);
                    ddl_state.options[ddl_state.length] = stateOption;
		        }		
	        }
	    }
	}	 
}

function childrenChange(children_id, children_one_id, children_two_id, children_three_id, children_label_id) {
    var ddl_children = $get(children_id);
    var ddl_children_one = $get(children_one_id);
    var ddl_children_two = $get(children_two_id);
    var ddl_children_three = $get(children_three_id);
    var lbl_children = $get(children_label_id);
    
    if(ddl_children)
    {
        if(ddl_children.selectedIndex>-1)
        {
            var selected_children_value = ddl_children.options[ddl_children.selectedIndex].value;
            
            if(selected_children_value=="1")
            {             
                if(lbl_children)                                 
                    lbl_children.style.display = "inline";
                if(ddl_children_one)               
                    ddl_children_one.style.display = "inline";
                if(ddl_children_two)
                    ddl_children_two.style.display = "none";
                if(ddl_children_three)
                    ddl_children_three.style.display = "none";             
            }
            else if(selected_children_value=="2")
            {
                if(lbl_children)
                    lbl_children.style.display = "inline";
                if(ddl_children_one)
                    ddl_children_one.style.display = "inline";
                if(ddl_children_two)
                    ddl_children_two.style.display = "inline";
                if(ddl_children_three)
                    ddl_children_three.style.display = "none";          
            }
            else if(selected_children_value=="3")
            {
                if(lbl_children)
                    lbl_children.style.display = "inline";
                if(ddl_children_one)
                    ddl_children_one.style.display = "inline";
                if(ddl_children_two)
                    ddl_children_two.style.display = "inline";
                if(ddl_children_three)
                    ddl_children_three.style.display = "inline";
            }
            else
            {
                if(lbl_children)
                    lbl_children.style.display = "none";
                if(ddl_children_one)
                    ddl_children_one.style.display = "none";
                if(ddl_children_two)
                    ddl_children_two.style.display = "none";
                if(ddl_children_three)
                    ddl_children_three.style.display = "none";                                               
            }
	    }
	}	 
}

function ProfilePopulate(traveller_id,
                        ddlTitleEdit_id,
                        txtFirstnameEdit_id,
                        txtMiddlenameEdit_id,
                        txtLastnameEdit_id,
                        ddlAddressTypeEdit_id,
                        txtAddress0Edit_id,
                        txtAddress1Edit_id,
                        txtCityEdit_id,
                        txtPostalnumberEdit_id,
                        txtEmailEdit_id,
                        ddlPhoneTypeEdit_id,
                        txtPhoneEdit_id,
                        txtFaxEdit_id,
                        ddlCountryEdit_id,
                        ddlStateEdit_id) {
    
    var ddl_traveller = $get(traveller_id);
    var ddl_TitleEdit = $get(ddlTitleEdit_id);
    var ddl_AddressTypeEdit = $get(ddlAddressTypeEdit_id);
    var ddl_PhoneTypeEdit = $get(ddlPhoneTypeEdit_id);
    var ddl_CountryEdit = $get(ddlCountryEdit_id);
    var ddl_StateEdit = $get(ddlStateEdit_id);
    var txt_FirstnameEdit = $get(txtFirstnameEdit_id);
    var txt_MiddlenameEdit = $get(txtMiddlenameEdit_id);
    var txt_LastnameEdit = $get(txtLastnameEdit_id);
    var txt_Address0Edit = $get(txtAddress0Edit_id);
    var txt_Address1Edit = $get(txtAddress1Edit_id);
    var txt_CityEdit = $get(txtCityEdit_id);
    var txt_PostalnumberEdit = $get(txtPostalnumberEdit_id);
    var txt_EmailEdit = $get(txtEmailEdit_id);
    var txt_PhoneEdit = $get(txtPhoneEdit_id);
    var txt_FaxEdit = $get(txtFaxEdit_id);
    
    var idx=ddl_traveller.selectedIndex -1;

    var txt_CityEdit = $get(txtCityEdit_id);
           
    var selected_profileid_value = ddl_traveller.options[ddl_traveller.selectedIndex].value;

    txt_FirstnameEdit.value  = _prFirstName[idx];
    txt_MiddlenameEdit.value = _prMiddleName[idx];
    txt_LastnameEdit.value   = _prLastName[idx];
    txt_Address0Edit.value = _prAddressLine1[idx];
    txt_Address1Edit.value = _prAddressLine2[idx];
    
    txt_CityEdit.value = _prCityName[idx];
    txt_PostalnumberEdit.value = _prPostalCode[idx];
    
    txt_EmailEdit.value = _prEmail[idx];
    txt_PhoneEdit.value = _prPhoneNumber[idx];
    txt_FaxEdit.value   = _prFaxNumber[idx];
    
    //titleType
    for (var i = 0; i < ddl_TitleEdit.options.length; i++) {
        var txt = ddl_TitleEdit.options[i].value; //.toUpperCase();
        if (txt == _prTitle[idx]) {
            ddl_TitleEdit.options[i].selected = true;
            ddl_TitleEdit.options[i].focus();
            break;
        }
    }
    //AddressType
    for (var i = 0; i < ddl_AddressTypeEdit.options.length; i++) {
        var txt = ddl_AddressTypeEdit.options[i].value; //.toUpperCase();
        if (txt == _prAddressType[idx]) {
            ddl_AddressTypeEdit.options[i].selected = true;
            ddl_AddressTypeEdit.options[i].focus();
            break;
        }
    }
    //PhoneType
    for (var i = 0; i < ddl_PhoneTypeEdit.options.length; i++) {
        var txt = ddl_PhoneTypeEdit.options[i].value; //.toUpperCase();
        if (txt == _prPhoneType[idx]) {
            ddl_PhoneTypeEdit.options[i].selected = true;
            ddl_PhoneTypeEdit.options[i].focus();
            break;
        }
    }

    //CoutryType
    for (var i = 0; i < ddl_CountryEdit.options.length; i++) {
        var txt = ddl_CountryEdit.options[i].value; //.toUpperCase();
        if (txt == _prCountryCode[idx]) {
            ddl_CountryEdit.options[i].selected = true;
            ddl_CountryEdit.options[i].focus();
            break;
        }
    }
    //stateType
    for (var i = 0; i < ddl_StateEdit.options.length; i++) {
        var txt = ddl_StateEdit.options[i].value; //.toUpperCase();
        if (txt == _prStateProv[idx]) {
            ddl_StateEdit.options[i].selected = true;
            ddl_StateEdit.options[i].focus();
            break;
        }
    }
}
//only for test
function show_props(obj, obj_name) { 
    var result = "" ;
    var ii = 0;
    for (var i in obj) 
        if (obj[i] != null && obj[i] != '')
        {
            if (ii <= 3)
            {
               result += obj_name + "." + i + " = " + obj[i] + "  " ;
               ii += 1;
            }
            else if (ii > 3)
            {
               result += obj_name + "." + i + " = " + obj[i] + "\n" ;
               ii = 0;

            }
        }
    return result; 
} 




function stateChange(state_id) {
    var ddl_state = $get(state_id);
    ddl_state.options[ddl_state.selectedIndex].selected = "selected";
}

function ddlbSelectByValue(id, default_selection) {
    var ddl_ = $get(id);
    
	for (i=0;i<ddl_.length;i++){
		if (ddl_[i].value==default_selection){
            ddl_.selectedIndex = i;
		}		
	}
}
//called from reservationpackageOption behind code 
function ClearTextbox(checkBox) {
    var cb = checkBox.id;
    var txbID = cb.replace('cxb','txb'); //the textbox has same name like checkbox except prefix (cxb/txb)
    var txb = document.getElementById(txbID);
    if(!checkBox.checked)
    {
       txb.value = '';
       txb.disabled = true; 

    }
    else
    {
      txb.disabled = false; 
      txb.focus();
    }
}

//call from imageUpload control to collect those images what the user wants to delete 
function CollectDelImage(checkBox,fileN, hiddenId) {
    var cb = checkBox.id;
    var hiddenF = $get(hiddenId);
    if(checkBox.checked)
    {
       hiddenF.value += fileN + ',';

    }
    else
    {
         if(hiddenF.indexOf(fileN) > -1)
         {
             hiddenF.value = hiddenF.replace(fileN + ',','');          
         }  
    }
}

//called from InfoControl when press the Save change button
function storeAllMyLinkNotice(checkboxID,message)
{
    var cbxChainSelect = document.getElementById(checkboxID);
    if(cbxChainSelect.checked == true)
    {
       return confirm (message);
    }else return true;

}

