var _gaq = _gaq || [];
 _gaq.push(['_setAccount', 'UA-15585834-1']);
 _gaq.push(['_setDomainName', '.ucuzabilet.com']);
 _gaq.push(['_setAllowAnchor', true]);
 _gaq.push(['_setAllowLinker', true]);
 _gaq.push(['_setAllowHash', false]);
 _gaq.push(['_trackPageview']);

 (function() {
   var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
   ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
 })();


function showHideDiv(divId){
	var currentDiv = document.getElementById(divId);
	if (currentDiv.style.display=="block"){
		currentDiv.style.display="none";
	}else{
		currentDiv.style.display="block"
	}
}




function ChangeComboDisp(objid){
  	var selectedCombo = document.getElementById(objid);
 	var selectedOption = selectedCombo.options[selectedCombo.selectedIndex].value

	var objTableBody = document.getElementById(selectedOption);
		if (objTableBody.style.display =="none"){
			objTableBody.style.display = "block";
		}else if(objTableBody.style.display =="block"){
			objTableBody.style.display = "none";
		}

    for(var x = 0; x < selectedCombo.options.length ; x++){
    	
    	if (selectedCombo.options[x].value!= selectedOption && selectedCombo.options[x].value!=""){
    	
    		var hiddenBody = document.getElementById(selectedCombo.options[x].value);
    		hiddenBody.style.display = "none";
    		
    	}
    
    }
		
}



function ChangeDisplayHideOthers(ObjName,ObjOrd){
var mydivs = [];
var tcount = 0;
var aDivs = document.getElementsByTagName('div');
for (var y = 0; y < aDivs.length; y++) {

	var dname = document.getElementById(ObjName+ y);
	if (dname!= null) {
		mydivs[tcount] =ObjName+ y;	
   		tcount++;
   	}
}
    var strDisplay = "block";
    var objTableBody = document.getElementById(ObjName+ObjOrd);
    if(objTableBody.style.display=="none"){
    objTableBody.style.display = "block";
    }else{
    objTableBody.style.display = "none";
    }
    for (var j=0; j<tcount; j++){
		  if (mydivs[j] != ObjName+ObjOrd){
		  	strDisplay = "none";
		  	objTableBody = document.getElementById(mydivs[j]);
		  	objTableBody.style.display = strDisplay;
		  }
	}
}



function goToLocation(location){
	window.location=location;
}

function showHideDetail(){
	var currentDiv = document.getElementById('searchDetail');
	var motherDiv = document.getElementById('mainForm');
	var linkDiv = document.getElementById('sumLink');
	var detlinkDiv = document.getElementById('detLink');
	
	if (currentDiv.style.display=="block"){
		motherDiv.style.height = '330px';
		currentDiv.style.display="none";
		linkDiv.style.display="block";
		detlinkDiv.style.display="none";
	}else{
		motherDiv.style.height = 'auto';
		currentDiv.style.display="block"
		linkDiv.style.display="none";
		detlinkDiv.style.display="block";
	}
}

function changeFlightType(){
	var motherDiv = document.getElementById('mainForm');
	var returnDate = document.getElementById('External_FlightFareSearch_ReturnDate');
	var returnTime = document.getElementById('External_FlightFareSearch_ArrivalTime');
	var roundTripDiv = document.getElementById('roundTrip');
	var multiLegDiv = document.getElementById('multiLeg');
	var detailDiv = document.getElementById('searchDetail');
	var motherDiv = document.getElementById('mainForm');
	var linkDiv = document.getElementById('sumLink');
	var detlinkDiv = document.getElementById('detLink');
	for (var i=0; i < document.flightForm.External_FlightFareSearch_SearchType.length; i++)
	   {
	   if (document.flightForm.External_FlightFareSearch_SearchType[i].checked)
		  {
			var rad_val = document.flightForm.External_FlightFareSearch_SearchType[i].value;
			if (rad_val =='OneWay'){
				multiLegDiv.style.display="none";
				roundTripDiv.style.display = 'block';
				returnDate.disabled = true;
				returnTime.disabled = true;
				$('#External_FlightFareSearch_ReturnDate').datepicker( "disable" );
			}else if(rad_val =='RoundTrip'){
				multiLegDiv.style.display="none";
				roundTripDiv.style.display = 'block';
				returnDate.disabled = false;
				returnTime.disabled = false;
				$('#External_FlightFareSearch_ReturnDate').datepicker( "enable" );
				if (detailDiv.style.display=="block"){
						detailDiv.style.display="none"
						detlinkDiv.style.display="none";
						linkDiv.style.display="block";
						motherDiv.style.height = '330px';
					}
			}else if(rad_val =='MultiLeg'){
				motherDiv.style.height = 'auto';
				multiLegDiv.style.display="block";
				roundTripDiv.style.display = 'none';
				detailDiv.style.display = "block";
				detlinkDiv.style.display="none";
				linkDiv.style.display="none";
				
			}
		  }
	   }
}



	
	
	
function updateNumberOfPassengersDropdowns(numAdult,numChildren,numSeaman,numSenior,numStudent,numYouth,numInfants) 

 { 

  var maxPassengers = 5;

  var adultDD = document.getElementById('External_FlightFareSearch_NumberOfAdults');

  var childrenDD = document.getElementById('External_FlightFareSearch_NumberOfChilds');

  var seamansDD = document.getElementById('External_FlightFareSearch_NumberOfSeamans');

  var seniorsDD = document.getElementById('External_FlightFareSearch_NumberOfSeniors');

  var studentsDD = document.getElementById('External_FlightFareSearch_NumberOfStudents');

  var youthsDD = document.getElementById('External_FlightFareSearch_NumberOfYouths');

  var infantsDD = document.getElementById('External_FlightFareSearch_NumberOfInfants');

  if (numAdult == null) numAdult = getDDValue(adultDD);

  if (numChildren == null) numChildren = getDDValue(childrenDD);

  if (numSeaman == null) numSeaman = getDDValue(seamansDD);

  if (numSenior == null) numSenior = getDDValue(seniorsDD);

  if (numStudent == null) numStudent = getDDValue(studentsDD);

  if (numYouth == null) numYouth = getDDValue(youthsDD);

  if (numInfants == null) numInfants = getDDValue(infantsDD);

numAdult = parseInt(numAdult);

numChildren = parseInt(numChildren);

numSeaman = parseInt(numSeaman);

numSenior = parseInt(numSenior);

numStudent = parseInt(numStudent);

numYouth = parseInt(numYouth);

numInfants = parseInt(numInfants);

var maxAdult   = maxPassengers-numChildren-numSeaman-numSenior-numStudent-numYouth;

var maxChildren = maxPassengers-numAdult-numSeaman-numSenior-numStudent-numYouth;

if((numAdult+numSeaman+numSenior+numYouth)==0)

{maxChildren = 0;}

var maxSeaman	= maxPassengers-numAdult-numChildren-numSenior-numStudent-numYouth;

var maxSenior	= maxPassengers-numAdult-numChildren-numSeaman-numStudent-numYouth;

var maxStudent= maxPassengers-numAdult-numChildren-numSeaman-numSenior-numYouth;

var maxYouth	= maxPassengers-numAdult-numChildren-numSeaman-numSenior-numStudent;

var allowInfantCount=numAdult+numSeaman+numSenior+numYouth;

var maxInfants = allowInfantCount;

clearDD(adultDD);

clearDD(childrenDD);

clearDD(seamansDD);

clearDD(seniorsDD);

clearDD(studentsDD);

clearDD(youthsDD);

clearDD(infantsDD);

  for (var counter=0; counter<=getMinValue(maxAdult,5); counter++) {

    adultDD[counter] = new Option(counter, counter);

  }

  for (var counter=0; counter<=getMinValue(maxChildren,5); counter++) {

    childrenDD[counter] = new Option(counter, counter);

  }

  for (var counter=0; counter<=getMinValue(maxSeaman,5); counter++) {

    seamansDD[counter] = new Option(counter, counter);

  }

  for (var counter=0; counter<=getMinValue(maxSenior,5); counter++) {

    seniorsDD[counter] = new Option(counter, counter);

  }

  for (var counter=0; counter<=getMinValue(maxStudent,5); counter++) {

    studentsDD[counter] = new Option(counter, counter);

  }

  for (var counter=0; counter<=getMinValue(maxYouth,5); counter++) {

    youthsDD[counter] = new Option(counter, counter);

  }

  for (var counter=0; counter<=maxInfants; counter++) {

    infantsDD[counter] = new Option(counter, counter);

  }

  if (numAdult > maxAdult || numAdult > 5) numAdult = getMinValue(maxAdult,5);

    adultDD.selectedIndex = numAdult;

  if (numChildren > maxChildren || numChildren > 5) numChildren = getMinValue(maxChildren,5);

    childrenDD.selectedIndex = numChildren;

  if (numSeaman > maxSeaman || numSeaman > 5) numSeaman = getMinValue(maxSeaman,5);

    seamansDD.selectedIndex = numSeaman;

  if (numSenior > maxSenior || numSenior > 5) numSenior = getMinValue(maxSenior,5);

    seniorsDD.selectedIndex = numSenior;

  if (numStudent > maxStudent || numStudent > 5) numStudent = getMinValue(maxStudent,5);

    studentsDD.selectedIndex = numStudent;

  if (numYouth > maxYouth || numYouth > 5) numYouth = getMinValue(maxYouth,5);

    youthsDD.selectedIndex = numYouth;

  if (numInfants > maxInfants) numInfants = maxInfants;

    infantsDD.selectedIndex = numInfants;

}


function clearDD(oDropDown){

if (oDropDown == null)

return;

  var	oOptions = oDropDown.options;

  for(var	i=oOptions.length; i>=0; i--){

    oOptions[i]	= null;

  }

}

function getDDValue(oDropDown){

  return oDropDown.options[oDropDown.selectedIndex].value;

}

function getMinValue(p_Value1,p_Value2){

  if (p_Value1>p_Value2)

  {return p_Value2;}

  else

  {return p_Value1;}

}
	
