function idOnOff(id, type){
	var layer = document.getElementById(id);
	layer.style.display = type;
}

var httpRequest = null;
var channelCode ="";
var tickerHtml = "";
//For arario Header PVUV check not depended on Third Party Framework (jQuery, prototypejs)
function getXHR(){
	if(window.ActiveXObject){
		try{
			return new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e){
			try{
				return new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e1){
				return null;
			}
		}
	}else if(window.XMLHttpRequest){
		return new XMLHttpRequest();
	}else{
		return null;
	}
}
var site = new Site();

function pvuvOnHeader(sub_no, code){
	document.location.replace(site.atong+"pvUvCheck.htmls?gbn=AT004003&sub_no=" +sub_no);
}

function Site(){
	this.atong = "http://www.arario.jp/";
	this.dc = "http://driftcity.arario.jp/";
	this.cf = "http://crossfire.arario.jp/";
	this.ao = "http://aceonline.arario.jp/";
	this.pt = "http://pristontale.arario.jp/";
	this.st = "http://stonline.arario.jp/";
}

function popMyPage(myPageURL){
	window.open(myPageURL,'myPage','width=655,height=600,statusbar=no,scrollbars=yes,toolbar=no,resizable=no');
}

function araTopGoLogin(){
	alert('ログインしてからご利用ください。');
	window.location.href = 'http://www.arario.jp/araLogin.htmls?gn=extra&rURL=' + document.location.href;
}

//Do not Use 
function remoteUVPV(gbn,sub_no){
	$.post(site.atong+"pvUvCheck.htmls?gbn="+gbn+"&sub_no="+ sub_no);
}

/**
 * add from 20101101 by Park Seung Kyoo
 * 2010年11月01日追加作業　朴勝奎
 * arario.header package 作成
*/
//set arario.header package
var arario = {
		"home":"http://www.arario.jp/",
		"dc_home":"http://driftcity.arario.jp/",
		"cf_home":"http://crossfire.arario.jp/",
		"ace_home":"http://aceonline.arario.jp/",
		"pt_home":"http://pristontale.arario.jp/",
		"st_home":"http://stonline.arario.jp/",
		"e2_home":"http://e2.arario.jp"
};
arario.header = {
	//get cookie value by cookie name
	getCookie:function(name){
		var search = name + "=";
	    if (document.cookie.length > 0){
	        offset = document.cookie.indexOf(search);
	        if (offset != -1){
	            offset += search.length;
	            end = document.cookie.indexOf(";",offset);
	            if (end == -1) end = document.cookie.length;
	            return unescape(document.cookie.substring(offset,end));
	        }
	        else return false;
	    }
	    else return false;
	}, 
	//ポータルチャネリングに従ってロゴを変える。　関係しているソース：ararioHeaderInfo.js
	changeLogo:function(){ 
		if(channelCode == "ocn"){
			document.getElementById("AraioHeaderLogo").innerHTML = '<a href="http://www.ocn.ne.jp"><img src="http://www.arario.jp/images/logo_OCN.jpg"  width="70" height="33" alt="" /></a>';
		}else if(channelCode == "goo"){
			document.getElementById("AraioHeaderLogo").innerHTML = '<a href="http://game.goo.ne.jp/index.html" target="_blank"><img src="'+arario.home+'images/topbar/logo_goo.jpg" alt="gooゲーム" /></a>';
		}else{
			document.getElementById("AraioHeaderLogo").innerHTML = '<a href="'+arario.home+'home.htmls?pn=main" onclick="pvuvOnHeader(\'2100\', \'atong\')" target="_top"><img src="http://www.arario.jp/images/logo.jpg"  width="70" height="33" alt="" /></a>';
		}
	}, 
	idToggle:function(id){
		var obj = document.getElementById(id);
		var dis = obj.style.display;
		obj.style.display = (dis == "block") ? "none" : "block";
	},
	//set Game List at potal site
	setGameList:function(){
		var ichiran = document.getElementById("ArarioHeaderIchiran");
		if(channelCode == "yahoo" ||channelCode == "ocn" ||channelCode == "goo"  ){
			ichiran.innerHTML = gameLists[channelCode];
		}else{
			ichiran.innerHTML =  gameLists.arario;
		}
	},
	//set ticker to each site 
	setTickers:function(){
		var html = [];
		var tickersSize = ararioHeaderTickers.length;
		
		if((channelCode !="yahoo" && channelCode !="goo" && channelCode !="ocn"))
			channelCode = "arario";
		
		var eul = document.createElement("ul");
		eul.setAttribute("class", "js-hidden");
		eul.setAttribute("id", "js-news");
		for(var i=0;i<tickersSize;i++){
			var tickerObj = ararioHeaderTickers[i];
			if(tickerObj.chCode == channelCode){
				eli = document.createElement("li");
				ea = document.createElement("a");
				ea.setAttribute("href", tickerObj.link);
				ea.setAttribute("target", tickerObj.target);
				ea.appendChild(document.createTextNode(tickerObj.contents));
				eli.appendChild(ea);
				eul.appendChild(eli);
			}
		}
		document.getElementById('ticker-wrapper').appendChild(eul);
		document.getElementById('js-news').style.display= "none";
	},
	//set New Game View On or Off
	setNewGameView:function(){
		if(channelCode == "yahoo" ||channelCode == "ocn" ||channelCode == "goo"  ){
			idOnOff('ararioHeaderNewGameBtn2', 'none');
		}else{
			idOnOff('ararioHeaderNewGameBtn', 'block');
			idOnOff('ararioHeaderNewGameBtn2', 'block');
		}  
	},
	
	/**
	 * アラリオヘッダーを描く
	 * 同時にティッカーの設定と会員登録、マイページ、サポートページのリンクを変える
	 */
	drawHeader:function(gameCode){
		drawAtong();
		document.getElementById('ArarioHeaderIchiran').
		
		channelCode = fcdCodes[arario.header.getCookie("__accpzm")];
		/*ticker start!*/
		arario.header.changeLogo();  /*logo change*/
		arario.header.setTickers(); 
		arario.header.setNewGameView();
		var $j = jQuery.noConflict(); 
		$j(function () {
			$j('#js-news').ticker({
				speed:0.10,
				fadeInSpeed:100,
				titleText:''
			});
			$j('#atongRegist').attr("href", arario.home+"?pn=regit&gn="+ gameCode);
			$j('#atongMypage').attr("href", arario.home+"memberInfoAuth.action?gn="+ gameCode);
			$j('#atongSupport').attr("href", arario.home+"support/go.htmls");
			$j('#atongRiocoin').attr("href", arario.home+"riocoin/go.htmls");
			
			//HTMLを描く時elementがないのに実行されるのを防ぐため
			arario.header.setGameList(); 
		});
	}
}; 
