// 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 LogoPopup(url) {
	targetURL = url;
	LogoWindow = window.open (targetURL, '', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1', borders=1);
	LogoWindow.focus();		
}

function TermsPopup(query, 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();
	
	if (query) LogWebRequest("ClickPage.ashx"+query+"&target=Terms And Conditions Link");
}

function showBiggerImage(query, 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();
	
	if (query) LogWebRequest("ClickPage.ashx"+query+"&target=Room Image Click");
}

function changePictureSrc(query, TargetImageID, SrcPath) {
    var MainImg=document.getElementById(TargetImageID);
    MainImg.src=SrcPath;
    if (query) LogWebRequest("ClickPage.ashx"+query+"&target=Gallery Image Click");
}
    
///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);    
    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(_44) {
    
    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 {
                if(_44)
                    el.className='CalendarNotAvailable44';
                else
                    el.className='CalendarNotAvailable';
            }
            if (serial==parseInt(selectedArrivalID.value)) {
                if(_44)
                    el.className = 'CalendarSelected44';
                else
                    el.className = 'CalendarSelected';
            } 
            else {
                if(_44)
                {
                    if (el.className!='Calendar_closed44' && serial>=parseInt(selectedArrivalID.value) && serial<=parseInt(selectedDepartureID.value)) {
                        el.className = 'CalendarSelected44';
                    }
                }
                else
                {
                    if (el.className!='Calendar_closed' && serial>=parseInt(selectedArrivalID.value) && serial<=parseInt(selectedDepartureID.value)) {
                        el.className = 'CalendarSelected';
                    }                
                }
            }
        }
    }
}
    
function reloadCalendar(calendar_id, is_postback, _44, _45) {
    if(is_postback)
        isReloaded = 1;
    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);
        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;
                    bStartFound = true;
                }
                if((curDay == parseInt(selectedDepartureID.value)) && 
                   (serial>=parseInt(selectedSerialID.value)) && 
                   (!bEndFound))
                {
                    oEnd = serial;
                    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(_45==true)
                //{
                    if (el.className!='Calendar_closed' && el.className!='CalendarPassedDate' && 
                       (serial>=oStart && serial<=oEnd) && 
                       (oStart<=parseInt(selectedSerialID.value) && parseInt(selectedSerialID.value)<=oEnd)) 
                    {
                        saveItem(serial,el.className);
                        el.className = 'CalendarSelected';
                    }
                //}
            }
        }
    }
}


function __calMOver(start,id,status,_44) {
 
    if (isArrivalSelected()) {
        
        var selectedArrivalID = document.getElementById(tmparid); 
        var selectedDepartureID = document.getElementById(tmpdpid);
                
        __changeSelections(_44);
        
        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(_44)
                    {
                        if (el!=null && el.className!='Calendar_closed44') {
                        // save the status before changing it 
                           
                            saveItem(k,el.className);
                            el.className='CalendarSelected44';
                        }
                    }
                    else
                    {
                        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,_44,_45) { 
    var aDateBoxDay=null;
    var aDateBoxYearMonth=null;
    var dDateBoxDay=null;
    var dDateBoxYearMonth=null;
    if(_45)
    {
        aDateBoxDay=parent.window.$find(parent.window['Arrival_day']);
        aDateBoxYearMonth=parent.window.$find(parent.window['Arrival_yearmonth']);
        dDateBoxDay=parent.window.$find(parent.window['Departure_day']);
        dDateBoxYearMonth=parent.window.$find(parent.window['Departure_yearmonth']);
        aDateBoxDay.set_closeDropDownOnBlur(false);
        aDateBoxYearMonth.set_closeDropDownOnBlur(false);
        dDateBoxDay.set_closeDropDownOnBlur(false);
        dDateBoxYearMonth.set_closeDropDownOnBlur(false);
    }
    else
    {
        aDateBoxDay=parent.window.document.getElementById('Arrival_day');
        aDateBoxYearMonth=parent.window.document.getElementById('Arrival_yearmonth');    
        dDateBoxDay=parent.window.document.getElementById('Departure_day');
        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;
        
        if(_45)
        {
            var item = aDateBoxDay.findItemByValue(sDateDay);
            if(item) {                   
                aDateBoxDay.set_selectedItem(item); 
                aDateBoxDay.set_text(item.get_text());   
                aDateBoxDay.set_value(item.get_value());            
            }      
            var item = aDateBoxYearMonth.findItemByValue(sDateYear+""+sDateMonth);
            if(item) {
                aDateBoxYearMonth.set_selectedItem(item); 
                aDateBoxYearMonth.set_text(item.get_text());   
                aDateBoxYearMonth.set_value(item.get_value());   
            }
        }
        else
        {
            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(_44);           
        
    if (parseInt(selectedDepartureID.value)==0) {
        if(_45)
        {
            var item = dDateBoxDay.findItemByValue(eDateDay);
            if(item) {                   
                dDateBoxDay.set_selectedItem(item); 
                dDateBoxDay.set_text(item.get_text());   
                dDateBoxDay.set_value(item.get_value());            
            }      
            var item = dDateBoxYearMonth.findItemByValue(eDateYear+""+eDateMonth);
            if(item) {
                dDateBoxYearMonth.set_selectedItem(item); 
                dDateBoxYearMonth.set_text(item.get_text());   
                dDateBoxYearMonth.set_value(item.get_value());   
            }
        }
        else        
        {
            dDateBoxDay.value=eDateDay;
            dDateBoxYearMonth.value=eDateYear+""+eDateMonth;
        }
    } 
    else {
        if(_45)
        {
            var item = dDateBoxDay.findItemByValue(sDateDay);
            if(item) {                   
                dDateBoxDay.set_selectedItem(item); 
                dDateBoxDay.set_text(item.get_text());   
                dDateBoxDay.set_value(item.get_value());            
            }      
            var item = dDateBoxYearMonth.findItemByValue(sDateYear+""+sDateMonth);
            if(item) {
                dDateBoxYearMonth.set_selectedItem(item); 
                dDateBoxYearMonth.set_text(item.get_text());   
                dDateBoxYearMonth.set_value(item.get_value());   
            }
        }
        else
        {
            dDateBoxDay.value=sDateDay;
            dDateBoxYearMonth.value=sDateYear+""+sDateMonth;
        }
    }
    
    var DateCell=document.getElementById(selfID);
    saveItem(selfID,DateCell.className);
    if(_44)
        DateCell.className = 'CalendarSelected44';
    else
        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 State is " + buf.length + "bytes");
}

var no_cc_selected = false;

function DoCollapseGuarantees(guaranteeTypeCC, guaranteeTypeEditID, CollapsePanelID, CollapsePPPanelID, guaranteeTypePP, vld1, vld2) {
   var bbb = document.getElementById(guaranteeTypeEditID); //at the modifycancel                                      
   if (bbb) 
   {       
      var cc_selected = false;
      if(guaranteeTypeCC!=null)
      {
          ChangeAll(false, CollapsePanelID);
          
          var ss = guaranteeTypeCC.split("|");
          for (i = 0; i < ss.length; i++)
          {
              if (bbb.options[bbb.selectedIndex].value == ss[i])
              {                  
                  ChangeAll(true, CollapsePanelID);
                  ChangeAll(false, CollapsePPPanelID);

                  cc_selected = true;                                                  
              }
          }  
          if (bbb.options[bbb.selectedIndex].value == "GX" || bbb.options[bbb.selectedIndex].value == "DX")
            cc_selected = true;       
          if(cc_selected)
          {
            var v1 = document.getElementById(vld1);
            if (v1) ValidatorEnable(v1, true);                  
            var v2 = document.getElementById(vld2);
            if (v2) ValidatorEnable(v2, true); 
            no_cc_selected = false;                 
          }              
          else if(!no_cc_selected)
          {
            var v1 = document.getElementById(vld1);
            if (v1) ValidatorEnable(v1, false);                  
            var v2 = document.getElementById(vld2);
            if (v2) ValidatorEnable(v2, false); 
            no_cc_selected = true;                 
          }
      }
      if(guaranteeTypePP!=null)
      {
          ChangeAll(false, CollapsePPPanelID);
          var ss = guaranteeTypePP.split("|");
          for (i = 0; i < ss.length; i++)
          {
              if (bbb.options[bbb.selectedIndex].value == ss[i])
              {              
                  ChangeAll(true, CollapsePPPanelID);
                  ChangeAll(false, CollapsePanelID);                  
              }
          }
      }          
   }   
}

function DoCollapseGuaranteesCB(guaranteeTypeCC, guaranteeTypeEditID, CollapsePanelID, CollapsePPPanelID, guaranteeTypePP, vld1, vld2) {
    var ddl = $find(guaranteeTypeEditID);
    if(!ddl)
    {
        setTimeout("DoCollapseGuaranteesCB('"+guaranteeTypeCC+"', '"+guaranteeTypeEditID+"', '"+CollapsePanelID+"', '"+CollapsePPPanelID+"', '"+guaranteeTypePP+"', '"+vld1+"', '"+vld2+"');",300);
        return;            
    } 
    if (ddl) 
    {       
        var cc_selected = false;     
        if(guaranteeTypeCC!=null)
        {
            ChangeAll(false, CollapsePanelID);
            
            var ss = guaranteeTypeCC.split("|");
            for (i = 0; i < ss.length; i++)
            {
                if (ddl.get_items().getItem(ddl.get_selectedIndex()).get_value() == ss[i])
                {                  
                    ChangeAll(true, CollapsePanelID);
                    ChangeAll(false, CollapsePPPanelID);

                    cc_selected = true;                                                  
                }
            }  
            if (ddl.get_items().getItem(ddl.get_selectedIndex()).get_value() == "GX" || ddl.get_items().getItem(ddl.get_selectedIndex()).get_value() == "DX")
                cc_selected = true;       
            if(cc_selected)
            {
                var v1 = document.getElementById(vld1);
                if (v1) ValidatorEnable(v1, true);                  
                var v2 = document.getElementById(vld2);
                if (v2) ValidatorEnable(v2, true);
                no_cc_selected = false;                 
            }              
            else if(!no_cc_selected)
            {
                var v1 = document.getElementById(vld1);
                if (v1) ValidatorEnable(v1, false);                  
                var v2 = document.getElementById(vld2);
                if (v2) ValidatorEnable(v2, false); 
                no_cc_selected = true;                 
            }
        }
        if(guaranteeTypePP!=null)
        {
            ChangeAll(false, CollapsePPPanelID);
            var ss = guaranteeTypePP.split("|");
            for (i = 0; i < ss.length; i++)
            {
                if (ddl.get_items().getItem(ddl.get_selectedIndex()).get_value() == ss[i])
                {              
                    ChangeAll(true, CollapsePPPanelID);
                    ChangeAll(false, CollapsePanelID);
                }
            }
        }             
    }   
}

var no_dc_selected = false;

function DoCollapseCardTypes(cardTypeCC, cardTypeEditID, CollapsePanelID, vld1) {
   var bbb = document.getElementById(cardTypeEditID); //at the modifycancel                                      
   if (bbb) 
   {       
      if(cardTypeCC!=null)
      {
          ChangeAll(false, CollapsePanelID);
          var dc_selected = false;
          if(no_cc_selected==false)
          {
              var ss = cardTypeCC.split("|");
              for (i = 0; i < ss.length; i++)
              {
                  if (bbb.options[bbb.selectedIndex].value == ss[i])
                  {                  
                      ChangeAll(true, CollapsePanelID);
                      dc_selected = true;                                                  
                  }
              }
              if (bbb.options[bbb.selectedIndex].value == "MS" || bbb.options[bbb.selectedIndex].value == "SO")
                dc_selected = true;   
          }    
          if(dc_selected)
          {
            var vld = document.getElementById(vld1);
            if(vld) ValidatorEnable(vld, true);                  
            no_dc_selected = false;                 
          }              
          else if(!no_dc_selected)
          {
            var vld = document.getElementById(vld1);
            if(vld) ValidatorEnable(vld, false);          
            no_dc_selected = true;                 
          }
      }
   }   
}

function DoCollapseCardTypesCB(cardTypeCC, cardTypeEditID, CollapsePanelID, vld1) {
    var ddl = $find(cardTypeEditID);
    if(!ddl)
    {
        setTimeout("DoCollapseCardTypesCB('"+cardTypeCC+"', '"+cardTypeEditID+"', '"+CollapsePanelID+"', '"+vld1+"');",300);
        return;            
    } 
    if (ddl) 
    {       
        if(cardTypeCC!=null)
        {
            ChangeAll(false, CollapsePanelID);
            var dc_selected = false;
            if(no_cc_selected==false)
            {            
                var ss = cardTypeCC.split("|");
                for (i = 0; i < ss.length; i++)
                {
                    if (ddl.get_items().getItem(ddl.get_selectedIndex()).get_value() == ss[i])
                    {                  
                        ChangeAll(true, CollapsePanelID);
                        dc_selected = true;                                                  
                    }
                }  
                if (ddl.get_items().getItem(ddl.get_selectedIndex()).get_value() == "MS" || ddl.get_items().getItem(ddl.get_selectedIndex()).get_value() == "SO")
                    dc_selected = true;     
            }                      
            if(dc_selected)
            {
                var vld = document.getElementById(vld1);
                if(vld) ValidatorEnable(vld, true);                  
                no_dc_selected = false;                 
            }              
            else if(!no_dc_selected)
            {
                var vld = document.getElementById(vld1);
                if(vld) ValidatorEnable(vld, false);          
                no_dc_selected = true;                 
            }
        }
    }   
}

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 = null;
          
    behavior = $find(CollapsePanelId);
    if(behavior==null) 
    {
        setTimeout("ChangeAll("+open+", '"+CollapsePanelId+"');",500);
        return;
    }        
    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'; 
        }         
            
        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)
    {
        setTimeout("countryChange('"+country_id+"', '"+state_id+"', '"+default_selection+"');",300);
        return;            
    } 
    
    if(ddl_country)
    {
        if(ddl_country.selectedIndex>=0)
        {
            var selected_country_value = ddl_country.options[ddl_country.selectedIndex].value;        
            
            if(!selected_country_value)
            {
                setTimeout("countryChange('"+country_id+"', '"+state_id+"', '"+default_selection+"');",300);
                return;            
            }            
            
            if(ddl_state)
            {
                ddl_state.length = 0;
                if((default_selection) && (default_selection.length>0)) {
                    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) {
			            stateOption = new Option(_names[i], _values[i]);
                        ddl_state.options[ddl_state.length] = stateOption;
		            }		
	            }
	        }	 
	    }
	}	 
}

function countryChangeCB(country_id, state_id, default_selection) {
    var ddl_country = $find(country_id);
    var ddl_state = $find(state_id);
    
    if(!ddl_country)
    {
        setTimeout("countryChangeCB('"+country_id+"', '"+state_id+"', '"+default_selection+"');",300);
        return;            
    } 
    if(ddl_country)
    {
        if(ddl_country.get_selectedIndex()>=0)
        {
            var selected_country_value = ddl_country.get_items().getItem(ddl_country.get_selectedIndex()).get_value();            
            
            if(selected_country_value==null)
            {
                setTimeout("countryChangeCB('"+country_id+"', '"+state_id+"', '"+default_selection+"');",300);
                return;            
            }            
            
            if(ddl_state)
            {
                ddl_state.set_closeDropDownOnBlur(false);
                ddl_state.trackChanges();
                ddl_state.clearItems();
                if((default_selection) && (default_selection.length>0)) {
                    var comboItem = new Telerik.Web.UI.RadComboBoxItem();                    
                    comboItem.set_text(default_selection);
                    comboItem.set_value("");
                    
                    //ddl_state.trackChanges();
                    ddl_state.get_items().add(comboItem);        
                    //ddl_state.commitChanges();    
                }
	            for (i=0;i<_values.length;i++) {
		            if (_country_values[i]==selected_country_value) {			                		                
                        var comboItem = new Telerik.Web.UI.RadComboBoxItem();                        
                        comboItem.set_text(_names[i]);
                        comboItem.set_value(_values[i]);                                                
                        ddl_state.get_items().add(comboItem);                                                     		            		                
		            }		
	            }
	            ddl_state.commitChanges();
	        }	 
	    }
	}	 
}

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 childrenChangeCB(children_id, children_one_id, children_two_id, children_three_id, children_label_id) {        
       
    var ddl_children = $find(children_id);
    if (ddl_children==null)
    {
        setTimeout("childrenChangeCB('"+children_id+"','"+children_one_id+"','"+children_two_id+"','"+children_three_id+"','"+children_label_id+"');",300);
        return;
    }                
    
    var ddl_children_one = $find(children_one_id);
    var ddl_children_two = $find(children_two_id);
    var ddl_children_three = $find(children_three_id);
    var lbl_children = $get(children_label_id);               
        
    if(ddl_children)
    {            
        if(ddl_children.get_selectedIndex()>-1)
        {            
            var selected_children_value = ddl_children.get_items().getItem(ddl_children.get_selectedIndex()).get_value();
            
            if(selected_children_value=="1")
            {             
                if(lbl_children)                                 
                    lbl_children.style.display = "inline";
                if(ddl_children_one)
                {
                    var el_children_one = $get(children_one_id);
                    el_children_one.style.display="inline";                    
                }
                if(ddl_children_two)
                {
                    var el_children_two = $get(children_two_id);
                    el_children_two.style.display="none"; 
                }
                if(ddl_children_three)
                {
                    var el_children_three = $get(children_three_id);
                    el_children_three.style.display="none";                                  
                }            
            }
            else if(selected_children_value=="2")
            {
                if(lbl_children)
                    lbl_children.style.display = "inline";
                if(ddl_children_one)
                {
                    var el_children_one = $get(children_one_id);
                    el_children_one.style.display="inline";                    
                }
                if(ddl_children_two)
                {
                    var el_children_two = $get(children_two_id);
                    el_children_two.style.display="inline"; 
                }
                if(ddl_children_three)
                {
                    var el_children_three = $get(children_three_id);
                    el_children_three.style.display="none";                                  
                }       
            }
            else if(selected_children_value=="3")
            {
                if(lbl_children)
                    lbl_children.style.display = "inline";
                if(ddl_children_one)
                {
                    var el_children_one = $get(children_one_id);
                    el_children_one.style.display="inline";                    
                }
                if(ddl_children_two)
                {
                    var el_children_two = $get(children_two_id);
                    el_children_two.style.display="inline"; 
                }
                if(ddl_children_three)
                {
                    var el_children_three = $get(children_three_id);
                    el_children_three.style.display="inline";                                  
                }
            }
            else
            {
                if(lbl_children)
                    lbl_children.style.display = "none";
                if(ddl_children_one)
                {
                    var el_children_one = $get(children_one_id);
                    el_children_one.style.display="none";                    
                }
                if(ddl_children_two)
                {
                    var el_children_two = $get(children_two_id);
                    el_children_two.style.display="none"; 
                }
                if(ddl_children_three)
                {
                    var el_children_three = $get(children_three_id);
                    el_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];
    if(txt_MiddlenameEdit)
        txt_MiddlenameEdit.value = _prMiddleName[idx];
    txt_LastnameEdit.value   = _prLastName[idx];
    if(txt_Address0Edit)
        txt_Address0Edit.value = _prAddressLine1[idx];
    if(txt_Address1Edit)
        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];
    if(txt_FaxEdit)
        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;
        }
    }
}

function ProfilePopulateCB(ddlTravellerEdit_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 = $find(ddlTravellerEdit_id);
    if (ddl_traveller==null)
    {
        setTimeout("ProfilePopulateCB('"+ddlTravellerEdit_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+"');",300);
        return;
    }         
    var ddl_TitleEdit = $find(ddlTitleEdit_id);
    var ddl_AddressTypeEdit = $find(ddlAddressTypeEdit_id);
    var ddl_PhoneTypeEdit = $find(ddlPhoneTypeEdit_id);
    var ddl_CountryEdit = $find(ddlCountryEdit_id);
    var ddl_StateEdit = $find(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 txt_CityEdit = $get(txtCityEdit_id);
    
    if(ddl_traveller)
    {
        var idx = ddl_traveller.get_selectedIndex() - 1;   
               
        var selected_profileid_value = ddl_traveller.get_items().getItem(ddl_traveller.get_selectedIndex()).get_value();

        txt_FirstnameEdit.value  = _prFirstName[idx];
        if(txt_MiddlenameEdit)
            txt_MiddlenameEdit.value = _prMiddleName[idx];
        txt_LastnameEdit.value = _prLastName[idx];
        if(txt_Address0Edit)
            txt_Address0Edit.value = _prAddressLine1[idx];
        if(txt_Address1Edit)
            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];
        if(txt_FaxEdit)
            txt_FaxEdit.value = _prFaxNumber[idx];
        
        //titleType
        var items = ddl_TitleEdit.get_items();
        ddl_TitleEdit.set_closeDropDownOnBlur(false);
        for (var i = 0; i < items.get_count(); i++) {
            var item = items.getItem(i);
            var txt = item.get_value();
            if (txt == _prTitle[idx]) {
                ddl_TitleEdit.trackChanges();
                ddl_TitleEdit.set_selectedItem(item); 
                ddl_TitleEdit.set_text(item.get_text());   
                ddl_TitleEdit.set_value(item.get_value());                 
                ddl_TitleEdit.commitChanges();
                break;
            }
        }
        //AddressType
        var items = ddl_AddressTypeEdit.get_items();
        ddl_AddressTypeEdit.set_closeDropDownOnBlur(false);        
        for (var i = 0; i < items.get_count(); i++) {
            var item = items.getItem(i);
            var txt = item.get_value(); 
            if (txt == _prAddressType[idx]) {
                ddl_AddressTypeEdit.trackChanges();
                ddl_AddressTypeEdit.set_selectedItem(item); 
                ddl_AddressTypeEdit.set_text(item.get_text());   
                ddl_AddressTypeEdit.set_value(item.get_value());
                ddl_AddressTypeEdit.commitChanges();                
                break;
            }
        }
        //PhoneType
        var items = ddl_PhoneTypeEdit.get_items();
        ddl_PhoneTypeEdit.set_closeDropDownOnBlur(false);           
        for (var i = 0; i < items.get_count(); i++) {
            var item = items.getItem(i);
            var txt = item.get_value(); 
            if (txt == _prPhoneType[idx]) {
                ddl_PhoneTypeEdit.trackChanges();
                ddl_PhoneTypeEdit.set_selectedItem(item); 
                ddl_PhoneTypeEdit.set_text(item.get_text());   
                ddl_PhoneTypeEdit.set_value(item.get_value());
                ddl_PhoneTypeEdit.commitChanges();                
                break;
            }
        }
        //CoutryType
        var items = ddl_CountryEdit.get_items();
        ddl_CountryEdit.set_closeDropDownOnBlur(false);         
        for (var i = 0; i < items.get_count(); i++) {
            var item = items.getItem(i);
            var txt = item.get_value(); 
            if (txt == _prCountryCode[idx]) {
                ddl_CountryEdit.trackChanges();
                ddl_CountryEdit.set_selectedItem(item); 
                ddl_CountryEdit.set_text(item.get_text());   
                ddl_CountryEdit.set_value(item.get_value());
                ddl_CountryEdit.commitChanges();  
                break;
            }
        }
        //stateType
        var items = ddl_StateEdit.get_items();
        ddl_StateEdit.set_closeDropDownOnBlur(false);              
        for (var i = 0; i < items.get_count(); i++) {
            var item = items.getItem(i);
            var txt = item.get_value(); 
            if (txt == _prStateProv[idx]) {  
                ddl_StateEdit.trackChanges();
                ddl_StateEdit.set_selectedItem(item); 
                ddl_StateEdit.set_text(item.get_text());   
                ddl_StateEdit.set_value(item.get_value());
                ddl_StateEdit.commitChanges();                              
                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);

    if (!ddl_state) {
        setTimeout("stateChange('"+state_id+"');",300);
        return;
    }    
    if(ddl_state)
    {
        ddl_state.options[ddl_state.selectedIndex].selected = true;
    }
}

function stateChangeCB(state_id) {
    var ddl_state = $find(state_id);
    if (ddl_state==null) {
        setTimeout("stateChangeCB('"+state_id+"');",300);
        return;
    }
    if (ddl_state) {
        ddl_state.set_closeDropDownOnBlur(false);
        ddl_state.trackChanges();
        var item = ddl_state.get_items().getItem(ddl_state.get_selectedIndex());        
        ddl_state.set_selectedItem(item); 
        //ddl_state.set_text(item.get_text());   
        //ddl_state.set_value(item.get_value());
        //alert(item.get_value());
        ddl_state.commitChanges();
    }
}

function ddlbSelectByValue(id, default_selection) {
    var ddl_ = $get(id);
    if(ddl_)
    {    
	    for (i=0;i<ddl_.length;i++){
		    if (ddl_.options[i].value==default_selection){
                ddl_.selectedIndex = i;
		    }		
	    }
	}
}

function ddlbSelectByValueCB(id, default_selection) {
    var ddl_ = $find(id);
    if (ddl_==null)
    {
        setTimeout("ddlbSelectByValueCB('"+id+"','"+default_selection+"');",100);
        return;
    }     
    if(ddl_)
    {    
        ddl_.set_closeDropDownOnBlur(false);
        ddl_.trackChanges();
        var items = ddl_.get_items();
	    for (i=0;i<items.get_count();i++){
	        var item = items.getItem(i);
		    if (item.get_value()==default_selection){                                        
                ddl_.set_selectedItem(item); 
                //ddl_.set_text(item.get_text());   
                //ddl_.set_value(item.get_value());                
		    }		
	    }
	    ddl_.commitChanges();                
	}
}

//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(txb)
    {
        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;

}

function IsDoubleCompare(textID1, textID2)
{        
    var textArea2 = $get(textID2);
    var id = textID1.id;
    var textArea1 = $get(id.replace("Button1","TextBox11"));
    
    if(textArea1)         
    {    
        if(textArea2)
        {
            if(textArea1.value!=textArea2.value)
            {
                alert("Please type the same email address in both fields!");
                return false;
            }
        }
    }
    return true;
}

function mailit(obj, m, address)
{
    var s = m + address;
    obj.href = s;
    s = s.replace("mailto:","");      
    return s;  
}
