Jetabroad.AffiliateId = 'CAAU';

Jetabroad.SearchButtonUri = 'http://www.jetabroad.com.au/static/affiliate/canonball/CAAU/button.jpg';
Jetabroad.CalendarUri = 'http://www.jetabroad.com.au/static/affiliate/canonball/CAAU/calendar.gif';

Jetabroad.Uri = 'http://www.jetabroad.com.au';

Jetabroad.RenderCannonball('cannonballForm');

jQuery('#jcDepartFromTextBox').wrap('<div class="inputDepartBg" />');
jQuery('#jcArriveIntoTextBox').wrap('<div class="inputArriveBg" />');

jQuery('#jcDepartFromError').html('Enter a departure city');
jQuery('#jcArriveIntoError').html('Enter an arrival city');

jQuery('.inputArriveBg').parent().attr('id','jcReturnPortPanel');

jQuery('.inputArriveBg').append('<div id="clearArrive"></div>');
jQuery('.inputDepartBg').append('<div id="clearDepart"></div>');

jQuery('#clearArrive').click(function(){
	jQuery("#jcArriveIntoTextBox").val("");	
	jQuery('#jcArriveIntoError').css('display','block');
	jQuery('#jcArriveIntoTextBox').focus();
});

jQuery('#clearDepart').click(function(){
	jQuery("#jcDepartFromTextBox").val("");	
	jQuery('#jcDepartFromError').css('display','block');
	jQuery('#jcDepartFromTextBox').focus();
});

jQuery("#jcDepartFromTextBox").blur(function(){  
        if (jQuery("#jcDepartFromTextBox").val() == "") 
            jQuery('#jcDepartFromError').css('display','block'); 
}); 

jQuery("#jcArriveIntoTextBox").blur(function(){ 
        if (jQuery("#jcArriveIntoTextBox").val() == "") 
            jQuery('#jcArriveIntoError').css('display','block'); 
}); 


jQuery('#jcDepartFromTextBox').focus(function(){
	jQuery('#jcDepartFromError').css('display','none');
	
});

jQuery('#jcArriveIntoTextBox').focus(function(){
	jQuery('#jcArriveIntoError').css('display','none');
	
});


jQuery('#jcDepartFromError').click(function(){
	jQuery('#jcDepartFromError').css('display','none');
	jQuery('#jcDepartFromTextBox').focus();
});

jQuery('#jcArriveIntoError').click(function(){
	jQuery('#jcArriveIntoError').css('display','none');
	jQuery('#jcArriveIntoTextBox').focus();
});


jQuery('<div id="clearDepart2"></div>').insertBefore('#jcLeg1DepartFromTextBox');
jQuery('<div id="clearDepart3"></div>').insertBefore('#jcLeg2DepartFromTextBox');
jQuery('<div id="clearDepart4"></div>').insertBefore('#jcLeg3DepartFromTextBox');

jQuery('<div id="clearArrive2"></div>').insertBefore('#jcLeg1ArriveIntoTextBox');
jQuery('<div id="clearArrive3"></div>').insertBefore('#jcLeg2ArriveIntoTextBox');
jQuery('<div id="clearArrive4"></div>').insertBefore('#jcLeg3ArriveIntoTextBox');

jQuery('<div id="clearStopover"></div>').insertBefore('#jcStopoverTextBox');

/*** stopover*/
jQuery('#clearStopover').click(function(){
	jQuery("#jcStopoverTextBox").val("");	
	jQuery('#jcStopoverError').css('display','block');
	jQuery('#jcStopoverTextBox').focus();
});



jQuery("#jcStopoverTextBox").blur(function(){  
        if (jQuery("#jcStopoverTextBox").val() == "") 
            jQuery('#jcStopoverError').css('display','block'); 
}); 




jQuery('#jcStopoverTextBox').focus(function(){
	jQuery('#jcStopoverError').css('display','none');
	
});



jQuery('#jcStopoverError').click(function(){
	jQuery('#jcStopoverError').css('display','none');
	jQuery('#jcStopoverTextBox').focus();
});




/*** multicity 1*/
jQuery('#clearArrive2').click(function(){
	jQuery("#jcLeg1ArriveIntoTextBox").val("");	
	jQuery('#jcLeg1ArriveIntoError').css('display','block');
	jQuery('#jcLeg1ArriveIntoTextBox').focus();
});

jQuery('#clearDepart2').click(function(){
	jQuery("#jcLeg1DepartFromTextBox").val("");	
	jQuery('#jcLeg1DepartFromError').css('display','block');
	jQuery('#jcLeg1DepartFromTextBox').focus();
});

jQuery("#jcLeg1DepartFromTextBox").blur(function(){  
        if (jQuery("#jcLeg1DepartFromTextBox").val() == "") 
            jQuery('#jcLeg1DepartFromError').css('display','block'); 
}); 

jQuery("#jcLeg1ArriveIntoTextBox").blur(function(){ 
        if (jQuery("#jcLeg1ArriveIntoTextBox").val() == "") 
            jQuery('#jcLeg1ArriveIntoError').css('display','block'); 
}); 


jQuery('#jcLeg1DepartFromTextBox').focus(function(){
	jQuery('#jcLeg1DepartFromError').css('display','none');
	
});

jQuery('#jcLeg1ArriveIntoTextBox').focus(function(){
	jQuery('#jcLeg1ArriveIntoError').css('display','none');
	
});


jQuery('#jcLeg1DepartFromError').click(function(){
	jQuery('#jcLeg1DepartFromError').css('display','none');
	jQuery('#jcLeg1DepartFromTextBox').focus();
});

jQuery('#jcLeg1ArriveIntoError').click(function(){
	jQuery('#jcLeg1ArriveIntoError').css('display','none');
	jQuery('#jcLeg1ArriveIntoTextBox').focus();
});

/*** multicity 2*/
jQuery('#clearArrive3').click(function(){
	jQuery("#jcLeg2ArriveIntoTextBox").val("");	
	jQuery('#jcLeg2ArriveIntoError').css('display','block');
	jQuery('#jcLeg2ArriveIntoTextBox').focus();
});

jQuery('#clearDepart3').click(function(){
	jQuery("#jcLeg2DepartFromTextBox").val("");	
	jQuery('#jcLeg2DepartFromError').css('display','block');
	jQuery('#jcLeg2DepartFromTextBox').focus();
});

jQuery("#jcLeg2DepartFromTextBox").blur(function(){  
        if (jQuery("#jcLeg2DepartFromTextBox").val() == "") 
            jQuery('#jcLeg2DepartFromError').css('display','block'); 
}); 

jQuery("#jcLeg2ArriveIntoTextBox").blur(function(){ 
        if (jQuery("#jcLeg2ArriveIntoTextBox").val() == "") 
            jQuery('#jcLeg2ArriveIntoError').css('display','block'); 
}); 


jQuery('#jcLeg2DepartFromTextBox').focus(function(){
	jQuery('#jcLeg2DepartFromError').css('display','none');
	
});

jQuery('#jcLeg2ArriveIntoTextBox').focus(function(){
	jQuery('#jcLeg2ArriveIntoError').css('display','none');
	
});


jQuery('#jcLeg2DepartFromError').click(function(){
	jQuery('#jcLeg2DepartFromError').css('display','none');
	jQuery('#jcLeg2DepartFromTextBox').focus();
});

jQuery('#jcLeg2ArriveIntoError').click(function(){
	jQuery('#jcLeg2ArriveIntoError').css('display','none');
	jQuery('#jcLeg2ArriveIntoTextBox').focus();
});


/*** multicity 3*/
jQuery('#clearArrive4').click(function(){
	jQuery("#jcLeg3ArriveIntoTextBox").val("");	
	jQuery('#jcLeg3ArriveIntoError').css('display','block');
	jQuery('#jcLeg3ArriveIntoTextBox').focus();
});

jQuery('#clearDepart4').click(function(){
	jQuery("#jcLeg3DepartFromTextBox").val("");	
	jQuery('#jcLeg3DepartFromError').css('display','block');
	jQuery('#jcLeg3DepartFromTextBox').focus();
});

jQuery("#jcLeg3DepartFromTextBox").blur(function(){  
        if (jQuery("#jcLeg3DepartFromTextBox").val() == "") 
            jQuery('#jcLeg3DepartFromError').css('display','block'); 
}); 

jQuery("#jcLeg3ArriveIntoTextBox").blur(function(){ 
        if (jQuery("#jcLeg3ArriveIntoTextBox").val() == "") 
            jQuery('#jcLeg3ArriveIntoError').css('display','block'); 
}); 


jQuery('#jcLeg3DepartFromTextBox').focus(function(){
	jQuery('#jcLeg3DepartFromError').css('display','none');
	
});

jQuery('#jcLeg3ArriveIntoTextBox').focus(function(){
	jQuery('#jcLeg3ArriveIntoError').css('display','none');
	
});


jQuery('#jcLeg3DepartFromError').click(function(){
	jQuery('#jcLeg3DepartFromError').css('display','none');
	jQuery('#jcLeg3DepartFromTextBox').focus();
});

jQuery('#jcLeg3ArriveIntoError').click(function(){
	jQuery('#jcLeg3ArriveIntoError').css('display','none');
	jQuery('#jcLeg3ArriveIntoTextBox').focus();
});


/*** depart and return dates ***/
jQuery('#jcDepartDayDropDownList').parent().attr('id','jcDepartDateTimePanel');
jQuery('#jcDepartDateTimePanel').prepend('<span id="departDateInput">Depart Date</span>'); 
jQuery('#jcReturnDateTimePanel').prepend('<span id="returnDateInput">Return Date</span>'); 

jQuery('#jcDepartDayDropDownList').change(function() {
	ddate1 = jQuery('#jcDepartDayDropDownList').val();
	ddate2 = jQuery('#jcDepartMonthDropDownList').val();
  	jQuery('#departDateInput').html(ddate1 + ' ' + ddate2).css('color','#000000');;
});

jQuery('#jcReturnDayDropDownList').change(function() {
	ddate1 = jQuery('#jcReturnDayDropDownList').val();
	ddate2 = jQuery('#jcReturnMonthDropDownList').val();
  	jQuery('#returnDateInput').html(ddate1 + ' ' + ddate2).css('color','#000000');;
});


/**** stopover date */
jQuery('<span id="stopoverDateInput">Enter Stopover Departure Date</span>').insertBefore('#jcStopoverDayDropDownList');

jQuery('#jcStopoverDayDropDownList').change(function() {
	ddate1 = jQuery('#jcStopoverDayDropDownList').val();
	ddate2 = jQuery('#jcStopoverMonthDropDownList').val();
  	jQuery('#stopoverDateInput').html(ddate1 + ' ' + ddate2).css('color','#000000');;
});



/*** depart and return dates multicity 1 ***/
jQuery('#jcLeg1DayDropDownList').parent().attr('id','jcLeg1DateDiv');
jQuery('#jcLeg1DateDiv').prepend('<span id="jcLeg1DateDivInput">Enter Depart Date</span>'); 

jQuery('#jcLeg1DayDropDownList').change(function() {
	ddate1 = jQuery('#jcLeg1DayDropDownList').val();
	ddate2 = jQuery('#jcLeg1MonthDropDownList').val();
  	jQuery('#jcLeg1DateDivInput').html(ddate1 + ' ' + ddate2).css('color','#000000');;
});


/*** depart and return dates multicity 2 ***/
jQuery('#jcLeg2DayDropDownList').parent().attr('id','jcLeg2DateDiv');
jQuery('#jcLeg2DateDiv').prepend('<span id="jcLeg2DateDivInput">Enter Depart Date</span>'); 

jQuery('#jcLeg2DayDropDownList').change(function() {
	ddate1 = jQuery('#jcLeg2DayDropDownList').val();
	ddate2 = jQuery('#jcLeg2MonthDropDownList').val();
  	jQuery('#jcLeg2DateDivInput').html(ddate1 + ' ' + ddate2).css('color','#000000');;
});

/*** depart and return dates multicity 3 ***/
jQuery('#jcLeg3DayDropDownList').parent().attr('id','jcLeg3DateDiv');
jQuery('#jcLeg3DateDiv').prepend('<span id="jcLeg3DateDivInput">Enter Depart Date</span>'); 

jQuery('#jcLeg3DayDropDownList').change(function() {
	ddate1 = jQuery('#jcLeg3DayDropDownList').val();
	ddate2 = jQuery('#jcLeg3MonthDropDownList').val();
  	jQuery('#jcLeg3DateDivInput').html(ddate1 + ' ' + ddate2).css('color','#000000');;
});


/**/
jQuery('#jcLeg1DepartFromTextBox').parent().attr('id','jcLeg1DepartDiv');
jQuery('#jcLeg2DepartFromTextBox').parent().attr('id','jcLeg2DepartDiv');
jQuery('#jcLeg3DepartFromTextBox').parent().attr('id','jcLeg3DepartDiv');

jQuery('#jcLeg1ArriveIntoTextBox').parent().attr('id','jcLeg1ReturnDiv');
jQuery('#jcLeg2ArriveIntoTextBox').parent().attr('id','jcLeg2ReturnDiv');
jQuery('#jcLeg3ArriveIntoTextBox').parent().attr('id','jcLeg3ReturnDiv');

jQuery('#jcStopoverTextBox').parent().attr('id','jcStopover1Div');


/***/
jQuery('#jcPassengersPanel').prepend('<div class="jcSegmentHeader">Passengers</div>');
	 
	 
jQuery('#jcClassDropDownList').parent().attr('id','jcClassDropDownPanel');

/****** drop down styling ****/

/*
 * jQuery selectbox plugin
 *
 * Copyright (c) 2007 Sadri Sahraoui (brainfault.com)
 * Licensed under the GPL license and MIT:
 *   http://www.opensource.org/licenses/GPL-license.php
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * The code is inspired from Autocomplete plugin (http://www.dyve.net/jquery/?autocomplete)
 *
 * Revision: $Id$
 * Version: 1.2
 * 
 * Changelog :
 *  Version 1.2 By Guillaume Vergnolle (web-opensource.com)
 *  - Add optgroup support
 *  - possibility to choose between span or input as replacement of the select box
 *  - support for jquery change event
 *  - add a max height option for drop down list
 *  Version 1.1 
 *  - Fix IE bug
 *  Version 1.0
 *  - Support jQuery noConflict option
 *  - Add callback for onChange event, thanks to Jason
 *  - Fix IE8 support
 *  - Fix auto width support
 *  - Fix focus on firefox dont show the carret
 *  Version 0.6
 *  - Fix IE scrolling problem
 *  Version 0.5 
 *  - separate css style for current selected element and hover element which solve the highlight issue 
 *  Version 0.4
 *  - Fix width when the select is in a hidden div   @Pawel Maziarz
 *  - Add a unique id for generated li to avoid conflict with other selects and empty values @Pawel Maziarz
 */
jQuery.fn.extend({
	selectbox: function(options) {
		return this.each(function() {
			new jQuery.SelectBox(this, options);
		});
	}
});


/* pawel maziarz: work around for ie logging */
if (!window.console) {
	var console = {
		log: function(msg) { 
	 	}
	}
}
/* */

jQuery.SelectBox = function(selectobj, options) {
	
	var opt = options || {};
	opt.inputType = opt.inputType || "input";
	opt.inputClass = opt.inputClass || "selectbox";
	opt.containerClass = opt.containerClass || "selectbox-wrapper";
	opt.hoverClass = opt.hoverClass || "current";
	opt.currentClass = opt.currentClass || "selected";
	opt.groupClass = opt.groupClass || "groupname"; //css class for group
	opt.maxHeight = opt.maxHeight || 250; // max height of dropdown list
	opt.loopnoStep = opt.loopnoStep || false; // to remove the step in list moves loop
	opt.onChangeCallback = opt.onChangeCallback || false;
	opt.onChangeParams = opt.onChangeParams || false;
	opt.debug = opt.debug || false;
	
	var elm_id = selectobj.id;
	var active = 0;
	var inFocus = false;
	var hasfocus = 0;
	//jquery object for select element
	var $select = jQuery(selectobj);
	// jquery container object
	var $container = setupContainer(opt);
	//jquery input object 
	var $input = setupInput(opt);
	// hide select and append newly created elements
	$select.hide().before($input).before($container);
	
	
	init();
	
	$input
	.click(function(){
		if (!inFocus) {
			$container.toggle();
		}
	})
	.focus(function(){
		if ($container.not(':visible')) {
			inFocus = true;
			$container.show();
		}
	})
	.keydown(function(event) {	   
		switch(event.keyCode) {
			case 38: // up
				event.preventDefault();
				moveSelect(-1);
				break;
			case 40: // down
				event.preventDefault();
				moveSelect(1);
				break;
			//case 9:  // tab 
			case 13: // return
				event.preventDefault(); // seems not working in mac !
				$('li.'+opt.hoverClass).trigger('click');
				break;
			case 27: //escape
			  hideMe();
			  break;
		}
	})
	.blur(function() {
		if ($container.is(':visible') && hasfocus > 0 ) {
			if(opt.debug) console.log('container visible and has focus')
		} else {
			// Workaround for ie scroll - thanks to Bernd Matzner
			if((jQuery.browser.msie && jQuery.browser.version.substr(0,1) < 9) || jQuery.browser.safari){ // check for safari too - workaround for webkit
				
				/* ADDED BY JC FOR SAFARI WORKAROUND - can't detect activeElement however leave IPHONE with the outside click bug otherwise it collapse onhover */
				
				// Apple detection object
				var Apple = {};
				Apple.UA = navigator.userAgent;
				Apple.Device = false;
				Apple.Types = ["iPhone", "iPod", "iPad"];
				for (var d = 0; d < Apple.Types.length; d++) {
					var t = Apple.Types[d];
					Apple[t] = !!Apple.UA.match(new RegExp(t, "i"));
					Apple.Device = Apple.Device || Apple[t];
				}
				// is this an Apple device?
				/*
				alert(
					"Apple device? " + Apple.Device +
					"\niPhone? " + Apple.iPhone +
					"\niPod? " + Apple.iPod +
					"\niPad? " + Apple.iPad
				);
				*/
				
				
				if (jQuery.browser.safari && !(Apple.Device)){
					checkTarget = event.currentTarget.getAttribute('id');
					
					if (checkTarget == "jcAirlineDropDownList_input"){
						if ($('#scrollChecker').val() == "out"){
							hideMe();	
						}else{
							$(this).focus();
						}
					}else{
						hideMe();
						
					}
				}else{
					clickStatus = document.activeElement.getAttribute('id').indexOf('_container');
					if(clickStatus==-1){
						hideMe();
					} else {
						$input.focus();
					}
				}
				
				
			} else {
				hideMe();
			}
		}
	});

	function hideMe() { 
		hasfocus = 0;
		$container.hide(); 
	}
	
	function init() {
		$container.append(getSelectOptions($input.attr('id'))).hide();
		var width = $input.css('width');
		if($container.height() > opt.maxHeight){
			$container.width(parseInt(width)+parseInt($input.css('paddingRight'))+parseInt($input.css('paddingLeft')));
			$container.height(opt.maxHeight);
		} else $container.width(width);
	}
	
	function setupContainer(options) {
		var container = document.createElement("div");
		$container = jQuery(container);
		$container.attr('id', elm_id+'_container');
		$container.addClass(options.containerClass);
        	$container.css('display', 'none');
		
		return $container;
	}
	
	function setupInput(options) {
		if(opt.inputType == "span"){
			var input = document.createElement("span");
			var $input = jQuery(input);
			$input.attr("id", elm_id+"_input");
			$input.addClass(options.inputClass);
			$input.attr("tabIndex", $select.attr("tabindex"));
		} else {
			var input = document.createElement("input");
			var $input = jQuery(input);
			$input.attr("id", elm_id+"_input");
			$input.attr("type", "text");
			$input.addClass(options.inputClass);
			$input.attr("autocomplete", "off");
			$input.attr("readonly", "readonly");
			$input.attr("tabIndex", $select.attr("tabindex")); // "I" capital is important for ie
			$input.css("width", $select.css("width"));
        	}
		return $input;	
	}
	
	function moveSelect(step) {
		var lis = jQuery("li", $container);
		if (!lis || lis.length == 0) return false;
		// find the first non-group (first option)
		firstchoice = 0;
		while($(lis[firstchoice]).hasClass(opt.groupClass)) firstchoice++;
		active += step;
    		// if we are on a group step one more time
    		if($(lis[active]).hasClass(opt.groupClass)) active += step;
		//loop through list from the first possible option
		if (active < firstchoice) {
			(opt.loopnoStep ? active = lis.size()-1 : active = lis.size() );
		} else if (opt.loopnoStep && active > lis.size()-1) {
			active = firstchoice;
		} else if (active > lis.size()) {
			active = firstchoice;
		}
        	scroll(lis, active);
		lis.removeClass(opt.hoverClass);

		jQuery(lis[active]).addClass(opt.hoverClass);
	}
	
	function scroll(list, active) {
      		var el = jQuery(list[active]).get(0);
      		var list = $container.get(0);
      
		if (el.offsetTop + el.offsetHeight > list.scrollTop + list.clientHeight) {
			list.scrollTop = el.offsetTop + el.offsetHeight - list.clientHeight;      
		} else if(el.offsetTop < list.scrollTop) {
			list.scrollTop = el.offsetTop;
		}
	}
	
	function setCurrent() {	
		var li = jQuery("li."+opt.currentClass, $container).get(0);
		var ar = (''+li.id).split('_');
		var el = ar[ar.length-1];
		if (opt.onChangeCallback){
        		$select.get(0).selectedIndex = $('li', $container).index(li);
        		opt.onChangeParams = { selectedVal : $select.val() };
			opt.onChangeCallback(opt.onChangeParams);
		} else {
			$select.val(el);
			$select.change();
		}
		if(opt.inputType == 'span') $input.html($(li).html());
		else $input.val($(li).html());
		return true;
	}
	
	// select value
	function getCurrentSelected() {
		return $select.val();
	}
	
	// input value
	function getCurrentValue() {
		return $input.val();
	}
	
	function getSelectOptions(parentid) {
		var select_options = new Array();
		var ul = document.createElement('ul');
		select_options = $select.children('option');
		if(select_options.length == 0) {
			var select_optgroups = new Array();
			select_optgroups = $select.children('optgroup');
			for(x=0;x<select_optgroups.length;x++){
				select_options = $("#"+select_optgroups[x].id).children('option');
				var li = document.createElement('li');
				li.setAttribute('id', parentid + '_' + $(this).val());
				li.innerHTML = $("#"+select_optgroups[x].id).attr('label');
				li.className = opt.groupClass;
				ul.appendChild(li);
				select_options.each(function() {
					var li = document.createElement('li');
					li.setAttribute('id', parentid + '_' + $(this).val());
					li.innerHTML = $(this).html();
					if ($(this).is(':selected')) {
						$input.html($(this).html());
						$(li).addClass(opt.currentClass);
					}
					ul.appendChild(li);
					$(li)
					.mouseover(function(event) {
						hasfocus = 1;
						if (opt.debug) console.log('over on : '+this.id);
						jQuery(event.target, $container).addClass(opt.hoverClass);
					})
					.mouseout(function(event) {
						hasfocus = -1;
						if (opt.debug) console.log('out on : '+this.id);
						jQuery(event.target, $container).removeClass(opt.hoverClass);
					})
					.click(function(event) {
						var fl = $('li.'+opt.hoverClass, $container).get(0);
						if (opt.debug) console.log('click on :'+this.id);
						$('li.'+opt.currentClass, $container).removeClass(opt.currentClass); 
						$(this).addClass(opt.currentClass);
						setCurrent();
						$select.get(0).blur();
						hideMe();
					});
				});
			}
		} else select_options.each(function() {
			var li = document.createElement('li');
			li.setAttribute('id', parentid + '_' + $(this).val());
			li.innerHTML = $(this).html();
			if ($(this).is(':selected')) {
				$input.val($(this).html());
				$(li).addClass(opt.currentClass);
			}
			ul.appendChild(li);
			$(li)
			.mouseover(function(event) {
				hasfocus = 1;
				if (opt.debug) console.log('over on : '+this.id);
				jQuery(event.target, $container).addClass(opt.hoverClass);
			})
			.mouseout(function(event) {
				hasfocus = -1;
				if (opt.debug) console.log('out on : '+this.id);
				jQuery(event.target, $container).removeClass(opt.hoverClass);
			})
			.click(function(event) {
			  	var fl = $('li.'+opt.hoverClass, $container).get(0);
				if (opt.debug) console.log('click on :'+this.id);
				$('li.'+opt.currentClass, $container).removeClass(opt.currentClass); 
				$(this).addClass(opt.currentClass);
				setCurrent();
				$select.get(0).blur();
				hideMe();
			});
		});
		return ul;
	}
	
	
	
};

//val1 = jQuery("#jcAirlineDropDownList option[value='2']").text();
//$("#list option[value='2']").text()
	//alert("hello");
function addLabels(){
	checkval = jQuery('#jcAdultCountDropDownList_input').val();
	
	if (checkval < 2){
		jQuery('#jcAdultCountDropDownList_input').val(checkval + ' Adult');
	}else{
		jQuery('#jcAdultCountDropDownList_input').val(checkval + ' Adults');	   
	}
	

	checkval2 = jQuery('#jcChildCountDropDownList_input').val();
	
	if (checkval2 < 2){
		jQuery('#jcChildCountDropDownList_input').val(checkval2 + ' Child');
	}else{
		jQuery('#jcChildCountDropDownList_input').val(checkval2 + ' Children');	   
	}

	checkval3 = jQuery('#jcInfantCountDropDownList_input').val();
	
	if (checkval2 < 2){
		jQuery('#jcInfantCountDropDownList_input').val(checkval3 + ' Infant');
	}else{
		jQuery('#jcInfantCountDropDownList_input').val(checkval3 + ' Infants');	   
	}
	
	checkval4 = jQuery('#jcCurrencyDropDownList_input').val();
	jQuery('#jcCurrencyDropDownList_input').val("Quote in " + checkval4);
	
	jQuery('#jcAdultCountDropDownList_container ul li').each(function(index) {
    	curVal = $(this).text();
		if (curVal == "1" || curVal == "0"){
			$(this).text(curVal + " Adult");
		}else{
			$(this).text(curVal + " Adults");
		}
  	});
	
	jQuery('#jcAdultCountDropDownList_container ul li:last').remove();
	
	jQuery('#jcChildCountDropDownList_container ul li').each(function(index) {
    	curVal = $(this).text();
		if (curVal == "1" || curVal == "0"){
			$(this).text(curVal + " Child");
		}else{
			$(this).text(curVal + " Children");
		}
  	});
	
	jQuery('#jcChildCountDropDownList_container ul li:last').remove();
	jQuery('#jcChildCountDropDownList_container ul li:last').remove();
	
	jQuery('#jcInfantCountDropDownList_container ul li').each(function(index) {
    	curVal = $(this).text();
		if (curVal == "1" || curVal == "0"){
			$(this).text(curVal + " Infant");
		}else{
			$(this).text(curVal + " Infants");
		}
  	});
	
	jQuery('#jcInfantCountDropDownList_container ul li:last').remove();
	jQuery('#jcInfantCountDropDownList_container ul li:last').remove();
	
	jQuery('#jcCurrencyDropDownList_container ul li').each(function(index) {
    	curVal = $(this).text();
		$(this).text("Quote in " + curVal);
		
  	});

}

function changeWidth(){
	jQuery('#jcAirlineDropDownList_container').css('width','290px');	
	jQuery('#jcClassDropDownList_container').css('width','290px');
	jQuery('#jcCurrencyDropDownList_container').css('width','290px');
	jQuery('#jcAdultCountDropDownList_container').css('width','92px');
	jQuery('#jcChildCountDropDownList_container').css('width','92px');
	jQuery('#jcInfantCountDropDownList_container').css('width','92px');
	
	jQuery('#jcAirlineDropDownList_input').css('width','290px');
	jQuery('#jcClassDropDownList_input').css('width','290px');
	jQuery('#jcCurrencyDropDownList_input').css('width','290px');
	jQuery('#jcAdultCountDropDownList_input').css('width','95px');
	jQuery('#jcChildCountDropDownList_input').css('width','95px');
	jQuery('#jcInfantCountDropDownList_input').css('width','95px');
	
}



jQuery(document).ready(function() {


	//jQuery('#myselectbox').selectbox({onChangeCallback: myFunction});
	setTimeout("jQuery('#jcAirlineDropDownList').selectbox()",2000);
	setTimeout("jQuery('#jcClassDropDownList').selectbox()",2000);
	setTimeout("jQuery('#jcAdultCountDropDownList').selectbox()",2000);
	setTimeout("jQuery('#jcChildCountDropDownList').selectbox()",2000);
	setTimeout("jQuery('#jcInfantCountDropDownList').selectbox()",2000);
	setTimeout("jQuery('#jcCurrencyDropDownList').selectbox()",2000);
	setTimeout("addLabels()",2100);
	setTimeout("changeWidth()",2100);
	setTimeout("jQuery('#jcHeader').fadeOut('slow')",2100);
	
	/*For safari, help determine if mouse is over the scrollbars for the drop down options */ 
	jQuery('#cannonballForm').append('<input type="hidden" name="scrollChecker" id="scrollChecker" value="" />');
	
	$('#jcAirlinePanel').mouseenter(function() {
		$('#scrollChecker').val('over');
	});
	
	$('#jcAirlinePanel').mouseleave(function() {
		$('#scrollChecker').val('out');
	});
	
	
});
/*****************************/	 
	 
	 
/*mouse*/
jQuery('body').click(function() {
 	//alert("blah");
	jQuery('.ajax__calendar_container').each(function() {
    	jQuery('.ajax__calendar_container').hide();
  	});
 });

 jQuery('.ajax__calendar_container').click(function(event){
     event.stopPropagation();
 });
 








