function banner(imgSource,url,chance,type) {
   this.imgSource = imgSource;
   this.url = url;
   this.chance = chance;
   this.type = type;
}
function dispBanner() {
	with (this)
	switch (type){
		case "img":
			document.write("<A HREF=" + url + " target=_blank><IMG SRC=http://smsimg.163.com/banner/" + imgSource + "468x60.gif BORDER=0 width=468 height=60></A>");
			break;
		case "html":
			document.write("<IFRAME WIDTH=468 HEIGHT=60 MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR=#000000 SRC=http://smsimg.163.com/banner/"+ imgSource + "468x60.html></iframe>");
			break;
		case "flash":
			document.write("<embed src=http://smsimg.163.com/banner/"+imgSource+"468x60.swf quality=high width=468 height=60 type=application/x-shockwave-flash pluginspage=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash></embed>");
			break;
		default:
			document.write("");
	}
    
}


banner.prototype.dispBanner = dispBanner;
banners = new Array();


// flash , html , img 代表三种不同的广告模式
// 200 之类的数目是设置出现的机率
// banner列表 
banners[0] = new banner("fb_","http://smspop.163.com/sms/special/fballcai.html",500,"img");//足彩
//banners[1] = new banner("03_eden","http://smspop.163.com/sms/popup/03_eden.html",400,"img");//伊甸乐园
banners[1] = new banner("03_mmshalf","http://smspop.163.com/sms/popup/03_mmshalf.html",300,"img");//降价风暴
//banners[2] = new banner("mtv_1129_","http://smspop.163.com/mtv/1129/",200,"img");//1129MTV
banners[2] = new banner("03_lunch","http://smspop.163.com/sms/popup/03_lunch.html",300,"img");//免费午餐
//banners[4] = new banner("free_","http://smspop.163.com/sms/special/free/free.html",200,"img");//免费图铃
//banners[5] = new banner("05_sexhm","http://smspop.163.com/sms/popup/05_sexhumor300x300.html",200,"img");//两性幽默
//banners[3] = new banner("man2_","http://popme.163.com./sms/popup/popup_man_health.html",300,"img");//男性健康
//banners[4] = new banner("05_sex","http://smspop.163.com/sms/popup/05_sexhealth300x300.html",300,"img");//两性健康

/*banners[8] = new banner("03_colorlife","",100,"flash");
banners[9] = new banner("04_colorcar","http://mms.163.com/sub.jsp",100,"img");
*/
sum_of_all_chances = 0;
for (i = 0; i < banners.length; i++) {
  sum_of_all_chances += banners[i].chance;
}
function randomBanner() {
  chance_limit = 0;
  randomly_selected_chance = Math.round((sum_of_all_chances - 1) * Math.random()) + 1;
  for (i = 0; i < banners.length; i++) {
    chance_limit += banners[i].chance;
    if (randomly_selected_chance <= chance_limit) {
      banners[i].dispBanner();
      break;
    }
  }
}
this_banner = randomBanner();
