jQuery.noConflict();

jQuery(document).ready(function (){
		
	/* IE 6 PNG Fix */
	jQuery('img[@src$=.png]').ifixpng();
	/* Modification : John Clarke, Insite Labs, 2008/07/30 */
	/* *************************************************** */
	
	jQuery("#search_link").click( function() 
	{
		//jQuery("#search_link").attr("href", "http://www.sovereignfoods.co.za/demo/search.php?TB_iframe=true&height=400&width=600");
		/*if( jQuery("#search_string").val() !== '' )
		{
			jQuery("#search_link").attr("href", "http://www.sovereignfoods.co.za/search.php?keepThis=true&search_string=" + jQuery("#search_string").val() + "&TB_iframe=true&height=400&width=600");
			jQuery.post( jQuery("#search_link").attr("href"), { search_string : jQuery("#search_string").val() }, function(data)
			{

			});
		}
		else
		{
			jQuery("#search_link").attr("href", "#");
		}*/
	});
	
	/* Linked dropdown lists */
	jQuery("#resource_cat_search").change(function() {
		//jQuery("#search_form_1").attr("action", "demo/corporate/");
		//jQuery("#search_form_1").attr("method", "post");
		
		var link = jQuery("#search_form_1").attr("action");
		var selected = jQuery(this).val();
		
		jQuery.post(link+"resource_list.php", { selection : selected }, function(data) {
				jQuery("#resource_list").html('');
				jQuery("#resource_list").append(data);
				
				jQuery("#resource_list").removeAttr("disabled")
					//.html(options)
					.find("option:first")
					.attr("selected", "selected");
			});
	});

	/* Open resource in new window */
	jQuery("#resource_list").change( function() {
		var link = jQuery(this).val();
		//window.open( jQuery("#search_form_1").attr("action")
		jQuery("#search_form_1").attr("action", jQuery("#search_form_1").attr("action") + link );
		jQuery("#search_form_1").attr("method", "get");
	} );
	
	jQuery("#form_1_button").click( function()
	{
		var link = jQuery("#search_form_1").attr("action");
		if( link != '#' )
			window.location = link;
	});
	
	/* Linked dropdown lists */
	jQuery("#press_cat_search").change(function() {
		//jQuery("#search_form_2").attr("action", "demo/corporate/");
		//jQuery("#search_form_2").attr("method", "post");
		
		var link = jQuery("#search_form_2").attr("action");
		var selected = jQuery(this).val();
		
		jQuery.post(link+"press_item_list.php", { selection : selected }, function(data) {
				jQuery("#press_release_list").html('');
				jQuery("#press_release_list").append(data);
				
				jQuery("#press_release_list").removeAttr("disabled")
					//.html(options)
					.find("option:first")
					.attr("selected", "selected");
			});
	});

	/* Open resource in new window */
	jQuery("#press_release_list").change( function() {
		var link = jQuery(this).val();
		//window.open( jQuery("#search_form_2").attr("action") + link );
		jQuery("#search_form_2").attr("action", jQuery("#search_form_2").attr("action") + link );
		jQuery("#search_form_2").attr("method", "get");
	} );
	
	jQuery("#form_2_button").click( function()
	{
		var link = jQuery("#search_form_2").attr("action");
		if( link != '#' )
			window.location = link;
	});
	/* *************************************************** */
	/* End Modifications */

	jQuery("#news_period").change(function () {
		var period = jQuery(this).val();
		jQuery("#news_period_form").submit();
	});

});