$(document).ready(function() {
    
     
    
    var panel = getUrlVars()["panel"];
    var pageName = getUrlVars()["pageName"];
    

    // ------- HOMEPAGE FEATURED SLIDER ------- 	
$('#coda-slider-1').codaSlider({
    autoSlide: true,
    autoSlideInterval: 6000,
    dynamicArrows: false,
    dynamicTabs: true,
    autoSlideStopWhenClicked: true,
    autoHeight: false

  });
    
  // allow for direct urls
  if (panel) {
    
    $('#wrapper').scrollTo("#" + panel, 800);
    $("div.contentArea").hide();
    $("." + pageName).show();
  };

	//get all link with class panel
	$('a.panel').click(function () {

    //reset and highlight the clicked link
    $('a.panel').removeClass('selected');
    $(this).addClass('selected');
      
    //grab the current item, to be used in resize function
    current = $(this);
      
     //scroll it to the destination
    $('#wrapper').scrollTo($(this).attr('href'), 800);		
      
    
    //show landing page content
    //$('div.contentArea').hide();
    $('div.contentArea').hide();
    $('div.landing').show();
    
    $('div.leftSideContent ul li a').removeClass('selected');
    
    //cancel the link default behavior
    return false;
  });


  //resize all the items according to the new browser size
  $(window).resize(function () {
		
      //call the resizePanel function
      //resizePanel();
	});
	
	// ------- browser scrolls to the top on every click ---------	
  $("a:not([href^='http']):not([href^='mailto']):not([href$='pdf']):not([href$='php'])").not('body.static a').click(function(){ 
        $('html, body').animate({scrollTop:0}, 'slow');
        return false;
  });
  
  
  // ------- browser opens in a new window for external links ---------
  $("a[href^=http],a[href$='pdf']").attr("target","_blank");

	
// ------- NAVIGATION --------- 


$('.leftSideContent ul li a,a.move').not('.static ul li a').click ( function () {
	  if ($(this).hasClass('subNavigation')) {}
	  else  {   
	    $("div.contentArea").not("." + $(this).attr('id')).hide();
      $("." + $(this).attr('id')).show();
      $('.bioText').hide();
      $(".bioText.default").show();
    }
      $('.leftSideContent ul li a').not('a#' + this.id).removeClass('selected');
      $(this).addClass('selected');
      
      return false;
    });

// ------- SUB NAVIGATION --------  
  

$('.leftSideContent ul li ul').hide();
  $('.leftSideContent ul li a.subNavigation').click(
    function() {
    var checkElement = $(this).next();
    if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
    return false;
  }
  if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
  $('.leftSideContent ul li ul').slideUp('normal');
  checkElement.slideDown('normal');
  return false;
  }
  }
  );
 
  
// ------- BIOS ------- 
	
	$('.bioThumbs img').tooltip({ 
    track: true, 
    delay: 0, 
    showURL: false, 
    showBody: " - ", 
    fade: 250 
  });
	
	
	$('.bioThumbs img').mouseover(function (){
	    $(this).fadeTo("slow", 1);
	    
	});
	
	$('.bioThumbs img').click(function (){
	    $('.bioThumbs img').removeClass('selected');
	    $('.bioThumbs img').not(this).fadeTo("fast", .3);
	    $(this).addClass('selected');
	    $('.bioText').hide();
	    $("." + $(this).attr('id')).show();

	    
	});
	
	$('.bioThumbs img').mouseout(function (){
	    if ($(this).hasClass('selected')) {}
	    else
	     {$(this).fadeTo("fast", .3);}
	});
	


// ------- HOMEPAGE LOGO SLIDER ------- 
$('#logo-Slider').codaSlider({
    autoSlide: true,
    autoSlideInterval: 1,
    dynamicArrows: false,
    dynamicTabs: false,
    autoSlideStopWhenClicked: true,
    slideEaseDuration: 20000,
    autoHeight: false

  });

// ------- CONFERENCE SLIDER ------- 
$('#conference-Slider').codaSlider({
    autoSlide: true,
    autoSlideInterval: 2000,
    dynamicArrows: false,
    dynamicTabs: false,
    autoSlideStopWhenClicked: false,
    slideEaseDuration: 1000,
    autoHeight: false

  });

// ------- CREATIVE IMAGE GALLERY -------
$("a.grouped_elements").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true,
		'overlayColor' : '#E2EACD',
		'titleShow' : true,
		'titlePosition' : 'inside'
	});



// ------- CONTACT US -------
$('.error').hide();
$(".contactBtn").click(function() {

  $('.error').hide();
  var nameFirst = $("input#nameFirst").val();
  if (nameFirst == "") {
    $("label#nameFirst_error").show();
    $("input#nameFirst").focus();
    return false;
  }
  var nameLast = $("input#nameLast").val();
  if (nameLast == "") {
    $("label#nameLast_error").show();
    $("input#nameLast").focus();
    return false;
  }
  var school = $("input#school").val();
  if (school == "") {
    $("label#school_error").show();
    $("input#school").focus();
    return false;
  }
  var email = $("input#email").val();
  if (email == "") {
    $("label#email_error").show();
    $("input#email").focus();
    return false;
  }
  
  var phone = $("input#phone").val();
  /*
  var interests = $("input#interests").val();
  if (interests == "") {
    $("label#interests_error").show();
    $("input#interests").focus();
    return false;
  }
  */
  var comments = $("textarea#comments").val();
  
  var dataString = 'nameFirst='+ nameFirst + '&nameLast='+ nameLast + '&school='+ school + '&email=' + email + '&phone=' + phone + /*'&interests=' + interests + */'&comments=' + comments;

  $.ajax({
    type: "POST",
    url: "process.php",
    data: dataString,
    success: function() {
      $('#contact_form').html("<div id='message'></div>");
      $('#message').html("<h5>Thank You!</h5>")
      .append("<p>We will be in touch soon.</p>")
      .hide()
      .fadeIn(1500, function() {
        $('#message');
      });
    }
  });
  return false;
});
    

// ------- REGISTRATION FOR WEBINARS -------

$(".regBtn").click(function() {

  $('.error').hide();
  var buyerName = $("input#buyerName").val();
  if (buyerName == "") {
    $("label#buyerName_error").show();
    $("input#buyerName").focus();
    return false;
  }
  var buyerTitle = $("input#buyerTitle").val();
  if (buyerTitle == "") {
    $("label#buyerTitle_error").show();
    $("input#buyerTitle").focus();
    return false;
  }
  var school = $("input#school").val();
  if (school == "") {
    $("label#school_error").show();
    $("input#school").focus();
    return false;
  }
  var email = $("input#email").val();
  if (email == "") {
    $("label#email_error").show();
    $("input#email").focus();
    return false;
  }
  var webinars = "";
  $("input[name='webinar[]']:checked").each(function(){
      webinars += $(this).val() + '\n';
  }); 
  
  var dataString = 'buyerName=' + buyerName + '&buyerTitle=' + buyerTitle + '&school='+ school + '&email=' + email + '&webinars=' + webinars;
 
  $.ajax({
    type: "POST",
    url: "checkout.php",
    data: dataString,
    success: function() {
      $('div.reg-part2').slideDown();
      $('button.regBtn').hide();
      $('div.checkboxes').hide();
    }
  });
  return false;
});

// ------- REGISTRATION FOR CONFERENCE -------

$(".con-submit").click(function() {

  $('.error').hide();
  var buyerName = $("input#buyerName").val();
  if (buyerName == "") {
    $("label#buyerName_error").show();
    $("input#buyerName").focus();
    return false;
  }
  var buyerTitle = $("input#buyerTitle").val();
  if (buyerTitle == "") {
    $("label#buyerTitle_error").show();
    $("input#buyerTitle").focus();
    return false;
  }
  var school = $("input#school").val();
  if (school == "") {
    $("label#school_error").show();
    $("input#school").focus();
    return false;
  }
  var email = $("input#email").val();
  if (email == "") {
    $("label#email_error").show();
    $("input#email").focus();
    return false;
  }
  var phone = $("input#phone").val();
  if (phone == "") {
    $("label#phone_error").show();
    $("input#phone").focus();
    return false;
  }
  var interests = $("select.interests").val();
  var entertainment = $("input[name='entertainment']:checked").val();
  
  var dataString = 'buyerName=' + buyerName + '&buyerTitle=' + buyerTitle + '&school=' + school + '&email=' + email + '&phone=' + phone + '&interests=' + interests + '&entertainment=' + entertainment;

  $.ajax({
    type: "POST",
    url: "con-checkout.php",
    data: dataString,
    success: function() {
      $('div.reg-part2').slideDown();
      $('button.con-submit').hide();
    }
  });
  return false;
});



// Expand Collapse

$('div.exp-col p').hide();

    
$('div.exp-col h5').click( function () {
    $('div.exp-col p').hide();
    $(this).next("p").show();
    $('div.exp-col div').removeClass("open");
    $(this).parent("div").addClass("open");
});    
    
$('.more-info').click(function(){
    $(this).next('div').slideToggle();
    $(this).toggleClass('open');
    return false;
});	

/* $('span.view-bio').click(function(){
    $(this).parent('p').next('div').slideToggle();
    return false;
});	
*/
$('span.view-bio').toggle(function(){
    $(this).parent('p').next('div').slideDown();
    $(this).text('hide bio');
  },function(){
    $(this).parent('p').next('div').slideUp();
    $(this).text('view bio');
  });


$("#con-2012").validate();


});





function resizePanel() {

	//get the browser width and height
	width = $(window).width();
	height = $(window).height();

	//get the mask width: width * total of items
	mask_width = width * $('.item').length;
		
	//set the dimension	
	$('#wrapper, .item').css({width: width, height: height});
	$('#mask').css({width: mask_width, height: height});
	
	//if the item is displayed incorrectly, set it to the corrent pos
	$('#wrapper').scrollTo($('a.selected').attr('href'), 0);
		
}


function getUrlVars() {
	var urlVars = {};
	var urlParts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
		urlVars[key] = value;
	});
	return urlVars;
}



