';
if (this.equipments[i].price.IncludedP) {
result_set_html += '
';
} else {
result_set_html += '
';
}
if (this.equipments[i].price.taxIncludedP) {
result_set_html += '
';
} else {
result_set_html += '
';
}
}
// coverages
result_set_html += '
' +this.displayContractDetails() + '
';
result_set_html += '
';
result_set_html += '
';
result_set_html += '
';
result_set_html += '
';
result_set_html += '
';
return result_set_html;
}
};
this.displayContractDetails = function () {
if (this.contractDetails == null) return "";
var result_set_details_html = '';
for (var i=0; i < this.contractDetailsSummary.length;i++) {
result_set_details_html += '
' + this.contractDetailsSummary[i].title + '
';
result_set_details_html += ' ';
var terms = this.contractDetailsSummary[i].terms;
for (var j=0;j < terms.length;j++) {
result_set_details_html += '
' + terms[j] + '
';
result_set_details_html += ' ';
}
}
for (var i=0; i < this.contractDetails.length;i++) {
result_set_details_html += '
' + this.contractDetails[i].title + '
';
var terms = this.contractDetails[i].terms;
for (var j=0;j < terms.length;j++) {
result_set_details_html += '
' + terms[j] + '
';
result_set_details_html += ' ';
}
}
return result_set_details_html;
};
this.showDetails = function (showP) {
var btn = getEBI('arrow_'+this.id);
var obj = getEBI('det_'+this.id);
if(showP){
if (this.contractDetails == null) this.getContractDetails();
obj.style.display = "block";
btn.innerHTML = 'Details';
}else{
obj.style.display = "none";
btn.innerHTML = 'Details';
}
};
this.showDetailsCompact = function(showP){
var btn = getEBI('arrow_'+this.id);
var obj = getEBI('det_compact_'+this.id);
if(showP){
if (this.contractDetails == null) this.getContractDetails();
obj.style.display = "block";
btn.innerHTML = 'Details';
}else{
obj.style.display = "none";
btn.innerHTML = 'Details';
}
};
this.updateDisplayContractDetails = function() {
//alert(this.displayContractDetails());
getEBI("contract_details_" + this.id).innerHTML = this.displayContractDetails();
};
this.constructor = function () {
//https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Functions_and_function_scope/arguments
// using the arguments array to initialise the dynamic amount, depending on the result type (car, accommodation), of locale properties (variables).
for (var i=0; i < arguments.length; i++) {
// may use this to initialise this.ota_codes
}
};
}
/********************************
* cr_goup object *
********************************/
function cr_group(PropVal, default_flat_p, max_results, sortBy , sortDescending, owner) {
this.owner = owner; // the cr_search object that owns this group
this.property_value = PropVal;
this.default_flat_p = default_flat_p;
this.max_results = max_results;
this.result_sets = new Array();
this.sortByProperty = null;
this.matchFilters = new Array();
// matchFilters is a Array of filters , all result_sets of this group must match all filter criterias, the Array will be empty on creation filters can be added or removed dynamicly
// matchFilters are usualy different from the filters used for sorting
this.filters = null;
this.sortBy = sortBy;
this.subSortBy = null;
this.sortIndex = null;
this.sortDescending = sortDescending; // true/false
this.currentPage = 1;
this.collectFilters = function () {
// first create standart filter for price
var filters = new Array();
filters[0] = new cr_filter("Price" , "price" , null , null);
filters[1] = new cr_filter("Car Size" , "car_type" , null , null);
// eqipments price
var equip_codes = new Array();
for (var j = 0; j < this.result_sets.length; j++ ) {
var equips = this.result_sets[j].equipments;
for (var i = 0; i < equips.length; i++) {
if (!this.owner.arrayExists(equip_codes, equips[i].code)) {
//filters[i + 2] = new cr_filter(equips[i].name , "equipments", "price" , equips[i].code);
equip_codes.push(equips[i].code);
}
}
}
this.filters = filters;
};
this.addMatchFilter = function (whichFilter , allResultSets) {
// first check if its a filter which has a variable subKey which has to be updated
var filters = this.matchFilters;
var updatedP = false;
for (var i=0; i < filters.length;i++) {
if (filters[i].key == whichFilter.key ) {
filters[i].subKey = whichFilter.subKey;
updatedP = true;
}
}
if (!updatedP) {
// filter dosent exist yet add it
this.matchFilters[this.matchFilters.length] = whichFilter;
}
this.updateResultSets(allResultSets);
this.resortGroup(this.sortBy, this.subSortBy, this.index);
};
this.removeMatchFilter = function (whichFilter , allResultSets) {
var filters = this.matchFilters;
for (var i=0; i < filters.length;i++) {
if (filters[i].key == whichFilter.key ) {
this.matchFilters = filters.slice(i,i);
}
}
this.updateResultSets(allResultSets);
this.resortGroup(this.sortBy, this.subSortBy, this.index);
};
this.updateResultSets = function(allResultSets) {
var newResultSets = new Array();
var filters = this.matchFilters;
var match = false;
for (var i=0;i < allResultSets.length;i++) {
match = false;
for (var j=0;j < filters.length;j++ ) {
match = allResultSets[i].matchFilterP(filters[j]);
if (!match) {
break;
}
}
if (match) {
// add result_set
newResultSets[newResultSets.length] = allResultSets[i];
}
}
this.result_sets = newResultSets;
};
this.display = function (flat_p, page_number) {
// if flat_p is true show all results
var group_html = '
';
if (flat_p) {
//group_html += this.display_inflate(page_number);
group_html += this.display_status(this.property_value);
} else {
//group_html += this.display_deflate(page_number);
group_html += this.display_status(this.property_value);
}
group_html += this.display_content(flat_p, page_number);
group_html += ''; // later may add pagination here
group_html += '
';
return group_html;
};
this.display_status = function (group_property){
var group_html = '
';
if(i == 4){// add separator to make two tablines
sort_by_html += '';
}
if (i < (this.filters.length - 1)) {
sort_by_html += " ";
}
}
sort_by_html += "
";
group_html += sort_by_html;
for (i=start; i <= end; i++) {
group_html += this.result_sets[i].display();
if (i == end) {
if (this.max_results < this.result_sets.length) {
// add group pagination
var page_count = this.result_sets.length / this.max_results;
var page_count_rounded = parseInt('' + page_count);
page_count = (page_count > page_count_rounded ? page_count_rounded + 1 : page_count);
var page_links = '';
for (j = 1;j <= page_count;j++) {
page_links += '' + j + '';
if (j
' + page_links + '
';
}
}
}
results_div.innerHTML = group_html;
hightLightTab("img_"+this.sortBy+"_desc", "img_"+this.sortBy+"_asc", "tab_"+this.sortBy+"_left", "tab_"+this.sortBy+"_middle", "tab_"+this.sortBy+"_right",true, this.descending);
};
this.resortGroup = function(sortBy, subSortBy, index) {
if (sortBy == this.sortBy && this.subSortBy == subSortBy && this.sortIndex == index) {
// if the same sort option is clicked the second time switch sort direction
this.descending = !this.descending;
}
this.sortBy = sortBy;
this.subSortBy = subSortBy;
this.sortIndex = index;
this.result_sets = this.owner.sort(this.result_sets, this.sortBy, this.descending, this.subSortBy, this.sortIndex);
this.showGroupPage(this.currentPage);
};
}
/************************************************************
* cr_car_search Objectwith functions and sub objects *
************************************************************/
function cr_car_search (travelDates,car_types, result_div_id, driver_age, locale_str, isoCurrency , filters_div_id , search_div_id, ajaxSearchKeyStr ) {
this.objName = function () {return "cr_car_search";};
this.travelDates = travelDates;
var month;
var hour;
var minute;
var day;
this.from_minute = ( (minute = (travelDates.fromDateTime.getMinutes() + "")).length == 1 ? ("0" + minute) : minute);
this.from_hour = ( (hour = (travelDates.fromDateTime.getHours() + "")).length == 1 ? ("0" + hour) : hour);
this.from_day = ( (day = (travelDates.fromDateTime.getUTCDate() +"")).length == 1 ? ("0" + day) : day);
this.from_month = ( (month = ( (travelDates.fromDateTime.getMonth() + 1) + "")).length == 1 ? ("0" + month) : month);
this.from_year = travelDates.fromDateTime.getFullYear();
this.to_minute = ( (minute = (travelDates.toDateTime.getMinutes() + "")).length == 1 ? ("0" + minute) : minute);
this.to_hour = ( (hour = (travelDates.toDateTime.getHours() + "")).length == 1 ? ("0" + hour) : hour);
this.to_day = ( (day = (travelDates.toDateTime.getUTCDate() +"")).length == 1 ? ("0" + day) : day);
this.to_month = ( (month = ( (travelDates.toDateTime.getMonth() + 1) + "")).length == 1 ? ("0" + month) : month);
this.to_year = travelDates.toDateTime.getFullYear();
this.from_id = null;
this.from_type = null;
this.to_id = null;
this.to_type = null;
this.base_url = 'https://www.clever-mietwagen.de:/car-rental/ajax/';
this.host_url = 'https://www.clever-mietwagen.de:';
this.driver_age = driver_age;
this.locale = locale_str;
this.isoCurrency = isoCurrency;
//this.check_hire_dates = cr_check_hire_dates;
this.car_types = new Array(new cr_option('cr_cartypes', 1 , 'Normal Car', ''));
this.select_car_types = new Array(new cr_option('cr_cartypes', 1 , 'Normal Car', ''));
//this.allCommonOptions = new Array(new cr_option('cr_price', null , 'Price', '') , new cr_option('cr_cartypes', 1 , 'Normal Car', ''));
// first is default property
this.allProperties = new Array (new cr_property("Price" , "price") , new cr_property("Currency" , "currency") , new cr_property("Car Size" , "car_type_id") , new cr_property("Description" ,"description") , new cr_property("OTA Codes" , "ota_codes") , new cr_property("Supplier" , "supplier_id") , new cr_property("Supplier Name", "supplier_name"));
this.sortBy = this.allProperties[0];
this.sortDescending = false;
// html properties
this.div_id = result_div_id; /* currently the id of the div in which the results should be displayed
later may add a reference to the Dom Object for direct (quicker) access */
this.filters_div_id = filters_div_id;
this.search_div_id = search_div_id;
this.noPictureURL = 'https://www.clever-mietwagen.de:/';
this.max_groups = 10; // display not more groups than max_groups on one page (ignore if groups are flated or only best result is shown)
this.max_group_results = 10;
// dynamic properties
this.result_sets_orig = Array(); // plain array of all result sets
this.result_sets_grouped_sorted = Array(); // current grouping and sorting of result sets.
this.allStations = Array(); // Array of all station objects
// order object
this.order = null;
// auto load info
this.ajaxSearchKey = ajaxSearchKeyStr;
this.ajaxSearchLoadedP = false;
this.getOrder = function (bookingReferenceId) {
var result_set = null;
for (var i = 0; i < this.result_sets_orig.length;i++) {
if (this.result_sets_orig[i].bookingReference.id == bookingReferenceId) {
result_set = this.result_sets_orig[i];
}
}
if (result_set != null) {
if (this.order != null) {
this.order.selected_result_set = result_set;
} else {
this.order = new cr_order(result_set);
}
}
return this.order;
};
this.showHideObject = function(objectId, pFlag){
var obj = document.getElementById(objectId);
if(obj){
if(pFlag){
obj.style.display = "block";
}else{
obj.style.display = "none";
}
}
};
this.selectOffer = function (bookingReferenceId) {
var order = this.getOrder(bookingReferenceId);
if (order == null ) {
//alert("No valid result set!");
locale_alert("form_container" , "Error" , "No valid result set!", 50 , 50 );
return false;
}
this.displayOrderPage();
this.showHideObject(this.search_div_id, false);
return false;
};
this.purchaseOffer = function () {
this.order.purchaseOffer();
};
this.showDetails = function (setId, showP) {
var set = this.getResultSetById(setId);
if(set != null) set.showDetails(showP);
};
this.showDetailsCompact = function (setId, showP) {
var set = this.getResultSetById(setId);
if(set != null) set.showDetailsCompact(showP);
};
// functions
/* a function which takes an array of objects (to sort), and a string defining whichProperty to compare, using the array elements property (function)
compare, to compare a element to a nother element, the whichProperty string is passed to the compare function of the elements.
returns a new array with elements in sorted order
*/
this.sort = function (arr_to_sort, propertyKey, descending, subPropertyKey, index) {
var run = true;
while(run) {
arr_to_sort = this.shellSort(arr_to_sort, propertyKey, descending, subPropertyKey, index);
run = false;
for (var i = 0; i < (arr_to_sort.length - 1); i++) {
if (descending == false) {
if (arr_to_sort[i] > arr_to_sort[i+1]) {
run = true;
break;
}
} else {
if (arr_to_sort[i] > arr_to_sort[i+1]) {
run = true;
break;
}
}
}
}
return arr_to_sort;
};
this.shellSort = function (arr_to_sort, propertyKey, descending, subPropertyKey, index) {
var last_loop = false;
for (var dist=Math.round(arr_to_sort.length/2);dist >= 1;dist = Math.round(dist/2) ) {
for (var i=0; i < (arr_to_sort.length - dist); i++ ) {
var comp = arr_to_sort[i].compare(arr_to_sort[i + dist] , propertyKey, subPropertyKey, index);
if (descending == false) {
if(comp == 1) {
var cache = arr_to_sort[i];
arr_to_sort[i] = arr_to_sort[i + dist];
arr_to_sort[i + dist] = cache;
}
} else {
if(comp == -1) {
var cache = arr_to_sort[i];
arr_to_sort[i] = arr_to_sort[i + dist];
arr_to_sort[i + dist] = cache;
}
}
}
if (last_loop == true) {
break;
} else if (dist == 1) {
dist = 2;
last_loop = true;
}
}
return arr_to_sort;
};
/* A function which gets whichPropertyToGroup passed, and returns an array of arraies where the inner arraies hold a group of elements,
the result has at least one group (inner array), the common group which applies to all ungroupable elements, holding all elements,
if no valid grouping is specified (which may be wanted).
function grouping (whichPropertyToGroup) uses this.result_sets_orig as src array
*/
this.grouping = function (whichProp) {
var result = new Array();
// add a group object with own sort compare function
//var group_values = new Array(cr_group(null));
var group_values = new Array(new cr_group(null, true , this.max_group_results, this.sortBy.key, false , this));
var cur_prop_val = null;
var match = false;
// finding all group values
for (var i=0;i < this.result_sets_orig.length;i++) {
cur_prop_val = this.result_sets_orig[i].get_property_value(whichProp);
match = false;
for (var j=0;j < group_values.length;j++) {
// may add the property comparing fuction here
if (cur_prop_val == group_values[j].property_value) {
match = true;
group_values[j].result_sets[group_values[j].result_sets.length] = this.result_sets_orig[i];
break;
}
}
if (!match) {
group_values[group_values.length] = cr_group(cur_prop_val);
group_values[group_values.length - 1].result_sets[group_values[group_values.length - 1].result_sets.length] = this.result_sets_orig[i];
}
match = false;
}
for (var i = 0; i < group_values.length; i++ ) {
group_values[i].collectFilters();
}
return group_values;
};
this.addRemoveMatchFilterFromGroup = function (groupID, whichFilter, checkedP) {
// may change groupID to current group
var group = this.getGroupByID(groupID);
//var group_props = group.Properties;
if (checkedP) {
// add property
group.addMatchFilter(whichFilter, this.result_sets_orig);
} else {
// remove property
group.removeMatchFilter(whichFilter, this.result_sets_orig);
}
};
this.init_result_sets = function () {/* do a request and init result_sets*/};
this.sort_result_sets = function (whichProp) {};
this.sort_group = function (groupID, key, subKey, index) {
/* sort the elements of a group*/
var group = this.getGroupByID(groupID);
this.sort(group.result_sets , group.sortBy, group.descending, subKey, index);
};
// request vars and functions
this.req = null;
this.onComplete = null;
this.onError = null;
this.makeRequest = function (url, meth, onComp, onErr, processReqChange , xmlToSend, pointer) {
if (meth != "POST")
meth = "GET";
if (pointer == null) pointer = this;
if (processReqChange == null) processReqChange = pointer.processReqChange;
pointer.onComplete = onComp;
pointer.onError = onErr;
// branch for native XMLHttpRequest object
if (window.XMLHttpRequest)
{
//this.req = new XMLHttpRequest();
//this.req.onreadystatechange = function () { pointer.processReqChange() };
pointer.req = new XMLHttpRequest();
pointer.req.onreadystatechange = function () { pointer.processReqChange() };
if (xmlToSend == null) {
pointer.req.open("GET", url, true); //
pointer.req.send(null);
//this.req.open("GET", url, true); //
//this.req.send();
} else {
pointer.req.open("POST", url, true); //
pointer.req.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
pointer.req.send(xmlToSend);
}
// branch for IE/Windows ActiveX version
}
else if (window.ActiveXObject)
{
pointer.req = new ActiveXObject("Microsoft.XMLHTTP");
if (pointer.req)
{
pointer.req.onreadystatechange = function () { pointer.processReqChange() };
if (xmlToSend == null) {
pointer.req.open('GET', url, true);
pointer.req.send();
} else {
pointer.req.open("POST", url, true); //
pointer.req.setRequestHeader('content-type', 'text/xml');
pointer.req.send(xmlToSend);
}
}
}
};
this.processReqChange = function() {
// only if req shows "loaded"
if (this.req.readyState == 4) {
// only if "OK"
if (this.req.status == 200){
this.onComplete( this.req );
} else {
this.onError( this.req.status );
}
loading_effect(false,"");
window.location.hash = "heading_top";//redirects to top of page, first result
}
};
this.getTextFromNode = function (node) {
if (node.hasChildNodes()) {
return node.childNodes[0].nodeValue;
} else {
return "";
}
};
this.req_xml = null;
this.parseXML = function (req) {
var req_xml = this.req_xml = req.responseXML;
// check for error
var result_node = this.req_xml.getElementsByTagName('SearchResults');
var result_type = result_node[0].getAttribute('Type');
if (result_type == "error") {
var error_nodes = this.req_xml.getElementsByTagName('Error');
for (var i = 0; i < error_nodes.length; i++) {
//alert("Error: " + error_nodes[i].childNodes[0].nodeValue);
locale_alert("form_container" , "Error" , "Error: " + error_nodes[i].childNodes[0].nodeValue, 50 , 50 );
}
return;
}
//alert ("req_xml = " + req_xml);
//var result_nodes = this.req_xml.childNodes[0].childNodes;
var result_nodes = this.req_xml.getElementsByTagName('SearchResult');
var type_node = null;
var suppl_node = null;
var price_node = null;
var equipemt_nodes = null;
var layout_nodes = null;
var equipment_node = null;
var cache_node = null;
var coverage_nodes = null;
var booking_node = null;
var station_node = null;
var charges_node = null;
for (var i = 0; i < result_nodes.length; i++) {
cur_set = new cr_car_result_set(0, '', 0, '', '', '', null, '', '', '', '');
cur_set.owner = this;
cur_set.id = result_nodes[i].getAttribute('resultId');
type_node = result_nodes[i].getElementsByTagName('Type');
cur_set.car_type_id = parseInt(type_node[0].getAttribute('type'));
cur_set.car_size_id = parseInt(type_node[0].getAttribute('size'));
cur_set.assetNumber = type_node[0].getAttribute('assetNumber');
cur_set.doors = type_node[0].getAttribute('Doors');
cur_set.car_type_name = type_node[0].getElementsByTagName('Name')[0].childNodes[0].nodeValue;
cur_set.description = type_node[0].getElementsByTagName('Description')[0].childNodes[0].nodeValue;
if (type_node[0].getElementsByTagName('Picture')[0].hasChildNodes()) {
cur_set.picture_url = type_node[0].getElementsByTagName('Picture')[0].childNodes[0].nodeValue;
} else {
cur_set.picture_url = this.noPictureURL;
}
// seting up equipments
equipment_nodes = type_node[0].getElementsByTagName('Equipment');
var code = null;
var name = null;
var amount = null;
var currency = null;
var tax_included = null;
var included = null;
var equipment_arr = new Array();
for (var j = 0; j < equipment_nodes.length; j++ ) {
code = equipment_nodes[j].getAttribute('Code');
cache_node = equipment_nodes[j].getElementsByTagName('Name');
name = this.getTextFromNode(cache_node[0]);
cache_node = equipment_nodes[j].getElementsByTagName('price');
if (cache_node[0].getAttribute('IncludedP') == "t") {
included = true;
} else {
included = false;
}
if (cache_node[0].getAttribute('TaxIncludedP') == "t") {
tax_included = true;
} else {
tax_included = false;
}
cache_node = cache_node[0].getElementsByTagName('Amount');
currency = cache_node[0].getAttribute('currency');
amount = this.getTextFromNode(cache_node[0]);
var equip_obj = new cr_equipment(code , name, amount, currency, tax_included, included);
equipment_arr[j] = equip_obj;
}
cur_set.equipments = equipment_arr;
// layouts
cur_set.layouts = new Array();
layout_nodes = result_nodes[i].getElementsByTagName('Layout');
for (var j = 0; j < layout_nodes.length; j++) {
cur_set.layouts[j] = new cr_layout(layout_nodes[j].getAttribute('Name') , this.getTextFromNode(layout_nodes[j]));
}
// coverages
coverage_nodes = result_nodes[i].getElementsByTagName('Coverage');
cur_set.coverages = new Array();
for (var j = 0; j < coverage_nodes.length; j++) {
code = coverage_nodes[j].getAttribute('Type');
cache_node = coverage_nodes[j].getElementsByTagName('Name');
name = this.getTextFromNode(cache_node[0]);
cache_node = coverage_nodes[j].getElementsByTagName('price');
//code = coverage_nodes[j].getAttribute('Type');
//name = this.getTextFromNode(coverage_nodes[j]);
if (cache_node[0].getAttribute('IncludedP') == "true") {
included = true;
} else {
included = false;
}
if (cache_node[0].getAttribute('TaxIncludedP') == "true") {
tax_included = true;
} else {
tax_included = false;
}
cache_node = cache_node[0].getElementsByTagName('Amount');
currency = cache_node[0].getAttribute('currency');
amount = this.getTextFromNode(cache_node[0]);
cur_set.coverages[j] = new cr_equipment(code, name , amount, currency,tax_included, included);
}
// charges , not all just ratequalifier and promocod yet
charges_node = result_nodes[i].getElementsByTagName('Charges');
cur_set.rateQualifier = charges_node[0].getAttribute('RateQualifier');
cur_set.romotionCode = charges_node[0].getAttribute('PromotionCode');
// booking references
var booking_obj = new cr_bookingReference(null,null,null,null,null);
booking_node = result_nodes[i].getElementsByTagName('BookingReference');
cache_node = booking_node[0].getElementsByTagName('Type');
booking_obj.type = this.getTextFromNode(cache_node[0]);
cache_node = booking_node[0].getElementsByTagName('ID');
booking_obj.idContext = cache_node[0].getAttribute('Context');
booking_obj.id = this.getTextFromNode(cache_node[0]);
cache_node = booking_node[0].getElementsByTagName('DateTime');
booking_obj.dateTime = this.getTextFromNode(cache_node[0]);
cache_node = booking_node[0].getElementsByTagName('URL');
booking_obj.url = this.getTextFromNode(cache_node[0]);
cur_set.bookingReference = booking_obj;
//alert('booking reference = ' + cur_set.bookingReference.type + '| ' + cur_set.bookingReference.id + '| ' + cur_set.bookingReference.idContext + ' ' + cur_set.bookingReference.dateTime + ' ' + cur_set.bookingReference.url);
// supplier information
suppl_node = result_nodes[i].getElementsByTagName('Supplier');
cur_set.supplier_id = suppl_node[0].getAttribute('id');
if ( suppl_node[0].getElementsByTagName('name')[0].hasChildNodes()) {
cur_set.supplier_name = suppl_node[0].getElementsByTagName('name')[0].childNodes[0].nodeValue;
} else {
cur_set.supplier_name = "";
}
cur_set.supplier_icon = suppl_node[0].getElementsByTagName('icon')[0].childNodes[0].nodeValue;
// Get from station
station_node = suppl_node[0].getElementsByTagName('FromStation');
var station_id = station_node[0].getAttribute('code');
var locale_station_id = station_node[0].getAttribute('station_id');
// check if station already exists
from_station = this.getStationByID(station_id);
if (from_station == null) {
// get all station information and create a new station object
var atAirportP = (station_node[0].getAttribute('atAirportP') == "1" ? true : false );
var station_name = this.getTextFromNode(station_node[0].getElementsByTagName('Name')[0]);
var station_addr = this.getTextFromNode(station_node[0].getElementsByTagName('Address')[0]);
from_station = new cr_station(station_id, station_name, station_addr, atAirportP);
// Get station Details
//var url = this.base_url + "get-station-details?cr_id=" + this.from_id + "&cr_id_type=" + this.from_type + "&cr_locale=" + this.locale;
//this.makeRequest(url , 'GET' , from_station.parseXML, from_station.conn_error, from_station.processReqChange );
}
cur_set.fromStation = from_station;
// Get to Station
station_node = suppl_node[0].getElementsByTagName('ToStation');
var station_id = station_node[0].getAttribute('code');
// check if station already exists
to_station = this.getStationByID(station_id);
if (to_station == null) {
// get all station information and create a new station object
var atAirportP = (station_node[0].getAttribute('atAirportP') == "1" ? true : false );
var station_name = this.getTextFromNode(station_node[0].getElementsByTagName('Name')[0]);
var station_addr = this.getTextFromNode(station_node[0].getElementsByTagName('Address')[0]);
to_station = new cr_station(station_id, station_name, station_addr, atAirportP);
// Get station Details
//var url = this.base_url + "get-station-details?cr_id=" + this.to_id + "&cr_id_type=" + this.to_type + "&cr_locale=" + this.locale;
//this.makeRequest(url , 'GET' , to_station.parseXML, to_station.conn_error, to_station.processReqChange );
}
cur_set.toStation = to_station;
price_node = result_nodes[i].getElementsByTagName('Price');
cur_set.currency = price_node[0].getAttribute('currency');
cur_set.price = price_node[0].childNodes[0].nodeValue;
this.result_sets_orig[i] = cur_set;
}
this.result_sets_grouped_sorted = this.grouping('init');
this.sort(this.result_sets_grouped_sorted[0].result_sets , this.sortBy.key, false);
this.display(1);
};
this.conn_error = function () {
//alert("Conn Error!");
locale_alert("form_container" , "Error" , "Conn Error!", 50 , 50 );
};
this.init = function () {
// request results from server
if (document.getElementById("cr_from_station_id").value != "-1" && document.getElementById("cr_from_station_id").value != "") {
var from_id = document.getElementById("cr_from_station_id").value;
var from_type = "station";
} else if (document.getElementById("cr_from_foreigen_id").value != "-1") {
var from_id = document.getElementById("cr_from_foreigen_id").value;
var from_type = "foreigen";
} else if (document.getElementById("ac_region_id").value != "-1") {
var from_id = document.getElementById("ac_region_id").value;
var from_type = "region";
} else if (document.getElementById("ac_state_id").value != "-1") {
var from_id = document.getElementById("ac_state_id").value;
var from_type = "state";
} else if (document.getElementById("ac_country_id").value != "-1") {
var from_id = document.getElementById("ac_country_id").value;
var from_type = "country";
} else {
var from_id = "-1";
var from_type = "none";
}
var to_id = from_id;
var to_type = from_type;
this.from_id = from_id;
this.from_type = from_type;
this.to_id = to_id;
this.to_type = to_type;
this.client_country = getEBI("cr_ref_country_code").value;
//alert("this.ajaxSearchKey.length=" + this.ajaxSearchKey.length + " this.ajaxSearchLoadedP=" + this.ajaxSearchLoadedP);
/*if () {
var url = this.base_url + 'get-cached-results';
var url_search = '?ajax_search_key=' + this.ajaxSearchKey;
this.ajaxSearchLoaded = true;
} else {
*/
var url = this.base_url + 'get-search-results';
//var url = 'http://www.clever-mietwagen.clever-devel.com/car-rental/example-search-ajax-xml';
var url_search = '?cr_from_date.day=' + this.from_day;
url_search += '&cr_from_date.month=' + this.from_month;
url_search += '&cr_from_date.year=' + this.from_year;
url_search += '&cr_from_date.hour=' + this.from_hour;
url_search += '&cr_from_date.minute=' + this.from_minute;
url_search += '&cr_to_date.day=' + this.to_day;
url_search += '&cr_to_date.month=' + this.to_month;
url_search += '&cr_to_date.year=' + this.to_year;
url_search += '&cr_to_date.hour=' + this.to_hour;
url_search += '&cr_to_date.minute=' + this.to_minute;
url_search += '&cr_client_country=' + this.client_country;
url_search += '&cr_from_id=' + this.from_id + '&cr_from_id_type=' + this.from_type;
url_search += '&cr_to_id=' + this.to_id + '&cr_to_id_type=' + this.to_type;
url_search += '&cr_iso_currency=' + this.isoCurrency;
url_search += '&cr_prefs=' + '';
url_search += '&cr_car_size=' + '1';
url_search += '&cr_locale=' + this.locale;
for (var i = 0; i < this.select_car_types.length;i++) {
if (this.select_car_types[i].selected) {
url_search += '&cr_car_types=' + this.select_car_types[i].car_type_id;
}
}
//}
// Check if we are already on a secured (ssl) connection
if (window.location.protocol != 'https:') {
getEBI("cr_search_form").submit();
} else {
this.makeRequest(url + url_search , 'GET' , this.parseXML, this.conn_error, this.processReqChange );
loading_effect(true,"Loading...");
}
};
this.getCountryOptions = function () {
// create apeace of option html
var options = '\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
';
return options;
};
this.display = function (page_number) {
// add togeather peaces of html, each enclosed into a div, where each div displays one group
// loop through all groups and add a div for each
var groups = this.result_sets_grouped_sorted;
//var create_group_html = this.displayGroupCreateHTML();
var create_group_html = "";
var all_results_html = create_group_html + '
';
var start = ((page_number - 1) * this.max_groups);
var end = (start + this.max_groups - 1);
end = (end > (groups.length - 1) ? (groups.length - 1) : end );
for (var i=start;i<=end;i++) {
all_results_html += groups[i].display(groups[i].default_flat_p , page_number);
}
all_results_html += '
';
// trigger after onSearchResults
onSearchResults();
document.getElementById(this.div_id).innerHTML = all_results_html;
this.display_filters();
};
this.displayGroupCreateHTML = function () {
var group_create_html = '
Group Results by this criteria.
';
// inclusivs
var all_results = this.result_sets_orig;
var coverages = new Array();
var coverage_codes = new Array();
for (var i = 0; i < all_results.length;i++) {
var cur_coverages = all_results[i].coverages;
for (var j = 0; j < cur_coverages.length;j++) {
if (!this.arrayExists(coverage_codes , cur_coverages[j].code)) {
coverages[coverages.length] = cur_coverages[j];
coverage_codes[coverage_codes.length] = cur_coverages[j].code;
}
}
}
/* var cov_html = '
';
cov_html += '
Offers with this Inclusivs only:
';
cov_html += '';
//alert ("cov len =" + coverages.length );
for (var i = 0; i < coverages.length; i++) {
cov_html += '
'+coverages[i].name + '
';
cov_html += '';
}
cov_html += '
'
*/
var equipments = new Array();
var equip_codes = new Array();
for (var i = 0; i < all_results.length;i++) {
var cur_equipments = all_results[i].equipments;
for (var j = 0; j < cur_equipments.length;j++) {
if (!this.arrayExists(equip_codes , cur_equipments[j].code)) {
equipments[equipments.length] = cur_equipments[j];
equip_codes[equip_codes.length] = cur_equipments[j].code;
}
}
}
/* var equip_html = '
';
equip_html += '
Offers wich have these extras available:
';
equip_html += '';
//alert ("equip len =" + equipments.length );
for (var i = 0; i < equipments.length; i++) {
equip_html += '
';
// get display div;
document.getElementById(this.div_id).innerHTML = order_html;
document.getElementById("right").style.display = "none";
document.getElementById("cr_customer_country_txt").value = this.client_country;
};
this.newGroup = function () {
// get the information for group creation from the form fields
var orig_result_sets = this.result_sets_orig;
var passenger_count = parseInt(document.getElementsByID(layout_baggages));
var bag_count = parseInt(document.getElementsByID(layout_passengers));
var equip_crt = new Array();
var cov_crt = new Array();
var equips_dom = document.getElementsByID(equip_check);
for (var i = 0 ; i < equips_dom.length; i++) {
if (equips_dom[i].checked) {
equip_crt.pusch(equips_dom.value);
}
}
var cov_dom = document.getElementsByID(cov_check);
for (var i = 0 ; i < cov_dom.length; i++) {
if (cov_dom[i].checked) {
cov_crt.pusch(cov_dom.value);
}
}
var group_result_sets = new Array();
var new_group = new cr_group(null, true , this.max_group_results, this.sortBy.key, false , this);
this.filterGroupResultsPassenger(orig_result_sets, group_result_sets, passenger_count);
this.filterGroupResultsBaggages(group_result_sets, bag_count);
this.filterGroupResultsEquipments(group_results, equip_crt);
this.filterGroupResultsCoverages(group_results, cov_crt);
// create a group and a result set array filtered by this criteria.
// may create the result set first so in case it is empty no group object is created.
var group_name = 'Group ';
var PropVal = 'group';
};
this.getGroupByProperty = function (PropVal) {
var groups = this.result_sets_grouped_sorted;
var check_prop = "null";
var check_prop_2 = "undefined";
if (check_prop == PropVal) {
PropVal = null;
} else if (check_prop_2 == PropVal) {
PropVal = undefined;
}
for (var j=0;j < groups.length;j++) {
// may add the property comparing fuction here
if (PropVal == groups[j].property_value) {
return groups[j];
}
}
};
this.getGroupByID = function (PropVal) {
return this.getGroupByProperty(PropVal);
};
this.getStationByID = function (id) {
var station = null;
for (var i = 0; i < this.allStations.length; i++) {
if (this.allStations[i].id == id) {
station = this.allStations[i];
break;
}
}
return station;
};
this.getResultSetById = function (setId) {
for (var i=0;i