var lState;var allCom=0;
function sa(){j=document.getElementById('uAge');if(j)j.innerHTML=setAge;};
function daccount(){if(confirm('Сигурни ли сте,че иската да изтриете акаунта си ?')){hide('tadd');hide('dacc');showt('dacc_chg');hide('aemail');hide('msgEmail');hide('dact');hide('dreg');hide('password');hide('showPass');hide('changes');hide('infoMsg');hide('pBoxTop');hide('pBoxBottom');hide('spacePos');showt('raccount');}};
function rPhoto(){if(confirm('Сигурни ли сте,че иската да изтриете снимката ?')){document.fdetails.evbut.value='rmphoto'+modify;document.fdetails.submit();}};
function swchg(){if(modify==0){modify=1;show('changes');}};
function chkchg(){swchg();if(document.getElementById('infoM')){hide('infoM');}};
function chg(id){chkchg();sh(id,id+'_chg');};
function sh(i1,i2){hide(i1);show(i2);};
function hide(i){document.getElementById(i).style.display='none';};
function show(i){document.getElementById(i).style.display='inline';};
function showt(i){document.getElementById(i).style.display='';};
function sform(i){document.getElementById(i).submit();};
function rform(i){document.getElementById(i).reset();};
function chgBirth(dmy){if(document.getElementById(dmy).value==0){vdmy=0;}else{vdmy=1;}if(dmy=='p_day'){bd=vdmy;}else if(dmy=='p_month'){bm=vdmy;}else by=vdmy;if((bd+bm+by)==3){showt('showAge');cAge();}else{hide('showAge');}};
function chgCnt(cn){if(cn!=24){otherCity='a';hide('city_chg');}else{otherCity='';hide('acity_chg');};chgCity();};
function chgCity(){if(modify==0){modify=1;show('changes');if(document.getElementById('infoM')){hide('infoM');}}sh('city',otherCity+'city_chg');};
function refuse(){hide('changes');rform('fdetails');showt('password');hide('showPass');sh('email_chg','email');hide('msgEmail');sh('pname_chg','pname');sh('photo_chg','photo');sh('sex_chg','sex');sh('birthday_chg','birthday');if((bd+bm+by)==3){showt('showAge')}else{hide('showAge');};sh('country_chg','country');sh('city_chg','city');hide('acity_chg');sh('favgame_chg','favgame');sh('dscript_chg','dscript');sh('enotify_chg','enotify');sh('abpass_chg','abpass');sh('ablock_chg','ablock');modify=0;};
function nr(){showt('tadd');sh('dacc_chg','dacc');showt('aemail');show('dact');showt('dreg');showt('infoMsg');hide('raccount');showt('spacePos');showt('pBoxTop');showt('pBoxBottom');refuse();};
function cAge(){with(document.fdetails){dd=parseInt(p_day.selectedIndex);mm=parseInt(p_month.selectedIndex);yy=parseInt(p_year.options[p_year.selectedIndex].value);days=new Date();tdate=days.getDate();tmonth=days.getMonth()+1;tyear=days.getFullYear();if(tyear<2000)tyear+=1900;age=tyear-yy;if(mm==tmonth){if(tdate<dd){age-=1;};}else{if(tmonth<mm){age-=1;};};setAge=age;sa();};};
function check_email(e){ok="1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";for(i=0;i<e.length;i++){if(ok.indexOf(e.charAt(i))<0){return(false);};};if(document.images){re=/(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;re_two=/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;if(!e.match(re)&&e.match(re_two)){return(-1);};};};
function chkFormProfile(){with(document.fdetails){
if((evbut.value=='delete')&&(rmreg.value.length==0)){
alert('Трябва да въведете паролата си за да изтриете акаунта си');
rmreg.focus();return false;};if(evbut.value=='change'){
if(opass.value.length!=0||npass.value.length!=0||cnpass.value.length!=0){
if(opass.value.length==0){
alert('Въведете сегашната си парола');
opass.focus();return false;};if(npass.value.length==0){
alert('Въведете нова парола');
npass.focus();return false;};if(npass.value!=cnpass.value){
alert('Двете пароли не съвпадат');
npass.focus();return false;};if(npass.value.length<6){
alert('Паролата не може да е по-къса от 6 символа');
npass.focus();return false;};};if(p_email.value==0){
alert('Въведете емейл адрес.');
p_email.focus();return false;};if(!check_email(p_email.value)){
alert('Въведете полето емейл коректно.');
p_email.focus();return false;};if(p_day.selectedIndex!=0||p_month.selectedIndex!=0||p_year.options[p_year.selectedIndex].value!=0){if(p_day.selectedIndex==0){
alert('Изберете ден за полето рожденна дата\n или оставете всички полета празни.');
p_day.focus();return false;};if(p_month.selectedIndex==0){
alert('Изберете месец за полето рожденна дата\n или оставете всички полета празни.');
p_month.focus();return false;};if(p_year.options[p_year.selectedIndex].value==0){
alert('Изберете година за полето рожденна дата\n или оставете всички полета празни.');
p_year.focus();return false;};};if(p_country.value!=0&&p_country.value!=24){if(acity.value.length==0){
alert('Въведете друг град');
acity.focus();return false;};var chkVName=/[^a-zA-Zа-яА-я_\.\- ]/g;if((acity.value).match(chkVName)){
alert('Полето град не е въведено коректно');
acity.focus();return false;};};};};};
function addList(tList){var e=document.getElementById('msg');var e1=document.getElementById('inMsg');var e2=document.getElementById('nameList');if(e.style.display==''&&lState==tList){e.style.display='none';}else{var sText;if(tList){sText="Контакти";sT='fav';}else{sText="Блокирани";sT='block';};e2.innerHTML=sText;lState=tList;httpRequest('getlists.php?tp='+sT,'',"sAddList");};};
function stlData(uid,uname,ustate,tlst){var txt="<div id='"+uid+"' class='lBrown' style='float: left;display: inline; width: 400px; text-align: center;margin-left: 50px;'>";txt+="<a class='bfList' target='_blank' href='"+"users.php?uid="+uid+"'>"+uname+"</a> ";if(tlst=='fav'){txt+="<div style='float: left; color: #"+((ustate==1)?"008000'>онлайн":"FF0000'>офлайн")+"</div>";tm="контакти";}else tm="блокирани";txt+=" <a class='bfList' href='javascript:if (confirm(\"Сигурни ли сте, че искате да изтриете "+uname+" от "+tm+"?\")) {httpRequest(\"delist.php?id="+uid+"\",\"\",\"dData\");  hText(\"Изтриване\",\"white\",\"#ff5d5d\");}'>изтрий</a>";txt+="</div>";return txt;};
function dData(x){hText('','','');if(x!=0){document.getElementById(x).style.display='none';var e=document.getElementById('msg');var e1=document.getElementById('inMsg');if((parseInt(e1.style.height)-15)>0){e.style.height=(parseInt(e.style.height)-15)+'px';e1.style.height=(parseInt(e1.style.height)-15)+'px';}else e1.innerHTML='Няма записани потребители';}else alert('Възникна грешка по време на операцията');};
function sAddList(x){var e=document.getElementById('msg');e.style.display='';var e1=document.getElementById('inMsg');var lst=x.getElementsByTagName("root");var br=15;var txtL="";if(lst[0]){var aList=lst[0].getElementsByTagName("list");if(aList[0]){var tLst=lst[0].getElementsByTagName("type")[0];tLst=tLst.getAttribute("id");br=0;for(var i=0;i<aList.length;i++){br+=15;txtL+=stlData(aList[i].getAttribute("id"),aList[i].firstChild.nodeValue,aList[i].getAttribute("state"),tLst);};}else{txtL='Няма записани потребители';};}else txtL='Няма записани потребители';e1.innerHTML=txtL;e.style.height=parseInt(br)+30+'px';e1.style.height=br+'px';};
function showComment(){var e1=document.getElementById('shcomments');if(e1.style.display=='none'){e1.style.display='';var rp=document.getElementById("sendTo");shLComment(rp.value,"");}else{e1.style.display='none';};};
function shLComment(rp,lm){httpRequest('getComm.php?rp='+rp+'&lm='+lm,"","sGetComment");};
function sGetComment(x){var lst=x.getElementsByTagName("root");var txtL="";var dt;var id;if(lst[0]){var aList=lst[0].getElementsByTagName("lst");var mComm=lst[0].getElementsByTagName("lm");if(aList[0]){allCom=aList.length;for(var i=0;i<aList.length;i++){id=aList[i].getAttribute("id");dt=aList[i].getAttribute("dt");txtL+="<div  style='float: left;display: inline;width: 340px; text-align: left;background: #f9f3e1;' id='"+id+"'>";txtL+="<span  style='float: left;width: 303px;'><a style='color: #274daf;' href='users.php?uid="+id+"' target='_blank'>"+aList[i].getAttribute("nName")+"</a> <b>каза:</b><font color='#71716a'> "+ago(dt)+"</font></span><a href='javascript:if (confirm(\"Сигурни ли сте, че искате да изтриете коментара?\")) {httpRequest(\"delcomm.php?id="+id+"\",\"\",\"dComm\");}' style='color: red;'>[del]</a>";txtL+="<br />"+aList[i].firstChild.nodeValue;txtL+="</div>";};if(mComm[0].getAttribute("vl")=='y'){allCom=mComm[0].firstChild.nodeValue;txtL+="<div  style='float: left;display: inline; width: 340px; text-align: left;background: #f9f3e1;' id='aRec'>";txtL+="<a style='color: #274daf;' href='#' onclick='shLComment("+mComm[0].getAttribute('id')+",\"n\"); return false;'>Всички коментари("+allCom+")</a>";txtL+="</div>";};}else{txtL='Няма коментари';};}else txtL='Няма коментари';var e1=document.getElementById('shcomments');e1.innerHTML=txtL;};
function ago(timestamp){var difference=timestamp;var txt="(преди: ";var sec=min=hour=day=week=month=null;if(difference<60)sec=difference;else{difference=Math.round(difference/60);if(difference<60)min=difference;else{difference=Math.round(difference/60);if(difference<24)hour=difference;else{difference=Math.round(difference/24);if(difference<7)day=difference;else{difference=Math.round(difference/7);if(difference<4)week=difference;else{difference=Math.round(difference/7);month=difference;};};};};};if(month!=null){txt+=month;txt+=(month==1)?" месец":" месеца";}else if(week!=null){txt+=week;txt+=(week==1)?" седмица":" седмици";}else if(day!=null){txt+=day;txt+=(day==1)?" ден":" дена";}else if(hour!=null){txt+=hour;txt+=(hour==1)?" час":" часа";}else if(min!=null){txt+=min;txt+=(min==1)?" минута":" минути";}else{txt+=sec;txt+=(sec==1)?" секунда":" секунди";};txt+=" )";return txt;};
function dComm(x){if(x!=0){allCom--;document.getElementById(x).style.display='none';document.getElementById("tComm").innerHTML='<a href="javascript:void showComment();" class="smessage">Коментари ('+allCom+')</a>';var e2=document.getElementById('aRec');var e1=document.getElementById('shcomments');if((e2!=null)&&(e2.style.display!='none')){e2.innerHTML="<a style='color: #274daf;' href='#' onclick='shLComment("+document.getElementById("sendTo").value+",\"n\"); return false;'>Всички коментари("+allCom+")</a>";};if(allCom>0){}else e1.innerHTML='Няма коментари';}else alert('Възникна грешка по време на операцията');};
function openalbwindow(location,sWidth,sHeight)
{
   winLeft = (screen.width-sWidth)/2;
   winTop = (screen.height-sHeight)/2;
   window.open( location ,"ForteGamesPhotos","width="+sWidth+",height="+sHeight+",left="+winLeft+",top="+winTop+",directories=no,menubar=no,location=no,scrollbars=no,resizable=no,status=0");
}
