jQuery(document).ready(function() {
	SurveyBindEvents();
});


function SurveyBindEvents() {
	
	
	jQuery('div#divSurveyFooter').hover(
      function() { jQuery(this).css('opacity', 0.6); },
      function() { jQuery(this).css('opacity', 1.0); }
    );

	jQuery('span#expandSurveyHeader').hover(
      function() { jQuery(this).css('opacity', 0.6); },
      function() { jQuery(this).css('opacity', 1.0); }
    );

	jQuery('div#divSurveyFooter').click(function() {
		console.log('footer clicked');
		if (jQuery(this).hasClass('closed')) {
			jQuery('div.surveyMainQuestion').slideDown('slow');
			jQuery('div.surveySubQuestion').slideDown('slow');
			jQuery(this).removeClass('closed').addClass('opened');
			jQuery('span#footerSpan').html('COLLAPSE RATINGS');
			jQuery('span#expandSurveyHeader').html('COLLAPSE RATINGS');

		} else {
			jQuery('div.surveySubQuestion').slideUp('slow');
			jQuery('div.surveyMainQuestion').slideUp('slow');
			jQuery(this).removeClass('opened').addClass('closed');
			jQuery('span#footerSpan').html('EXPAND RATINGS');
			jQuery('span#expandSurveyHeader').html('EXPAND RATINGS');
		}

	});

	jQuery('span#expandSurveyHeader').click(function() {
		if (jQuery(this).hasClass('closed')) {
			jQuery('div.surveyMainQuestion').slideDown('slow');
			jQuery('div.surveySubQuestion').slideDown('slow');
			jQuery(this).removeClass('closed').addClass('opened');
			jQuery('span#footerSpan').html('COLLAPSE RATINGS');
			jQuery('span#expandSurveyHeader').html('COLLAPSE RATINGS');

		} else {
			jQuery('div.surveySubQuestion').slideUp('slow');
			jQuery('div.surveyMainQuestion').slideUp('slow');
			jQuery(this).removeClass('opened').addClass('closed');
			jQuery('span#footerSpan').html('EXPAND RATINGS');
			jQuery('span#expandSurveyHeader').html('EXPAND RATINGS');
		}

	});

	if (jQuery('.benchmarkToggle').children('input').attr('checked')) {
		jQuery('.surveyMainRow.benchmarkTopRow.closed').removeClass('borderBottom');
		//jQuery('div.average').slideDown('slow');
	} else {
		jQuery('div.average').hide();
		jQuery('.surveyMainRow.benchmarkTopRow.closed').addClass('borderBottom');
	}
	
	if (jQuery('.graph').length > 0) {
		jQuery('.graph').corner('5px');
	}
	if (jQuery('.bar').length > 0) {
		jQuery('.bar').corner('5px');
	}
	if (jQuery('.bar2').length > 0) {
		jQuery('.bar2').corner('5px');
	}
	if (jQuery('.logoBackgroundOuter').length > 0) {
		jQuery('.logoBackgroundOuter').corner('10px');
	}

	jQuery('.benchmarkToggle').click(function() {
		if (jQuery(this).children('input').attr('checked')) {
			//jQuery('.descriptionBenchmark').css('visibility', 'hidden');
			//jQuery('.productRatingText').css('visibility', 'visible');
			jQuery('.surveyMainRow.benchmarkTopRow.closed').removeClass('borderBottom');
			jQuery('div.average').slideDown('slow');
		} else {
			//jQuery('.descriptionBenchmark').css('visibility', 'visible');
			jQuery('div.average').slideUp('slow');
			jQuery('.surveyMainRow.benchmarkTopRow.closed').addClass('borderBottom');
			//jQuery('.productRatingText').css('visibility', 'visible');
			//jQuery('.productRatingText').css('visibility', 'hidden');

		}

	});
}
