new function(){
	
	var url = HTTP_HOST+"/banner/";
	
	function sideBanner(request){
		
		var elm = document.getElementById('mBanner');
		
		var data = eval("("+request.responseText+")");
		
		for(var i= 0; i < data.bannerList.length; i++){
			
			var li = document.createElement("li");
			
			var a = createBanner(data.bannerList[i], data.area_id);
			
			li.appendChild(a);
			elm.appendChild(li);
		}
	}

	function programBanner(request){
		
		var elm = document.getElementById('pBanner');
		
		var data = eval("("+request.responseText+")");
		
		
		for(var i= 0; i < data.bannerList.length; i++){
			
			var li = document.createElement("li");
			
			var a = createBanner(data.bannerList[i], data.area_id);
			
			li.appendChild(a);
			elm.appendChild(li);
		}
	}
	
	function headerBanner(request){
		
		var data = eval("("+request.responseText+")");
		
		var a = createBanner(data.bannerList[0], data.area_id);
		
		document.getElementById("lBanner").appendChild(a);
	}
	
	
	function footerBanner(request){
		
		var elm = document.getElementById('sBanner');
		
		var data = eval("("+request.responseText+")");
		//alert(data.bannerList.length);
		
		for(var i= 0; i < data.bannerList.length; i++){
			
			var li = document.createElement("li");
			
			var a = createBanner(data.bannerList[i], data.area_id);
			
			var img = a.getElementsByTagName("IMG");
			//alert(img);
			//img[0].width = 190;
			//img[0].height = 48;
			img[0].setAttribute("width", 190);
			img[0].setAttribute("height", 48);
			
			if((i+1)%5==0){
				li.setAttribute("class", "rightSide");
			}
			li.appendChild(a);
			elm.appendChild(li);
		}
	}
	
	function createBanner(banner, area_id){
		
		var a = document.createElement("a");
		
		a.onclick = function(){
			var pars = "banner_id="+banner.id+"&area_id="+area_id;
			var myAjax = new Ajax.Request(
				url+"click.php",
				{
					method: 'get', 
					parameters: pars
			});
			//alert(url+"?"+pars);
			if(banner.target){
				window.open(banner.url);
			}else{
				//alert(banner.url);
				window.location.href = banner.url;
				return false;
			}

		}
		a.href = "javascript:void(0);"
		
		var img = document.createElement("img");
		img.src = HTTP_HOST+"/images/banner/"+banner.img;
		/*
		img.onload = function(){
			if(fontSizeWatcher){
				setTimeout(function(){
					fontSizeWatcher.execFunctions('change');
				}, 5000);
			}
		}*/
		a.alt = img.alt = banner.title;
		
		a.appendChild(img);
		return a;
	}
	
	function getBannerList(code, limit, func){
	
		var pars = "code="+code+"&limit="+limit;
		
		var myAjax = new Ajax.Request(
				url+"ajax.php", 
				{
					method: 'get', 
					parameters: pars, 
					onComplete: func
		});
		
	}
	
	var dir = window.location.pathname.split("/")[1];
	
	var reg = new RegExp("\.");
	
	if(dir == "" || dir == "index.html"){
		//top
		getBannerList('top', 2, sideBanner);
		getBannerList('program', 10, programBanner);
		getBannerList('footer',10 ,footerBanner);
		
	}else{
		getBannerList(dir, 10, sideBanner);
	}
	
	getBannerList('large', 1, headerBanner);
	

}