/* global.js v 1.0 */
function getCookie(cookieName){var cookies=document.cookie;if(cookies.indexOf(cookieName)==-1)return false;cookie=cookies.substr(cookies.indexOf(cookieName));cookie=cookie.split(';')[0];cookie=cookie.substr(cookie.indexOf('=')+1);return cookie;}function getStyleAtt(obj,stylePrp){var att="";if(obj.currentStyle){stylePrp=stylePrp.replace(/\-(\w)/g,function(k,z){return z.toUpperCase();});att=obj.currentStyle[stylePrp];}else if(document.defaultView&&document.defaultView.getComputedStyle)att=document.defaultView.getComputedStyle(obj,null).getPropertyValue(stylePrp);return att;}function imgOverScope(scope){var rollarea;rollarea=(scope==null)?document:scope;imgs=rollarea.getElementsByTagName('img');for(i=0;i<imgs.length;i++){if(imgs[i].className=='over'||imgs[i].className.indexOf('over')>=0){imgs[i].onmouseover=imgOver;imgs[i].onmouseout=imgOver;}}}function imgOver(obj){if(window.event){var img=(obj!=null&&obj.type!='mouseover'&&obj.type!='mouseout')?obj:this;}else var img=(obj.type=='mouseover'||obj.type=='mouseout')?this:obj;var imgurl=img.src;var imginfo=imgurl.substr(imgurl.lastIndexOf('_')+1).split('.');if(imginfo[0]=='on'){img.src=imgurl.substr(0,imgurl.lastIndexOf('_'))+'_off.'+imginfo[1];}else{img.src=imgurl.substr(0,imgurl.lastIndexOf('_'))+'_on.'+imginfo[1];}}function rowClassChange(elementId,tagName,denyClass){if(document.getElementById(elementId)==null)return;var xElement=document.getElementById(elementId).getElementsByTagName(tagName);for(i=0;i<xElement.length;i++){if(xElement[i].className!=denyClass){xElement[i].onmouseover=classOver;xElement[i].onmouseout=classOut;}}}function classOver(obj){if(window.event){var xElement=(obj!=null&&obj.type!='mouseover'&&obj.type!='mouseout')?obj:this;}else var xElement=(obj.type=='mouseover'||obj.type=='mouseout')?this:obj;if(xElement.className=="")xElement.className="on";else xElement.className=xElement.className+" on";}function classOut(obj){if(window.event){var xElement=(obj!=null&&obj.type!='mouseover'&&obj.type!='mouseout')?obj:this;}else var xElement=(obj.type=='mouseover'||obj.type=='mouseout')?this:obj;if(xElement.className=="on")xElement.className="";else xElement.className=xElement.className.replace(" on","");}function openPopup(obj,objWidth,objHeight,objName,objScroll,deny,objFull,addParam){try{if(typeof(obj)=='string'){var setup="width="+objWidth+",height="+objHeight+",toolbar=no,location=no,status=no,menubar=no,top=20,left=20,scrollbars="+objName+",resizable=no";if(objScroll==""||!objScroll)objScroll="popup";if(objFull)setup="fullscreen=1,scrollbars=0";var win=window.open(obj,objScroll,setup);if(win!=null)win.focus();return;}if(!objName)objName="popup";if(!objScroll)objScroll="auto";var url=addParam?obj.href+'?'+addParam:obj.href;var setup="width="+objWidth+",height="+objHeight+",toolbar=no,location=no,status=no,menubar=no,top=20,left=20,scrollbars="+objScroll+",resizable=no";if(objFull)setup="fullscreen=1,scrollbars=0";var win=window.open(url,objName,setup);if(deny){if(win==null)alert('팝업 차단을 해제하여 주시기 바랍니다.');else win.focus();}}catch(e){}}function flashOpenPage(popUrl,popWidth,popHeight,isScroll,logId){try{_trk_clickTrace("EVT",logId);}catch(_e){}if(popWidth=="0"&&popHeight=="0"){if(isscroll=="0")document.location.href=popUrl;else window.open(popUrl,"_blank");}else{var setup="width="+popWidth+",height="+popHeight+",toolbar=no,location=no,status=no,menubar=no,top=20,left=20,scrollbars="+isScroll+",resizable=no";window.open(popUrl,"openbyflash",setup);}}function toggleMenu(menu,sub){var toggleid=document.getElementById(menu);var togglediv=sub.split('.');var togglesub=toggleid.getElementsByTagName(togglediv[0]);this.openContents=function(){var currentmenu=navigator.userAgent.indexOf("MSIE")==-1?this.nextSibling.nextSibling:this.nextSibling;var menustatus=currentmenu.style.display=='block'?1:0;var closemenu=this.parentNode.getElementsByTagName(currentmenu.tagName);for(i=0;i<closemenu.length;i++){closemenu[i].style.display='none';}if(menustatus)return;currentmenu.style.display='block';};for(i=0;i<togglesub.length;i++){if(togglediv[1]){if(togglesub[i].className!=togglediv[1]){togglesub[i].onclick=this.openContents;}}else{togglesub[i].onclick=this.openContents;}}}function showFlashObject(objID,objSource,objWidth,objHeight,objQuality,objWmode,objBgcolor,objXML){if(objXML){var chkMovie=0;if(objSource.match(/=/))objSource=objSource+"&server="+objXML+"&chkMovie="+chkMovie;else objSource=objSource+"?server="+objXML+"&chkMovie="+chkMovie;}var pageUrl=self.window.location.href;if(pageUrl.substring(0,5)=="https")swfUrl="https";else swfUrl="http";if(!objID)objID="ShockwaveFlash1";if(!objWidth)objWidth="0";if(!objHeight)objHeight="0";if(!objQuality)objQuality="high";if(!objWmode)objWmode="transparent";document.writeln('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+swfUrl+'://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0" width="'+objWidth+'" height="'+objHeight+'" id="'+objID+'" align="middle">');document.writeln('<param name="allowFullScreen" value="false" />');document.writeln('<param name="scale" value="noscale" />');document.writeln('<param name="movie" value="'+objSource+'" />');document.writeln('<param name="allowScriptAccess" value="always" />');document.writeln('<param name="menu" value="false" />');document.writeln('<param name="quality" value="high" />');document.writeln('<param name="bgcolor" value="'+objBgcolor+'" />');document.writeln('<param name="wmode" value="'+objWmode+'" />');document.writeln('<embed src="'+objSource+'" allowScriptAccess="always" menu="false" quality="high" bgcolor="'+objBgcolor+'" wmode="'+objWmode+'" width="'+objWidth+'" height="'+objHeight+'" name="'+objID+'" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');document.writeln('</object>');}function showMediaObject(objSource,objID,objWidth,objHeight,autostart,showcontrols){if(!objID)objID="MovieClip1";if(!objWidth)objWidth="400";if(!objHeight)objHeight="345";if(!autostart)autostart="0";if(!showcontrols)showcontrols="0";if(-1!=navigator.userAgent.indexOf("MSIE")){document.writeln('<object classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" id="'+objID+'" width="'+objWidth+'" height="'+objHeight+'">');document.writeln('<param name="AutoSize" value="1">');document.writeln('<param name="AutoStart" value="'+autostart+'">');document.writeln('<param name="AutoRewind" value="1">');document.writeln('<param name="ClickToPlay" value="0">');document.writeln('<param name="Enabled" value="1">');document.writeln('<param name="EnableTracker" value="1">');document.writeln('<param name="EnableContextMenu" value="0">');document.writeln('<param name="ShowStatusBar" value="0">');document.writeln('<param name="ShowControls" value="'+showcontrols+'">');document.writeln('<param name="ShowAudioControls" value="'+showcontrols+'">');document.writeln('<param name="ShowCaptioning" value="0">');document.writeln('<param name="Mute" value="0">');document.writeln('<param name="ShowDisplay" value="0">');document.writeln('<param name="filename" value="'+objSource+'">');document.writeln('</object>');}else{document.writeln(' <object id="'+objID+'" type="video/x-ms-wmv" data="'+objSource+'" width="'+objWidth+'" height="'+objHeight+'">');document.writeln(' <param name="AutoStart" value="'+autostart+'">');document.writeln(' <param name="AutoRewind" value="1">');document.writeln(' <param name="Enabled" value="1">');document.writeln(' <param name="EnableTracker" value="1">');document.writeln(' <param name="EnableContextMenu" value="0">');document.writeln(' <param name="ShowStatusBar" value="0">');document.writeln(' <param name="ShowControls" value="'+showcontrols+'">');document.writeln(' <param name="ShowAudioControls" value="'+showcontrols+'">');document.writeln(' <param name="ShowCaptioning" value="0">');document.writeln(' <param name="ShowDisplay" value="0">');document.writeln(' <param name="url" value="'+objSource+'">');document.writeln(' <param name="src" value="'+objSource+'">');document.writeln(' </object>');}}
/* aion.js */
function openDenyPopup(url,width,height,scroll,winName){
var setup="width="+width+",height="+height+",toolbar=no,location=no,status=no,menubar=no,top=20,left=20,scrollbars="+scroll+",resizable=no";
if(winName==""||!winName)winName="popup";
var win=window.open(url,winName,setup);
if(win==null)alert("Please allow pop-up windows.");
else win.focus();
}

function showLayer(layerId){
var layer=(layerId!=null&&layerId.type!="mouseover"&&layerId.type!="mouseout")?layerId:this.name;
document.getElementById(layer).style.display="block";
}
function hideLayer(layerId){
var layer=(layerId!=null&&layerId.type!="mouseover"&&layerId.type!="mouseout")?layerId:this.name;
document.getElementById(layer).style.display="none";
}
var _stringPrototype=String.prototype;
_stringPrototype.lTrim=_stringPrototype.trimStart=function()
{
return this.replace(/^\s*/,"");
}
_stringPrototype.rTrim=_stringPrototype.trimEnd=function()
{
return this.replace(/\s*$/,"");
}
_stringPrototype.trim=function()
{
return this.trimStart().trimEnd();
}

function open_popup(url,wid,hei,scroll,winName) {
var url=url;
var posi="width="+wid+",height="+hei+",toolbar=no,location=no,status=no,menubar=no,top=10,left=50,scrollbars="+scroll+",resizable=no";
if(winName=="")
{
winName=popup;
}
window.open(url,winName,posi);
}

function bookmarksite (title, url) {
if (window.sidebar) //firefox
window.sidebar.addPanel(title, url, "");
else if (window.opera && window.print) { //opera
var elem = document.createElement('a');
elem.setAttribute('href', url);
elem.setAttribute('title', title);
elem.setAttribute('rel', 'sidebar');
elem.click();
}
else if (document.all) //ie
window.external.AddFavorite(url, title);
}
function startPage(Obj,urlStr){
if (document.all && window.external){
Obj.style.behavior='url(#default#homepage)';
Obj.setHomePage(urlStr);
} else {
alert('To make Aion your home page, drag the button to the home icon atop the browser window.');
}
}

function toggleMenu_state(menu, sub) {
var toggleid = document.getElementById(menu);
var togglediv = sub.split('.');
var togglesub = toggleid.getElementsByTagName(togglediv[0]);
this.openContents = function() {
var currentmenu = navigator.userAgent.indexOf("MSIE") == -1 ? this.nextSibling.nextSibling : this.nextSibling;
var menustatus = currentmenu.style.display == 'block' ? 1 : 0;
var closemenu = this.parentNode.getElementsByTagName(currentmenu.tagName);
for (i=0;i<closemenu.length;i++) {
currentmenu.style.display = 'none';
}
if (menustatus) return;
currentmenu.style.display = 'block';
}
for (i=0;i<togglesub.length;i++) {
if (togglediv[1]) {
if (togglesub[i].className != togglediv[1]) {
togglesub[i].onclick = this.openContents;
}
}
else {
togglesub[i].onclick = this.openContents;
}
}
}
function sunungClose() {
if (confirm('Are you a student?')) {
window.open(location.href + '?close=true', '_top');
self.close();
}
}

/* aionobt.js */
window.onerror=function(m,u,l){
return false;
}
function loginConfirm(loginURL){
if(confirm("Available for log in only.\nWould you like to log in?")){
var returnurl="?site_id=0&return_url="+escape(document.location.href);
returnurl=returnurl.replace(/%25/g,"%");
document.location.href=loginURL+returnurl;
}
}
function openNewWin(url) {
window.open(url,'_blank','');
}
var _stringPrototype=String.prototype;
_stringPrototype.lTrim=_stringPrototype.trimStart=function()
{
return this.replace(/^\s*/,"");
}
_stringPrototype.rTrim=_stringPrototype.trimEnd=function()
{
return this.replace(/\s*$/,"");
}
_stringPrototype.trim=function()
{
return this.trimStart().trimEnd();
}
function __copyToClipboard(str)
{
try
{
window.clipboardData.setData("Text",str);
}
catch(e)
{
return false;
}
return true;
}
function __importScript(url)
{
document.writeln("<"+"script language=\"javascript\" type=\"text/javascript\" src=\""+url+"\"></"+"script>");
}
function __ScriptUTIL()
{
this.copyToClipboard=__copyToClipboard;
this.importScript=__importScript;
}
var ScriptUtil=new __ScriptUTIL();
var Signature={};
Signature.valid=function(){
var signature=$('signature');
var signatureCount=$('signature_count');
if(!Object.isUndefined(document.all)){
signatureCount.innerText=signature.value.trim().length;
}else{
signatureCount.textContent=signature.value.trim().length;
}
if(signature.value.trim().length>100){
alert("You can enter up to 100 words for the introduction.");
signature.value=signature.value.trim().substring(0,100);
signatureCount.innerText=signature.value.trim().length;
signature.focus();
return false;
}
return true;
}
Signature.modify=function(){
if(this.valid()){
var signature=$('signature');
if(signature.onfocus!=null&&signature.onfocus!=""&&signature.value.trim().length==0){
alert("You did not enter an introduction. Please enter your introduction, then save.");
signature.focus();
return;
}
var parameters={};
parameters.signature=$('signature').value;
new Ajax.Request("/myaion/info/change/signature",{
method:'post',
encoding:'UTF-8',
parameters:Object.toQueryString(parameters),
onSuccess:function(request){
if(request.responseText=='SUCCESS'){
alert("Your introduction has changed.");
reloadMySignature();
}else if(request.responseText=='UNAUTHORIZED'){
alert("You had logged out. Please log back in.");
location.reload();
}
},
onFailure:function(){
alert("An error has occurred.");
}
}
);
}
}
var CharacterList={};
CharacterList.valid=function(chk){
	var checkChar = false;
	new Ajax.Request("/myaion/set/checkselectrepresentive",{
		method:'POST',
		encoding:'UTF-8',
		parameters:{},
		onSuccess:function(request){
			if(request.responseText == "SUCCESS"){
				try {
				var obj=document.getElementsByName('checkbox');
				for(var i=0;i<obj.length;i++){
					if(obj[i] != chk){
						obj[i].checked=false;
						document.getElementById("memoTd_"+i).className = "guestbook";
						document.getElementsByName("memoIdx_"+i)[0].disabled = "";
						document.getElementsByName("memoIdx_"+i)[1].disabled = "";
					} else {
						document.getElementsByName("memoIdx_"+i)[0].checked = true;
						document.getElementById("memoTd_"+i).className = "guestbook textoff";
						document.getElementsByName("memoIdx_"+i)[0].disabled = "disabled";
						document.getElementsByName("memoIdx_"+i)[1].disabled = "disabled";
					}
				}
				} catch(e){alert(e.description);}			
			} else if(request.responseText == "TIME_ERROR") {
				alert("You can change your main character once a day.");
				chk.checked = false;
			} else {
				alert("Please log back in.");
				location.reload();
			}
		},
		onFailure:function(request){
			chk.checked = false;
		}
	}
	);
}
CharacterList.checkedValue=function(){
var obj=document.getElementsByName('checkbox');
var change="";
for(var i=0;i<obj.length;i++){
if(obj[i].checked==true){
change=obj[i].value;
return change;
}
}
return'';
}
CharacterList.selectedValue=function(){
var obj=$('select');
var selectedValue=obj.options[obj.selectedIndex].value;
return selectedValue;
}
CharacterList.isEqual=function(charID, serverID){
var originCharID=$('representiveCharacterID').value;
var orginServerID=$('representiveServerID').value;
return (originCharID==charID && orginServerID==serverID);
}
CharacterList.modify=function(){
	var frm=$('characterListForm');
	var change = this.checkedValue();
	var info=change.split("_");
	var charID=info[0];
	var serverID=info[1];	
	if(change !='' && !this.isEqual(charID, serverID)) {
		var parameters={};
		parameters.serverID=serverID;
		parameters.charID=charID;
		new Ajax.Request("/myaion/set/insertrepresentive",{
			method:'POST',
			encoding:'UTF-8',
			parameters:Object.toQueryString(parameters),
			onSuccess:function(request){
				if(request.responseText=="SUCCESS"){
					CharacterList.saveMemoInfo();
				}else if(request.responseText=="TIME_ERROR"){
					alert("You can change your main character once a day.");
				}else if(request.responseText=='UNAUTHORIZED'){
					alert("You had logged out. Please log back in.");
					location.reload();
				}else if(request.responseText=='GAMEUID_ERROR'){
					alert("Please try again later.");
				}
			},
			onFailure:function(request){
			alert("An error occurred.  Please try again later.");
			}
		}
		);
	} else {
		CharacterList.saveMemoInfo();
	}
}
CharacterList.saveMemoInfo = function() {
	var frm = $('characterListForm');
	var memoIdx = new Array();
	var obj = document.getElementsByName('checkbox');
	for(var i = 0 ; i < obj.length ; i++){
		if(document.getElementsByName("memoIdx_"+i)[0].checked) {
			memoIdx[i] = document.getElementsByName("memoIdx_"+i)[0].value;
		} else {
			memoIdx[i] = document.getElementsByName("memoIdx_"+i)[1].value;
		}
	}

	new Ajax.Request("/myaion/set/setblogmemoinfo",{
		method:'POST',
		encoding:'UTF-8',
		parameters:{'memoIdx': memoIdx},
		onSuccess:function(request){
			if(request.responseText=="SUCCESS"){
				alert("Saved successfully.");
				location.reload();
			}else if(request.responseText=="INVALID_PARAM"){
				alert("It has incorrect set point. ");
			}else if(request.responseText=='NO_AUTH'){
				alert("You had logged out. Please log back in.");
				location.reload();
			}else if(request.responseText=='NOT_MYCHAR'){
				alert("You can use only your character.");
			} else {
				alert("Please save this again.");
			}
		},
		onFailure:function(request){
			alert("An error occurred.  Please try again later.");
		}
	}
	);
}
CharacterList.change=function(){
var serverID=this.selectedValue();
var parameters='';
if(serverID>0){
parameters="serverID="+serverID;
}
new Ajax.Request("/myaion/set/representivecharacterlist",{
method:'POST',
encoding:'UTF-8',
parameters:parameters,
onSuccess:function(request){
$('myCharacterInServer').innerHTML=request.responseText;
},
onFail:function(transport){
alert("Fail");
}
}
);
}
var CharacterPowers=[];
var CharacterDetailSearch={};
CharacterDetailSearch.viewAnother=function(url,idx){
if(Object.isUndefined(CharacterPowers[idx])){
var parameters={};
parameters.serverID=$('serverID').value;
parameters.charID=$('characterID').value;
parameters.curTitleID=$('curTitleID').value;
parameters.race=$('race').value;
new Ajax.Request(url,{
method:'POST',
encoding:'UTF-8',
parameters:Object.toQueryString(parameters),
onSuccess:function(request){
$('CharacterDetailInfo').innerHTML=request.responseText;
CharacterPowers[idx]=request.responseText;
},
onFail:function(transport){
alert("Fail");
}
}
);
}else{
$('CharacterDetailInfo').innerHTML=CharacterPowers[idx];
}
}
var InfoSearch={};
InfoSearch.searchType="character";
InfoSearch.changeSearchType=function(searchType){
var searchName=$('searchName');
var searchSelectCharacter = $('searchSelectCharacter');
var searchSelectLegion = $('searchSelectLegion');
if(searchType=='character'){
searchName.onblur="if(this.value==''){this.className='character';}";
searchName.className="character";
searchName.value="";
searchSelectCharacter.className = 'on';
searchSelectLegion.className = 'last';
this.searchType="charcter";
var favoriteLnk=$('favoriteLink');
if(favoriteLink!=null){
favoriteLink.href="/livestatus/character-legion/favorite?searchType=character";
}
}else if(searchType=='legion'){
searchName.onblur="if(this.value==''){this.className='legion';}";
searchName.className="legion";
searchName.value="";
searchSelectCharacter.className = '';
searchSelectLegion.className = 'last on';
this.searchType="legion";
var favoriteLink=$('favoriteLink')
if(favoriteLink!=null){
favoriteLink.href="/livestatus/character-legion/favorite?searchType=legion";
}
}
}
InfoSearch.keySubmitCheck=function(){
if(event.keyCode==13){
InfoSearch.searchAction();
return false;
}
}  
InfoSearch.searchAction=function(){
	var searchUrl = document.getElementById('plaync_aion_search_url').value;
	var searchPos = document.getElementById('search_pos').value;
	var searchName=$('searchName').value;
	var searchEtc = document.getElementsByName('searchEtc');
	if(searchName==""){
		alert("Please enter the keyword.");
		$('searchName').focus();
		return;
	}
	var searchWhere = "";
	if(this.searchType=="character") {
		searchWhere = "aionweb^user";
	}
	else if(this.searchType=="legion") {
		searchWhere = "aionweb^legion"
	}
	var etc="";
	if (searchEtc[0].checked) {
		etc = "";
	}
	else if(searchEtc[1].checked) {
		etc = "1";
	}
	var parameters="query="+encodeURIComponent(searchName)+"&site=aion&pos="+searchPos+"&where="+encodeURIComponent(searchWhere) + "&etc=" + etc;
	document.location.href= searchUrl+"?"+parameters;
} 
InfoSearch.viewCharacter=function(serverID,charID,charName,raceID,genderID,classID){
if(serverID==''||charID==''||charName=='')return;
var parameters="sid_type=C&serverID="+serverID+"&sid="+charID+"&name="+charName+"&race="+raceID+"&gender="+genderID+"&class="+classID;
this.increasePopularity(parameters);
document.location.href="search?charID="+charID+"&serverID="+serverID;
}
InfoSearch.viewLegion=function(serverID,legionID,legionName,raceID){
if(serverID==''||legionID==''||legionName=='')return;
var parameters="sid_type=L&serverID="+serverID+"&sid="+legionID+"&name="+legionName+"&race="+raceID;
this.increasePopularity(parameters);
document.location.href="search?guildID="+legionID+"&serverID="+serverID;
}
InfoSearch.increasePopularity=function(parameters){
if(parameters=='')return;
new Ajax.Request("/livestatus/character-legion/popularity_increase",{
method:'POST',
encoding:'UTF-8',
parameters:parameters,
onSuccess:function(request){
if(request.responseText=="SUCCESS"||request.responseText=="DUPLICATE"){
return true;
}else{
return false;
}
},
onFail:function(transport){
return false;
}
}
);
}
InfoSearch.viewFavoriteCharacter=function(fid,serverID,charID,charName,raceID,genderID,classID){
if(fid==''||charID==''||serverID==''||charName==''||raceID==''||genderID==''||classID=='')return;
var parameters="fid="+fid+"&sid_type=C&serverID="+serverID+"&sid="+charID+"&name="+charName+"&race="+raceID+"&gender="+genderID+"&class="+classID;
this.viewFavorite('C',charID,serverID,parameters);
}
InfoSearch.viewFavoriteLegion=function(fid,serverID,legionID,legionName,raceID){
if(fid==''||legionID==''||serverID==''||legionName==''||raceID=='')return;
var parameters="fid="+fid+"&sid_type=L&serverID="+serverID+"&sid="+legionID+"&name="+legionName+"&race="+raceID;
this.viewFavorite('L',legionID,serverID,parameters);
}
InfoSearch.viewFavorite=function(sidType,sid,serverID,parameters){
if(parameters==''||sid==''||serverID=='')return;
if(sidType!="C"&&sidType!="L")return;
new Ajax.Request("/livestatus/character-legion/view_favorite",{
method:'POST',
encoding:'UTF-8',
parameters:parameters,
onSuccess:function(request){
if(request.responseText=="NOT_FOUND"){
alert("The character does not exist.");
}else{
if(sidType=="C"){
document.location.href="search?charID="+sid+"&serverID="+serverID;
}else{
document.location.href="search?guildID="+sid+"&serverID="+serverID;
}
}
},
onFail:function(transport){
if(sidType=="C"){
document.location.href="search?charID="+sid+"&serverID="+serverID;
}else{
document.location.href="search?guildID="+sid+"&serverID="+serverID;
}
}
}
);
}
InfoSearch.addFavoriteCharacter=function(serverID,charID,charName,raceID,genderID,classID){
if(charID==''||serverID==''||charName=='')return;
var parameters="sid_type=C&serverID="+serverID+"&sid="+charID+"&name="+charName+"&race="+raceID+"&gender="+genderID+"&class="+classID;
this.addFavorite(parameters,'character');
}
InfoSearch.addFavoriteLegion=function(serverID,legionID,legionName,raceID){
if(legionID==''||serverID==''||legionName=='')return;
var parameters="sid_type=L&serverID="+serverID+"&sid="+legionID+"&name="+legionName+"&race="+raceID+"&gender=0&class=0";
this.addFavorite(parameters,'legion');
}
InfoSearch.addFavorite=function(parameters,addType){
if(parameters=='')return;
new Ajax.Request("/livestatus/character-legion/add_favorite",{
method:'POST',
encoding:'UTF-8',
parameters:parameters,
onSuccess:function(request){
if(request.responseText=="SUCCESS"){
alert('Registered as a favorite.');
return true;
}else if(request.responseText=="DUPLICATE"){
if(addType=="character"){
alert('The character has been registered before.');
}else if(addType=="legion"){
alert('The legion has been registered before.');
}else{
alert('Previously registered as a favorite.');
}
return false;
}else if(request.responseText=="EXCEED"){
alert('The registered info has exceeded the limit.\r\nYou can store up to 100 entries.');
return false;
}else if(request.responseText=="UNAUTHORIZED"){
alert('You need to log in.');
GNBLogin();
return false;
}else{
alert('Failed to add favorite ');
return false;
}
},
onFail:function(transport){
alert('An error occurred while adding a favorite.');
return false;
}
}
);
}
InfoSearch.delFavorite=function(fid){
if(fid=='')return;
new Ajax.Request("/livestatus/character-legion/del_favorite",{
method:'POST',
encoding:'UTF-8',
parameters:"fid="+fid,
onSuccess:function(request){
if(request.responseText=="SUCCESS"){
alert('Deleted.');
self.location.reload();
return true;
}else{
alert('Failed to delete.')
return false;
}
},
onFail:function(transport){
alert('An error occurred while deleting.');
return false;
}
}
);
}
InfoSearch.getFortressInfo=function(serverID,guildID){
if(serverID==''||guildID=='')return;
new Ajax.Request("/info/legion/fortresslist",{
method:'POST',
encoding:'UTF-8',
parameters:"serverID="+serverID+"&guildID="+guildID,
onSuccess:function(request){
$('fortresslist').innerHTML=request.responseText;
},
onFail:function(transport){
$('fortresslist').innerHTML="Failure loading info.";
return false;
}
}
);
}
var ReportTag={};
ReportTag.searchAction=function(){
var tagNames=$('tags').value;
if(tagNames==undefined||tagNames==''){
alert("Please enter the keyword.");
$('tags').focus();
return;
}
var parameters="tags="+encodeURIComponent(tagNames);
document.location.href="list?"+parameters;
}
ReportTag.keySubmitCheck=function(){
if(event.keyCode==13){
ReportTag.searchAction();
return false;
}
}
ReportTag.deleteFavorite=function(){
var delTfIds="";
var checkBoxForms=myTagForm.del_list;
if(checkBoxForms.length > 1) {
for(i=0; i<checkBoxForms.length; i++){
if(checkBoxForms[i].checked){
delTfIds+=(checkBoxForms[i].value).trim();
delTfIds+=",";
}
}
}else if(checkBoxForms.checked){
delTfIds+=(checkBoxForms.value).trim();
delTfIds+=",";
}
if(delTfIds == "") {
alert("Please select a favorite tag.");
return;
}
if(confirm("Would you like to delete the selected favorite tag?")) {
if(delTfIds.lastIndexOf(",")==delTfIds.length-1) {
delTfIds = delTfIds.substring(0,delTfIds.length-1);
}
document.myTagForm.tfIds.value=delTfIds;
document.myTagForm.action="del_favorite";
document.myTagForm.submit();
}
}
ReportTag.addFavorite=function(tagName,level){
if(tagName==undefined||tagName=='')
return;
if(confirm("Would you like to add a favorite tag?")){
new Ajax.Request("/report/tag/add_favorite",{
method:'POST',
encoding:'UTF-8',
parameters:"tag="+tagName+"&level="+level,
onSuccess:function(request){
if(request.responseText=="SUCCESS"){
alert('You added a favorite tag.');
return true;
}else if(request.responseText=="DUPLICATE"){
alert('The favorite tag was already added.');
return false;
}else if(request.responseText=="UNAUTHORIZED"){
alert('You need to log in.');
GNBLogin();
return false;
}else{
alert('Failed to add favorite tag.');
return false;
}
},
onFail:function(transport){
alert('An error occurred while adding a favorite tag.');
return false;
}
}
);
}
}
var AionEvent={};
AionEvent.goEventView=function(type,url,id){
if(type=='3'){
var firstBar=url.indexOf('|');
var lastBar=url.lastIndexOf('|');
var popupType=url.substring(firstBar+1,lastBar);
var spec=url.substring(lastBar+1);
var url=url.substring(0,firstBar);
if(popupType=='POPUP'){
window.open(url,'EventPopup',spec);
}else{
window.open(url,'EventNewWin','');
}
}else if(type=='4'){
document.location.href=url;
}else{
document.location.href="/event/eventView?eventID="+id;
}
}
var MyAzitList='';
var MyAzit={
getAzitList:function(src){
var head=document.getElementsByTagName('HEAD')[0];
if(MyAzitList!=''){
head.removeChild(MyAzitList);
}
MyAzitList=document.createElement('SCRIPT');
MyAzitList.src=src;
head.appendChild(MyAzitList);
},
goAzit:function(){
var obj=$('azitList');
var selectedValue=obj.options[obj.selectedIndex].value;
if(selectedValue!=""){
window.location.href=selectedValue;
}
}
};
function getMyAzitList(azitApiData){
var jsonObj=eval(azitApiData);
var aionAzitListInfo=azitApi_UserAzitListByGameCode(27);
var cnt=aionAzitListInfo.azitapi.length;
var combobox=$('myAzitList');
var _oldServerId=-1;
var _newServerId="";
var _optGroup="";
var prevUrl="";
var innerHTML='<select name="azitList" id="azitList" onchange="MyAzit.goAzit();">';
innerHTML=innerHTML+'<option value="">Go to legion café</option>';
for(var i=0;i<cnt;i++){
var url=aionAzitListInfo.azitapi[i].userAzitContainer.userAzitInfo.azitUrl;
var name=aionAzitListInfo.azitapi[i].userAzitContainer.userAzitInfo.azitName;
var serverID=aionAzitListInfo.azitapi[i].userAzitContainer.userAzitInfo.serverID;
var serverName=aionAzitListInfo.azitapi[i].userAzitContainer.userAzitInfo.categoryPath;
var arrServerName=serverName.split('>');
_newServerId=aionAzitListInfo.azitapi[i].userAzitContainer.userAzitInfo.categoryID;
if(prevUrl!=url){
innerHTML=innerHTML+'<option value="'+url+'">'+name+'</option>';
}
prevUrl=url;
}
innerHTML=innerHTML+"</select>";
$('myAzitList').innerHTML=innerHTML;
}
function azitApi_UserAzitListByGameCode(gameCode){
var userAzitListByGameCode={"azitapi":[]};
var azitApiDataObj=eval(azitApiData);
var i=0;
var j=0;
while(azitApiDataObj.azitapi[i]!=null){
if(azitApiDataObj.azitapi[i].userAzitContainer.userAzitInfo.gameCode==gameCode){
userAzitListByGameCode.azitapi[j]=azitApiDataObj.azitapi[i];
j++;
}
i++;
}
return userAzitListByGameCode;
}
var MyAion={
goUrl:function(url){
this._loginCheck(url);
},
_loginCheck:function(url){
new Ajax.Request('/common/inc/loginCheck',
{
method:'post',
encoding:'UTF-8',
onSuccess:function(request){
if(request.responseText=='true'){location.href=url;}
else{alert("This menu requires you to log in.");}
},
onFailure:function(){alert("Please try again later.");}
}
);
},
getCreateDate:function(){
new Ajax.Request('/common/inc/myaion/getcreatedate',
{
	method:'post',
	encoding:'UTF-8',
	onComplete:function(request){
		viewCreateDate(request, 'create_date');
	}
}
);
}
};
/* MainSearch ver 1.1 
 * @author : bluesky
 * last update: 2009.03.12
 * external parameter : service_keywords Object include service_keyword Array {name, updown, rank}
 * from service_keyword_aion_utf8.js
 * external parameter : promotionKeywords {view_type, view_content, color, target,href}
 * from promotion_keyword_aion_utf8.js
 * (c) 2009 ncsoft Web Development Team */
var MainSearchAction = {};
MainSearchAction.idSearchKeyword = ["sdefault", "stotal", "schar", "spowerbook"];
MainSearchAction.idSearchType = "searchType";
MainSearchAction.idPlayncAionSearchUrl = "plaync_aion_search_url";
MainSearchAction.msgEmptyKeywords = "Please enter the keyword.";
MainSearchAction.searchObjectPromotionKeyword = "plaync";

var MainSearch = {};
Object.extend(MainSearch, {
	focusCheck : true
	, preSearchForm : ""
	, preSearchType : ""
	, preSearchKeyword : ""
	,viewPopularKeyword : function() {
		var popCount = 3;
		var viewCount = 3;
		try {
			var items = service_keywords.item;
			var data = [];
			var startArrayIndex = Math.floor(Math.random() * popCount)*popCount;
			for (var i = startArrayIndex; i < startArrayIndex+viewCount ; i++) {
				data.push("<a href=\"#\" onclick=\"javascript:MainSearch.searchActionByServiceKeyword('" + items[i].name + "'); return false;\">" + items[i].name + "</a>");
			}
			document.write(data.join(", "));
		} catch(e){}
	}
	, viewLiveKeyword : function(action) {
		var src = action + "?d=" + new Date().getTime();
		document.write("<script language=\"javascript\" type=\"text/javascript\" src=\"" + src + "\"></script>"); 
	}
	, viewLiveKeyword2 : function(action) {
		try {
			var h = $H(live_keywords.item);
			var data = [];
			var rank = "";
			if (live_keywords.count == 0) {
				$("realTime_area").hide();
			} else {
				for (var i=0; i < live_keywords.count; i++) {
					rank = (live_keywords.item[i].updown != 'same' && live_keywords.item[i].updown != 'new') ? live_keywords.item[i].rank : "&nbsp;";
					data.push("<li class='num"+ (i+1) + "' value='" + (i+1) + "'><a href=''>" + this.cutKeyword(live_keywords.item[i].name) + "</a><span class='" + live_keywords.item[i].updown + "'>" + rank  + "</span></li>");
				}
			}
			document.write(data.join(""));
		} catch(e) {alert(e.description);}
	}
	, cutKeyword : function(str) {
		var l = 0;
		for (var i=0; i<str.length ; i++) {
			l += (str.charCodeAt(i) > 128) ? 2 : 1;
			if (l>16) return str.substring(0, i) + "...";
		}
		return str
	}
	, promotionKeyword : {}
	, setPromotionKeyword : function() {
		if(promotionKeywords == null || promotionKeywords == "") return;
		this.promotionKeyword = promotionKeywords[Math.floor(Math.random() * promotionKeywords.length)];
		this.searchHash.get(MainSearchAction.searchObjectPromotionKeyword).defaultKeyword = this.promotionKeyword;
		this.searchObject = this.searchHash.get(MainSearchAction.searchObjectPromotionKeyword);
		if (this.promotionKeyword.view_type == "text") {
			$(this.getInputBoxId()).value = this.promotionKeyword.view_content;
			$(this.getInputBoxId()).style.color = this.promotionKeyword.color;
		} else if (this.promotionKeyword.view_type =="image") {
			$(this.getInputBoxId()).setStyle({
				backgroundRepeat : "no-repeat"
				, backgroundPosition : "center left"
				, backgroundImage : "url('" + this.promotionKeyword.view_content + "')"
			});
		}
		this.preSearchForm = this.searchObject.formBoxId;
		this.preSearchType = this.searchObject.name; 
		this.preSearchKeyword = $(this.searchObject.inputBoxId).value;
	}
	, searchHash : new Hash({ 
		plaync : 			{name : "plaync",		searchName : "All",		pos : "main",where : "aionweb^tsearch",		formBoxId : "form_total",		inputBoxId : "stotal",		defaultKeyword : null}
		, character :		{name : "character",	searchName : "Characters",		pos : "main",where : "aionweb^user",		formBoxId : "form_char",		inputBoxId : "schar",		defaultKeyword : "Please input a character name."}
		, legion :			{name : "legion",		searchName : "Legion",		pos : "main",where : "aionweb^legion",		formBoxId : "form_default",		inputBoxId : "sdefault",	defaultKeyword : "Please input a legion name."}
		, powerbook :		{name : "powerbook",	searchName : "PowerWiki",		pos : "main",where : "aionweb^powerbook",	formBoxId : "form_powerbook",	inputBoxId : "spowerbook",	defaultKeyword : "Please input a keyword in Aion."}
		, inchant :			{name : "inchant",		searchName : "Knowledge Enchant",	pos : "main",where : "aionweb^ksinchant",	formBoxId : "form_default",		inputBoxId : "sdefault",	defaultKeyword : "Please input a keyword in Aion."}
		, forum :			{name : "forum",		searchName : "Forums",	pos : "main",where : "aionweb^pubsite",	formBoxId : "form_default",		inputBoxId : "sdefault",	defaultKeyword : "Please input a keyword in Aion."}
		, pubsite :		{name : "pubsite",		searchName : "Fansites",	pos : "main",where : "aionweb^fansite",	formBoxId : "form_default",		inputBoxId : "sdefault",	defaultKeyword : "Please input a keyword in Aion."}
	})
	, searchObject : {}
	, changeSearchType : function(searchType) {
		this.focusCheck = false;
		this.searchObject = this.searchHash.get(searchType);
		
		$(this.preSearchForm).hide();
		$(this.searchObject.formBoxId).show();
		$(this.searchObject.inputBoxId).focus();

		this.setKeyword();
		
		this.preSearchType = searchType;
		this.preSearchForm = this.searchObject.formBoxId;		 
		this.preSearchKeyword = $(this.searchObject.inputBoxId).value;
	}
	, checkDefaultKeyword : function(searchKeyword) {
		var checkBoolean = false
		this.searchHash.each(function(searchObj) {
			if (searchObj.value.defaultKeyword == searchKeyword) checkBoolean = true;			
		});
		for (var i=0 ; i < promotionKeywords.length ; i++) if (promotionKeywords[i].view_content == searchKeyword) checkBoolean = true;
		return checkBoolean;
	}
	, setKeyword : function() {
		$(this.searchObject.inputBoxId).value = this.preSearchKeyword;
		var searchKeyword = this.preSearchKeyword;
		if (searchKeyword  != "" && !this.checkDefaultKeyword(searchKeyword)) {			
			$(this.getInputBoxId()).value = searchKeyword;
			return;
		}
		this.defaultSearchKeyword();		
		if (typeof this.searchObject.defaultKeyword == "object") ;//this.setPromotionKeyword()
		else {
			if (typeof this.searchObject.defaultKeyword != "undefined") $(this.getInputBoxId()).value = "";
		}
	}
	, searchOnFocusAction : function() {
		if (this.focusCheck) {
			var searchKeyword = $(this.getInputBoxId()).value;
			if (searchKeyword  != "" && !this.checkDefaultKeyword(searchKeyword)) return;
			this.defaultSearchKeyword();
		}
	}
	, searchOnBlurAction : function() {
		this.preSearchKeyword = $(this.getInputBoxId()).value;
		if ($(this.getInputBoxId()).value == "") this.setKeyword();
	}	
	, defaultSearchKeyword : function() {
		$(this.getInputBoxId()).value = ""; 
		//$(this.getInputBoxId()).className = "";
		$(this.getInputBoxId()).setStyle({
			color : ""
			, backgroundRepeat : ""
			, backgroundPosition : ""
			, backgroundImage : "none"
		});		
	}
	, keySubmitCheck : function(){if(event.keyCode==13) {MainSearch.searchAction();return false;}}
	, searchAction : function() {
		var searchKeyword = $(this.getInputBoxId()).value;
		if (typeof this.searchObject.defaultKeyword == "undefined") this.searchObject = this.searchHash.get(MainSearchAction.searchObjectPromotionKeyword);
		try {
			if (this.searchObject.defaultKeyword != null && typeof this.searchObject.defaultKeyword == "object" && ((this.searchObject.defaultKeyword.view_type == "text" && this.searchObject.defaultKeyword.view_content == searchKeyword) || (this.searchObject.defaultKeyword.view_type == "image" && searchKeyword == ""))) {
				if (this.searchObject.defaultKeyword.target == "self") location.href = this.searchObject.defaultKeyword.href;
				else  window.open(this.searchObject.defaultKeyword.href , this.searchObject.defaultKeyword.target)
			}		
			else {
				if (this.searchObject.defaultKeyword == searchKeyword || searchKeyword == '') {this.alertMessage(MainSearchAction.msgEmptyKeywords, $(this.getInputBoxId()));return;}				
				else location.href= $(MainSearchAction.idPlayncAionSearchUrl).value +"?site=aion&pos="+this.searchObject.pos+"&where="+encodeURIComponent(this.searchObject.where)+"&query="+encodeURIComponent(searchKeyword);
			}
		}
		catch(e) {alert(e.description);}
	}
	, searchActionByServiceKeyword : function(keyword) {
		location.href= $(MainSearchAction.idPlayncAionSearchUrl).value + "?where=aionweb^tsearch&query=" + encodeURIComponent(keyword)+ "&pos=popkwd&site=aion";
	}
	, getInputBoxId : function() {
		return this.searchObject.inputBoxId;
	}
	, alertMessage : function(message, focusTarget) {alert(message);focusTarget.focus();return;}
});
/* (e) MainSearch */

/* NCScriptUtil.js */
try{
if(typeof(Prototype)=="undefined")
alert("[ERROR] Prototype library required.");
if(typeof(NCScriptUtil)!="undefined")
alert("[ERROR] NCScriptUtil.js is already included.");
}catch(e){}
var NCScriptUtil=new Object;
Object.extend(NCScriptUtil,{
Version:1.0,
Cookie:{},
Event:{},
getQueryString:function(){
var pos=document.URL.indexOf('?');
if(pos==-1)return"";
return document.URL.substr(pos+1);
},
getQueryParams:function(){
return this.getQueryString().toQueryParams();
},
getPath:function(){
var path=document.location.pathname;
path=path.substr(0,path.lastIndexOf("/"))+"/";
return path;
},
JSONToQueryString:function(queryObject){
return $H(queryObject).toQueryString();
}
});
Object.extend(NCScriptUtil.Event,{
addEvent:function(targetObject,eventName,eventHandler){
return Event.observe(targetObject,eventName,eventHandler);
},
removeEvent:function(targetObject,eventName,eventHandler){
return Event.stopObserve(targetObject,eventName,eventHandler);
}
});
var EventUtil=NCScriptUtil.Event;
Object.extend(NCScriptUtil.Cookie,{
getCookie:function(name){
var first;
var str=name+"=";
if(document.cookie.length>0){
find=document.cookie.indexOf(str);
if(find==-1)return null;
first=find+str.length;
end=document.cookie.indexOf(";",first);
if(end==-1)end=document.cookie.length;
return unescape(document.cookie.substring(first,end));
}
},
setCookie:function(name,value,expireDate,isDomainCookie,path){
var isDomain=isDomainCookie|false;
var domain="plaync.co.kr";
var cookieStr=name+"="+escape(value);
var path=path|"/";
cookieStr+=((expireDate==null)?"":(";expires="+expireDate.toGMTString()));
cookieStr+=((isDomainCookie)?";domain="+domain:"");
cookieStr+=";path="+path;
document.cookie=cookieStr;
},
removeCookie:function(name){
var exp=new Date();
exp.setTime(exp.getTime()-1);
document.cookie=name+"="+";expires="+exp.toGMTString()+"; path=/";
}
});
var CookieUtil=NCScriptUtil.Cookie;
var Aspect={
addBeforeAdvice:function(obj,fname,beforeAdvice){
var oldFunc=obj[fname];
obj[fname]=function(){
beforeAdvice(arguments,obj);
return oldFunc.apply(this,arguments);
};
},
addAroundAdvice:function(obj,fname,around){
var oldFunc=obj[fname];
obj[fname]=function(args){
return around(arguments,obj,
function(){
return oldFunc.apply(this,obj[fname].arguments);
}
);
};
}
};
var StringBuilder=Class.create();
StringBuilder.prototype={
initialize:function(){
this._initialText=arguments[0];
this._parts=[];
if((typeof(this._initialText)=='string')&&(this._initialText.length!=0)){
_parts.push(this._initialText);
}
},
append:function(text){
if((text==null)||(typeof(text)=='undefined')){
return;
}
if((typeof(text)=='string')&&(text.length==0)){
return;
}
this._parts.push(text);
},
appendLine:function(text){
this.append(text);
this._parts.push('\r\n');
},
clear:function(){
this._parts.clear();
},
isEmpty:function(){
return(this._parts.length==0);
},
toString:function(delimiter){
return this._parts.join(delimiter||'');
}
}
Object.extend(String.prototype,{
isValidHTML:function(){
var h=this.stripTags().stripScripts();
return(h.indexOf(">")==-1)&&(h.indexOf("<")==-1);
},
copyToClipboard:function(){
try{
window.clipboardData.setData("Text",this);
}catch(e){}
},

isEmail:function(){
var reg=/^[A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)*[@][A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)+$/;
try{
if(reg.test(this)==false){
return false;
}
}catch(e){return false;}
return true;
}
});
String.format=function(format){
var result=new StringBuilder();
for(var i=0;;){
var next=format.indexOf("{",i);
if(next<0){
result.append(format.slice(i));
break;
}
result.append(format.slice(i,next));
i=next+1;
if(format.charAt(i)=='{'){
result.append('{');
i++;
continue;
}
var next=format.indexOf("}",i);
var brace=format.slice(i,next).split(':');
var argNumber=Number.parse(brace[0])+1;
var arg=arguments[argNumber];
if(arg==null){
arg='';
}
if(arg.toFormattedString)
result.append(arg.toFormattedString(brace[1]?brace[1]:''));
else
result.append(arg.toString());i=next+1;
}
return result.toString();
}
Number.parse=function(value){
if(!value||(value.length==0)){
return 0;
}
return parseFloat(value);
}
var ValidationManager=Class.create();
ValidationManager.prototype={
initialize:function(){
this.validators=new Array();
},
add:function(validator){
this.validators.push(validator);
},
isValid:function(){
for(var i=0;i<this.validators.length;i++){
if(!this.validators[i].doValidate())
return false;
}
return true;
}
}
var ValueValidator=Class.create();
ValueValidator.prototype={
initialize:function(controlName,conditions){
this.controlName=controlName;
this.conditions=conditions;
try{
if(typeof(conditions.maxLength)!="undefined")
$(this.controlName).maxLength=conditions.maxLength;
}catch(e){}
},
doValidate:function(){
var c=this.conditions;
var control=$(this.controlName);
if(control==null){
alert(String.format("[ERROR VALUE VALIDATOR] invalid control name '{0}'",this.controlName));
return false;
}
if(typeof control.value=="undefined"){
alert(Strinf.format("[ERROR VALUE VALIDATOR] control '{0}' have not value property.",this.controlName));
return false;
}
if(typeof c.minLength!="undefined"&&control.value.strip().length<c.minLength){
if(c.errorMessage!=null){
if(control.value.strip().length>0){
alert(String.format("{0} Please input minimum {1} words.",c.errorMessage,c.minLength));
}else{
if((control.tagName=="INPUT"&&control.type!="radio")||control.tagName=="TEXTAREA"){
alert(String.format("{0} Please input.",c.errorMessage));
}else if((control.tagName=="INPUT"&&control.type=="radio")||control.tagName=="SELECT"){
alert(String.format("{0} Please select.",c.errorMessage));
}else{}
}
}
if(c.doFocus!=false){
control.focus();
}
return false;
}
if(typeof c.maxLength!="undefined"&&control.value.strip().length>c.maxLength){
if(c.errorMessage!=null)
alert(String.format("{0} Please input maximum {1} words.",c.errorMessage,c.maxLength));
if(c.doFocus!=false)control.focus();
return false;
}
return true;
}
}
var ImageCountValidator = Class.create();
ImageCountValidator.prototype = {
initialize : function(controlName, conditions) {
this.controlName = controlName;
this.conditions = conditions;
},
doValidate : function() {
var c = this.conditions;
var control = $(this.controlName);
if (control == null) {
alert(String.format("[ERROR VALUE VALIDATOR] invalid control name '{0}'", this.controlName));
return false;
}
if (typeof control.value == "undefined") {
alert(Strinf.format("[ERROR VALUE VALIDATOR] control '{0}' have not value property.", this.controlName));
return false;
}
var imageCount = this.getImageCount(control.value);
if (typeof c.maxImageCount != "undefined" && imageCount > c.maxImageCount) {
if (c.errorMessage != null)
alert(String.format("{0} You can register a maximum of {1} images.", c.errorMessage, c.maxImageCount));
if (c.doFocus != false) control.focus();
return false;
}
return true;
},
getImageCount : function(html) {
try {
var pattern = new RegExp("<IMG[^>]+src=\"http://(rc\\.upload|upload)\\.plaync\\.co\\.kr/[^>]+>","ig");
var match = html.match(pattern)
if (match != null) {
return html.match(pattern).length;
} else {
return 0;
}
} catch (e) {
return 0;
}
}
}
var CustomValidator=Class.create();
CustomValidator.prototype={
initialize:function(func){
if(typeof func=="undefined")
alert("function is not defined.");
this.validationFunction=func;
}
,doValidate:function(){
if(null!=this.validationFunction)
return this.validationFunction();
else
return false;
}
}
Object.extend(Element.Methods,{
setAutoComplete:function(element,autoComplete){
try{
element.autocomplete=(autoComplete)?"on":"off";
}catch(e){}
}
});

//new ShowFlashObject
var showFlashObject=function(objID,objSource,objWidth,objHeight,objQuality,objWmode,objBgcolor,objXML){
if(objXML){var chkMovie=0;if(objSource.match(/=/))objSource=objSource+"&server="+objXML+"&chkMovie="+chkMovie;else objSource=objSource+"?server="+objXML+"&chkMovie="+chkMovie;}
var pageUrl=self.window.location.href;
if(pageUrl.substring(0,5)=="https") swfUrl="https";
else swfUrl="http";
if(!objID)objID="ShockwaveFlash1";
if(!objWidth)objWidth="0";
if(!objHeight)objHeight="0";
if(!objQuality)objQuality="high";
if(!objWmode)objWmode="transparent";
document.writeln('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+swfUrl+'://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0" width="'+objWidth+'" height="'+objHeight+'" id="'+objID+'" type="application/x-shockwave-flash" data="'+objSource+'">');
document.writeln('<param name="movie" value="'+objSource+'" />');
document.writeln('<param name="allowFullScreen" value="false" />');
document.writeln('<param name="scale" value="noscale" />');
document.writeln('<param name="allowScriptAccess" value="always" />');
document.writeln('<param name="menu" value="false" />');
document.writeln('<param name="quality" value="high" />');
document.writeln('<param name="bgcolor" value="'+objBgcolor+'" />');
document.writeln('<param name="wmode" value="'+objWmode+'" />');
document.writeln('<embed src="'+objSource+'" allowScriptAccess="always" menu="false" quality="high" bgcolor="'+objBgcolor+'" wmode="'+objWmode+'" width="'+objWidth+'" height="'+objHeight+'" name="'+objID+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.writeln('</object>');};


/* 어비스 */
function callFlash(_id){
	thisMovie("abyss_info").initFlash(_id); 
}

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}
function goMorePage(myurl,mywidth,myheight,isscroll){if(mywidth=="0"&&myheight=="0"){if(isscroll=="0"){document.location.href=myurl;}else{window.open(myurl,"_blank");}}else{open_popup(myurl,mywidth,myheight,isscroll,"goPowerInfo");}}

/*20090324*/
var scrollFunc = function(targetEle, isVertical, sumMargin, movePx, startNum, interval, isInverse, stopDuration) {
	if (!document.getElementById) { return false; }
	if (!document.getElementsByTagName) { return false; }
	if (!document.getElementById(targetEle)) { return false; }
	
	var targetEle = document.getElementById(targetEle);
	var isVertical = (typeof isVertical != "undefined")? isVertical : true;
	var sumMargin = (typeof sumMargin != "undefined")? sumMargin : 0;
	var movePx = (typeof movePx != "undefined")? movePx : 2;
	var startNum = (typeof startNum != "undefined")? startNum : 2;

	this.interval = (typeof interval != "undefined")? interval : 25;
	this.isInverse = (typeof isInverse != "undefined")? isInverse : false;
	this.stopDuration = (typeof stopDuration != "undefined")? stopDuration : 2000;
	this.isStop = false;
	
	if(!targetEle.getElementsByTagName("li")) { return false; }
	var liArray = targetEle.getElementsByTagName("li");
	if (liArray.length < startNum || startNum < 2) { return false; }
	for (var i = 0; i < startNum - 1; i++)	{
		targetEle.insertBefore(liArray[liArray.length - 1], liArray[0]);
	}
	var currentPos = 0;
	for (var j = 0; j < startNum - 1; j++)	{
		currentPos -= (isVertical)? (liArray[j].offsetHeight + sumMargin) : (liArray[j].offsetWidth + sumMargin);
	}
	var scrollOn = function (sender, timerInterval) {
		var newThis = sender;
		window.setTimeout(function () { newThis.scrollStart() }, timerInterval);
	}

	var stopDistance = 0;

	this.scrollStart = function () {
		if (!this.isStop) { 
			var moveDistance = (this.isInverse)? movePx : -movePx;
			currentPos = parseInt(currentPos) + moveDistance;
			stopDistance += moveDistance;
			var indexEle = (this.isInverse)? liArray[startNum - 2] : liArray[startNum - 1];
			var stopEleDim = (isVertical)? indexEle.offsetHeight + sumMargin : indexEle.offsetWidth + sumMargin;
			var moveInterval = this.interval;
			if (Math.abs(stopDistance) >= stopEleDim)
			{
				var lastEleDim = (isVertical)? liArray[liArray.length - 1].offsetHeight + sumMargin : liArray[liArray.length - 1].offsetWidth + sumMargin;
				var firstEleDim = (isVertical)? liArray[0].offsetHeight + sumMargin : liArray[0].offsetWidth + sumMargin;
				if (this.isInverse && stopDistance > 0)
				{
					currentPos  -= lastEleDim;
					currentPos -= (stopDistance - stopEleDim)
					targetEle.insertBefore(liArray[liArray.length - 1], liArray[0]);
					stopDistance = 0;
					moveInterval = this.stopDuration;
				} else if (!this.isInverse && stopDistance < 0) {
					currentPos += firstEleDim;
					currentPos -= (stopDistance + stopEleDim)
					targetEle.appendChild(liArray[0]);
					stopDistance = 0;
					moveInterval = this.stopDuration;
				}
			}
			currentPos += "px";
			if (isVertical)	{
				targetEle.style.top = currentPos;
			} else {
				targetEle.style.left = currentPos;
			}
		}
		scrollOn(this, moveInterval);
	}
	this.scrollStart();
}
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function')	{
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}
function showRanking() {
	$('scrollRanking').observe('mouseover',function(e) {
		aionRanking.isStop=true; //stop rolling
		var el=e.element();
		if (el.tagName!='LI') el=el.up('li');
		if ($('rankList').select('li.over')[0]) $('rankList').select('li.over')[0].className = 'out';
		$('rankList').style.display = 'block';
		for(var i=1;i<$('rankList').select('li').length+1; i+=1) {
			if(parseInt(el.value)===i) $('rankList').select('li')[i-1].className = 'over';
		}
	});
	$('rankList').observe('mouseover',function(e) {
		$('rankList').style.display = 'block';
	});
	$('rankList').observe('mouseout',function(e) {
		Event.stop(e);
		aionRanking.isStop=false;//start rolling
		var el=e.element();
		$('rankList').style.display = 'none';
	});
}

var CharacterRecom = {
	displayRecomCnt : function(response, parameter) {
		var result = response.evalJSON();
		try {
			if(result[0].result == 'SUCCESS') {
				document.getElementById("goodCnt").innerHTML = result[0].totalGoodCnt;
				document.getElementById("badCnt").innerHTML = result[0].totalBadCnt;
			} 
		} catch(e) { alert(e.description); }
	},
	doRecommend : function(serverID, charID, recomType) {
		var url = "/info/character/recommendcharacter";
		var parameters = {};
		parameters.serverID = serverID;
		parameters.charID = charID;
		parameters.recomType = recomType;
		
		ajaxUtil.callAjaxReturnByMethod(url, parameters, CharacterRecom.resultRecom);
	},
	resultRecom : function(response, parameter) {
		var result = response.evalJSON();
		try {
			if(result[0].result == 'SUCCESS') {
				alert("You recommended this.");
				document.getElementById("goodCnt").innerHTML = result[0].totalGoodCnt;
				document.getElementById("badCnt").innerHTML = result[0].totalBadCnt;
			} else if(result[0].result == 'ALREADY_RECOM') {
				alert("You have already recommended this.");
			} else if(result[0].result == 'MYCHAR') {
				alert("You cannot recommend yourself.");
			} else if(result[0].result == 'NO_AUTH') {
				alert("You had logged out. Please log back in.");
				location.reload();
			} else {
				alert("Failed to recommend.");
			}
		} catch(e) { alert(e.description); }
	}
}


var CharacterTab=[];
var CharacterInfoSearch={};
CharacterInfoSearch.viewAnother=function(idx){
	if (Object.isUndefined(CharacterTab[idx])) {
		if (idx == 1) {
			CharacterTab[idx] = "CHECK";
			$('wrap_character_2d').show();
			$('wrap_character_3d').hide();
		}
		else if (idx == 2) {
//			var parameters={};
//			parameters.serverID=$('serverID').value;
//			parameters.charID=$('characterID').value;
//			new Ajax.Request(url,{
//				method:'POST',
//				encoding:'UTF-8',
//				parameters:Object.toQueryString(parameters),
//				onSuccess:function(request){
//				$('Character3DInfo').innerHTML=request.responseText;
//				LoadCharacterView();
//				CharacterTab[idx]=$('Character3DInfo').innerHTML;
//				},
//				onFail:function(transport){
//				alert("Fail");
//				}
//				}
//			);
			CharacterTab[idx] = "CHECK";
			LoadCharacterView();
			$('wrap_character_2d').hide();
			$('wrap_character_3d').show();
		}
	}
	else {
		if (idx == 1) {
			$('wrap_character_2d').show();
			$('wrap_character_3d').hide();
		}
		else if (idx == 2) {
			$('wrap_character_2d').hide();
			$('wrap_character_3d').show();
		}
	}
	characterInfo.closeShowLayer();
}

function LoadCharacterView()
{
	var appletsource = '<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="280" height="564" codebase="http://java.sun.com/update/1.6.0/jinstall-6u10-windows-i586.cab#Version=6,0,0,10">'
		+ '<param name="java_code" value="avatar.AppletTestAvatar">'
		+ '<param name="mayscript" value="true">'
		+ '<param name="java_codebase" value="http://gdsv.ncsoft.dev:8083/aionweb/">'
		+ '<param name="java_archive" value="windows_natives.jar,commons-httpclient-3.1.jar,commons-logging-1.1.1.jar,commons-codec-1.3.jar,lwjgl_util_applet.jar,lwjgl.jar,jme.jar,jme-awt.jar,jme-model.jar,data.jar,avatar.jar">'
		+ '<param name="type" value="application/x-java-applet;version=1.6">'
		+ '<param name="name" value="applet">'
		+ '<param name="separate_jvm" value="true">'
		+ '<param name="classloader_cache" value="false">'
		+ '<comment>'
		+ '<embed id="JMEApplet" type="application/x-java-applet;version=1.6" width="280" height="564" pluginspage="http://java.sun.com/products/plugin/" java_code="avatar.AppletTestAvatar" java_codebase="http://gdsv.ncsoft.dev:8083/aionweb/" java_archive="windows_natives.jar,commons-httpclient-3.1.jar,commons-logging-1.1.1.jar,commons-codec-1.3.jar,lwjgl_util_applet.jar,lwjgl.jar,jme.jar,jme-awt.jar,jme-model.jar,data.jar,avatar.jar" name="applet"  mayscript="true"/>'
		+ '<noembed>'
		+ '<br /><Strong>Java plug-in required.<br />'
		+ '<a href="http://www.java.com/ko/download/"> Download Java plug-in here (US)</a></Strong>'
		+ '<img src="http://static.uk.aiononline.com/aion/info/zone/img_jme.gif" alt="" />'
		+ '</noembed>'
		+ '</comment>'
		+ '</object>';
	
	$('appletplace').innerHTML = appletsource;
}