jQuery(document).ready(function($){
	
	//**************************************************Replace align attribute with class**************************************************//
	
	$('img[align="left"]').addClass('left').removeAttr('align');
	$('img[align="right"]').addClass('right').removeAttr('align');
	$('img[align="middle"]').addClass('middle').removeAttr('align');
	
	
	//**************************************************Replace target attribute with class*************************************************//
	
	$('a[target]').addClass('newwindow').removeAttr('target');
	
	
	//**************************************************The following function make it possible to have web standard popups*****************//
	
	$('a.newwindow').click(function() {
		window.open($(this).attr('href'));
    return false;
	});
	
	
	//**************************************************Clear search text out search box on focus*******************************************//
	
	$('#txtSearch').focus(function() {
    if ($(this).val() == "SEARCH") {
      $(this).val('');
	  }
  });
  
	
	//**************************************************Toggle the search box***************************************************************//
  
	$('#searchForm').hide();
	$('ul#utilityNav li a.search').click(function () {
		$('#searchForm').slideToggle('slow');
	  return false;
	});   
	
	
	//************************************************Toggle Testimonials*******************************************************************//
	
	$('.blurb h5').hide();
	$('.blurb h6').hide();
	$('.testimonyWrap h4').addClass('inactive');
	$('.testimonyWrap h4').click(function () {
		$(this).toggleClass('inactive');
		$(this).toggleClass('active');		
	  $(this).parent().find('.blurb h5').slideToggle();
		$(this).parent().find('.blurb h6').slideToggle();
		$(this).parent().find('.blurb h5 span').slideToggle();
	});
	
	
	//************************************************Toggle All Testimonial Answers********************************************************//
	
	$('p.showAllTestimonials span').click(function () {
		if($(this).html() == 'Show All Case Studies') {
			$(this).parent().parent().find('.blurb h5').slideDown('');
			$(this).parent().parent().find('.blurb h6').slideDown('');
			$(this).parent().parent().find('.blurb h5 span').slideDown('');
			$(this).html('Hide All Case Studies');
			$(this).parent().parent().find('.testimonyWrap h4').removeClass('inactive');
			$(this).parent().parent().find('.testimonyWrap h4').addClass('active');
	  } else {
			$(this).parent().parent().find('.blurb h5').slideUp();
			$(this).parent().parent().find('.blurb h6').slideUp();
			$(this).parent().parent().find('.blurb h5 span').slideUp();
			$(this).parent().parent().find(this).html('Show All Case Studies');
			$(this).parent().parent().find('.testimonyWrap h4').removeClass('active');
			$(this).parent().parent().find('.testimonyWrap h4').addClass('inactive');
		}
	});
	

  //**************************************************Toggle Categories*******************************************************************//
	
	$('h5 span').hide();
	$('p.pdf').hide();
	$('.sectionWrap h4').addClass('inactive');
	$('.sectionWrap h4').click(function () {
		$(this).toggleClass('inactive');
		$(this).toggleClass('active');
		$('p.showAll span').hide();
		$('.faqList').hide();
		$('h5 span').removeClass('active');
		$('h5 span').addClass('inactive');		
	  $(this).parent().find('h5 span').slideToggle();
		$(this).parent().find('p.pdf').slideToggle();
  });	
  

	//**************************************************Toggle Category Lists***************************************************************//
	
	$('.faqList').hide();
	$('p.showAll span').hide();
	$('h5 span').addClass('inactive');
	$('h5 span').click(function () {
		$(this).toggleClass('inactive');
		$(this).toggleClass('active');
	  $(this).parent().parent().find('p.showAll span').slideToggle();
	  $(this).parent().parent().find('.faqList').slideToggle('');
  });
  

	//**************************************************Toggle All Answers******************************************************************//
  
	$('.faqList h6').addClass('inactive');
	$('p.showAll span').click(function () {
		if($(this).html() == 'Show All Answers') {
    	$(this).parent().parent().find('.faqList div:visible').slideToggle('');
    	$(this).parent().parent().find('.faqList div').slideToggle('');
    	$(this).html('Hide All Answers');
  		$(this).parent().parent().find('.faqList h6').removeClass('inactive');
  	  $(this).parent().parent().find('.faqList h6').addClass('active');
    } else {
			$(this).parent().parent().find('.faqList div:hidden').slideToggle('');
      $(this).parent().parent().find('.faqList div').slideToggle('');
      $(this).parent().parent().find(this).html('Show All Answers');
      $(this).parent().parent().find('.faqList h6').removeClass('active');
      $(this).parent().parent().find('.faqList h6').addClass('inactive');
    }
  });
  

	//**************************************************Toggle FAQ Question/Answer**********************************************************//
  
	$('.faqList div').hide();
  $('.faqList h6').click(function () {
		$(this).toggleClass('inactive');
		$(this).toggleClass('active');
    $($(this).next('div')).slideToggle('');
  });
   

	//*************************************************Toggle Who Uses iClicker*************************************************************//
	
	  $('div.toggle').hide();
	  $('.reveal').addClass('inactive');
	  $('.revealCopyWrap .reveal').click(function () {	
			$(this).toggleClass('inactive');
			$(this).toggleClass('active');
			$(this).parent().find('div.toggle').slideToggle();
	  });	
	
	
	//*****Add swfobject flash call*********************************************************************************************************//
	
	var flashvars = {};
	var params = {};
	params.wmode = "transparent";
	var attributes = {};
	swfobject.embedSWF("/swf/home.swf", "flash-content", "685", "306", "8.0.0", false, flashvars, params, attributes);
	swfobject.embedSWF("/swf/higher-ed.swf", "flashhighereducation", "227", "93", "8.0.0", false, flashvars, params, attributes);
	swfobject.embedSWF("/swf/k-12.swf", "flashk12education", "227", "93", "8.0.0", false, flashvars, params, attributes);
	swfobject.embedSWF("/swf/corporate.swf", "flashcorporategovernmentnonprofit", "227", "93", "8.0.0", false, flashvars, params, attributes);
	swfobject.embedSWF("/swf/timeline.swf", "flash-timeline", "605", "458", "8.0.0", false, flashvars, params, attributes);
	swfobject.embedSWF("/swf/partners.swf", "partnersFlash", "227", "93", "8.0.0", false, flashvars, params, attributes);
	
	//*****Contact form switcher*********************************************************************************************************//
	function chooseType() {
    hide();
	  selected();
	  $('ul#quesionOptions a').click(function() {
	    $('#hdnWhatType').val($(this).attr('class'));
	    selected();
	    return false;
	  });
	}
	chooseType();
	function hide() {
	  $('.questionsAboutIclicker').hide();
	  $('.questionsAboutLectureCapture').hide();
    $('.showHide').hide();
    $('.contact').hide();
    $('.suggestion').hide();
  }
	function selected() {
    if ($('#hdnWhatType').val() == 'iclicker') {
      hide();
      $('#formType').val('contact');
      $('.questionsAboutIclicker').show();
      iAmA();
    } else if ($('#hdnWhatType').val() == 'feedback') {
      hide();
      $('#formType').val('suggestion');
      $('.contactSuggestion').show();
	    $('.suggestion').show();
	    $('fieldset.contactSuggestion > span.top').removeClass('top01');
	    $('fieldset.contactSuggestion > span.top').addClass('top02');
	    $('#formTitle').text('Share your suggestions now');
	    $('.subtitle').hide();
    } else if ($('#hdnWhatType').val() == 'lectureCapture') {
      hide();
      $('.questionsAboutLectureCapture').show();
      iAmInterestedIn();
    } else {
      hide();
    }
  }
	function iAmA() {
	  if ($('#slctIAmA option:selected').val() == 'K12 Teacher / Administrator') {
      $('.showHide').hide();
      $('.contact').hide();
      $('.suggestion').hide();
      $('.k12').show();
    } else if ($('#slctIAmA option:selected').val() == 'Higher Education Instructor / Administrator') {
      $('.showHide').hide();
      $('.contactSuggestion').show();
      $('.contact').show();
      $('#formTitle').text('Higher Education Contact Form');
      $('.subtitle').show();
    } else if ($('#slctIAmA option:selected').val() == 'Corporate Customer') {
      $('.showHide').hide();
      $('.contactSuggestion').show();
      $('.contact').show();
      $('#formTitle').text('Corporate Customer Contact Form');
      $('.subtitle').show();
    } else {
      $('.showHide').hide();
      $('.contact').hide();
      $('.suggestion').hide();
      $('.k12').hide();
    }
  }
	function iAmInterestedIn() {
	  if ($('#slctIAmInterestedIn option:selected').val() == 'Higher Education') {
      $('.showHide').hide();
      $('.higherEducation').show();
    } else if ($('#slctIAmInterestedIn option:selected').val() == 'Information other than Higher Education') {
      $('.showHide').hide();
      $('.otherHigherEducation').show();
    } else {
      $('.showHide').hide();
    }
  }
  $('#slctIAmInterestedIn').change(function () {
    iAmInterestedIn();
  });
  $('#slctIAmA').change(function () {
	  iAmA();
  });
});


//**************************************************Custom Animation Methods jQuery**************************************************//