function checkForm(form, type) {
	
	// pri vyplnem promocode nedelame kontrolu formu
	if (jQ('#promocode').val() != '') {
	    return true;
	}
	
	// pokud prechazime na multiSector, nic nekontrolujeme
	if (type === 'index')  return true;
	// form se odesila a je v poradku
	if (type != 'next' || (checkDestination(form) && checkPreferences(form) && checkPassengersCount(form))) {
		// vracime true, napred odesleme do GA data
		// monitoruje se pro vsechny formulare na hp
		onSubmitFormGATrackEvent(form);
		return true;
	}
	return false;
}

function onReady() {
    if (typeof myLytebox == 'undefined') {
        initLytebox();
    }
	setLyteBox();
    
    // skryvani/zobrazeni Additional preferences
    jQ('#additionalPreferencesToggle').click(function(e) {
        jQ('#additionalPreferences').slideToggle('slow');
        e.preventDefault();
    });

	// skryvani/zobrazeni Availability time - zavisle na checkboxu '#avbPricer' => pak je pricer availabilita
	jQ('#avbPricer').click(function(e) {
        if (jQ(this).is(':checked')) {
            jQ('#defaultPricer').attr('name','pricerPreferenceDisabled');
            jQ(this).attr('name','pricerPreference');
        } else {
            jQ('#defaultPricer').attr('name','pricerPreference');
            jQ(this).attr('name','pricerPreferenceDisabled');
        }
        jQ('#timePreferences').slideToggle('slow');
    });
    
    addDestinationInputMethods();
}

function checkPassengersCount(form) {
	if (getPricerType(form) == 'OFP') return true;
	var field, Message, adults, children, infants, youths, seniors;
	
	if (typeof passengerCountNameADT == 'undefined') adults = 0;
	else adults = parseInt(getCombo(form, passengerCountNameADT));
	if (typeof passengerCountNameYTH == 'undefined') youths = 0;
	else youths = parseInt(getCombo(form, passengerCountNameYTH));
	if (typeof passengerCountNameYCD == 'undefined') seniors = 0;
	else seniors = parseInt(getCombo(form, passengerCountNameYCD));
	
	adults = adults + youths + seniors;
	
	if (typeof passengerCountNameCHD == 'undefined') children = 0;
	else children = parseInt(getCombo(form, passengerCountNameCHD));
	if (typeof passengerCountNameINF == 'undefined') infants = 0;
	else infants = parseInt(getCombo(form, passengerCountNameINF));

  	if (!adults && children) {
  		Message = "Children cannot travel alone!";
		field = getElement(form, passengerCountNameCHD);
  	} 
  	else if (adults < infants) {
  		Message = "Number of infants cannot be higher then number of adult passengers!";
		field = getElement(form, passengerCountNameINF);
  	} 
  	else if (!adults) {
  		Message = "Please select passengers!";
		field = getElement(form, passengerCountNameADT);
  	}
  	else if (9 < (adults + children)) {
  		Message = "Maximal number of passengers has been exceeded!";
		field = getElement(form, passengerCountNameADT);
  	}
  	else {
    	return true;
  	}
	if (Message.length) alert(Message);
	if (field != null) {
		field.focus();
		if (field.type == 'text') field.select();
	}
	return false;
}

function checkPreferences(form) {
	var field, Message;
	var airlines = getElement(form, airlinesName);
	var salePoint = getElement(form, saleLocationName);
	if ((getPricerType(form) == 'SCP') && airlines && (clearContent('', airlines) || !airlines.value.length)) {
		Message = "Choose preferred airline";
		field = airlines;
	} 
	else if(salePoint.options && !salePoint.options[salePoint.selectedIndex].value.length) {
		Message = "Please, select some point of sale!";
		field = salePoint;
	} else {
    	return true;
  	}
	if (Message.length) alert(Message);
	if (field != null) {
		field.focus();
		if (field.type == 'text') field.select();
	}
	return false;
}

function getPricerType(form) {
	var data = getCombo(form, pricerName);
	if (data == false) {
		data = getInput(form, pricerName);
	}
	return data.substring(0, 3); 
}

function datesLimits(form) {
    if (getPricerType(form) == 'OFP') return true;
    var field = null;
    var date1 = getCalValue(0, form);
    var date2 = getCalValue(1, form);
    var journeyType = getRadio(form, journeyTypeName);
    var both = (journeyType == 'RT' || journeyType == 'OJ') ? true : false;
    var param = new Array();
    
    if (date1 < depDateResFrom[0]) {
        param[0] = depDateResFrom[0].getVal('Y-m-d');
        Message = sprintf('Departure date cannot be before %0!', param);
        field = getElement(form, depDayName[0]);
    }
    else if (date1 > depDateResTo[0]) {
        param[0] = depDateResTo[0].getVal('Y-m-d');
        Message = sprintf('Departure date cannot be after %0!', param);
        field = getElement(form, depDayName[0]);
    }
    else if (both && date2 < depDateResFrom[1]) {
        param[0] = depDateResFrom[1].getVal('Y-m-d');
        Message = sprintf('Return date cannot be before %0!', param);
        field = getElement(form, depDayName[1]);
    }
    else if (both && date2 > depDateResTo[1]) {
        param[0] = depDateResTo[1].getVal('Y-m-d');
        Message = sprintf('Return date cannot be after %0!', param);
        field = getElement(form, depDayName[1]);
    }
    else if (both && date1 > date2) {
        Message = 'Returning date cannot be before departure date!';
        field = getElement(form, depDayName[1]);
    }
    else {
        return true;
    }
  
    if (Message.length) alert(Message);
    if (field != null) {
        field.focus();
        field.select();
    }
    return false;
}

function validDates(form) {
  if (getCombo(form, pricerName) == 'OFP') return true;
  var Message, field;
  var day1value = getInput(form, depDayName[0]);
  var month1value = depMonthNameOptions[0][getCombo(form, depMonthSelName[0])];
  var day2value = getInput(form, depDayName[1]);
  var month2value = depMonthNameOptions[1][getCombo(form, depMonthSelName[1])];
  var journeyType = getRadio(form, journeyTypeName);
  var both = (journeyType == 'RT' || journeyType == 'OJ') ? true : false;
  
  var year1 = guessYear(day1value, month1value);
  var year2 = guessYear(day2value, month2value);

  if (month1value < 1 || month1value > 12) {
  	field = getElement(form, depMonthSelName[0]); 
  	Message = "Departure month is out of range!"; 
  } else if (both && (month2value < 1 || month2value > 12)) {
  	field = getElement(form, depMonthSelName[1]);
  	Message = "Returning month is out of range!"; 
  } else if (day1value < 1 || day1value > DayEnd(month1value, year1)) {
  	field = getElement(form, depDayName[0]);
  	Message = "Departure day is out of range!"; 
  } else if (both && (day2value < 1 || day2value > DayEnd(month2value, year2))) {
  	field = getElement(form, depDayName[1]);
  	Message = "Returning day is out of range!"; 
  } else return true;

  if (Message.length) alert(Message);
  if (field != null) {
    field.focus();
    field.select();
  }
  return false;
}

//kontrola datumu odletu a priletu
function checkDates(form) {
    if (getPricerType(form) == 'OFP') return true;
    var date1 = getCalValue(0, form);
    var date2 = getCalValue(1, form);
    var Message = '';
    var field = null;
    var journeyType = getRadio(form, journeyTypeName);
    var both = (journeyType == 'RT' || journeyType == 'OJ') ? true : false;
    
    if(!date1) {
        Message = "Departure day is out of range!"; 
        field = getElement(form, depDayName[0]);
    }
    else if(both && !date2) {
        Message = "Returning day is out of range!";  
        field = getElement(form, depDayName[1]);
    }
    else {
        return true;
    }

    if (Message.length) alert(Message);
    if (field != null) {
        field.focus();
        field.select();
    }
    return false;
}

//kontrola destinaci
function checkDestination(form) {
  var from1 = getElement(form, depDestinationName[0]);
  var to1 = getElement(form, arrDestinationName[0]);
  var from2 = getElement(form, depDestinationName[1]);
  var to2 = getElement(form, arrDestinationName[1]);
  var journeyType = getRadio(form, journeyTypeName);
  var Message = '';
  var field = null;

  if (journeyType == 'RT' || journeyType == 'OW') from2 = to2 = null;
  
  if (from1 && from1.type == 'text' && from1.value.length < 3) {
    Message = "Please fill in a valid Departing FROM!";  
    field = from1;
  }
  else if (to1 && to1.type == 'text' && to1.value.length < 3) {
    Message = "Please fill in a valid Departing TO!";  
    field = to1;
  }
  else if (from2 && from2.type == 'text' && from2.value.length < 3) {
    Message = "Please fill in a valid Departing FROM 2!"; 
    field = from2;
  }
  else if (to2 && to2.type == 'text' && to2.value.length < 3) {
    Message = "Please fill in a valid Departing TO 2!"; 
    field = to2;
  }
  else if (from1 && to1 != null && (from1.value == to1.value) ) {
    Message = "Departing FROM and TO must be different!"; 
    field = from2;
  }
  else if (from1 && from1.type == 'select-one' && to1 != null && to1.type == 'select-one' && from1.options[from1.selectedIndex].value == to1.options[to1.selectedIndex].value) {
    Message = "Departing FROM and TO must be different!"; 
    field = from1;
  }
  else if (from2 && to2 && (from2.value == to2.value)) {
    Message = "Returning FROM and TO must be different!"; 
    field = from2;
  }
  else return true;

  if (Message.length) alert(Message);
  if (field != null) {
    field.focus();
    if (field.type == 'text') field.select();
  }
  return false;
}

function switchHidden(what) {
	if (journeyTypeAction[what] != undefined) {
		return _submitFormButton(getFormByName(formName), journeyTypeAction[what][0], journeyTypeAction[what][1], journeyTypeAction[what][2]);
	}
	switch(what) {
		case 'OW':
			iterateSwitch('depIataRow', 0, 2, 3);
			iterateSwitch('calendarDiv', 0, 1, 2);
			reLabel('from1suffix', '');
			reLabel('to1suffix', '');
			iterateSwitch('returnDate', 0, 1, 2);
			iterateSwitch('returnTime', 0, 1, 2);
			/* additional preferences */
			jQ('#apArrivalTime').hide();
			jQ('#apArrivalTime select').attr('disabled','disabled');
			break;
		case 'RT':
			iterateSwitch('depIataRow', 0, 2, 3);
			iterateSwitch('calendarDiv', 1, 1, 2);
			reLabel('from1suffix', '');
			reLabel('to1suffix', '');
			iterateSwitch('returnDate', 1, 1, 2);
			iterateSwitch('returnTime', 1, 1, 2);
			/* additional preferences */
			jQ('#apArrivalTime').show();
			jQ('#apArrivalTime select').removeAttr('disabled');
			break;
		case 'OJ':
			iterateSwitch('depIataRow', 1, 2, 3);
			iterateSwitch('calendarDiv', 1, 1, 2);
			reLabel('from1suffix', "&nbsp;1");
			reLabel('to1suffix', "&nbsp;1");
			iterateSwitch('returnDate', 1, 1, 2);
			iterateSwitch('returnTime', 1, 1, 2);
			setPreferenceCombo(null, 'ONP|SCP'); //nelze ONP a SCP
			/* additional preferences */
			jQ('#apArrivalTime').show();
			jQ('#apArrivalTime select').removeAttr('disabled');
			break;
		case 'prefPricer':
			setJourney(); // muze prenastavit vybranou hodnotu v combu ceniku
			setPreferenceCombo(); //resi korektni zafungovani po pripadnem prenastaveni comba
			/* additional preferences */
			jQ('#apArrivalTime').show();
			jQ('#apArrivalTime select').removeAttr('disabled');
			break;
	}
}

function reLabel(elName, val) {
	if (!is.dom) return;
	var el = document.getElementById(elName);
	if (el) el.innerHTML = val;
}

function setPreferenceCombo(wanted, unwanted) {
	var test, m, i;
	var uwpole = new Array();
	var combo = document.getElementById('prefPricer');
	if (!combo) return;
	var actual = getPricerType(combo.form);
	actual = actual.substring(0, 3);
	if (!wanted && !unwanted) wanted = actual;
	else if (!wanted && unwanted) {
		uwpole = unwanted.split('|');
		test = true;
		for (i = 0; i < uwpole.length; i++) {
			if (actual == uwpole[i]) {
				test = false;
				break;
			}
		}
		if (test) { //nothing to change
			switchVisibility('depTimes', (actual == 'AVB') ? 1 : 0);
			return;
		}
	}
	
	if (!combo.type || (combo.type != 'select-one')) {
		switchVisibility('depTimes', (actual == 'AVB') ? 1 : 0);
		return;
	}
	var found = '';
	for (m = 0; m < combo.options.length; m++) {
		test = true;
		for (i = 0; i < uwpole.length; i++) {
			if (combo.options[m].value.substring(0, 3) == uwpole[i]) {
				test = false;
				break;
			}
		}
		if (test) {
			if (!wanted || (combo.options[m].value.substring(0, 3) == wanted)) {
				found = combo.options[m].value;
				wanted = combo.options[m].value.substring(0, 3);
				break;				
			}
		}
	}
	if (wanted != actual) {
		if (found != '') combo.value = found;
		else combo.value = combo.options[0].value;
	}
	actual = getPricerType(combo.form);
	actual = actual.substring(0, 3);
	switchVisibility('depTimes', (actual == 'AVB') ? 1 : 0);
}

function setJourney() {
	var combo = document.getElementById('prefPricer');
	if (!combo) return;
	var actual = getPricerType(combo.form);
	var changed = false;
	
	if (actual == 'OFP') {
		iterateSwitch('journeyTypeOJ', 0, 1, 2);
		switchVisibility('depDates', 0);
		switchVisibility('depCalendars', 0);
		switchVisibility('depTimes', 0);
		iterateSwitch('depIataRow', 0, 2, 3);
		reLabel('from1suffix', '');
		reLabel('to1suffix', '');
		iterateSwitch('depAirlines', 0, 1, 4);
		iterateSwitch('depClass', 0, 1, 4);
		iterateSwitch('depPassengers', 0, 1, 8);
		changed = setRadio(journeyTypeName, 'RT', 'OJ'); //set "roundTrip" only if "other" is checked!
	} 
	else if (actual == 'ONP') { //|| actual == 'MSP') {
		iterateSwitch('journeyTypeOJ', 1, 1, 2);
		switchVisibility('depDates', 1);
		switchVisibility('depCalendars', 1);
		iterateSwitch('depAirlines', 1, 1, 4);
		iterateSwitch('depClass', 1, 1, 4);
		iterateSwitch('depPassengers', 1, 1, 8);
		changed = setRadio(journeyTypeName, 'RT', 'OJ'); //set "roundTrip" only if "other" is checked!
	} 
	else if (actual == 'SCP') {
		iterateSwitch('journeyTypeOJ', 1, 1, 2);
		switchVisibility('depDates', 1);
		switchVisibility('depCalendars', 1);
		iterateSwitch('depAirlines', 1, 1, 4);
		iterateSwitch('depClass', 1, 1, 4);
		iterateSwitch('depPassengers', 1, 1, 8);
		changed = setRadio(journeyTypeName, 'RT', 'OJ'); //set "roundTrip" only if "other" is checked!
	} 
	else {
		iterateSwitch('journeyTypeOJ', 1, 1, 2);
		switchVisibility('depDates', 1);
		switchVisibility('depCalendars', 1);
		iterateSwitch('depAirlines', 1, 1, 4);
		iterateSwitch('depClass', 1, 1, 4);
		iterateSwitch('depPassengers', 1, 1, 8);
	}
	
	if (changed) {
		switchHidden('RT');
	}
}

function copyDestComboData(partId) {
    var el1 = document.getElementById('destSelect_'+partId);
    var el2 = document.getElementById('destInput_'+partId);
    el2.value = el1.options[el1.selectedIndex].text; 
}

function switchDestCombo(partId) {
    var el1 = document.getElementById('destSelect_'+partId);
    var el2 = document.getElementById('destInput_'+partId);
    if (el2.style.display == 'none') {
        copyDestComboData(partId);
        //el1.disabled = true;
        //el2.disabled = false;
        el1.style.display = 'none';
        el2.style.display = '';
    }
}

//funkce z click4sky, ktera meni comboboxy na zaklade odletoveho letiste
function refresh_airports(first_select, second_select, values) {
	var j, i, oOption, textnode;
	if (first_select.options) {
		var second_length = second_select.length;
		var second_value = second_select.options[second_select.selectedIndex].value;
		for(j=second_length-1; j >= 1; j--) {
			second_select.remove(j);
		}
		if (first_select.options[first_select.selectedIndex].value == 'PRG') {
			for(i=0; i < values.length; i++) {
				if (values[i][0] != 'PRG') {
					oOption = document.createElement('OPTION');
					second_select.appendChild(oOption);
					oOption.setAttribute('value', values[i][0]);
					textnode = document.createTextNode(values[i][1]);
					oOption.appendChild(textnode);
					if (values[i][0] == second_value) second_select.options[second_select.length-1].selected = true;
				}
			}
		} else {
			for(i=0; i < values.length; i++) {
				if (values[i][0] == 'PRG') {
					oOption = document.createElement('OPTION');
					second_select.appendChild(oOption);
					oOption.setAttribute('value', values[i][0]);
					textnode = document.createTextNode(values[i][1]);
					oOption.appendChild(textnode);
					break;
				}
			}
		}
	} 
}

/* ***************************** SPECIALNI NABIDKY ***************** */

function onReadySpecialOffer() {
	urlHalves = actionLink.split('?');
	initLoading('short');
}

function getAllSpecialOffer() {
	urlHalves = actionLink.split('?');
	initLoading('full');
}


/* AJAX funkce pro nacitani letu */

// GLOBALNI PROMENNE

var aTimers = new Array();
var extQueryStr = parseURL();
var urlHalves = '';
var jsHost = (("https:" == document.location.protocol) ? "https://" : "http://");
var sUrlPathOffer = jsHost + window.location.hostname + "/" + extQueryStr + "/ajaxSpecialOfferList.php";
var nTimeoutDelay = 60000;

var takeResultStatus = "";
var takeResultNextPageStatus = "";

// Zpusob trideni PRICE, NAME, RATING;
var sSortingMode = "PRICE";
var sSortingOrder = "ASC";

var nMaxRequestCount = 3;
var nRequestCount = 0;

var errorMessage = "";

// FUNKCE

// Inicializace nacitani.
function initLoading(type) {
  // Inicializace timeru pro prevenci "zatuhnuti" nacitani.
  aTimers["timeoutCheck"] = setTimeout("stopLoading()", nTimeoutDelay);
  requestData(0, type);
}

function stopLoading() {
  // Vypnuti timeru pro prevenci "zatuhnuti" nacitani.
  try {
    clearTimeout(aTimers["timeoutCheck"]);
  } catch(eException) {
  }
  
}

function requestData(takeResultStatus, type) {
  	var sParameters = "";
  	
  	// Reset timeru pro prevenci "zatuhnuti" nacitani.
  	try {
		clearTimeout(aTimers["timeoutCheck"]);
  	} catch(eException) {}
  	
  	aTimers["timeoutCheck"] = setTimeout("stopLoading()", nTimeoutDelay);
	
	sParameters = "specOffType=" + type + "&" + urlHalves[1];
	
	
  	if (takeResultStatus != 0) {
  		sParameters = "getResult=" + takeResultStatus + "&" + sParameters;
  	}
  	
  	callAjaxSpecialOffer(sParameters, type);
  	
}

// nacteni nabidek pres ajax a zapis do daneho containeru
function callAjaxSpecialOffer(sQueryStr, type) {

  	var sReplyData = null;
  	var sDivContainer = "#specialOffersContainer";
  	var sDivRealContainer = "#realSpecialOfferContainer"; // kontainer pro SPO na vrstve
  	var sWaitingContainer = "#specialOfferWaiting";
  	var sAllOffersLink = "#spoAllOffersLink";
  	var error = null;
  	
  	if (type == 'full') {
  	    sDivContainer = "#lbIframe";
  	    sWaitingContainer = "#loadingBox_container";
      }
	
	jQ(sWaitingContainer).show();
	
  	jQ.ajax({
    	type: "GET",
    	async: true,
    	url: sUrlPathOffer,
    	data: sQueryStr,
    	dataType: "xml",
    
    	success: function(replyData) {
    	    
    	    // Pokud je na ajaxove strance chyba
			var error = jQ(replyData).find('/root/error');
			var errorMessage = jQ(error).text();
			
			// pokud vyprsela session a mam provest redirect
			if (errorMessage.length > 0 && errorMessage == 'SESSION_EXPIRED_MAKE_INDEX_REDIRECT') {
			    var jsHost = (("https:" == document.location.protocol) ? "https://" : "http://");
			    var redirectUrl = jsHost + window.location.hostname + '/?error=expired';
			    stopLoading();
			    showLoadingBox(false);
			    window.location.href = redirectUrl;
			    return false;
			}
    	    
         	// vraceni obsahu description
     		sReplyData = jQ(replyData).find('/root/page/description').text();
         	takeResultStatus = jQ(replyData).find('/root/page/takeResults').text();
         	takeResultNextPageStatus = jQ(replyData).find('/root/page/takeResultsNextPage').text();
         	
         	if (sReplyData != "") {
         		if (jQ(sDivRealContainer).size()) {
         		    jQ(sDivRealContainer).append(sReplyData);
         		} else {
         		    jQ(sDivContainer).append(sReplyData);
         	    }
         		jQ(sAllOffersLink).show("blind", { direction: "horizontal" }, 50);
         	}
         	
     		// Pokud je na ajaxove strance chyba, tak ji zobrazim na standardnim miste.
			if (errorMessage.length >= 1) { 
				stopLoading();
			}
			
			if (type == 'full' && takeResultNextPageStatus != "" && takeResultNextPageStatus != null) {
	     	    // pri nextPage hodnote muzeme zobrazit link pro dalsi nacteni
	     	    setTimeout('requestData(' + takeResultNextPageStatus + ', "' + type + '")', takeResultNextPageStatus*400 ); // TODO:vylepsit podminku pro prodluzovani
	     	    
	     	} else if (takeResultStatus != "" && takeResultStatus != null) {
				 setTimeout('requestData(' + takeResultStatus + ', "' + type + '")', takeResultStatus*400 ); // TODO:vylepsit podminku pro prodluzovani
	     	} else {
                jQ(sWaitingContainer).hide();
            }
            
		} ,
	   
	   	error: function(xmlObject, errorMsg, exception) {
			jQ(sWaitingContainer).hide();
	   	} 
	});

}

function showPassengers(id) {
    jQ("#" + id).toggle("slide", { direction: "up" }, 500);
    
}

/* FOR DELETE
function setAdultPassenger() {
    var selectedValue = jQ("#passengersTotal :selected").val();
    jQ("#passengersContainer select").each(function() {
        jQ(this).val(0);
    });
    jQ("#numberOfPassenger_ADTCount").val(selectedValue);
    
}
function setAdultPassenger(formIndex) {
    var selectedValue = jQ("#passengersTotal" + formIndex + " :selected").val();
    jQ("#passengersContainer" + formIndex + " select").each(function() {
        jQ(this).val(0);
    });
    jQ("#numberOfPassenger_ADTCount" + formIndex).val(selectedValue);
}
*/

function summarizeAllPassengers(formIndex) {

    // zjistime, jestli je dodan index formu (pokud je form vicekrat na strance, pouzijeme danou ciselnou radu ID elementu = tier)
    if (formIndex == undefined || formIndex == "" || isNaN(formIndex)) {
        tier = '';
    }
    else {
        tier = formIndex;
    }

    var totalCount = 0;
    jQ("#passengersContainer" + tier + " select").each(function() {
        totalCount += parseInt(jQ(this).val(), 10);
    });
    
    if (totalCount > 9) {
        alert('Maximal number of passengers has been exceeded!' + ' ' +'Your booking can be made for maximum 9 passengers.');
        jQ("#passengersContainer" + tier + " select").each(function() {
            if (jQ(this).attr('id') == 'numberOfPassenger_ADTCount' + tier) {
                totalCount = parseInt(jQ(this).val(), 10);
            } else {
                jQ(this).val(0);
            }
        });
    }

    jQ("#passengersTotal" + tier).val(totalCount);

}

function switchFwJourneyType(input, id) {
    if (input.checked) {
        jQ("#fwJourneyType_" + id).val('OW');
        jQ("#fwReturnDateLabel_" + id).hide();
        jQ("#fwReturnDate_" + id).hide();
    } else {
        jQ("#fwJourneyType_" + id).val('RT');
        jQ("#fwReturnDateLabel_" + id).show();
        jQ("#fwReturnDate_" + id).show();
    }
}

/** 
 * ziska IATA kod destinace ze stringu, nebo vrati cely string pokud neni
 */
function getAirportCode (inputName, form) {
	inputVal = form[inputName].value.match(/\((.*)\)$/);
	
	if (inputVal === null) {
		return form[inputName].value;
	}
	return inputVal[1];
}

/**
 * send picked data with Track Event
 */
function onSubmitFormGATrackEvent (form) {
	// current form
	aagGaq.callEvent('pick','search_form_departure',form.fullDate0.value);
	aagGaq.callEvent('pick','search_form_return',form.fullDate1.value);
	aagGaq.callEvent('pick','most_wanted_destination',getAirportCode('arr0', form)); // GA AAG Destinace, pouze kam
	aagGaq.callEvent('pick','most_wanted_citypair',getAirportCode('dep0', form) + '-' + getAirportCode('arr0', form)); // GA AAG CP, pouze za prvni

	var keys = Array('total_passengers','ADTCount','YTHCount','CHDCount', 'YCDCount', 'INFCount');
	len=keys.length;

	for (var num=0;num<len;num++) {
		if (typeof(form[keys[num]]) !== 'undefined' && form[keys[num]].value > 0) {
			aagGaq.callEvent('pick','search_form_'+keys[num],form[keys[num]].value);
		}
	}
}

