// Ultimate client-side JavaScript client sniff. Version 3.03
// (C) Netscape Communications 1999.  Permission granted to reuse and distribute.
// Revised 17 May 99 to add is.nav5up and is.ie5up (see below).
// Revised 21 Nov 00 to add is.gecko and is.ie5_5 Also Changed is.nav5 and is.nav5up to is.nav6 and is.nav6up
// Revised 22 Feb 01 to correct Javascript Detection for IE 5.x, Opera 4, 
//                      correct Opera 5 detection
//                      add support for winME and win2k
//                      synch with browser-type-oo.js
// Revised 26 Mar 01 to correct Opera detection
// Revised 02 Oct 01 to add IE6 detection

// Everything you always wanted to know about your JavaScript client
// but were afraid to ask ... "Is" is the constructor function for "is" object,
// which has properties indicating:
// (1) browser vendor:
//     is.nav, is.ie, is.opera, is.hotjava, is.webtv, is.TVNavigator, is.AOLTV
// (2) browser version number:
//     is.major (integer indicating major version number: 2, 3, 4 ...)
//     is.minor (float   indicating full  version number: 2.02, 3.01, 4.04 ...)
// (3) browser vendor AND major version number
//     is.nav2, is.nav3, is.nav4, is.nav4up, is.nav6, is.nav6up, is.gecko, is.ie3, 
//     is.ie4, is.ie4up, is.ie5, is.ie5up, is.ie5_5, is.ie5_5up, is.ie6, is.ie6up, is.hotjava3, is.hotjava3up
// (4) JavaScript version number:
//     is.js (float indicating full JavaScript version number: 1, 1.1, 1.2 ...)
// (5) OS platform and version:
//     is.win, is.win16, is.win32, is.win31, is.win95, is.winnt, is.win98, is.winme, is.win2k
//     is.os2
//     is.mac, is.mac68k, is.macppc
//     is.unix
//     is.sun, is.sun4, is.sun5, is.suni86
//     is.irix, is.irix5, is.irix6
//     is.hpux, is.hpux9, is.hpux10
//     is.aix, is.aix1, is.aix2, is.aix3, is.aix4
//     is.linux, is.sco, is.unixware, is.mpras, is.reliant
//     is.dec, is.sinix, is.freebsd, is.bsd
//     is.vms
//
// See http://www.it97.de/JavaScript/JS_tutorial/bstat/navobj.html and
// http://www.it97.de/JavaScript/JS_tutorial/bstat/Browseraol.html
// for detailed lists of userAgent strings.
//
// Note: you don't want your Nav4 or IE4 code to "turn off" or
// stop working when Nav5 and IE5 (or later) are released, so
// in conditional code forks, use is.nav4up ("Nav4 or greater")
// and is.ie4up ("IE4 or greater") instead of is.nav4 or is.ie4
// to check version in code which you want to work on future
// versions.


function Is ()
{   // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is.ie5up to detect IE5.

    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);

    // Note: Opera and WebTV spoof Navigator.  We do strict client detection.
    // If you want to allow spoofing, take out the tests for opera and webtv.
    this.nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
		 && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
		 && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    this.nav2 = (this.nav && (this.major == 2));
    this.nav3 = (this.nav && (this.major == 3));
    this.nav4 = (this.nav && (this.major == 4));
    this.nav4up = (this.nav && (this.major >= 4));
    this.navonly      = (this.nav && ((agt.indexOf(";nav") != -1) ||
				      (agt.indexOf("; nav") != -1)) );
    this.nav6 = (this.nav && (this.major == 5));
    this.nav6up = (this.nav && (this.major >= 5));
    this.gecko = (agt.indexOf('gecko') != -1);


    this.ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    this.ie3    = (this.ie && (this.major < 4));
    this.ie4    = (this.ie && (this.major == 4) && (agt.indexOf("msie 4")!=-1) );
    this.ie4up  = (this.ie  && (this.major >= 4));
    this.ie5    = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    this.ie5_5  = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.5") !=-1));
    this.ie5up  = (this.ie  && !this.ie3 && !this.ie4);
    this.ie5_5up =(this.ie && !this.ie3 && !this.ie4 && !this.ie5);
    this.ie6    = (this.ie && (this.major == 4) && (agt.indexOf("msie 6.")!=-1) );
    this.ie6up  = (this.ie  && !this.ie3 && !this.ie4 && !this.ie5 && !this.ie5_5);

    // KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
    // or if this is the first browser window opened.  Thus the
    // variables is.aol, is.aol3, and is.aol4 aren't 100% reliable.
    this.aol   = (agt.indexOf("aol") != -1);
    this.aol3  = (this.aol && this.ie3);
    this.aol4  = (this.aol && this.ie4);
    this.aol5  = (agt.indexOf("aol 5") != -1);
    this.aol6  = (agt.indexOf("aol 6") != -1);

    this.opera = (agt.indexOf("opera") != -1);
    this.opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
    this.opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
    this.opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
    this.opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
    this.opera5up = (this.opera && !this.opera2 && !this.opera3 && !this.opera4);

    this.webtv = (agt.indexOf("webtv") != -1); 

    this.TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1)); 
    this.AOLTV = this.TVNavigator;

    this.hotjava = (agt.indexOf("hotjava") != -1);
    this.hotjava3 = (this.hotjava && (this.major == 3));
    this.hotjava3up = (this.hotjava && (this.major >= 3));

    // *** JAVASCRIPT VERSION CHECK ***
    if (this.nav2 || this.ie3) this.js = 1.0;
    else if (this.nav3) this.js = 1.1;
    else if (this.opera5up) this.js = 1.3;
    else if (this.opera) this.js = 1.1;
    else if ((this.nav4 && (this.minor <= 4.05)) || this.ie4) this.js = 1.2;
    else if ((this.nav4 && (this.minor > 4.05)) || this.ie5) this.js = 1.3;
    else if (this.hotjava3up) this.js = 1.4;
    else if (this.nav6 || this.gecko) this.js = 1.5;
    // NOTE: In the future, update this code when newer versions of JS
    // are released. For now, we try to provide some upward compatibility
    // so that future versions of Nav and IE will show they are at
    // *least* JS 1.x capable. Always check for JS version compatibility
    // with > or >=.
    else if (this.nav6up) this.js = 1.5;
    // note ie5up on mac is 1.4
    else if (this.ie5up) this.js = 1.3

			     // HACK: no idea for other browsers; always check for JS version with > or >=
			     else this.js = 0.0;

    // *** PLATFORM ***
    this.win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
    // NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all
    //        Win32, so you can't distinguish between Win95 and WinNT.
    this.win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));

    // is this a 16 bit compiled version?
    this.win16 = ((agt.indexOf("win16")!=-1) || 
		  (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) || 
		  (agt.indexOf("windows 16-bit")!=-1) );  

    this.win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
		  (agt.indexOf("windows 16-bit")!=-1));

    // NOTE: Reliable detection of Win98 may not be possible. It appears that:
    //       - On Nav 4.x and before you'll get plain "Windows" in userAgent.
    //       - On Mercury client, the 32-bit version will return "Win98", but
    //         the 16-bit version running on Win98 will still return "Win95".
    this.win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
    this.winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
    this.win32 = (this.win95 || this.winnt || this.win98 || 
		  ((this.major >= 4) && (navigator.platform == "Win32")) ||
		  (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));

    this.winme = ((agt.indexOf("win 9x 4.90")!=-1));
    this.win2k = ((agt.indexOf("windows nt 5.0")!=-1));

    this.os2   = ((agt.indexOf("os/2")!=-1) || 
		  (navigator.appVersion.indexOf("OS/2")!=-1) ||   
		  (agt.indexOf("ibm-webexplorer")!=-1));

    this.mac    = (agt.indexOf("mac")!=-1);
    // hack ie5 js version for mac
    if (this.mac && this.ie5up) this.js = 1.4;
    this.mac68k = (this.mac && ((agt.indexOf("68k")!=-1) || 
				(agt.indexOf("68000")!=-1)));
    this.macppc = (this.mac && ((agt.indexOf("ppc")!=-1) || 
                                (agt.indexOf("powerpc")!=-1)));

    this.sun   = (agt.indexOf("sunos")!=-1);
    this.sun4  = (agt.indexOf("sunos 4")!=-1);
    this.sun5  = (agt.indexOf("sunos 5")!=-1);
    this.suni86= (this.sun && (agt.indexOf("i86")!=-1));
    this.irix  = (agt.indexOf("irix") !=-1);    // SGI
    this.irix5 = (agt.indexOf("irix 5") !=-1);
    this.irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1));
    this.hpux  = (agt.indexOf("hp-ux")!=-1);
    this.hpux9 = (this.hpux && (agt.indexOf("09.")!=-1));
    this.hpux10= (this.hpux && (agt.indexOf("10.")!=-1));
    this.aix   = (agt.indexOf("aix") !=-1);      // IBM
    this.aix1  = (agt.indexOf("aix 1") !=-1);    
    this.aix2  = (agt.indexOf("aix 2") !=-1);    
    this.aix3  = (agt.indexOf("aix 3") !=-1);    
    this.aix4  = (agt.indexOf("aix 4") !=-1);    
    this.linux = (agt.indexOf("inux")!=-1);
    this.sco   = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
    this.unixware = (agt.indexOf("unix_system_v")!=-1); 
    this.mpras    = (agt.indexOf("ncr")!=-1); 
    this.reliant  = (agt.indexOf("reliantunix")!=-1);
    this.dec   = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) || 
                  (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) || 
                  (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1)); 
    this.sinix = (agt.indexOf("sinix")!=-1);
    this.freebsd = (agt.indexOf("freebsd")!=-1);
    this.bsd = (agt.indexOf("bsd")!=-1);
    this.unix  = ((agt.indexOf("x11")!=-1) || this.sun || this.irix || this.hpux || 
                 this.sco ||this.unixware || this.mpras || this.reliant || 
		  this.dec || this.sinix || this.aix || this.linux || this.bsd || this.freebsd);

    this.vms   = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1));
}




var req;
var order_send_p = false;
// Get an XMLHttpRequest object in a portable way.
function newRequest() {
    
    req = false;
    // For Safari, Firefox, and other non-MS browsers
    if (window.XMLHttpRequest) {
	try {
	    req = new XMLHttpRequest();
	} catch (e) {
	    req = false;
	}
    } else if (window.ActiveXObject) {
	// For Internet Explorer on Windows
	try {
	    req = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	    try {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch (e) {
		req = false;
	    }
	}
    }
}












function ac_enlarge_select(select_id) {
    
    if (is.ie) {
	//document.getElementById(select_id).style.width = '200px';
	//window.setTimeout("ac_shrinc_select(\'" + select_id + "\')" , 12000);
    }
}

function ac_shrinc_select(select_id) {

    document.getElementById(select_id).style.width = ac_rooms_style_width + 'px';
}

var req = false;


function ac_sendFeedBack(txtId, locale){

    var message = document.getElementById(txtId).value;

    req = false;
    // For Safari, Firefox, and other non-MS browsers
    if (window.XMLHttpRequest) {
	try {
	    req = new XMLHttpRequest();
	} catch (e) {
	    req = false;
	}
    } else if (window.ActiveXObject) {
	// For Internet Explorer on Windows
	try {
	    req = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	    try {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch (e) {
		req = false;
	    }
	}
    }
    
    

    req.open("POST", "/hotel/feed-back.tcl", false);
    req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
 

  var encoded = "";
  encoded = "message=" + escape(message) +  "&locale=" + escape(locale) + "&url=" + escape(window.location.href); 
  req.send(encoded);


  if (req.status != 200) {

      document.getElementById(txtId).value = "There was a communications error: " +  req.responseText;

  } else {

      document.getElementById(txtId).value = req.responseText;
     
  }
  
  return false;
}




function ac_getStates(country_id,locale,returnAs){


    req = false;
    // For Safari, Firefox, and other non-MS browsers
    if (window.XMLHttpRequest) {
	try {
	    req = new XMLHttpRequest();
	} catch (e) {
	    req = false;
	}
    } else if (window.ActiveXObject) {
	// For Internet Explorer on Windows
	try {
	    req = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	    try {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch (e) {
		req = false;
	    }
	}
    }
    
    

    req.open("POST", "/hotel/get-states.tcl", false);
    req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
 

  var encoded = "";
  encoded = "country_id=" + escape(country_id) + "&locale=" + escape(locale); 
  req.send(encoded);


  if (req.status != 200) {
    alert("There was a communications error:  " +  req.responseText);
    return;
  } else {
      
      
      if (returnAs == "xml") {
	  
	  return xml = req.responseXML;

      } else {

	  return req.responseText;
      }

      if (xml) {

	  // updating the states select widget
	  var newStates = new Array();

	  var options  = xml.getElementsByTagName("option");



	  if (options.length) {

	      for (i=0;i < options.length;i++) {
		  

		  newStates[(i + 1)] = new Option(options[i].firstChild.data, options[i].attributes.getNamedItem("value").value);
	      }
             
              return newStates;
	  }
      } else {
	alert(req.responseText);
      }

  }

}




function ac_getRegionGroups(state_id,locale){


    var req = false;
    // For Safari, Firefox, and other non-MS browsers
    if (window.XMLHttpRequest) {
	try {
	    req = new XMLHttpRequest();
	} catch (e) {
	    req = false;
	}
    } else if (window.ActiveXObject) {
	// For Internet Explorer on Windows
	try {
	    req = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	    try {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch (e) {
		req = false;
	    }
	}
    }


  req.open("POST", "/hotel/get-regions.tcl", false);
  req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
 

  var encoded = "";
  encoded = "state_id=" + escape(state_id) + "&locale=" + escape(locale); 
  req.send(encoded);


  if (req.status != 200) {
    alert("There was a communications error: " +  req.responseText);
    return;
  } else {
 
      var xml = req.responseXML;
      return  req.responseText;

      if (xml) {

	  // updating the states select widget
	  var newGroups = new Array();
	  var newGroupNames = new Array();

          var groups = xml.getElementsByTagName("optiongroup");

	  var options  = xml.getElementsByTagName("option");



	  if (groups.length) {

	      for (i=0;i < groups.length;i++) {
		  
                  newGroupNames[(i + 1)] = groups.attributes.getNamedItem("label").value;
		  var options  = groups.getElementsByTagName("option");
		  var curOptions = new Array();

                  for (j=0;j< options.length;j++) {
		      
		      curOptions[(j + 1)] = new Option(options[j].firstChild.data, options[j].attributes.getNamedItem("value").value);

		  }

		  
		  newGroups[(i + 1)] = curOptions;
	      }
             
	      var retVal = new Array();
	      retVal[1] = newGroupNames;
	      retVal[2] = newGroups;

              return retVal;
	  }

      } else {

      }

  }

}



function ac_getDays(month_year,returnAs){


    req = false;
    // For Safari, Firefox, and other non-MS browsers
    if (window.XMLHttpRequest) {
	try {
	    req = new XMLHttpRequest();
	} catch (e) {
	    req = false;
	}
    } else if (window.ActiveXObject) {
	// For Internet Explorer on Windows
	try {
	    req = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	    try {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch (e) {
		req = false;
	    }
	}
    }
    
    

    req.open("POST", "/hotel/get-days.tcl", false);
    req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
 

  var encoded = "";
  encoded = "month_year=" + escape(month_year); 
  req.send(encoded);


  if (req.status != 200) {
    alert("There was a communications error: " +  req.responseText);
    return;
  } else {
      
      
      if (returnAs == "xml") {
	  
	  return xml = req.responseXML;

      } else {

	  return req.responseText;
      }
      
  }

}





// helper functions


function ac_remove_options (curSelectID) {


    var curSelect = document.getElementById(curSelectID);
    var curOptions = curSelect.options;

    for (var i=0;i<curOptions.length;i++) {

	curOptions[i] = null;

    }
    
    
}


var globxml = null;

function ac_add_options (curSelectID,xml) {



    // updating the states select widget


    var curSelect = document.getElementById(curSelectID);

    var curOptions = curSelect.options;
    globxml = xml;
    var xmloptions  = xml.getElementsByTagName("option");



    if (xmloptions.length) {

	for (i=0;i < xmloptions.length;i++) {


	    curOptions[i] = new Option(options[i].firstChild.data, options[i].attributes.getNamedItem("value").value);
	}
             
             
    }
       
}



function disable_form (curForm) {

    for(i=1;i<curForm.elements.length;i++) {


      if(curForm.elements[i].disabled !== undefined) {

       curForm.elements[i].disabled = true;

      }

    }

}

function enable_form (curForm) {

    for(i=1;i<curForm.elements.length;i++) {

      if(curForm.elements[i].disabled !== undefined) {

       curForm.elements[i].disabled = false;

      }

    }

}

 
function ac_update_select (origOptions, newOptions) {


  
   for(i=1;i<=origOptions.length;i++) {

     origOptions[i] = null; 

   }

   for(i=1;i<=newOptions.length;i++) {

     origOptions[i] = newOptions[i]; 

   }



}


var payment_directdebit_textfields_html = ' \
              <table border="0"> \
               <tr> \
                <td> \
                  Account Holder        \
                </td> \
                <td> \
                  <input type="text" name="ac_payment_bank_account_holder" id="ac_payment_bank_account_holder_id"> \
                </td> \
               </tr> \
               <tr> \
                <td> \
                  Bank Name        \
                </td> \
                <td> \
                  <input type="text" name="ac_payment_bank_name" id="ac_payment_bank_name_id"> \
                </td> \
               </tr> \
               <tr> \
                <td> \
                  Bank Code        \
                </td> \
                <td> \
                  <input type="text" name="ac_payment_bank_number" id="ac_payment_bank_number_id"> \
                </td> \
               </tr> \
               <tr> \
                <td> \
                  Account        \
                </td> \
                <td> \
                  <input type="text" name="ac_payment_bank_account" id="ac_payment_bank_account_id"> \
                </td> \
               </tr> \
              </table>';

var payment_directdebit_widget_html = '<input class="directdebit" type="radio" name="ac_payment_method" value="directdebit" id="order_form:elements:ac_payment_method:directdebit">';
var payment_directdebit_method_html = 'Direct Debit';

var payment_directdebit_info_html = 'You can enter your account information below which will be transferred over a secure conection (SSL) to our office. After successfull debit you recive a Voucher. (Note: German Bank Accounts only) ';

var payment_directdebit_shown_p = false;


function payment_directdebit_show() {

    // first check if directdebit can be shown

    if (ac_show_payment_directdebit_p) {

	// directdebit can be shown now check if it's on display and has to be removed
	// or if it's not on display and has to be added
	
	if (payment_directdebit_shown_p && document.getElementById("ac_country").value != 'DE') {

	    // direct debit is on display and the country is not Germany, probably called by the onChange event of the country select 
	    // remove directdebit from display

	    document.getElementById("payment_directdebit_widget").innerHTML = '';
	    document.getElementById("payment_directdebit_method").innerHTML = '';	    
	    document.getElementById("payment_directdebit_info").innerHTML = '';	    
	    document.getElementById("payment_directdebit_textfields").innerHTML = '';
	    
	    payment_directdebit_shown_p = false;
	    
	}


	if (!payment_directdebit_shown_p && document.getElementById("ac_country").value == 'DE') {

	    // direct debit is not on display and the country is  Germany, probably called by the onChange event of the country select or on init 
	    // add directdebit to display

	    document.getElementById("payment_directdebit_widget").innerHTML = payment_directdebit_widget_html;
	    document.getElementById("payment_directdebit_method").innerHTML = payment_directdebit_method_html;	    
	    document.getElementById("payment_directdebit_info").innerHTML = payment_directdebit_info_html;	    
	    document.getElementById("payment_directdebit_textfields").innerHTML = payment_directdebit_textfields_html;

	    payment_directdebit_shown_p = true;

	}


    }


}




var pax_options_html =  "<option value=\"-1\" label=\"please select\">please select</option> \
                     <optgroup label=\"Travellers WITHOUT Children \"> \
                     <option value=\"1_0\"  label=\"Room for 1 Adult\">Room for 1 Adult</option> \
                     <option value=\"2_0\" label=\"Room for 2 Adults\">Room for 2 Adults</option> \
                     <option value=\"3_0\" label=\"Room for 3 Adults\">Room for 3 Adults</option> \
                     <option value=\"4_0\" label=\"Room for 4 Adults\">Room for 4 Adults</option> \
                     <option value=\"5_0\" label=\"Room for 5 Adults\">Room for 5 Adults</option> \
                     <option value=\"6_0\" label=\"Room for 6 Adults\">Room for 6 Adults</option> \
                    </optgroup> \
                    <optgroup label=\"Travellers WITH Children\"> \
                     <option value=\"1_1\" label=\"Room for 1 Adult + 1 Child\">Room for 1 Adult + 1 Child</option> \
                     <option value=\"2_1\" label=\"Room for 2 Adults + 1 Child\">Room for 2 Adults + 1 Child</option> \
                     <option value=\"2_2\" label=\"Room for 2 Adults + 2 Children\">Room for 2 Adults + 2 Children</option> \
                     <option value=\"2_3\" label=\"Room for 2 Adults + 3 Children\">Room for 2 Adults + 3 Children</option> \
                     <option value=\"2_4\" label=\"Room for 2 Adults + 4 Children\">Room for 2 Adults + 4 Children</option> \
                     <option value=\"3_1\" label=\"Room for 3 Adults + 1 Child\">Room for 3 Adults + 1 Child</option> \
                     <option value=\"3_2\" label=\"Room for 3 Adults + 2 Children\">Room for 3 Adults + 2 Children</option> \
                     <option value=\"3_3\" label=\"Room for 3 Adults + 3 Children\">Room for 3 Adults + 3 Children</option> \
                     <option value=\"4_1\" label=\"Room for 4 Adults + 1 Child\">Room for 4 Adults + 1 Child</option> \
                     <option value=\"4_2\" label=\"Room for 4 Adults + 2 Children\">Room for 4 Adults + 2 Children</option> \
                     <option value=\"5_1\" label=\"Room for 5 Adults + 1 Child\">Room for 5 Adults + 1 Child</option> \
                    </optgroup> \
                   ";


var pax_slim_options_html =  "<option value=\"-1\" label=\"please select\">please select</option> \
                     <optgroup label=\"WITHOUT Children\"> \
                     <option value=\"1_0\"  label=\"1 Adult\">1 Adult</option> \
                     <option value=\"2_0\" label=\"2 Adults\">2 Adults</option> \
                     <option value=\"3_0\" label=\"3 Adults\">3 Adults</option> \
                     <option value=\"4_0\" label=\"4 Adults\">4 Adults</option> \
                     <option value=\"5_0\" label=\"5 Adults\">5 Adults</option> \
                     <option value=\"6_0\" label=\"6 Adults\">6 Adults</option> \
                    </optgroup> \
                    <optgroup label=\"WITH Children\"> \
                     <option value=\"1_1\" label=\"1 Ad. + 1 Child\">1 Ad. + 1 Child</option> \
                     <option value=\"2_1\" label=\"2 Ad. + 1 Child\">2 Ad. + 1 Child</option> \
                     <option value=\"2_2\" label=\"2 Ad. + 2 Children\">2 Ad. + 2 Children</option> \
                     <option value=\"2_3\" label=\"2 Ad. + 3 Children\">2 Ad. + 3 Children</option> \
                     <option value=\"2_4\" label=\"2 Ad. + 4 Children\">2 Ad. + 4 Children</option> \
                     <option value=\"3_1\" label=\"3 Ad. + 1 Child\">3 Ad. + 1 Child</option> \
                     <option value=\"3_2\" label=\"3 Ad. + 2 Children\">3 Ad. + 2 Children</option> \
                     <option value=\"3_3\" label=\"3 Ad. + 3 Children\">3 Ad. + 3 Children</option> \
                     <option value=\"4_1\" label=\"4 Ad. + 1 Child\">4 Ad. + 1 Child</option> \
                     <option value=\"4_2\" label=\"4 Ad. + 2 Children\">4 Ad. + 2 Children</option> \
                     <option value=\"5_1\" label=\"5 Ad. + 1 Child\">5 Ad. + 1 Child</option> \
                    </optgroup> \
                   ";




var ac_room_type_indexes = {"-1": 0, "a1_c0": 1, "a2_c0": 2, "a3_c0": 3, "a4_c0": 4, "a5_c0": 5, "a6_c0": 6, "a1_c1": 7, "a2_c1": 8, "a2_c2": 9, "a2_c3": 10, "a2_c4": 11, "a3_c1": 12, "a3_c2": 13, "a3_c3": 14, "a4_c1": 15, "a4_c2": 16, "a5_c1": 17};

var child_age_options_html = '<option value="-1" >please select</option><option value="0" >0 Years</option><option value="1" >1 Years</option><option value="2" >2 Years</option><option value="3" >3 Years</option><option value="4" name="4 Years">4 Years</option><option value="5" name="5 Years">5 Years</option><option value="6" name="6 Years">6 Years</option><option value="7" name="7 Years">7 Years</option><option value="8" name="8 Years">8 Years</option><option value="9" name="9 Years">9 Years</option><option value="10" name="10 Years">10 Years</option><option value="11" name="11 Years">11 Years</option><option value="12" name="12 Years">12 Years</option><option value="13" name="13 Years">13 Years</option><option value="14" name="14 Years">14 Years</option><option value="15" name="15 Years">15 Years</option><option value="16" name="16 Years">16 Years</option>';



function ac_flush_pax(postfix) {

document.getElementById("ac_a1_c0" + postfix).value = 0;
document.getElementById("ac_a1_c1" + postfix).value = 0;

document.getElementById("ac_a2_c0" + postfix).value = 0;
document.getElementById("ac_a2_c1" + postfix).value = 0;
document.getElementById("ac_a2_c2" + postfix).value = 0;
document.getElementById("ac_a2_c3" + postfix).value = 0;
document.getElementById("ac_a2_c4" + postfix).value = 0;


document.getElementById("ac_a3_c0" + postfix).value = 0;
document.getElementById("ac_a3_c1" + postfix).value = 0;
document.getElementById("ac_a3_c2" + postfix).value = 0;
document.getElementById("ac_a3_c3" + postfix).value = 0;

document.getElementById("ac_a4_c0" + postfix).value = 0;
document.getElementById("ac_a4_c1" + postfix).value = 0;
document.getElementById("ac_a4_c2" + postfix).value = 0;

document.getElementById("ac_a5_c0" + postfix).value = 0;
document.getElementById("ac_a5_c1" + postfix).value = 0;

document.getElementById("ac_a6_c0" + postfix).value = 0;



}

//var ac_room_type[_oa] = new Array(0,0,0,0);
var ac_room_type = new Object;
ac_room_type["_oa"] = new Array(new Array(0,0,0,0));
ac_room_type[""] = new Array(new Array(0,0,0,0));

function ac_room_type_init(postfix) {

    ac_room_type[postfix][0] = 0;
    ac_room_type[postfix][1] = 0;
    ac_room_type[postfix][2] = 0;
    ac_room_type[postfix][3] = 0;
}



function ac_remove_child_ages() {

    // check if the form has child nodes with id vals like ac_child_age. 
    // if exist remove this nodes
    var cur_form = document.getElementById(ac_form_id);
    
    var reg = new RegExp("ac_child_age");

    for (var i=0;i<cur_form.childNodes.length;i++) {

	if ( cur_form.childNodes[i].id != null && cur_form.childNodes[i].id.match(reg) != null) {

	    cur_form.removeChild(cur_form.childNodes[i]);
	}
    
    }
    
}




function ac_check_child_ages(postfix) {



    for (var i=0;i<4;i++) {
	    
	var room_type = ac_room_type[postfix][i];

	if (room_type != 0) {

	    var child_count = room_type.split("_");

	    if (child_count[1] > 0) {

		for(var j=1;j<=child_count[1];j++) {

		    var cur_child_age_id = "room_" + (i + 1) +  postfix + "_" + j;
		

		    if (document.getElementById(cur_child_age_id).value == "-1") {

			return false;

		    } 

		}

	    }

	}

    }


    return true;    
    
}
function ac_insert_child_ages(postfix) {

    //ac_remove_child_ages();

    // Check type of input field room_count
    // if its hidden no room type selects are available 
    // so drag the information, to be inserted into  the hidden fields 
    // for ac_child_ages and ac_js_room_types, from ac_rooms 


    if (document.getElementById("room_count" + postfix).type == "hidden") {

	var cur_room_count = document.getElementById("room_count" + postfix).value;


	for (var i=0;i<cur_room_count;i++) {
	    
	    var room_key = "room_" + (i + 1) + postfix;
	    var this_type = ac_rooms[room_key].type;
	    
	    var cur_field_id = 'ac_js_room_types.' + (i + 1) + postfix;

	    var cur_hidden_field = document.createElement("input");
	    cur_hidden_field.type = 'hidden';
	    cur_hidden_field.name = 'ac_js_room_types.' + (i + 1);
	    cur_hidden_field.id = 'ac_js_room_types.' + (i + 1) + postfix;
	    cur_hidden_field.value = this_type;

	    document.getElementById(ac_form_id + postfix).appendChild(cur_hidden_field);

	    var child_age = this_type.split("_");

	    child_age = parseInt(child_age[1].slice(1,2));

	    if (child_age > 0) {

		for (var j=1;j<=child_age;j++) {
		    
		    var cur_age = ac_rooms[room_key].age[j];

		    var cur_pax_id = "ac_" + this_type + "_" + j + "_" + (i+1);

		    var cur_hidden_field = document.createElement("input");
		
		    cur_hidden_field.type = 'hidden';
		    cur_hidden_field.name = 'ac_child_age.' + cur_pax_id;
		    cur_hidden_field.id = 'ac_child_age.' + cur_pax_id + postfix;
		    cur_hidden_field.value = cur_age;
		
		    document.getElementById(ac_form_id).appendChild(cur_hidden_field);

		
		}
	    }
	}

    } else {

	// drag the information from the selects
	for(var i=0;i<4;i++) {

	    cur_room_type = ac_room_type[postfix][i];


	
	    var cur_room_type_number = 1;

	    for(k=0;k<i;k++) {
	    
		if(cur_room_type == ac_room_type[postfix][k]) {

		    cur_room_type_number += 1;
		}

	    }



	    if (cur_room_type == 0) {
		
		var child_count = new Array(0,0);

	    } else {

		var child_count = cur_room_type.split("_");

	

		// check if hidden field already exists

		var cur_field_id = 'ac_js_room_types.' + (i + 1) + postfix;

		
        

		if (document.getElementById(cur_field_id) == null || document.getElementById(cur_field_id).id == "") {
		    
		    var cur_hidden_field = document.createElement("input");
		    cur_hidden_field.type = 'hidden';
		    cur_hidden_field.name = 'ac_js_room_types.' + (i + 1);
		    cur_hidden_field.id = 'ac_js_room_types.' + (i + 1) + postfix;
		    cur_hidden_field.value = "a" + child_count[0] + "_c"  + child_count[1];
		    document.getElementById(ac_form_id + postfix).appendChild(cur_hidden_field);

		} else {
		
		    document.getElementById(cur_field_id).value = "a" + child_count[0] + "_c"  + child_count[1];
		}
		
	    }

       

	    if (child_count[1] > 0) {

		for(var j=1;j<=child_count[1];j++) {

		    cur_pax_id = "ac_a" + child_count[0] + "_c" + child_count[1] + "_" + j + "_" + (i + 1);
		
		    cur_child_age_id = "room_" + (i + 1) + postfix + "_" + j;
		
	
		    var cur_age = document.getElementById(cur_child_age_id).options[document.getElementById(cur_child_age_id).selectedIndex].value;
		
		    var cur_field_id = 'ac_child_age.' + cur_pax_id + postfix;
		
		    if (document.getElementById(cur_field_id) == null || document.getElementById(cur_field_id).id == "") {

			var cur_hidden_field = document.createElement("input");
		
			cur_hidden_field.type = 'hidden';
			cur_hidden_field.name = 'ac_child_age.' + cur_pax_id;
			cur_hidden_field.id = 'ac_child_age.' + cur_pax_id  + postfix;
			cur_hidden_field.value = cur_age;
		
			document.getElementById(ac_form_id + postfix).appendChild(cur_hidden_field);

		    } else {
		
			document.getElementById(cur_field_id).value =  cur_age;
		    }

		}
	    	    
	    }
	
	}
    }
} 

function ac_room_type_onChange(room_index, postfix) {

    
    var room_type = document.getElementById(room_index).options[document.getElementById(room_index).options.selectedIndex].value; 

    var child_count = room_type.split("_");
    var room_index_array = room_index.split("_");


    // subtract old pax count

    var old_room_type = ac_room_type[postfix][(room_index_array[1] - 1)];

    if (old_room_type != 0) {
	 
	old_child_count = old_room_type.split("_");
	var old_pax_id = "ac_a" + old_child_count[0] + "_c" + old_child_count[1] + postfix;
	
	var old_pax_type_count = parseInt(document.getElementById(old_pax_id).value);

	old_pax_type_count -= 1;
	document.getElementById(old_pax_id).value = old_pax_type_count;

	if (parseInt(old_child_count[1]) > 0) {

	    var room_number = room_index.split("_");

	    for (var ch=1;ch<=parseInt(old_child_count[1]);ch++) {

		var old_child_age_key = "ac_child_age." + old_pax_id + "_" + ch + "_" + room_number[1] + postfix;

		
	    }
	} 

    }

    // set curent room_type

    ac_room_type[postfix][(room_index_array[1] - 1)] = room_type; 
    

    // get the number of selected rooms for this type
    // and add one

    //var pax_key = "a" + child_count[0] + "_c" + child_count[1];
    var pax_id = "ac_a" + child_count[0] + "_c" + child_count[1] + postfix;


    var pax_type_count = parseInt(document.getElementById(pax_id).value);
    pax_type_count += 1;
    document.getElementById(pax_id).value = pax_type_count;
    



    var room_type_child_select_html = '';
    var box_id = room_index + "_age_box";

    if (child_count[1] > 0) {

	/*var room_type_child_select_html = '<table style="border: 0px;padding: 0px;marging: 0px;"><tr><td align="left">Children Age</td></tr>';

	for(i=1;i<=child_count[1];i++) {

	    room_type_child_select_html += '<tr><td align="left"><select style="width: ' + 160 +  'px;font: normal normal 9px verdana;" name="tmp_child_age.' + pax_id + '_' + i + '_' + pax_type_count + '" id="' + room_index + '_' + i  + '">' + child_age_options_html + '</select></td></tr>';
	
	}

	room_type_child_select_html += '</table>';*/
	
	
	
	for(i=1;i<=child_count[1];i++) {
		room_type_child_select_html += '<div class="labelform_large2">Children Age</div>';
	    room_type_child_select_html += '<div class="inputform"><select name="tmp_child_age.' + pax_id + '_' + i + '_' + pax_type_count + '" id="' + room_index + '_' + i  + '">' + child_age_options_html + '</select></div>';
		room_type_child_select_html += '<div class="spacer"></div>';
	}
	
	
	document.getElementById(box_id).innerHTML = room_type_child_select_html;

    } else {

	// Flush child age div 
	document.getElementById(box_id).innerHTML = room_type_child_select_html;
    }

    sum_pax(postfix);

    
    //document.getElementById(room_index).style.width = ac_rooms_style_width + 'px';
}










function ac_room_count_change (postfix) {

    // do  not prepare for a lower room count for now

    ac_room_type_init(postfix);
    var room_count = document.getElementById("room_count" + postfix).options[document.getElementById("room_count" + postfix).options.selectedIndex].value; 

    if (is.ie && slim_options_p) {
    
	pax_options_html = pax_slim_options_html; 
    }

    //var room_type_select_html = '<table cellpadding="0" cellspacing="0" border="0">';
	
    //for (i=1;i<=room_count;i++) {

	//room_type_select_html += '<tr><td align="left"><b>Room Type ' + i + '. Room*</b></td></tr>'
	//room_type_select_html += "<tr><td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td id=\"side_style\"><select style=\"width:" + ac_rooms_style_width + "px;font: normal normal 9px verdana;\" name=\"room_" + i + "\" id=\"room_" + i + postfix + "\" onChange=\"ac_room_type_onChange(\'room_" + i  + postfix + "\' , \'" + postfix + "\')\" onMouseOver=\"ac_enlarge_select(\'room_" +  i  + postfix + "\')\">" + pax_options_html + "</select></td></tr>";

	//room_type_select_html += "<tr><td><div id=\"room_" + i + postfix + "_age_box"  +  "\" style=\"marging: 0px;padding: 0px;\"></td></tr></table></td></tr>";

    
    //}
	
   // room_type_select_html += '</table>';
	
	var ie_enlarge_select = '';
	
	
	
	var room_type_select_html = '';
	for (i=1;i<=room_count;i++) {
	
		if(is.ie){
			ie_enlarge_select += ' onclick="this.style.width = \'auto\';"  ';
			ie_enlarge_select +=' onblur="this.style.width = \'150px\'; ';
		}
		room_type_select_html +='<div class="labelform_large2">Room Type ' + i + '. Room*</div>';
		//room_type_select_html +="<div class=\"inputform\"><select  name=\"room_" + i + "\" id=\"room_" + i + postfix + "\" onChange=\"ac_room_type_onChange(\'room_" + i  + postfix + "\' , \'" + postfix + "\')\" onMouseOver=\"ac_enlarge_select(\'room_" +  i  + postfix + "\')\">" + pax_options_html + "</select></div>";
		room_type_select_html +="<div class=\"inputform\"><select  name=\"room_" + i + "\" id=\"room_" + i + postfix + "\" onChange=\"ac_room_type_onChange(\'room_" + i  + postfix + "\' , \'" + postfix + "\')\"   onMouseOver=\"ac_enlarge_select(\'room_" +  i  + postfix + "\')\">" + pax_options_html + "</select></div>";
		room_type_select_html += '<div id="room_' + i + postfix + '_age_box"></div>';
		room_type_select_html +='<div class="spacer"></div>';
	}
	
	 

    
    document.getElementById("room_type_select_box" + postfix).innerHTML = room_type_select_html;

    ac_flush_pax(postfix);
    sum_pax(postfix);
}


function ac_rooms_init(postfix) {

    
    if ( ac_init_p == true && document.getElementById("room_count" + postfix).type != "hidden" ) {
 
	if (ac_rooms) {
	

	    ac_room_type_init(postfix);
	    var room_count = parseInt(document.getElementById("room_count" + postfix).options[document.getElementById("room_count" + postfix).options.selectedIndex].value); 
	
	    if (is.ie && slim_options_p) {
		
		// use options with short/slim labels
		pax_options_html = pax_slim_options_html; 
	    }

	    // add the type selects first

	    /*var room_type_select_html = '<table style="border:solid 0px #000000;">';
	
	    for (i=1;i<=room_count;i++) {
	    
		var room_key = "room_" + i;
		var this_type = ac_rooms[room_key].type;
	    
		room_type_select_html += '<tr><td align="left"><b>Room Type ' + i + '. Room*</b></td></tr>'
		room_type_select_html += "<tr><td style=\"border:solid 0px;margin: 0px;padding: 0px;\"><table style=\"border:solid 0px #000000;margin: 0px;padding: 0px;\"><tr><td style=\"border:solid 0px #000000;\"><select style=\"width: " + ac_rooms_style_width + "px;font: normal normal 9px verdana;\" name=\"room_" + i + "\" id=\"room_" + i  + postfix + "\" onChange=\"ac_room_type_onChange(\'room_" + i  + postfix + "\' , \'" + postfix + "\')\"  onMouseOver=\"ac_enlarge_select(\'room_" +  i + postfix +"\')\">" + pax_options_html + "</select></td></tr>";

		room_type_select_html += "<tr><td><div id=\"room_" + i + postfix + "_age_box" + "\" style=\"marging: 0px;padding: 0px;\"></td></tr></table></td></tr>";
	    
    
	    }
	
	    room_type_select_html += '</table>';*/
		
		
		var ie_enlarge_select = '';
		
		
		var room_type_select_html = '';
		for (i=1;i<=room_count;i++) {
			var room_key = "room_" + i;
			var this_type = ac_rooms[room_key].type;
			
			/*if(is.ie){
				ie_enlarge_select += ' onclick="this.style.width = \'auto\';"  ';
				ie_enlarge_select +=' onblur="this.style.width = \'150px\';" ';
			}*/
			
		    
			room_type_select_html += '<div class="labelform_large2"><b>Room Type ' + i + '. Room*</div>';
			//room_type_select_html += "<div class=\"inputform\"><select  name=\"room_" + i + "\" id=\"room_" + i  + postfix + "\" onChange=\"ac_room_type_onChange(\'room_" + i  + postfix + "\' , \'" + postfix + "\')\"  onMouseOver=\"ac_enlarge_select(\'room_" +  i + postfix +"\')\">" + pax_options_html + "</select></div>";
			room_type_select_html += "<div class=\"inputform\"><select  name=\"room_" + i + "\" id=\"room_" + i  + postfix + "\" onChange=\"ac_room_type_onChange(\'room_" + i  + postfix + "\' , \'" + postfix + "\')\"  onMouseOver=\"ac_enlarge_select(\'room_" +  i + postfix +"\')\">" + pax_options_html + "</select></div>";
			room_type_select_html += '<div class="spacer"></div>';
			room_type_select_html += "<div id=\"room_" + i + postfix + "_age_box" + "\" ></div>";
		}
	
    
	    document.getElementById("room_type_select_box"  + postfix).innerHTML = room_type_select_html;


	    ac_flush_pax(postfix);
	    sum_pax(postfix);

	

	    // Now set up the age selects for the rooms 

	    for (var i=1;i<=room_count;i++) {


		var room_key = "room_" + i;
		var this_type = ac_rooms[room_key].type;


		if (this_type != "-1") {

		    var child_count = this_type.split("_");
		    child_count = parseInt( child_count[1].slice(1,2)) ;

		    // set selected index in select check if onChange is fired implicedly

		    document.getElementById(room_key + postfix).options.selectedIndex = ac_room_type_indexes[this_type];
		
		    // trigger the onChange function to add child age selects

		    ac_room_type_onChange(room_key + postfix , postfix);

		} else {

		    var child_count = 0;
		}

		
		
		if (child_count > 0) {
		    
		    // there are children the selects should be added by now, just set the index
		    
		    for(var j=1;j<=child_count;j++) {
			
			var child_age_id = room_key + postfix + "_" + j;

			document.getElementById(child_age_id).options.selectedIndex = ac_rooms[room_key].age[j] + 1;			
		    }
		    
		}
		
		
	    }
	    
	}
	
    } else {

	// insert ac_js_room_types as hidden vars

	//ac_room_type_init();
	//var room_count = parseInt(document.getElementById("room_count").options[document.getElementById("room_count").options.selectedIndex].value); 


    
    }
    
}


function ac_escape(to_escape) {
    
    ret_val = escape(to_escape);
    ret_val = ret_val.replace(/\+/g, "%2B");
    
    //alert("test_val = " + to_escape + "escaped_val = " + ret_val);

    return ret_val;
}

function ac_export_form_vars(base_url) {

    var cur_form = document.getElementById("order_form");
    var cur_elements = cur_form.elements;
    
    var temp_name = "";
    var temp_value = "";
    var cur_query = base_url;
    
    //ac_escape("test+test++test--++test");
    

    for (var i=0;i<cur_elements.length;i++) {

	// loop through allelements of the form

	if (cur_elements[i].type == 'checkbox') {

	    if (cur_elements[i].checked == true) {

		temp_name = cur_elements[i].name;
		temp_value = ac_escape(cur_elements[i].value);
 
	    } else {
		
		// jump to the next iteration of the loop

		continue;
	    }
	
	} else if (cur_elements[i].name == "ac_payment_method") {
	    // skip payment method radio
	    var temp_name = "";
	    var temp_value = "";


	} else {

	    // all other elements are simple name/value pairs

	    temp_name = cur_elements[i].name;
	    temp_value = ac_escape(cur_elements[i].value);
	    
	    //alert("unescaped = " + cur_elements[i].value + " escaped = " + temp_value );
	}


	//alert("element name: cur_elements[i].name" + " ; temp_name = " + temp_name + " ; temp_value = " + temp_value + " ;")
	if (cur_query == base_url && temp_name != "") {

	    cur_query +=  temp_name + "=" + temp_value;

	} else if (temp_name != "") {

	    cur_query += "&" + temp_name + "=" + temp_value;
	}


    }


    cur_query += "&ac_payment_method=creditcard&return_xml_p=t";

	
    return cur_query;
    

}


function ac_storeOrder(url_vars,returnAs){


    req = false;
    // For Safari, Firefox, and other non-MS browsers
    if (window.XMLHttpRequest) {
	try {
	    req = new XMLHttpRequest();
	} catch (e) {
	    req = false;
	}
    } else if (window.ActiveXObject) {
	// For Internet Explorer on Windows
	try {
	    req = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	    try {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch (e) {
		req = false;
	    }
	}
    }
    
    

    req.open("POST", "/hotel/order", false);
    req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
 

    //var encoded = "";
  //encoded = "country_id=" + escape(country_id) + "&locale=" + escape(locale); 
  req.send(url_vars);


  if (req.status != 200) {
    alert("There was a communications error: " +  req.responseText);
    return;
  } else {
      
      
      if (returnAs == "xml") {
	  
	  return xml = req.responseXML;

      } else {

	  return req.responseText;
      }
  }

}



function ac_update_ptool_form (order_details) {


    var cur_details = order_details.split("|");

    document.getElementById("orderID").value = cur_details[0]; 
    document.getElementById("ptool_amount").value = cur_details[1];
    document.getElementById("ptool_SHASIGN").value = cur_details[4];


    document.getElementById("ptool_tp").value = "https://www.cluster.Clever-Hotels.clever-devel.com/hotel/acceptance-template.tcl";

    document.getElementById("accepturl").value = document.getElementById("accepturl").value + "?order_id=" + cur_details[0];

    document.getElementById("ptool_cn").value = document.getElementById("ac_first_names").value + " " + document.getElementById("ac_last_name").value;
    document.getElementById("ptool_owneraddress").value = document.getElementById("ac_address_1").value;
    document.getElementById("ptool_ownertown").value = document.getElementById("ac_region").value;
    document.getElementById("ptool_ownerzip").value = document.getElementById("ac_postcode").value;
    document.getElementById("ptool_ownertelno").value = document.getElementById("ac_telefon").value;
    document.getElementById("ptool_ownercty").value = document.getElementById("ac_country").value;


    document.getElementById("form1").submit();
}



function ac_min_stars_click(cur_id) {

    var cur_element = "acco_search:elements:ac_min_stars:" + cur_id;
    document.getElementById(cur_element).checked = true;
}



function update_from_days (form_id) {

    //disable_form(document.getElementById(form_id));
  
   var newoptions =  ac_getDays(document.getElementById("ac_from_date.month_year").options[document.getElementById("ac_from_date.month_year").options.selectedIndex].value, "noxml");

   var old_day = document.getElementById("ac_from_date.day").value;

    if (is.ie) {

      var newselect = '<Select name="ac_from_date.day" id="ac_from_date.day">' + newoptions + '</select>';
      document.getElementById("ac_from_date_id_div").innerHTML = newselect;
    
    } else {

      document.getElementById("ac_from_date.day").innerHTML = newoptions;

    }



    document.getElementById("ac_from_date.day").value = old_day;
    //enable_form(document.getElementById(form_id));
    

}

function update_to_days (form_id) {

    //   disable_form(document.getElementById(form_id));
  
   var newoptions = ac_getDays(document.getElementById("ac_to_date.month_year").options[document.getElementById("ac_to_date.month_year").options.selectedIndex].value, "noxml");

   var old_day = document.getElementById("ac_to_date.day").value;

    if (is.ie) {

      var newselect = '<Select name="ac_to_date.day" id="ac_to_date.day">' + newoptions + '</select>';
      document.getElementById("ac_to_date_id_div").innerHTML = newselect;
    
    } else {

      document.getElementById("ac_to_date.day").innerHTML = newoptions;

    }



    document.getElementById("ac_to_date.day").value = old_day;
    //enable_form(document.getElementById("form_id"));


}



function add_seven_days(form_id, postfix) {

/**   from_date = new Date(document.getElementById("ac_from_date.year").value.split("|")[1] ,
    (document.getElementById("ac_from_date.month").value.split("|")[0] - 1) , document.getElementById("ac_from_date.day").value );
**/


    //if(is.geko) {

   from_day_str = document.getElementById("ac_from_date.day" + postfix).value;
   (from_day_str.indexOf("0") == 0?from_day_str = from_day_str.substring(1,2):from_day_str = from_day_str);

    from_month_str = document.getElementById("ac_from_date.month_year" + postfix).value.split("|")[0];
   (from_month_str.indexOf("0") == 0?from_month_str = from_month_str.substring(1,2):from_month_str = from_month_str);

    from_month = (parseInt(from_month_str) - 1);


    from_date = new Date(document.getElementById("ac_from_date.month_year" + postfix).value.split("|")[1] ,
     from_month , from_day_str );
  

    new_to_date = new Date();
    new_to_date.setTime(from_date.getTime() + (86400000));

    new_to_day_str = new_to_date.getDate().toString();
    new_to_month_str = (new_to_date.getMonth() + 1).toString();
    new_to_year_str = new_to_date.getFullYear().toString();

    (new_to_day_str.length == 1? new_to_day_str = "0" + new_to_day_str:
    new_to_day_str = new_to_day_str);

    (new_to_month_str.length == 1? new_to_month_str = "0" + new_to_month_str:
    new_to_month_str = new_to_month_str);
    

    document.getElementById("ac_to_date.month_year" + postfix).value = new_to_month_str + "|" + new_to_year_str;
    update_to_days(form_id);
    document.getElementById("ac_to_date.day" + postfix).value = new_to_day_str;

    // document.getElementById("ac_to_date.year").value = new_to_year_str;


    //}

   update_from_days(form_id);
}

function check_traveler_names () {

	var cur_room_count = document.getElementById("room_count").value;
	var names_error = false;

	for (var i=0;i<cur_room_count;i++) {
	    
	    var room_key = "room_" + (i + 1);
	    var this_type = ac_rooms[room_key].type;
	    var room_persons = ac_rooms[room_key].persons;
  
	    for (var j=1;j<=room_persons;j++) {

		var cur_first_names_id = "ac_" + this_type + "_first_" + j  + "_" + (i + 1);  
		var cur_last_name_id = "ac_" + this_type + "_last_" + j  + "_" + (i + 1);  


		if (document.getElementById(cur_first_names_id).value.length == 0 || document.getElementById(cur_first_names_id).value.length > 20) {
		    
		    document.getElementById(cur_first_names_id).style.background = "#ffec5c";

		    names_error = true;
		}


		if (document.getElementById(cur_last_name_id).value.length == 0 || document.getElementById(cur_last_name_id).value.length > 20) {
 	
		    document.getElementById(cur_last_name_id).style.background = "#ffec5c";
		    names_error = true;
		    
		}

	    }

	}



	if (names_error) {

	    window.alert("Please fill in all Traveler names.");
	    return false;
	    
	}


	return true;

}


function undo_error_mark(e) {

    var target = e.target ? e.target : e.srcElement;
    target.style.background = "white";
	//target.className = "get_focus";
	
}


function check_payment_selected() {

    var is_selected = false;
    var show_error_msg = true;


    if (document.getElementById("order_form:elements:ac_payment_method:creditcard") != null) {

	if (document.getElementById("order_form:elements:ac_payment_method:creditcard").checked) {

	    is_selected = true;

	}

    }
    
    if (document.getElementById("order_form:elements:ac_payment_method:banktransfer") != null) {


	if (document.getElementById("order_form:elements:ac_payment_method:banktransfer").checked == true) {

	    is_selected = true;

	}

    }


    if (document.getElementById("order_form:elements:ac_payment_method:directdebit") != null) {

	
	if (document.getElementById("order_form:elements:ac_payment_method:directdebit").checked) {

	    show_error_msg = false;

	    if (check_directdebit_data()) {
		

		is_selected = true;
	    }

	}
    }
 


    if (!is_selected) {

	if (show_error_msg) {

	    alert("Please select a payment method. ");

	}
	
	return false;

    } else {

	return true;

    }
	
        
} 


function check_directdebit_data() {

    if (document.getElementById("ac_payment_bank_account_holder_id").value.length == 0) {

	alert("Please fill in the Bank Account holder.");
	return false;
    }

    if (document.getElementById("ac_payment_bank_name_id").value.length == 0) {

	alert("Please fill in the Bank name.");
	return false;
    }

    if (document.getElementById("ac_payment_bank_number_id").value.length != 8 || isNaN(document.getElementById("ac_payment_bank_number_id").value)) {

	alert("The Bank number must be 8 characters long. Use digets 0...9 only, no Spaces or other characters.");
	return false;
    }

    if (document.getElementById("ac_payment_bank_account_id").value.length < 7 || document.getElementById("ac_payment_bank_account_id").value.length > 10 || isNaN(document.getElementById("ac_payment_bank_account_id").value)) {

	alert("Please check the Bank account number. Use digets (0...9) only, no Spaces or other characters.");
	return false;
    }

    
    return true;

}



var names     = new makeArray0('Januar','February','March','April','Mai','June','July','August','September','October','November','December');
var days      = new makeArray0(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var dow       = new makeArray0('Sun','Mon','Tue','Wed','Thu','Fri','Sat');

var calendar_year = 0;
var calendar_month = 0;
var calendar_fiering_id = '';
var calendar_month_year_id = '';
var calendar_day_id = '';
var calendar_window_id = '';
var calendar_move_left = 0;
var calendar_move_top = 0;


/* Calendar functions */

    function Calendar(Month,Year,month_year_id,day_id,window_id) {


	var output = '';
    
	output += '<form name="Cal"><table bgcolor="#FFFFFF" border=0 width="170px">';
	output += '<tr><td id="calendar_month">';
	output += '<select name="Month" onChange="changeMonth();" class="month">';

	for (month=0; month<12; month++) {
	    if (month == Month) output += '<option value="' + month + '" selected>' + names[month] + '<\/option>';
	    else                output += '<option value="' + month + '">'          + names[month] + '<\/option>';
	}

	output += '<\/select></td>';

	output += '<td id="calendar_year"><select name="Year" onChange="changeYear();" class="year">';

	for (year=2010; year<=2010; year++) {
	    if (year == Year) output += '<option value="' + year + '" selected>' + year + '<\/option>';
	    else              output += '<option value="' + year + '">'          + year + '<\/option>';
	}

	output += '<\/select><\/td><\/tr><tr><td align=center colspan=2>';

	firstDay = new Date(Year,Month,1);
	startDay = firstDay.getDay();

	if (((Year % 4 == 0) && (Year % 100 != 0)) || (Year % 400 == 0))
	days[1] = 29; 
	else
	days[1] = 28;

	output += '<table callspacing=0 cellpadding=0 border-style="solid" border=0 bordercolordark="#FFFFFF" bordercolorlight="#C0C0C0"><tr>';

	for (i=0; i<7; i++)
        output += '<td width="20px" align=center valign=middle id="calendar_days">' + dow[i] +'<\/td>';

	output += '<\/tr><tr align=center valign=middle>';

	var column = 0;
	var lastMonth = Month - 1;
	if (lastMonth == -1) lastMonth = 11;

	for (i=0; i<startDay; i++, column++)
        output += '<td width="20px" height="20px" id="calendar_entry">' + (days[lastMonth]-startDay+i+1) + '<\/td>';

	for (i=1; i<=days[Month]; i++, column++) {
	    output += '<td width="20px" height="20px" id="calendar_entry">' + '<a href="javascript:changeDay(' + i + ')" >' + i + '<\/a>' +'<\/td>';
	    if (column == 6) {
		output += '<\/tr><tr align=center valign=middle>';
		column = -1;
	    }
	}

	if (column > 0) {
	    for (i=1; column<7; i++, column++)
            output +=  '<td width="20px" height="20px" id="calendar_entry">' + i + '<\/td>';
	}

	output += '<\/tr><\/table><\/form><\/td><\/tr><\/table>';

	return output;
    }

function changeDay(day) {

    day = day + '';


    if (day.length == 1) {

	day = "0" + day;

    }

    var month = parseInt(document.Cal.Month.options[document.Cal.Month.selectedIndex].value);
    month += 1;
    
    if (month < 10) {

	month = "0" + month;

    }
    

    var year = document.Cal.Year.options[document.Cal.Year.selectedIndex].value + '';


    document.getElementById(calendar_month_year_id).value = month + "|" + year;
    document.getElementById(calendar_day_id).value = day;
    document.getElementById(calendar_month_year_id).onchange();

    closeFloatingError();
}

function changeMonth() {


    calendar_month = parseInt(document.Cal.Month.options[document.Cal.Month.selectedIndex].value) + 1;
    var ihtml = Calendar(document.Cal.Month.options[document.Cal.Month.selectedIndex].value + '' , calendar_year, calendar_month_year_id, calendar_day_id, calendar_window_id);

    displayFloatingCalendar( calendar_window_id, calendar_fiering_id, "Calendar", "170", "300", calendar_move_left, calendar_move_top, ihtml); 
    //document.getElementById(calendar_window_id).innerHTML 

}

function changeYear() {

    calendar_year = parseInt(document.Cal.Year.options[document.Cal.Year.selectedIndex].value);

    var ihtml = Calendar((calendar_month -1 ) , calendar_year, calendar_month_year_id, calendar_day_id, calendar_window_id);

    displayFloatingCalendar( calendar_window_id, calendar_fiering_id, "Calendar", "170", "300", calendar_move_left,  calendar_move_top, ihtml); 


}

function makeArray0() {
    for (i = 0; i<makeArray0.arguments.length; i++)
        this[i] = makeArray0.arguments[i];
}




function open_calendar(month_year_id, fiering_id,day_id , window_id , move_left, move_top) {


    var month_year_ar = document.getElementById(month_year_id).value.split("|");
    var Month = parseInt(month_year_ar[0]);
    
    if (Month == 0) {

	Month = parseInt(month_year_ar[0].replace('0',''));
    } 

    var Year = parseInt(month_year_ar[1]);

    //alert("hello");
    calendar_year = Year;
    calendar_month = Month;
    calendar_fiering_id = fiering_id;
    calendar_month_year_id = month_year_id;
    calendar_day_id = day_id;
    calendar_window_id = window_id;
    calendar_move_left = move_left;
    calendar_move_top = move_top;

    var ihtml = Calendar((Month -1), Year, month_year_id, day_id, window_id);

    displayFloatingCalendar("windowerror", fiering_id, "Calendar", "170", "300",  calendar_move_left,  calendar_move_top, ihtml); 

    return false;
}



// checks

var pax_ids = new Array("ac_a1_c0" , "ac_a1_c1" , "ac_a2_c0" , "ac_a2_c1" , "ac_a3_c0" , "ac_a2_c2" , "ac_a2_c3" , "ac_a2_c4" , "ac_a3_c1" , "ac_a3_c2" , "ac_a3_c3" , "ac_a4_c0" , "ac_a4_c1" , "ac_a4_c2" , "ac_a5_c0" , "ac_a5_c1" , "ac_a6_c0");

var pax_names = new Array("1 Adult" , "1 Adult + 1 Child" , "2 Adults" , "2 Adults + 1 Child" , "3 Adults" , "2 Adults + 2 Children" , "2 Adults + 3 Children" , "2 Adults + 4 Children" , "3 Adults + 1 Child" , "3 Adults + 2 Children" , "3 Adults + 3 Children" , "4 Adults" , "4 Adults + 1 Child" , "4 Adults + 2 Children" , "5 Adults" , "5 Adults + 1 Child" , "6 Adults");


function check_pax_vals(postfix) {



     for (i=0;i < pax_ids.length;i++) {


   
       if (document.getElementById(pax_ids[i] + postfix).value.length == 0) {

           document.getElementById(pax_ids[i] + postfix).value = "0";

       }


       if (isNaN(document.getElementById(pax_ids[i] + postfix).value) ) {

           var top = 0;
           var left = 0;
           var cur_element = document.getElementById(pax_ids[i] + postfix);
 
           while ("" + cur_element.offsetParent != "[object HTMLBodyElement]") {

              top += cur_element.offsetTop;
              left += cur_element.offsetLeft;
              cur_element = cur_element.offsetParent;
           }

           //top += cur_element.offsetTop;
           //left += cur_element.offsetLeft;
      
           var error_msg = "Please fill in a Number into the Field" + pax_names[i] +  "" + " style top " + document.getElementById(pax_ids[i]).offsetParent.offsetParent + " " + top ;

    displayFloatingError("windowerror", "Wrong Pax", 150 , 75 , left - 200 ,  top - 180 , error_msg);
 
     window.setTimeout("closeFloatingError()" , 7000);
    //alert("Please fill in a Number into the Field" +  pax_names[i] +  "");
    
           document.getElementById(pax_ids[i] + postfix).value = "0";
           document.getElementById(pax_ids[i] + postfix).focus();
           return false;           

       } else {


           document.getElementById(pax_ids[i] + postfix).value = "" + parseInt(document.getElementById(pax_ids[i] + postfix).value);
       }
    
     }

  return true;

} 

function ac_add_user_search_data(current_id) {

    for (var i=1;i<=ac_search_object_length;i++) {

        var cur_hidden_field = document.createElement("input");
        cur_hidden_field.type = 'hidden';
        cur_hidden_field.name = ac_search_object[i].name;
        //cur_hidden_field.id = search_option_names[i].value;
        cur_hidden_field.value = ac_search_object[i].value;

        document.getElementById(current_id).appendChild(cur_hidden_field);

    }

}

/**
 * @author javier
 * @since 2008/05/28
 */

function $(pId){
    var obj = "";
    obj = document.getElementById(pId);
    return obj;
}

function ac_check_text_len(ptxt_id, pmax_len) {
    var str_aux = "";
    var max_len = (pmax_len -1);
    var str = $(ptxt_id).value;
        var str_length = str.length
	    if(str_length >= max_len){
                str_aux = str.substr(0,max_len);
                $(ptxt_id).value = str_aux;
	    }else{
                $(ptxt_id).value=str;
	    }
}




function check_unit_key(unit_key , sub_key) {

		
    
    $('order_form')[unit_key][sub_key].checked = true; 
	
    update_complete_price();

};

