$(function(){
	//#ie6 png fix on home page
	//$('.pngfix').pngFix(); 
	//$('.pngfix').supersleight({shim: '/interface/scripts/x.gif'});
	//#open external links in new window
	$("a[href^='http']").not("[href*='germanteachers.ie']").attr('target', '_blank');
		   
	//#resource search box - only useful if js enabled
	$('#form-resources').removeClass('hidden');
	//#only show dropdown for selected cycle
	$('#form-resources select').hide();
	var cycleid = $('input[@name=cycle]:checked').attr('value');
	$('#category'+cycleid).show();
	
	/*
	//#get resource dropdown menu working in ie6 and ie7
	$('#nav li.primary').hover(function () {
		$('#nav li.primary').removeClass('sfhover');
      	$(this).addClass('sfhover');
    });
	*/
	
	$('#nav li.primary').hover(
		function() { $('ul', this).addClass('sfhover'); },
		function() { $('ul', this).removeClass('sfhover'); }
	);
	
	//#on change in cycle option, adjust dropdown options to only show relevant categories 
	$('input[name=cycle]').change(function(){
		var cycle = $(this).val();
		$('#form-resources select').hide();
		$('#category'+cycle).show();
	});
	
	//#when select dropdown submit form to save having to press button
	$('#form-resources select').change( function () {
        $('#form-resources').submit();
      });

	
	//#on submit, redirect to appropriate resource category page
	$('#form-resources').submit(function(e){
		e.preventDefault();
		//#determine which cycle and topic was chosen
		var cycleid = $('input[@name=cycle]:checked').attr('value');
		//alert(parentid);
		var topic = $('#category'+cycleid).val();
		//alert(topic);
		if(topic)
		{
			window.location = '/resources/category/' + topic;
		}
	});
});
