
function ShowPM(isShow) {	
	if (isShow && PMspan.innerHTML=="") {
		switch (PMmelodyPath) {
			case null:
			case "":
				s = "shared/event-pm.wav"
				break;
			case -1:
				s = "";
				break;
			default:
				s = PMmelodyPath 
				break;
		}
		try {
			if (s!="") BgSoundObj.src = s
		}
		catch(e) {}
	}
	PMspan.innerHTML = isShow ? "<a target='_blank' onclick='setTimeout(PMoff,10);' href='pm.php'><img src='images/pmNewYes2.gif' width='19' height='11' alt='личные сообщения' border='0'>&nbsp;<b>ПИСЬМО</b></a>": ""
}

function PMoff() {
	try {
		BgSoundObj.src = "event-chat-null.mid"
		PMspan.innerHTML = ""
	}
	catch(e) {alert(1)}
}

var ScriptObj = null;
function GeneratePing(spanObj) {
	fn = location.pathname;
	n = fn.lastIndexOf("/")
	if (n!=-1) fn = fn.substring(n+1)
  	var path = 'global.php?cmd=ping&name=' + UserName + '&fn=' + fn + '&rnd=' + Math.round(Math.random() * 1000000000);	
    try{
		var cmp = document.getElementById(spanObj.id);	
		if (cmp!=null) {
			if (ScriptObj!=null) cmp.parentNode.removeChild(ScriptObj);	
			ScriptObj = document.createElement('SCRIPT');
			ScriptObj.setAttribute('type','text/javascript');
			ScriptObj.setAttribute('src', path + '&isPMcheck=1');
			cmp.parentNode.appendChild(ScriptObj)
		}
    }
	catch(e) {	
		var s = new Image();
		s.src = path + '&isPMcheck=0';
	}
}		

function InsertUserMainButton() {
   	if (UserName=="") {
   	   	s1 = "!";
   	}
   	else {
   		s1 = ", " + UserName + "!";
   	}
	document.write("<span class='WelcomeClass'>Добро пожаловать" + s1 + "</span>\n");
}


function InsertFlash(filename) {
	s = "";
	s = s + "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,79,0'";
	s = s + "id='FlashUp' class='FlashClass' width='299' height='60'>";
	s = s + "<param name='movie' value='images/" + filename + "'>";
	s = s + "<param name='quality' value='High'>";
	s = s + "<param name='allowscriptaccess' value='samedomain'>";
	s = s + "<param name='wmode' value='transparent'>";
	s = s + "<embed type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' name='FlashUp'";
	s = s + "  src='images/" + filename + "'";
	s = s + "  width='299' height='60' quality='High' allowscriptaccess='samedomain' wmode='transparent'";
	s = s + ">";
	s = s + "<noembed></noembed>";
	s = s + "</embed>";
	s = s + "</object>";
	document.write(s);
}

function GetUserLastPMToNames() {
   	if (UserLastPMToNames=="") return "";
	var d = UserLastPMToNames.split(":");
	var s1 = "";
    for (i=0;i<=d.length-1;i++) {
        if (d[i]!="") {
			s1 = s1+"&nbsp;<a target='_blank' href='pm.php?cmd=ShowAddPMform&nameTo="+d[i]+"'>"+d[i]+"</a><br>";
		}
    }
	return s1;
}

function ClearLastNameList() {
	if (!confirm('Очистить список последних используемых имен Жителей?')) return
	location = "pm.php?cmd=clearUserLastNames"
}


/////////////////////////////////////
function NowTime() {
    var Now = new Date()
    var h=Now.getHours()+""   ; if (h.length<2) h= "0" + h
    var m=Now.getMinutes()+"" ; if (m.length<2) m= "0" + m
    var s=Now.getSeconds()+"" ; if (s.length<2) s= "0" + s
    var dn = new Array("воскресенье", "понедельник", "вторник", "среда", "четверг", "пятница", "суббота")
	var mn=new Array("января","февраля","марта","апреля","мая","июня","июля","августа","сентября","октября","ноября","декабря");

    var dd=Now.getDate() + " " + mn[Now.getMonth()] + ", " + dn[Now.getDay()]
    return dd + " - " + h + ":" + m + ":" + s
}

function ShowBukvaLinks(Cur) {
	eng="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	rus="АБВГДЕЁЖЗИКЛМНОПРСТУФХЦЧШЩЭЮЯ";
	document.write("начальные буквы - ");
	document.write(ShowBukva1Link(rus,Cur));
	document.write(" - ");
	document.write(ShowBukva1Link(eng,Cur));
}
function ShowBukva1Link(str,Cur) {
	s="";
    for(i=0; i<str.length; i++){
		t = str.substring(i, i+1);
		if (t==Cur) t="-<span class='Box4'><b>"+t+"</b></span>-"; else t="<a href='login-main-code.php?Bukva=" + t + "'>" + t + "</a>"
		s = s + t ;
	}	
	return s;
}
