$().ready(
	function(){
		$('.nohide').removeClass("hidden"); 
		$('input').removeClass("hidden"); 
		$('#icons').html($('#pagetools').html());
		$('#path').html($('#breadcrumb').html()); 
		
		$('#category_selector').change(function() {
			var str = "";
			$("#category_selector option:selected").each(function () {
					str = "#" + $(this).attr('value');
			});
				
			$(".tabHelpText").hide();
			$(str).show();
		}
		);
		
		if(SHOW_PERMA) {
			$('#icons').append($('#perma_a'));
			$('#perma_a').each(function(idx,el){
				el.style.display='';
			});
		}
		
		if(ADJUST_WIDTH) {
			$('#path').css("width","590px");
			$('#icons').css("width","350px");
		}
		
		/*
		// PROTECTED DOWNLOAD OF BROCHURES
		
		// Load the encryption library
		$.getScript("/scripts/jquery.rc4.js");
			
		// Add click event to all elements with the class pwd_protect
		$('.pwd_protect').click(function() {
			// Variables
			var hostname = window.location.hostname;
			var numRand = Math.floor(Math.random()*101)
			var fetchUrl = "http://"+ hostname +"/?alttemplate=brochurepwd&id="+ $(this).attr('id') +"&"+ numRand +"";
			
			// Initiate form - clear any old content
			$("#passwordError").hide();
			$("#passwordHelpText").hide();
			$("#pwd").val("");
			
			// Load the encrypted password - store it in the key textarea
			$("#key").load(fetchUrl);
			
			//Set action and target on form element - action is the URL from the link
			$("#secretForm").attr("action", $(this).attr('data'));
			$("#secretForm").attr("target", "_blank");
			
			//Place password layer below the clicked link
			var eleOffset = $(this).offset();
			$('#show_password').css('position', 'absolute');
			$('#show_password').css('left', eleOffset.left+10);
			$('#show_password').css('top', eleOffset.top+5);
			
			// Show password layer
			//$('#show_password').show();
			$('#show_password').slideDown("slow")
			
			return false;
		});
	
		// Config the OnSubmit event on form
		$("#secretForm").submit(function() {
			//Encrypted password
			var secretWord = jQuery.trim($('#thePassword').val());
			
			// User entered value - Encrypt it for compare
			var typedWord = jQuery.trim($('#pwd').val());
			var encTypedWord = "0";
			if (typedWord.toString() != '') {
				encTypedWord = jQuery.trim($('#pwd').rc4({"key":ENCRYPT_KEY,"method":"encrypt"}).val());	
			}
			
			// Is password correct?
			if (secretWord.toString() == encTypedWord.toString()) {
				$('#show_password').hide();
				return true;
			} else {
				$("#pwd").focus().select();
				$("#passwordError").show();
				$("#passwordHelpText").show();
			}
			return false;
		});
		
		// Close password layer again
		$("#passwordCloseLink").click(function() {
			//$('#show_password').hide();
			$('#show_password').slideUp("slow")
		});
		*/
	}
);
