document.write("<script type='text/javascript' src='/js/global_url.js'></script>");
var nxCard = $.flash.create({swf:"http://nxcache.nexon.net/combatarms/flash/left_nxcard_button.swf",width:182,height:120,params:{wmode:"transparent", bgcolor:"#FFFFFF", allowScriptAccess:"always"}});
var leftDownload = $.flash.create({swf:"http://nxcache.nexon.net/combatarms/flash/left_download.swf",width:182,height:129,params:{wmode:"transparent", bgcolor:"#FFFFFF", allowScriptAccess:"always"}});
var gamesBanner = $.flash.create({swf:"http://nxcache.nexon.net/combatarms/flash/games_182x100.swf",width:182,height:100,params:{wmode:"transparent", bgcolor:"#FFFFFF", allowScriptAccess:"always"}});

var TOTAL_OFFICIAL_SCREENSHOTS = 35;
var TOTAL_WALLPAPER = 8;

// TOP NAVIGATION---------
var hn="0",sn="0",cn="0",tn="0",globalId="0",flaFarm="0";
function Mnav(){
	try{
		var Depth = arguments.length;
		var DepthName = new Array("hn","sn","cn","tn");
		for(i=0;i<Depth;i++){
			if(i==0) hn =  arguments[i];if(i==1) sn =  arguments[i];if(i==2) cn =  arguments[i];if(i==3) tn =  arguments[i];
			globalId = (i==0) ? arguments[i] : globalId+"_"+arguments[i] ;
			flaFarm = (i==0) ?  DepthName[i]+"="+arguments[i] : flaFarm+"&"+DepthName[i]+"="+arguments[i] ;
		}
		document.write("<h1>COMBATARMS</h1><div id=\"swf_mnav\"></div>");
		$('#swf_mnav').flash({swf:'http://nxcache.nexon.net/combatarms/flash/mnav.swf?'+flaFarm,width:1000,height:116,params:{wmode:"transparent", bgcolor:"#FFFFFF", allowScriptAccess:"always"}});
	}catch(e){}
}

// LEFT NAVIGATION---------
function Snav(){
	var Fheight = new Array ('119','287','215','202','119','119','143','143');
	$('#swf_snav').flash({swf:'http://nxcache.nexon.net/combatarms/flash/snav0'+hn+'.swf?'+flaFarm,width:182,height:Fheight[hn-1],params:{wmode:"transparent", bgcolor:"#FFFFFF", allowScriptAccess:"always"}});
}

// LEFT NAVIGATION---------
function link(){
	var url = "";
	var depth = arguments.length;
	try {
		if(depth==0) return;
		else if(depth==1) url = eval("u"+arguments[0]+"[0]");
		else if(depth==2) url = eval("u"+arguments[0]+"_"+arguments[1]+"[0]");
		else if(depth==3) url = eval("u"+arguments[0]+"_"+arguments[1]+"_"+arguments[2]+"[0]");
		else if(depth==4) url = eval("u"+arguments[0]+"_"+arguments[1]+"_"+arguments[2]+"_"+arguments[3]+"[0]");
		else if(depth==5) url = eval("u"+arguments[0]+"_"+arguments[1]+"_"+arguments[2]+"_"+arguments[3]+"_"+arguments[4]+"[0]");
		if(url=="") alert("Coming Soon!");
		else location.href = url;
	}catch(e) { alert("Coming Soon!"); }
}

// LINEMAP---------
function setString(node){
	var spStr = "" , last="";
	try{
		var url  = eval(node+"[0]");
		var name = eval(node+"[1]");
	}
	catch(e){
		document.write("The id does not exist : " + node);
	}
	var nodeId  = node;
	var spStr = " > ";
	if(node.lastIndexOf('_') != -1) setString(node.substring(0,node.lastIndexOf('_')));
	else lineMapStr += "<a href='"+eval("u0[0]")+"'>"+ eval("u0[1]")+"</a>" + spStr;
	if(currentPath != nodeId)
		lineMapStr += "<a href='"+url+"'>"+ name+"</a>" + spStr;
	else
		lineMapStr += "<span class='last'>"+name+"</span>";
}

function Path(){
	try{
		lineMapStr = "";
		index = 0;
		currentPath="u"+globalId;
		setString("u"+globalId);
		document.write("<img src='http://nxcache.nexon.net/combatarms/icon/ico_path.gif' alt='' class='am' /> "+lineMapStr);
	}catch(e){
		document.write("Exception handling occurrence : " +  e);
	}
}

// ---------LINEMAP

// image rollover
function over(obj,type){
	if(type) obj.src = obj.src.replace(".gif","_.gif");
	else  obj.src = obj.src.replace("_.gif",".gif");
}

function layerView(obj){ document.getElementById(obj).style.display = "block"; } /* layer open */
function layerClose(obj){ document.getElementById(obj).style.display = "none"; } /* layer close */

// - Dynamic CSS - Neil
function DynamicCss(cssUrl) {
	$("link").eq(1).attr({type:"text/css",rel:"stylesheet", href: "../CSS/" + cssUrl + ".css"});
}
function CS() {
    alert("Coming Soon!");
}
function pop() {
    var isOpen = window.open("http://combatarms.nexon.net/Popup.htm", "newWindow", "width=792,height=550,resizeable=0,scrollbars=1");
    if (isOpen == null) {
		alert("Your browser has prevented us from opening a window. Please change your browser's settings.");
    }
}
function getQueryVariable(variable) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	}
	return null;
}
// -- SSO Functions
var objUpdateInterval = null;
function onUpdateResponse(resultObject, responseXML)
{
	if (resultObject.ErrorCode == undefined)	// do Logout if the session doesn't exist
	{
		NgbLogin.Logout();
	}
	else if (resultObject.ErrorCode == CommonError.NoError)		// OK
	{
		window.clearInterval(objUpdateInterval);
// After ExpireLimit(Second), do UpdateSession
		objUpdateInterval = setInterval("doUpdateSession()", resultObject.UpdateInterval * 1000);	
}
	else if (resultObject.ErrorCode == AuthSystemError.Disconnected)
	{
// Replace the following line to a custom code
		alert("Disconnected by other session.");
		NgbLogin.Logout();
	}
	else
	{
// Replace the following line to a custom code
		alert("Disconnected.");
		NgbLogin.Logout();
	}
}
function doUpdateSession()
{
	AuthSystem.UpdateSession(onUpdateResponse);
}
function startUpdateSession(b)
{
	if (b)
		setTimeout("doUpdateSession()", 1);
}
// google analytics code
function gaLoad(gaId) {
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	$.ajax({
		url:gaJsHost + "google-analytics.com/ga.js",
		complete: function(){
			try {
				pageTracker = _gat._getTracker(gaId);
				pageTracker._initData();
				pageTracker._trackPageview();
			} catch(err) {}
		},
		dataType:"script" 
    });
}