$(document).ready(function () {
				
	/*$("#main_menu ul li").hover(function(){
		$("#main_menu ul li").removeClass('ajaxmenu_active'); // first.removeClass('first');
		$('#main_menu ul li ul').hide();
		$(this).addClass('ajaxmenu_active').find('ul').show();
		$(this).find('.menu_spots').rotate({animateTo:180});
	},
	function(){
		$(this).find('.menu_spots').rotate({animateTo:0});
		$('.ajaxmenu_active').find('ul').show();
		$(this).addClass('ajaxmenu_active').find('ul').show();
	}); */
	
	$("#mainNavigation li").hover(function(){
			$("#mainNavigation li").removeClass('active');
			$('#mainNavigation li ul').hide();
			$(this).addClass('active').find('ul').show();
		},
		function(){
			$('.active').find('ul').show();
			$(this).addClass('active').find('ul').show();
		}); 
				
    $(".ui-tabs").tabs();
								
	$("#tweet").getTweet($('#twitter_account').text());//"spacetechexpo"
				
				
	$('#gallery_img').cycle({ 
		fx:     'fade', 
		fit: true,
		width: 620,
		height: 340,
		speed:  4000, 
		timeout: 0, 
		pager:  '#slider_thumbs', 
					 
		// callback fn that creates a thumbnail to use as pager anchor 
		/* pagerAnchorBuilder: function(idx, slide) { 
			// Split off the filename with no extension (period + 3 letter extension)
			var new_src = slide.src.substring(0,slide.src.length-4);

			// Add the "t"
			new_src += "_thumb";

			// Add the period and the 3 letter extension back on
			new_src += slide.src.substring(slide.src.length-4,slide.src.length);

			return '<a href="#" class="nav_thumb"><img src="' + new_src + '" width="80" height="80"  /></a>'; 
		} */
	});
       $('.vidframe').click(function() { 
             $('#gallery_img').cycle('pause'); 
       });
				
				
	$(".fancy").fancybox({
		'titleShow'       : false,
		'autoDimensions'  : true
	});
				
	$(function() {
		$("#exhibitor-carousel").carouFredSel({
			width: 1000,
                        height: 80,
			align: false,
			auto : {
				items: null,
				duration : 20000,
				easing : "linear",
				pauseDuration	: 0,
				pauseOnHover : false
			}
		});
	}); 
	
	//Hotel pic slider
    $('.hotel_pics').each(function() {
        var show = $(this);     
        show.cycle({ 
			fx:    		'fade',
			speed:  	2000
        });
                
    });

	//Hotel page popup
	$(".google_map").fancybox({
		'width'				: '90%',
		'height'			: '90%',
        'autoScale'     	: false,
        'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'type'				: 'iframe'
	});
	
	
	
	//Exhib list show hide
	$(".expand-button").toggle(
	function()
		{
			$height = $(this).parent().height();
			if($height > 48) {
			$(this).closest('.col2').animate({ height: $height + 'px' }, 1000 );
			return false;
		}
	},
	function()
	{
		$(this).closest('.col2').animate({ height: '48px' }, 1000 );
		return false;
	});

	//Spekaer list show hide	
	 $(".speaker-expand-button").toggle(
	   function()
	   {
		  $height = $(this).parent().height();

		  if($height > 100) {
			 
			  $(this).closest('.col2').animate({ height: $height + 'px' }, 1000 );
			 
                  return false;
		  }

	   },
	   function()
	   {
		   $(this).closest('.col2').animate({ height: '100px' }, 1000 );
                   return false;
	});
	
	
$telephone = new Array(4)
$telephone[0] = "--"
$telephone[1] = "--"
$telephone[2] = "+33"
$telephone[3] = "+49"
$telephone[4] = "+39"
$telephone[5] = "+34"
$telephone[6] = "+44"
$telephone[7] = "+1"
$telephone[8] = "--"
$telephone[9] = "+93"
$telephone[10] = "+355"
$telephone[11] = "+213"
$telephone[12] = "+684"
$telephone[13] = "+33"
$telephone[14] = "+244"
$telephone[15] = "+264"
$telephone[16] = "+268"
$telephone[17] = "+54"
$telephone[18] = "+374"
$telephone[19] = "+297"
$telephone[20] = "+247"
$telephone[21] = "+61"
$telephone[22] = "+43"
$telephone[23] = "+994"
$telephone[24] = "+351"
$telephone[25] = "+242"
$telephone[26] = "+973"
$telephone[27] = "+34"
$telephone[28] = "+880"
$telephone[29] = "+1 246"
$telephone[30] = "+375"
$telephone[31] = "+680"
$telephone[32] = "+32"
$telephone[33] = "+501"
$telephone[34] = "+229"
$telephone[35] = "+441"
$telephone[36] = "+975"
$telephone[37] = "+591"
$telephone[38] = "+387"
$telephone[39] = "+267"
$telephone[40] = "+55"
$telephone[41] = "+246"
$telephone[42] = "+1 284"
$telephone[43] = "+673"
$telephone[44] = "+359"
$telephone[45] = "+226"
$telephone[46] = "+257"
$telephone[47] = "+855"
$telephone[48] = "+237"
$telephone[49] = "+1"
$telephone[50] = "+34"
$telephone[51] = "+238"
$telephone[52] = "+345"
$telephone[53] = "+236"
$telephone[54] = "+235"
$telephone[55] = "+56"
$telephone[56] = "+86"
$telephone[57] = "+672"
$telephone[58] = "+672"
$telephone[59] = "+57"
$telephone[60] = "+269"
$telephone[61] = "+242"
$telephone[62] = "+242"
$telephone[63] = "+682"
$telephone[64] = "+495"
$telephone[65] = "+506"
$telephone[66] = "+385"
$telephone[67] = "+53"
$telephone[68] = "+599"
$telephone[69] = "+357"
$telephone[70] = "+420"
$telephone[71] = "+45"
$telephone[72] = "+253"
$telephone[73] = "+599"
$telephone[74] = "+809"
$telephone[75] = "+670"
$telephone[76] = "+593"
$telephone[77] = "+20"
$telephone[78] = "+353"
$telephone[79] = "+503"
$telephone[80] = "+240"
$telephone[81] = "+291"
$telephone[82] = "+372"
$telephone[83] = "+251"
$telephone[84] = "+500"
$telephone[85] = "+298"
$telephone[86] = "+679"
$telephone[87] = "+358"
$telephone[88] = "+594"
$telephone[89] = "+689"
$telephone[90] = "+596"
$telephone[91] = "+241"
$telephone[92] = "+220"
$telephone[93] = "+970"
$telephone[94] = "+995"
$telephone[95] = "+233"
$telephone[96] = "+350"
$telephone[97] = "+30"
$telephone[98] = "+299"
$telephone[99] = "+599"
$telephone[100] = "+590"
$telephone[101] = "+671"
$telephone[102] = "+502"
$telephone[103] = "+224"
$telephone[104] = "+245"
$telephone[105] = "+592"
$telephone[106] = "+509"
$telephone[107] = "+504"
$telephone[108] = "+852"
$telephone[109] = "+36"
$telephone[110] = "+354"
$telephone[111] = "+91"
$telephone[112] = "+62"
$telephone[113] = "+98"
$telephone[114] = "+964"
$telephone[115] = "+972"
$telephone[116] = "+225"
$telephone[117] = "+876"
$telephone[118] = "+81"
$telephone[119] = "+962"
$telephone[120] = "+7"
$telephone[121] = "+254"
$telephone[122] = "+686"
$telephone[123] = "+82"
$telephone[124] = "+850"
$telephone[125] = "+377"
$telephone[126] = "+965"
$telephone[127] = "+996"
$telephone[128] = "+856"
$telephone[129] = "+371"
$telephone[130] = "+961"
$telephone[131] = "+266"
$telephone[132] = "+231"
$telephone[133] = "+218"
$telephone[134] = "+42"
$telephone[135] = "+370"
$telephone[136] = "+352"
$telephone[137] = "+853"
$telephone[138] = "+389"
$telephone[139] = "+261"
$telephone[140] = "+351"
$telephone[141] = "+265"
$telephone[142] = "+60"
$telephone[143] = "+960"
$telephone[144] = "+223"
$telephone[145] = "+356"
$telephone[146] = "+670"
$telephone[147] = "+692"
$telephone[148] = "+596"
$telephone[149] = "+222"
$telephone[150] = "+230"
$telephone[151] = "+269"
$telephone[152] = "+52"
$telephone[153] = "+691"
$telephone[154] = "+373"
$telephone[155] = "+33"
$telephone[156] = "+976"
$telephone[157] = "+382"
$telephone[158] = "+664"
$telephone[159] = "+212"
$telephone[160] = "+258"
$telephone[161] = "+95"
$telephone[162] = "+264"
$telephone[163] = "+674"
$telephone[164] = "+977"
$telephone[165] = "+31"
$telephone[166] = "+599"
$telephone[167] = "+687"
$telephone[168] = "+64"
$telephone[169] = "+64"
$telephone[170] = "+505"
$telephone[171] = "+227"
$telephone[172] = "+234"
$telephone[173] = "+672"
$telephone[174] = "+47"
$telephone[175] = "+968"
$telephone[176] = "+92"
$telephone[177] = "+507"
$telephone[178] = "+675"
$telephone[179] = "+595"
$telephone[180] = "+51"
$telephone[181] = "+63"
$telephone[182] = "+64"
$telephone[183] = "+48"
$telephone[184] = "+351"
$telephone[185] = "+1 787"
$telephone[186] = "+974"
$telephone[187] = "+262"
$telephone[188] = "+40"
$telephone[189] = "+7"
$telephone[190] = "+250"
$telephone[191] = "+290"
$telephone[192] = "+869"
$telephone[193] = "+758"
$telephone[194] = "+508"
$telephone[195] = "+784"
$telephone[196] = "+39"
$telephone[197] = "+239"
$telephone[198] = "+966"
$telephone[199] = "+221"
$telephone[200] = "+381"
$telephone[201] = "+248"
$telephone[202] = "+232"
$telephone[203] = "+65"
$telephone[204] = "+421"
$telephone[205] = "+386"
$telephone[206] = "+677"
$telephone[207] = "+252"
$telephone[208] = "+27"
$telephone[209] = "+34"
$telephone[210] = "+47"
$telephone[211] = "+94"
$telephone[212] = "+249"
$telephone[213] = "+597"
$telephone[214] = "+268"
$telephone[215] = "+46"
$telephone[216] = "+41"
$telephone[217] = "+963"
$telephone[218] = "+886"
$telephone[219] = "+7"
$telephone[220] = "+255"
$telephone[221] = "+66"
$telephone[222] = "+86"
$telephone[223] = "+228"
$telephone[224] = "+676"
$telephone[225] = "+868"
$telephone[226] = "+290"
$telephone[227] = "+216"
$telephone[228] = "+90"
$telephone[229] = "+993"
$telephone[230] = "+649"
$telephone[231] = "+688"
$telephone[232] = "+256"
$telephone[233] = "+380"
$telephone[234] = "+971"
$telephone[235] = "+598"
$telephone[236] = "+7"
$telephone[237] = "+678"
$telephone[238] = "+39"
$telephone[239] = "+58"
$telephone[240] = "+84"
$telephone[241] = "+1 340"
$telephone[242] = "+808"
$telephone[243] = "+681"
$telephone[244] = "+212"
$telephone[245] = "+685"
$telephone[246] = "+967"
$telephone[247] = "+260"
$telephone[248] = "+263"

	//Change telephone code on country select
	$("#country").change(function() {
		cIndex = $("#country")[0].selectedIndex;
		$(".numprefix").val($telephone[cIndex]);
	});


	//Inline form labels
	$('input[title]').each(function() {
		if($(this).val() === '') {
			$(this).val($(this).attr('title'));	
		}
		$(this).focus(function() {
			if($(this).val() == $(this).attr('title')) {
				$(this).val('').addClass('focused');	
			}
		});
		$(this).blur(function() {
			if($(this).val() === '') {
				$(this).val($(this).attr('title')).removeClass('focused');	
			}
		});
	});
	
	
	//Hide others
	$("#subprimary_activity_other_box, #subjob_title2_other_box, #heard_event_from_other_box").hide();
				
			//Show other free format field when other dropdown is selected
			$("select#subprimary_activity").change(function() {
				
				var val = $("select#subprimary_activity").val();
				
				if(val === "100 Other (please specify)") {
						$("#subprimary_activity_other_box").slideDown('slow');
				} else {
				
						$("#subprimary_activity_other_box").slideUp();
				}
				
			});
			
			//Show other free format field when other dropdown is selected
			$("select#subjob_title2").change(function() {
				
				var val = $("select#subjob_title2").val();
				
				if(val == "200 Other (please specify)") {
						$("#subjob_title2_other_box").slideDown('slow');
				} else {
				
						$("#subjob_title2_other_box").slideUp();
				}
				
			});
			
			//Show other free format field when other dropdown is selected
			$("select#heard_event_from").change(function() {
				
				var val = $("select#heard_event_from").val();
				
				if(val == "Other") {
						$("#heard_event_from_other_box").slideDown('slow');
				} else {
				
						$("#heard_event_from_other_box").slideUp();
				}
				
			});
			
			//Change color of selects when option is chosen
			$("select").change(function() {
				
					var val = $(this).val();
				
				if(val == "") {
						$(this).css({"color":"#999999"});
				} else {
						$(this).css({"color":"black"});
				}
				
			});

	//Check on submit that real values are in fields NOT the field titles...
	$("#register").submit(function() {
	
			$('input').each(function() {
			
			if($(this).val() == $(this).attr('title')) {
			$(this).val('');	
			}
			
			});
		
		return true;
	
	});
	
	
//VALIDATE EXHIB FEEDBACK FORM 2012
$("#sub_btn").click(function() {

	var data_q1 = $("input:radio[@name='q1']:checked").val();
	var data_q2 = $("input:radio[@name='q2']:checked").val();
	var data_q3 = $("input:radio[@name='q3']:checked").val();
	var data_q4 = $.trim($("#q4").val());
	var data_q5 = $("input:radio[@name='q5']:checked").val();
	var data_q6 = $("input:radio[@name='q6']:checked").val();
	var data_q7 = $("input:radio[@name='q7']:checked").val();	
	var data_q8 = $.trim($("#q8").val());
	var data_q9 = $("input:radio[@name='q9']:checked").val();


	//Validate all fields have been filled
	if(data_q1 == "" || data_q2 == "" || data_q3 == "" || data_q4 == "" || data_q5 == "" || data_q6 == "" || data_q7 == "" || data_q8 == "" || data_q9 == "") {alert("Please complete all nine questions"); return false;}else{return true;}

});// END VALIDATE EXHIB FEEDBACK FORM 2012
	
});//end doc ready
