document.observe("dom:loaded", function() {
		// initially hide all containers for tab content
		window.setInterval("refresh_banners()", 5000);
	});



	function file_name_only(str)
	{
		var slash = '/'
		if (str.match(/\\/)) {
					slash = '\\'
		}
		sURL = str.substring(str.lastIndexOf(slash) + 1)
		return sURL
	}	
	
	function refresh_banners()
	{
		var req = '';
		if ($('banner_top') != null)
			req += '&banner_top='+file_name_only($('banner_top').src);
			
		if ($('banner_center') != null)
			req += '&banner_center='+file_name_only($('banner_center').src);
			
		if ($('banner_bottomm_1') != null)
			req += '&banner_bottomm_1='+file_name_only($('banner_bottomm_1').src);
			
		if ($('banner_bottomm_2') != null)
			req += '&banner_bottomm_2='+file_name_only($('banner_bottomm_2').src);
			
		if ($('banner_bottomm_3') != null)
			req += '&banner_bottomm_3='+file_name_only($('banner_bottomm_3').src);
      
		if ($('details_banner_top') != null)
			req += '&details_banner_top='+file_name_only($('details_banner_top').src);
      
		if ($('details_banner_bottomm_1') != null)
			req += '&details_banner_bottomm_1='+file_name_only($('details_banner_bottomm_1').src);
      
		if ($('details_banner_bottomm_2') != null)
			req += '&details_banner_bottomm_2='+file_name_only($('details_banner_bottomm_2').src);		      
		
		new Ajax.Request('banners.php?getbanners=1'+req,
		{
			onComplete: function(transport)
			{
				var data = transport.responseText.evalJSON();
				
				if (data.banner_top != null)
				{
					$('banner_top').src = data.banner_top;
					$('banner_top').parentNode.href = data.banner_top_url;
				}
				if (data.banner_center != null)
				{
					$('banner_center').src = data.banner_center;
					$('banner_center').parentNode.href = data.banner_center_url;
				}
				if (data.banner_bottomm_1 != null)
				{
					$('banner_bottomm_1').src = data.banner_bottomm_1;
					$('banner_bottomm_1').parentNode.href = data.banner_bottomm_1_url;
				}
				if (data.banner_bottomm_2 != null)
				{
					$('banner_bottomm_2').src = data.banner_bottomm_2;
					$('banner_bottomm_2').parentNode.href = data.banner_bottomm_2_url;
				}
				if (data.banner_bottomm_3 != null)
				{
					$('banner_bottomm_3').src = data.banner_bottomm_3;
					$('banner_bottomm_3').parentNode.href = data.banner_bottomm_3_url;
				}
        
				if (data.details_banner_top != null)
				{
					$('details_banner_top').src = data.details_banner_top;
					$('details_banner_top').parentNode.href = data.details_banner_top_url;
				}        
				if (data.details_banner_bottomm_1 != null)
				{
					$('details_banner_bottomm_1').src = data.details_banner_bottomm_1;
					$('details_banner_bottomm_1').parentNode.href = data.details_banner_bottomm_1_url;
				}
				if (data.details_banner_bottomm_2 != null)
				{
					$('details_banner_bottomm_2').src = data.details_banner_bottomm_2;
					$('details_banner_bottomm_2').parentNode.href = data.details_banner_bottomm_2_url;
				}        
			}
		});
	}


