	// JavaScript functions to hide and display submenu
	$(document).ready(function(){ 
		setTimeout(function() {
    		$('.loader').hide();
		}, 12000);	
		$("ul.sf-menu").superfish({
  		delay:       400,																				// one second delay on mouseout 
			animation:   {opacity:'show',height:'show'},  					// fade-in and slide-down animation 
			speed:       'fast'                          						// faster animation speed 
		});

	  $(".toggleField").each( function()
	  {
	    $(this).data( "labelName", $(this).val() );
	  });
	
	  $('.toggleField').focus(function(){
	  if ( $(this).val() == $(this).data("labelName") )
	  {
	    $(this).val("");
	  }
	  }).blur(function(){
	    if ( $(this).val() == "" )
	    {
	      $(this).val($(this).data("labelName"));
	    }
	  });		

		// Logo Image Fading
		$("#logo").hover(function(){
			$(this).stop().fadeTo(250, 0.8);			
		},function(){
			$(this).stop().fadeTo(250, 1);
		});    
		// Top-level menu item highlighting
		$("#mainNav li").hover(function(){$(this).addClass('active');},function(){$(this).removeClass('active');});
		$("#mainNav li.active").hover(function(){$(this).addClass('active');},function(){$(this).addClass('active');});
		
		$("#homeLink, #contactLink, #blogLink, #careerLink, #myQuirkLink").fadeTo(500, 0.5);
		$("#quickLinks ul li").hover(function(){
			$(this).stop().fadeTo(500, 1);			
		},function(){
			$(this).stop().fadeTo(500, 0.5);
		});    
		
	// Smooth Back to top scrolling
    $('.backtotop').click(function(){
      $('html, body').animate({scrollTop:0}, 1500);
      return false;
    });
		
    $('#js_downloadEmailContactHide').live('click',function(e){
			e.preventDefault();
      $('#js_downloadInfoPackEmail').hide();
    });

    $('#js_downloadInfoPackCourse').live('click',function(e){
      e.preventDefault();
      $('#js_downloadInfoPackEmail').show();
    });
		
		$('.js_downloadInfoPackEmailText').live('click',function(e){
			e.preventDefault();
			$('#js_downloadInfoPackEmail').show();
		});
		
    $('#js_downloadInfoPackEmailForm').live('submit',function(e){
      $.ajax({
      type:'post',
      url:$('#js_downloadInfoPackEmailForm').attr( 'action' ),
      data: $(this).serialize(),
      async:true,
      dataType:'json',
      success: function( json ) { 
            if( json.status == "success" )
            {
							console.log(" download info pack success");
              $('#js_downloadInfoPackEmail').hide();
				      $('#js_fldDownloadInfoEmail').val('');
				      $('#js_downloadEmailContactHide').trigger('click');
							var gaUrl = $(this).attr("rel");
							_gaq.push(['_trackPageView', gaUrl]);
							
//              $('.contactThanksBlock').show();
//              $('html, body').animate({scrollTop:0}, 1500);
//              _gaq.push(['_trackPageview', '/contact/thanks']);
            }
            else if( json.status == "error" )
            {
//              $('.js_errors').remove();
//              $('.js_field_error').remove();
//              $('.hasError').removeClass( 'hasError');
//              
//              $errors = $('<ul class="js_errors hasError"></ul>');
//              
//              if( json.errors )
//              {
//                $.each( json.errors, function(index, value)
//                {
//                  $.each( value, function( key, value )
//                  {
//                    $(".js_comment_errorPlaceholder").addClass( 'hasError' );
//                    $("#js_comment_" + key).append( $("<p class='js_field_error'>" + value + "</p>") );
//                  });
//                });
//                
//                $errors.append( $("<li>Please complete all fields</li>") );
//              }                
//                
//              $("#js_frmOrderWine").prepend( $errors );
            }
						
						window.open($('#js_downloadInfoPackCourse').attr('href'));
          }
      });
			return false;
    });

    $('#js_downloadInfoPackEmailFormadfasdfas').live('submit',function(e){
      e.preventDefault();
      var userEmail = $('#js_fldDownloadInfoEmail').val();
      console.log("userEmail:%s" , userEmail);
      var downloadEmail = $('#js_fldDownloadInfoEmail').val();
      var infopackurl = $('#js_infoPackEmailUrl').val() + escape(downloadEmail);
      console.log("infopackurl:%s", infopackurl);
      var url = $('#js_downloadInfoPackCourse').attr('href');
      
      setTimeout(5000);
      window.open(url);
      
      setTimeout(5000);
      window.open(infopackurl);
      
      $('#js_fldDownloadInfoEmail').val('');
      $('#js_downloadEmailContactHide').trigger('click');
    });

	});
  // end document ready
	function formatText(index, panel) {
	  return index + "";
  }

	/*$(function () {
			$('.anythingSlider').anythingSlider({
					easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
					autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
					delay: 5000,                    // How long between slide transitions in AutoPlay mode
					startStopped: false,            // If autoPlay is on, this can force it to start stopped
					animationTime: 600,             // How long the slide transition takes
					hashTags: true,                 // Should links change the hashtag in the URL?
					buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
			pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
			startText: "Go",             // Start text
			stopText: "Stop",               // Stop text
			navigationFormatter: formatText       // Details at the top of the file on this use (advanced use)
			});
			
			$("#slide-jump").click(function(){
					$('.anythingSlider').anythingSlider(6);
			});
	});
	*/	
	
	/* write out the email address to protect from spam harvesters*/
	var emailLinkStart = "<a href=\"mailto:";
	var emailLinkMiddle = "\" id=\"mailtolink\">";
	var emailLinkImage = "<img src=\"/images/hello@quirk.gif\" alt=\"Email\" border=\"0\" align=\"top\" style=\"margin-bottom:\-3px;\"/>";
	var emailLinkEnd = "</a>";

	function email( name, domain )
	{
		document.write( emailLinkStart + name + "@" + domain + emailLinkMiddle + name + "@" + domain + emailLinkEnd );
	}

	function emailImage( name, domain )
	{
		document.write( emailLinkStart + name + "@" + domain + emailLinkMiddle + emailLinkImage + emailLinkEnd );
	}		
	
//Accordion function on Courses landing page
	$(function() {
		$( "#accordion" ).accordion();
	});
