
<!--
//var skin = '<?php echo $u->skin; ?>';

function toggle(txt){
	if (txt.style.display == "" || txt.style.display == "inline"){
		txt.style.display = "none";
	}else {
		txt.style.display = "inline";
	}
}

function load_innerHTML(target,html,d){
	if(d){ obj = d; }else{ obj = document; }
	targ = obj.getElementById(target);
	targ.innerHTML = html;
}

//pt tradus stringuri din urlencode() din php;
function URLDecode(psEncodeString) {
  // Create a regular expression to search all +s in the string
  var lsRegExp = /\+/g;
  // Return the decoded string
  return unescape(String(psEncodeString).replace(lsRegExp, " ")); 
}


function getExplorerVersion() {
	var ieVers = parseFloat(navigator.appVersion);
	if( navigator.appName != 'Microsoft Internet Explorer' ) return ieVers;
	var tempVers = navigator.appVersion;
	var i = tempVers.indexOf( 'MSIE ' );
	if( i >= 0 ) {
		tempVers = tempVers.substring( i+5 );
		ieVers = parseFloat( tempVers ); 
	}
	return ieVers;
}

//INTERFATA DIALOGURI 
var keepnotify_frmhref;
var keepnotify_status = 'active';

function prepareWindowDecoration(){
	if(document.getElementById('messageWindowDecoration').style['display'] != 'inline'){
		dlgDisplayDiv(document.getElementById('messageWindowDecoration'),'','');
	}
}

function dlgUserDetails(uid){
	//alert('user details');
	//window.showModalDialog("dlg/dlg.userdetails.php?uid="+uid+"","","dialogHeight:350px;dialogWidth:350px;resizable:no;scroll:no;help:no;edge:raised;center:yes;unadorned:yes");	
	//pauseKeepnotify(); inainte sa fi folosit ajax
	//function showPopWin(url, html, width, height, returnFunc, dlgbg, isfrm) {
	prepareWindowDecoration();
	showPopWin("dlg/dlg.userdetails.php?uid="+uid+"",'', '','', '','',true);
}

function dlgPrincipleInfo(p){
	prepareWindowDecoration();
	showPopWin("dlg/dlg.principle_info.php?p="+p+"",'', 820,730, '', 'big');
}

function dlgAchievementInfo(a){
	prepareWindowDecoration();
	showPopWin("dlg/dlg.achievement_info.php?p="+a+"",'', 820,730, '', 'big');
}

function dlgSpellInfo(s){
	prepareWindowDecoration();
	showPopWin("dlg/dlg.spellpage_info.php?s="+s+"",'', 820,730, '', 'big');
}

function dlgMdaDocsRead(d,u){
	prepareWindowDecoration();
	showPopWin("dlg/dlg.docread.php?d="+d+"&u="+u+"",'', 820,730, '', 'big');
}

function dlgMdaDocsWrite(d,u){
	prepareWindowDecoration();
	showPopWin("dlg/dlg.docwrite.php?d="+d+"&u="+u+"",'', 820,730, '', 'big');
}

function dlgNotesDocsWrite(d,u){
	myRef = window.open("../dlg/dlg.notesdocwrite.php?d="+d+"&u="+u+"",'mdnotesdoc'+d,'left=40,top=20,width=820,height=700,toolbar=1,resizable=1,scrollbars=1');
}

function dlgRPCQDocsRead(rpcq){
	prepareWindowDecoration();
	//showPopWin("dlg/dlg.rpcqdocread.php?rpcq="+rpcq+"",'', 820,730, '', 'big');
	showPopWin("dlg/dlg.rpcqdocread.php?rpcq="+rpcq+"",'', '','', '', true);
}

function dlgRPCQDocsWrite(rpcq){
	prepareWindowDecoration();
	//showPopWin("dlg/dlg.rpcqdocwrite.php?rpcq="+rpcq+"",'', 820,730, '', 'big');
	showPopWin("dlg/dlg.rpcqdocwrite.php?rpcq="+rpcq+"",'', '','', '', true);
}

function dlgChangelog(){
	prepareWindowDecoration();
	showPopWin("dlg/dlg.changelog.php",'', 820,730, '', 'big');
}

function dlgAdventurelog(){
	prepareWindowDecoration();
	showPopWin("dlg/dlg.adventurelog.php",'', 820,730, '', 'big');
}

function dlgStartupTutorial(s){
	prepareWindowDecoration();
	showPopWin("dlg/dlg.startuptutorial_"+s+".php",'', '','', '',true);
}

function dlgTutorial(t){
	prepareWindowDecoration();
	showPopWin("dlg/dlg.tutorial.php?t="+t+"",'', 820,730, '', 'big');
}

function dlgKncollections(c){
	prepareWindowDecoration();
	showPopWin("dlg/dlg.kncollections.php?c="+c,'', '','', '',true);
}

function dlgProgresslog(){
	prepareWindowDecoration();
	showPopWin("dlg/dlg.todaysprofile.php",'', '','', '',true);
}

function dlgCalendar(d,m,init){
	prepareWindowDecoration();
	showPopWin("dlg/dlg.calendar.php?d="+d+"&m="+m+"&i="+init,'', '','', '',true);
}

function dlgNewMessageAlert(){
	prepareWindowDecoration();
	leftmenu.SetVariable("action_msg","normal");
	showPopWin("dlg/dlg.showmessage.php?what=lastunread",'', '','', '',true);
}

function dlgComposeMessage(uid,c){
	prepareWindowDecoration();
	showPopWin("dlg/dlg.sendmsg.php?eid="+uid+"&c="+c+"",'', '','', '',true);
}

function dlgBestiary(u){
	prepareWindowDecoration();
	showPopWin("dlg/dlg.bestiary.php?u="+u,'', 820, 730, '', 'big');
}

function dlgMessageList(categ){
	prepareWindowDecoration();
	showPopWin("dlg/dlg.messagelist.php?categ="+categ+"",'', '','', '',true);
}

function dlgComposeMessageLivehelp(uid, subj){
	prepareWindowDecoration();
	showPopWin("dlg/dlg.sendmsglivehelp.php?id="+uid+"&subject="+subj,'', '','', '',true);
}

function dlgNewCombatAlert(){
	prepareWindowDecoration();
	leftmenu.SetVariable("action_atc","normal");
	showPopWin("dlg/dlg.combatreplay.php",'', '','', '',true);
}

function dlgBattleLog(){
	prepareWindowDecoration();
	showPopWin("dlg/dlg.battlelog.php",'', '','', '',true);
}

function dlgUserList(){
	prepareWindowDecoration();
	showPopWin("dlg/dlg.usersonline.php",'', '','', '',true); 
}

function dlgStartCombat(eid){
	prepareWindowDecoration();
	showPopWin("dlg/dlg.liststrategies.php?eid="+eid,'', '','', '',true); 
}

function dlgArtefact(art,a){
	prepareWindowDecoration();
	showPopWin("dlg/dlg.artefact.php?art="+art+"&a="+a,'', 820,730, '', 'big');
}

function dlgArtefactDetailPage(artf,pg){
	prepareWindowDecoration();
	showPopWin("art/artefacts/"+artf+"/pag_"+pg+".php",'', 820,730, '', 'big');
}

function dlgAllianceDetails(id){
	prepareWindowDecoration();
	showPopWin("ui/app-housing/details.php?id="+id,'', '','', '',true);
}

function dlgApplication(loc,params){
	prepareWindowDecoration();
	//loc e doar ca sa verifice daca mai e linkul valid sau nu
	showPopWin("dlg/dlg.application.php?loc="+loc+"&params="+params,'', '','', '',true); 
}

function dlgRealmMap(){
	prepareWindowDecoration();
	showPopWin("dlg/dlg.realmmap.php",'', 820,730, '', 'big');
	//showPopWin("dlg/dlg.realmmap.php",'', 750,550, '', 'big');
}

function dlgNotif(k,r,v){
	prepareWindowDecoration();
	if(document.getElementById("popupFrame")){
		doc = document;
	}else if(document.getElementById("pagecontent").document.getElementById("popupFrame")){
		doc = document.getElementById("pagecontent").document;
	}else{
		alert("showPopWin ERROR, no popupFrame obj found");	
	}
	doc.getElementById("popupContainer").style["backgroundImage"] = "";	
	showPopWin("dlg/dlg.notif.php?key="+k+"&type="+r+"&vars="+v,'', 820,730,  '', 'big');
}

function dlgMsg(n,l){
	prepareWindowDecoration();
	if(document.getElementById("popupFrame")){
		doc = document;
	}else if(document.getElementById("pagecontent").document.getElementById("popupFrame")){
		doc = document.getElementById("pagecontent").document;
	}else{
		alert("showPopWin ERROR, no popupFrame obj found");	
	}
	doc.getElementById("popupContainer").style["backgroundImage"] = "";	
	showPopWin("dlg/dlg.msg.php?n="+n+"&l="+l,'', 820,730,  '', 'big');
}

//dlgsection e div in pagina
function dlgDisplayDiv(o,w,h){
	var obj = o;
		//alert(obj);
	var objHtml = obj.innerHTML;
	if(!obj){
		alert('Invalid command, document refresh required'); //Error:
		location.href = location.href; 
	}else{
		//alert("AAAAAAAAA");
		//pauseKeepnotify(); inainte sa fi folosit ajax
		//se incarca pag de sus mai intai abia pe urma pot sa schimb innerhtml
		//dlg/dlg.default.php?pag=loading
		//showPopWin(url, html, width, height, returnFunc, dlgbg, imgpth
		showPopWin("",objHtml, w, h, '','',''); //350x350 default //resumeKeepnotify cand nu era ajax
	}
}

var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

function encode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   do {
      chr1 = input.charCodeAt(i++);
      chr2 = input.charCodeAt(i++);
      chr3 = input.charCodeAt(i++);

      enc1 = chr1 >> 2;
      enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
      enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
      enc4 = chr3 & 63;

      if (isNaN(chr2)) {
         enc3 = enc4 = 64;
      } else if (isNaN(chr3)) {
         enc4 = 64;
      }

      output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + 
         keyStr.charAt(enc3) + keyStr.charAt(enc4);
   } while (i < input.length);
   
   return output;
}

function decode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
   input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

   do {
      enc1 = keyStr.indexOf(input.charAt(i++));
      enc2 = keyStr.indexOf(input.charAt(i++));
      enc3 = keyStr.indexOf(input.charAt(i++));
      enc4 = keyStr.indexOf(input.charAt(i++));

      chr1 = (enc1 << 2) | (enc2 >> 4);
      chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
      chr3 = ((enc3 & 3) << 6) | enc4;

      output = output + String.fromCharCode(chr1);

      if (enc3 != 64) {
         output = output + String.fromCharCode(chr2);
      }
      if (enc4 != 64) {
         output = output + String.fromCharCode(chr3);
      }
   } while (i < input.length);

   return output;
}

function loadContentiFrame(menuinfo){
//if($u->customizations['scrollbar']) { ?>
	//var pagecontent_ifrm = top.mainFrame.document.getElementById('pagecontent');
	var pagecontent_ifrm = parent.document.getElementById('pagecontent');
	
	pagecontent_ifrm.style.height=800; //reset
	pagecontent_ifrm.style.height=document.body.scrollHeight; //orig

	//top.document.pagecontent.style.height=document.body.scrollHeight; 
	//parent.document.getElementById('pagecontent').style.height=500; 
	top.document.title=document.title; 

	for (var word in menuinfo){
		parent.document.getElementById(word).innerHTML = menuinfo[word];
	}
}


function updateLeftMenu(sho,glo){
	if(parent.document.getElementById('leftmenu')){
		m = parent.document.getElementById('leftmenu');
	}else{
		m = document.getElementById('leftmenu');
	}
	m.SetVariable("sho",sho);
	m.SetVariable("glo",glo);
	m.SetVariable("reset","true");
}
