﻿var GlueProject = function() {
	function init() {
		$(document.body).addClass('js');
		
		if ($('body#questions').length) {
			$(".questionControl").css({'display':'block'});
			$(".questionsList li").each(function(index){$(this).addClass('closed');});
			$(".questionControl").click(toggleQuestionAnswer);
		}
	
		if ($('body#home').length) {
			getRandomValuesBoxes();
		}
		
		pngFix();
	}
	
	function pngFix() {
		if (typeof(jQuery.fn.pngFix) == 'function') {
			$(document).pngFix();
		}	
	}
	
	function toggleQuestionAnswer() {
		$(this).parent().parent().parent().toggleClass('closed');
	}
	
	function getRandomValuesBoxes() {
		environmentId = Math.floor(Math.random()*6) + 1;
		communityId = Math.floor(Math.random()*2) + 1;
		consumerId = Math.floor(Math.random()*2) + 1;
		
		$("#environmentValuesBox").load("values-boxes/environment-" + environmentId + ".html");
		$("#communityValuesBox").load("values-boxes/community-" + communityId + ".html");
		$("#consumerValuesBox").load("values-boxes/consumer-" + consumerId + ".html");
	}
			
	return {
		init: init
	}
}();

$(document).ready(function(){
	GlueProject.init();
});
