jQuery.noConflict();

jQuery(document).ready(function (){
	
	/* IE 6 PNG Fix */
	jQuery('img[@src$=.png]').ifixpng();
	
	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", "#");
		}
	});

	jQuery("#primary_tab").click(function () {
		jQuery("#primary_wrapper").show();
		jQuery("#secondary_wrapper").hide();
		jQuery("#primary_tab").css("backgroundImage" , "url('images/business_support_centre/red_tab.png')");
		jQuery("#secondary_tab").css("backgroundImage" , "url('images/business_support_centre/grey_tab.png')");
	});
	
	jQuery("#secondary_tab").click(function () {
		jQuery("#primary_wrapper").hide();
		jQuery("#secondary_wrapper").show();
		jQuery("#primary_tab").css("backgroundImage" , "url('images/business_support_centre/grey_tab.png')");
		jQuery("#secondary_tab").css("backgroundImage" , "url('images/business_support_centre/red_tab.png')");	
	});
	
	/* Modifications : John Clarke, Insite Labs, 2008/07/30 */
	/* **************************************************** */
	/* Linked dropdown lists */
	jQuery("#cat_search").change( function() {
		var link = jQuery("#business_tools_search").attr("action");
		var selected = jQuery(this).val();
		
		//jQuery("#business_tools_search").attr("action", "demo/business/");
		//jQuery("#business_tools_search").attr("method", "post");
		
		if( selected != '#' )
		{
			jQuery.post( link+"tools_list.php", { selection : selected }, function(data) {
				jQuery("#tools_list").removeAttr("disabled");	
				jQuery("#tools_list").html('');
				jQuery("#tools_list").prepend(data);
			} );
		}
		else
		{
			jQuery("#tools_list").attr("disabled", "disabled");
			jQuery("#tools_list").html('<option>Select Tool</option>');
		}
	} );
	
	/* Open business tool in new window */
	jQuery("#tools_list").change( function() 
	{
		var link = jQuery(this).val();
		//if( link != "#" )
		//{
		//	window.open( jQuery("#business_tools_search").attr("action") + link );
		//}
		jQuery("#business_tools_search").attr("action", link);
		jQuery("#business_tools_search").attr("method", "get");
	} );
	
	jQuery("#form_2_button").click( function()
	{
		var link = jQuery("#form_2_button").val();
		if( link != '#' )
			window.location = link;
	});
	/* **************************************************** */
});