/**
 * OfficialBanner
 * 
 * @version $Revision: 1.306 $
 * @access public
 * @author oono
 */

var AD_LIST = new Array();
AD_LIST[0]  = new Array('http://vclick.ameba.jp/click?vci=51164','小林麻央がBLOGで交際宣言！','option_header_news','header_news');
AD_LIST[1]  = new Array('http://vclick.ameba.jp/click?vci=51157','大好評！平山あやレギンス！','option_header_news','header_news');
AD_LIST[2]  = new Array('http://vclick.ameba.jp/click?vci=51156','えなりかずきブログＯＰＥＮ','option_header_news','header_news');
AD_LIST[3]  = new Array('http://vclick.ameba.jp/click?vci=51158','ユンナ新曲は『好きなんだ』','option_header_news','header_news');
AD_LIST[4]  = new Array('http://vclick.ameba.jp/click?vci=51159','長澤まさみ、ほっこり顔','option_header_news','header_news');
AD_LIST[5]  = new Array('http://vclick.ameba.jp/click?vci=51160','藤井りながブログに登場！','option_header_news','header_news');
AD_LIST[6]  = new Array('http://vclick.ameba.jp/click?vci=51161','太陽と小池徹平の意外な関係','option_header_news','header_news');
AD_LIST[7]  = new Array('http://vclick.ameba.jp/click?vci=51162','香取慎吾「歯の痛みなし！」','option_header_news','header_news');
AD_LIST[8]  = new Array('http://vclick.ameba.jp/click?vci=51163','矢口真里、保田圭に人生相談','option_header_news','header_news');
AD_LIST[9]  = new Array('http://vclick.ameba.jp/click?vci=51165','ファンモン加藤が質問に回答','option_header_news','header_news');
AD_LIST[10]  = new Array('http://vclick.ameba.jp/click?vci=30255','アノ芸能人もBlog始めました','option_header_amesta','header_amesta');
AD_LIST[11]  = new Array('http://vclick.ameba.jp/click?vci=30256','新着ブログを写真でチェック','option_header_amesta','header_amesta');
AD_LIST[12]  = new Array('http://vclick.ameba.jp/click?vci=30254','芸能人と同じブログを始めよう','option_header_amesta','header_amesta');

function OfficialBanner(){
var self = this;
	this.nowBanner = null;
	this.bannerList = null;
	this.creteFlag = false;
	this.randomNum = -1;

	this.init = function(){
		if(AD_LIST == null){return;}
		if(AD_LIST.length <= 0){return;}

		this.nowBanner = document.getElementById("nowBanner");
		this.bannerList = document.getElementById('bannerList');
		if(this.nowBanner == null){return;}
		this.shuffleBanner();

		this.nowBanner.onmouseover = function(){self.openList();};
		this.bannerList.onmouseover = function(){self.openList();};
		this.bannerList.onmouseout = function(){self.closeList();};
	}

	this.shuffleBanner = function(){
		this.randomNum = Math.floor(Math.random()*AD_LIST.length);
		this.nowBanner.appendChild(this.setA(AD_LIST[this.randomNum]));
	}

	this.openList = function(){
		if(this.creteFlag == false){this.createList();}
		this.show(true);
	}
	this.closeList = function(){
		this.show(false);
	}

	this.createList = function(){
		this.bannerList.innerHTML = "";

		var ul_blog = document.createElement("ul");
		var ul_amesta = document.createElement("ul");
		this.bannerList.appendChild(ul_blog);
		this.bannerList.appendChild(ul_amesta);
		ul_blog.id = "ulBlog";
		ul_amesta.id = "ulAmesta";

		for (var i=0; i<AD_LIST.length; i++){
			if(i == this.randomNum){continue;}
			if(!AD_LIST[i]){continue;}

			var li = document.createElement("li");
			li.appendChild(this.setB(AD_LIST[i]));

			if(AD_LIST[i][2] == "option_header_news"){
				ul_blog.appendChild(li);
			}else{
				ul_amesta.appendChild(li);
			}
		}
		this.creteFlag = true;
	}

	this.setA = function(data){
		var a = document.createElement("a");
		a.href = data[0] || '';
		a.innerHTML = data[1] || '';
		a.className = data[3];
		a.id = data[3];
		return a;
	}

	this.setB = function(data){
		var a = document.createElement("a");
		a.href = data[0] || '';
		a.innerHTML = data[1] || '';
		a.className = data[2];
		return a;
	}

	this.show =function(flag){
		if(flag){
			this.bannerList.style.display = "block";
		}else{
			this.bannerList.style.display = "none";
		}
	}
	this.init();
}