		function set_mood2($mood) {
			makeRequest( 'ajax/moodMod.php?action=set2&mood=' + encodeURI( $mood ), 'moodDiv' );		
		}
		
		function prepareHints() {
			var els = document.getElementsByTagName("a");
			for (var i=0; i<els.length; i++){
				if ( els[i].title == '' ) {
					continue;
				}
				eval('els[i].onmouseover = function (event) {show_hint(event, \'' + els[i].title  + '\');	}');
				els[i].onmouseout = function () {
					hide_hint();
				}
				els[i].onmousemove = function (event) {
					move_hint(event);
				}
				els[i].setAttribute("title", "");
			}
		}
		
		function show_hint(e, msg) {
		    var posx = 0;
		    var posy = 0;
		    if (!e) var e = window.event;
		    if (e.pageX || e.pageY)
		    {
		        posx = e.pageX;
		        posy = e.pageY;
		    }
		    else if (e.clientX || e.clientY)
		    {
		        posx = e.clientX + document.documentElement.scrollLeft;
		        posy = e.clientY + document.documentElement.scrollTop;;
		    }
			
			posy += 20;

			if ( document.getElementById('hintDiv' ) ) {
				document.getElementById('hintDiv').innerHTML = msg;
				document.getElementById('hintDiv').style.left = posx + "px";
				document.getElementById('hintDiv').style.top = posy + "px";
				document.getElementById('hintDiv').style.display = 'block';
			}
		}
		function showImg(e, img, ts, w, h, divName) {
		    var posx = 0;
		    var posy = 0;
		    if (!e) var e = window.event;
		    if (e.pageX || e.pageY)
		    {
		        posx = e.pageX;
		        posy = e.pageY;
		    }
		    else if (e.clientX || e.clientY)
		    {
		        posx = e.clientX + document.documentElement.scrollLeft;
		        posy = e.clientY + document.documentElement.scrollTop;;
		    }
			
			posy += 20;
			if ( document.getElementById(divName ) ) {
				document.getElementById(divName).innerHTML = '<img src="' + img + '?ts=' + ts + '" width="' + w + '" height="' + h + '" />';
				document.getElementById(divName).style.left = posx + "px";
				document.getElementById(divName).style.top = posy + "px";
				document.getElementById(divName).style.display = 'block';
			}
		}
		function moveImg( e, divName ) {
		    var posx = 0;
		    var posy = 0;
		    if (!e) var e = window.event;
		    if (e.pageX || e.pageY)
		    {
		        posx = e.pageX;
		        posy = e.pageY;
		    }
		    else if (e.clientX || e.clientY)
		    {
		        posx = e.clientX + document.documentElement.scrollLeft;
		        posy = e.clientY + document.documentElement.scrollTop;;
		    }
			
			posy += 20;

			if ( document.getElementById(divName ) ) {
				document.getElementById(divName).style.left = posx + "px";
				document.getElementById(divName).style.top = posy + "px";
			}
		}

		function move_hint(e) {
		    var posx = 0;
		    var posy = 0;
		    if (!e) var e = window.event;
		    if (e.pageX || e.pageY)
		    {
		        posx = e.pageX;
		        posy = e.pageY;
		    }
		    else if (e.clientX || e.clientY)
		    {
		        posx = e.clientX + document.documentElement.scrollLeft;
		        posy = e.clientY + document.documentElement.scrollTop;;
		    }
			
			posy += 20;

			if ( document.getElementById('hintDiv' ) ) {
				document.getElementById('hintDiv').style.left = posx + "px";
				document.getElementById('hintDiv').style.top = posy + "px";
			}
		}
		
		function hide_hint() {
			if ( document.getElementById('hintDiv' ) ) {
				document.getElementById('hintDiv' ).style.display = 'none';
			}
		}
		function hideImg(event, divName) {
			if ( document.getElementById(divName ) ) {
				document.getElementById(divName ).style.display = 'none';
			}
		}

		function set_mood() {
			makeRequest('ajax/moodMod.php?action=set', 'moodDiv' );
			/*
			if ( document.getElementById('moodDiv') ) {
				mdiv = document.getElementById('moodDiv');
				ih = '<div style="float: left; margin-left: 17px; background: #edf0f5;">' + "\n";
				ih = ih + '<input type="text" name="mood" class="tah10 gray70" value="Напиши тук, какво правиш сега" style="display: inline; width: 160px;" onclick="tclear( this, \'Напиши тук, какво правиш сега\');">' + "\n";
				ih = ih + '</div>' + "\n";
				ih = ih + '<div style="float: left; background: #edf0f5; margin-top: 1px;">' + "\n";
				ih = ih + '<input type="image" src="images/iconAccept.gif" width="16" height="16" style="display: block ;">' + "\n";
				ih = ih + '</div>';
				ih = ih + '<div style="float: left; background: #edf0f5; margin-top: 1px;">' + "\n";
				ih = ih + '<input onclick="cancel_mood();" type="image" src="images/iconReject.gif" width="16" height="16" style="display: block ;">' + "\n";
				ih = ih + '</div>';
				mdiv.innerHTML = ih;
			}
			*/
		}

		function cancel_mood() {
			makeRequest( 'ajax/moodMod.php?', 'moodDiv' );		
		}
		
		function minimize_module(module, minimized, generic) {
			if ( document.getElementById( module + 'MinMax' ) ) {
				generic = typeof(generic) != 'undefined' ? generic : module;
				modContent = document.getElementById( module + 'Cont' );
				modMinMax = document.getElementById( module + 'MinMax' );
				modMinimized = 'no';
				if ( modContent.style.display == 'none' ) {
					modMinimized = 'yes';
				}
				if ( minimized == 'yes' || ( minimized == null && modMinimized == 'no' ) ) {
					modContent.style.display = 'none';
					modMinMax.innerHTML = '<img src="images/maximizeMod.gif" width="12" height="12" border="0" alt="" onmouseover="show_hint( event, \'Покажи\');" onmousemove="move_hint(event);" onmouseout="hide_hint();" />';
					modMinimized = 'yes';
				} else if ( minimized == 'no' || ( minimized == null && modMinimized == 'yes' ) ) {
					modContent.style.display = 'inline';
					modMinMax.innerHTML = '<img src="images/minimizeMod.gif" width="12" height="12" border="0" alt="" onmouseover="show_hint( event, \'Скрий\');" onmousemove="move_hint(event);" onmouseout="hide_hint();" />';
					modMinimized = 'no';
				}
				if ( minimized == null ) {
					makeRequest( 'ajax/toggleSetting.php?key=' + module + 'Minimized' + '&value=' + modMinimized, 'nulldiv' );
				}
			}
			return false;
		}

		function lock_module(module, locked) {
			if ( document.getElementById( module + 'LockUnlock' ) ) {
				modContent = document.getElementById( module + 'Cont' );
				modLockUnlock = document.getElementById( module + 'LockUnlock' );
				modLocked = 'no';
				if ( document.getElementById(module + 'IsLocked').innerHTML == 'locked' ) {
					modLocked = 'yes';
				}
				if ( locked == 'yes' || ( locked == null && modLocked == 'no' ) ) {
					document.getElementById(module + 'IsLocked').innerHTML = 'locked';
					modLockUnlock.innerHTML = '<img src="images/lockedMod.gif" width="11" height="11" border="0" alt="" onmouseover="show_hint( event, \'Статус в момента: Видимо само за приятели\');" onmousemove="move_hint(event);" onmouseout="hide_hint();" />';
					modLocked = 'yes';
				} else if ( locked == 'no' || ( locked == null && modLocked == 'yes' ) ) {
					document.getElementById(module + 'IsLocked').innerHTML = 'unlocked';
					modLockUnlock.innerHTML = '<img src="images/unlockedMod.gif" width="11" height="11" border="0" alt="" onmouseover="show_hint( event, \'Статус в момента: Видимо за всички\');" onmousemove="move_hint(event);" onmouseout="hide_hint();" />';
					modLocked = 'no';
				} else if ( locked == '' ) {
					document.getElementById(module + 'IsLocked').innerHTML = 'unlocked';
					modLockUnlock.innerHTML = '<img src="images/lockedMod.gif" width="11" height="11" border="0" alt="" onmouseover="show_hint( event, \'Статус в момента: Видимо за всички\');" onmousemove="move_hint(event);" onmouseout="hide_hint();" />';
					modLocked = 'no';
				}
				if ( locked == null ) {
					makeRequest( 'ajax/toggleSetting.php?key=' + module + 'Locked' + '&value=' + modLocked, 'nulldiv' );
				}
				return false;
			}
		}


function openSearchWindow() {
	var w = 800; 
	var h = 600;
	if ( window.innerWidth ) {
		w = window.innerWidth;
		h = window.innerHeight;
	} else if ( document.body.offsetWidth ) {
		w = document.body.offsetWidth;
		h = document.body.offsetHeight;
	}
	if ( document.getElementById( 'searchWindow' ) ) {
		searchWin = document.getElementById( 'searchWindow' );
		searchWin.style.top = parseInt( ( h - parseInt( searchWin.style.height ) ) / 2 ) + 'px';
		searchWin.style.left = parseInt( ( w - parseInt( searchWin.style.width ) ) / 2 ) + 'px';
		searchWin.style.display = 'inline';
	}

}

		function tabclick(id) {
			for( i = 1; i <= 4; i++ ) {
				if ( i == id ) { 
					document.getElementById( 'tab' + i + 1 ).className = 'searchSelLeft';
					document.getElementById( 'tab' + i + 2 ).className = 'searchSelMiddle';
					document.getElementById( 'tab' + i + 3 ).className = 'searchSelRight';
					document.getElementById( 'divSearch' + i ).style.display = 'block';
				} else {
					document.getElementById( 'tab' + i + 1 ).className = 'searchDesLeft';
					document.getElementById( 'tab' + i + 2 ).className = 'searchDesMiddle';
					document.getElementById( 'tab' + i + 3 ).className = 'searchDesRight';
					document.getElementById( 'divSearch' + i ).style.display = 'none';
				}
			}
		}
		
		function tclear( inp, default_value ) {
			if ( inp.value == default_value ) {
				inp.value = '';
			}
		}
		
		function showSearch() {
			var w = 800; 
			var h = 600;
			if ( document.body.clientWidth ) {
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			} else if ( window.innerWidth ) {
				w = window.innerWidth;
				h = window.innerHeight;
			} else if ( document.documentElement.clientWidth ) {
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
			}
			if ( document.getElementById( 'fogWar' ) ) {
				outerWin = document.getElementById( 'fogWar' );
				outerWin.style.width = w + 'px';
				outerWin.style.height = h + 'px';
				outerWin.style.display = 'inline';
				innerWin = document.getElementById( 'FrontWindow' );
				innerWin.style.top = 300 + 'px';
				innerWin.style.left = parseInt( ( w - 507 ) / 2 ) + 'px';
				innerWin.style.display = 'inline';
			}
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'none';
			}
		}
		
		function hideSearch() {
			outerWin = document.getElementById( 'fogWar' );
			innerWin = document.getElementById( 'FrontWindow' );
			outerWin.style.display = 'none';
			innerWin.style.display = 'none';
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'block';
			}
		}

		
//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
        var version;
        var axo;
        var e;

        // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

        try {
                // version will be set for 7.X or greater players
                axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
                version = axo.GetVariable("$version");
        } catch (e) {
        }

        if (!version)
        {
                try {
                        // version will be set for 6.X players only
                        axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");

                        // installed player is some revision of 6.0
                        // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
                        // so we have to be careful.

                        // default to the first public version
                        version = "WIN 6,0,21,0";

                        // throws if AllowScripAccess does not exist (introduced in 6.0r47)
                        axo.AllowScriptAccess = "always";

                        // safe to call for 6.0r47 or greater
                        version = axo.GetVariable("$version");

                } catch (e) {
                }
        }

        if (!version)
        {
                try {
                        // version will be set for 4.X or 5.X player
                        axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
                        version = axo.GetVariable("$version");
                } catch (e) {
                }
        }

        if (!version)
        {
                try {
                        // version will be set for 3.X player
                        axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
                        version = "WIN 3,0,18,0";
                } catch (e) {
                }
        }

        if (!version)
        {
                try {
                        // version will be set for 2.X player
                        axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
                        version = "WIN 2,0,0,11";
                } catch (e) {
                        version = -1;
                }
        }

        return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
        // NS/Opera version >= 3 check for Flash plugin in plugin array
        var flashVer = -1;

        if (navigator.plugins != null && navigator.plugins.length > 0) {
                if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
                        var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
                        var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
                        var descArray = flashDescription.split(" ");
                        var tempArrayMajor = descArray[2].split(".");
                        var versionMajor = tempArrayMajor[0];
                        var versionMinor = tempArrayMajor[1];
                        var versionRevision = descArray[3];
                        if (versionRevision == "") {
                                versionRevision = descArray[4];
                        }
                        if (versionRevision[0] == "d") {
                                versionRevision = versionRevision.substring(1);
                        } else if (versionRevision[0] == "r") {
                                versionRevision = versionRevision.substring(1);
                                if (versionRevision.indexOf("d") > 0) {
                                        versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
                                }
                        }
                        var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
                }
        }
        // MSN/WebTV 2.6 supports Flash 4
        else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
        // WebTV 2.5 supports Flash 3
        else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
        // older WebTV supports Flash 2
        else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
        else if ( isIE && isWin && !isOpera ) {
                flashVer = ControlVersion();
        }
        return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
        versionStr = GetSwfVer();
        if (versionStr == -1 ) {
                return false;
        } else if (versionStr != 0) {
                if(isIE && isWin && !isOpera) {
                        // Given "WIN 2,0,0,11"
                        tempArray         = versionStr.split(" ");      // ["WIN", "2,0,0,11"]
                        tempString        = tempArray[1];                       // "2,0,0,11"
                        versionArray      = tempString.split(",");      // ['2', '0', '0', '11']
                } else {
                        versionArray      = versionStr.split(".");
                }
                var versionMajor      = versionArray[0];
                var versionMinor      = versionArray[1];
                var versionRevision   = versionArray[2];

                // is the major.revision >= requested major.revision AND the minor version >= requested minor
                if (versionMajor > parseFloat(reqMajorVer)) {
                        return true;
                } else if (versionMajor == parseFloat(reqMajorVer)) {
                        if (versionMinor > parseFloat(reqMinorVer))
                                return true;
                        else if (versionMinor == parseFloat(reqMinorVer)) {
                                if (versionRevision >= parseFloat(reqRevision))
                                        return true;
                        }
                }
                return false;
        }
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?');
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs)
{
  var str = '';
  if (isIE && isWin && !isOpera)
  {
    str += '<object ';
    for (var i in objAttrs)
    {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else
  {
    str += '<embed ';
    for (var i in embedAttrs)
    {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }

  document.write(str);
}

function AC_FL_RunContent(){
  var ret =
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret =
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();

    switch (currArg){
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblclick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace":
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

function modSelection() {
	var userSelection;
	if (window.getSelection) {
		userSelection = window.getSelection();
	} else if (document.selection) { // should come last; Opera!
		userSelection = document.selection.createRange();
	}
}


function getSelection(ta) { 
	var bits = [ta.value,'','','']; 

	ta.focus();   
	if(document.selection) { 
		var vs = '#$%^%$#';
        var tr=document.selection.createRange()
        if(tr.parentElement()!=ta) return null;
        bits[2] = tr.text;
        tr.text = vs;
        fb = ta.value.split(vs);
        tr.moveStart('character',-vs.length);
        tr.text = bits[2];
        bits[1] = fb[0];
        bits[3] = fb[1];
	} else { 
		if(ta.selectionStart == ta.selectionEnd) 
			return null;
        //bits=(new RegExp('([\x00-\xff]{'+ta.selectionStart+'})([\x00-\xff]{'+(ta.selectionEnd - ta.selectionStart)+'})([\x00-\xff]*)', 'gmi')).exec(ta.value);
	//tmp = new RegExp("(.{" + ta.selectionStart + "})(.{" + (ta.selectionEnd - ta.selectionStart) + "})(.*)", "m");
	//alert(tmp);
	//alert(ta.value);
        //bits=tmp.exec(ta.value);
	bits = [ta.value, ta.value.substr(0, ta.selectionStart), ta.value.substr(ta.selectionStart, (ta.selectionEnd - ta.selectionStart)), ta.value.substr(ta.selectionEnd, ta.value.length)];
	//alert(bits);
      }
     return bits;
  }

function matchPTags(str)
  { str = ' ' + str + ' ';
    ot = str.split(/\[[B|U|I].*?\]/i);
    ct = str.split(/\[\/[B|U|I].*?\]/i);
    return ot.length==ct.length;
  }

function addPTag(ta,pTag) {
	bits = getSelection(ta);
    if(bits) { 
		if(!matchPTags(bits[2])) {
			alert('Избраният текст съдържа незатворени маркери.\nМоля, изберете текста отново.');
			return;
		}
		ta.value = bits[1] + '[' + pTag + ']' + bits[2] + '[/' + pTag + ']' + bits[3];
	}
}

		function showCalEntry() {
			var w = 800; 
			var h = 600;
			if ( document.body.clientWidth ) {
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			} else if ( window.innerWidth ) {
				w = window.innerWidth;
				h = window.innerHeight;
			} else if ( document.documentElement.clientWidth ) {
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
			}
			if ( document.getElementById( 'fogWar' ) ) {
				outerWin = document.getElementById( 'fogWar' );
				outerWin.style.width = w + 'px';
				outerWin.style.height = h + 'px';
				outerWin.style.display = 'inline';
				innerWin = document.getElementById( 'calEditWindow' );
				innerWin.style.top = 200 + 'px';
				innerWin.style.left = parseInt( ( w - parseInt( innerWin.style.width ) ) / 2 ) + 'px';
				innerWin.style.display = 'inline';
			}
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'none';
			}
		}

		function closeNewCalEntry() {
			outerWin = document.getElementById( 'fogWar' );
			innerWin = document.getElementById( 'calEditWindow' );
			outerWin.style.display = 'none';
			innerWin.style.display = 'none';
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'block';
			}
		}

		function updateCal(ts) {
			makeRequest('ajax/calendar.php?when=' + ts, 'calendarDiv');
		}
		function calSelectDate(ts,date) {
			document.getElementById( 'calSelDate' ).innerHTML = date;
			document.getElementById( 'eventTs' ).value = ts;
		}

		function editCalEntry(recno,ts,date,name,repeatSel,e_public) {
			showCalEntry();
			document.getElementById('eventId').value = recno;
			document.getElementById('eventTs').value = ts;
			document.getElementById('calSelDate').innerHTML = date;
			document.getElementById('eventName').value = name;
			document.getElementById(repeatSel).checked = true;
			if ( e_public == 'yes' ) {
				document.getElementById('eventPublic').checked = true;
			} else {
				document.getElementById('eventPublic').checked = false;
			}
		}
		
		function newCalEntry() {
			showCalEntry();
			document.getElementById('eventId').value = 0;
			document.getElementById('eventTs').value = 0;
			document.getElementById('calSelDate').innerHTML = 'Моля изберете дата от календара';
			document.getElementById('eventName').value = '';
			document.getElementById('repeatNo').checked = true;
		}

		function showCalDelEntry(recno) {
			var w = 800; 
			var h = 600;
			if ( document.body.clientWidth ) {
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			} else if ( window.innerWidth ) {
				w = window.innerWidth;
				h = window.innerHeight;
			} else if ( document.documentElement.clientWidth ) {
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
			}
			if ( document.getElementById( 'fogWar' ) ) {
				outerWin = document.getElementById( 'fogWar' );
				outerWin.style.width = w + 'px';
				outerWin.style.height = h + 'px';
				outerWin.style.display = 'inline';
				innerWin = document.getElementById( 'calDelWindow' );
				innerWin.style.top = 300 + 'px';
				innerWin.style.left = parseInt( ( w - parseInt( innerWin.style.width ) ) / 2 ) + 'px';
				innerWin.style.display = 'inline';
			}
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'none';
			}
			document.getElementById('calDelRecno').value = recno;
		}

		function hideCalDelEntry() {
			outerWin = document.getElementById( 'fogWar' );
			innerWin = document.getElementById( 'calDelWindow' );
			outerWin.style.display = 'none';
			innerWin.style.display = 'none';
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'block';
			}
		}
		
		function showMoodEditWindow(recno,text,mypage) {
			var w = 800; 
			var h = 600;
			if ( document.body.clientWidth ) {
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			} else if ( window.innerWidth ) {
				w = window.innerWidth;
				h = window.innerHeight;
			} else if ( document.documentElement.clientWidth ) {
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
			}
			if ( document.getElementById( 'fogWar' ) ) {
				outerWin = document.getElementById( 'fogWar' );
				outerWin.style.width = w + 'px';
				outerWin.style.height = h + 'px';
				outerWin.style.display = 'inline';
				innerWin = document.getElementById( 'moodEditWindow' );
				innerWin.style.top = 300 + 'px';
				innerWin.style.left = parseInt( ( w - parseInt( innerWin.style.width ) ) / 2 ) + 'px';
				innerWin.style.display = 'inline';
			}
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'none';
			}
			document.getElementById('moodRecno').value = recno;
			document.getElementById('moodText').value = text;
			if ( mypage = 'myhome' ) {
				document.getElementById('myhome').value = 1;
			}
		}

		function hideMoodEditWindow() {
			outerWin = document.getElementById( 'fogWar' );
			innerWin = document.getElementById( 'moodEditWindow' );
			outerWin.style.display = 'none';
			innerWin.style.display = 'none';
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'block';
			}
		}

		function show_hint2(e, msg) {
		    var posx = 0;
		    var posy = 0;
		    if (!e) var e = window.event;
		    if (e.pageX || e.pageY)
		    {
		        posx = e.pageX;
		        posy = e.pageY;
		    }
		    else if (e.clientX || e.clientY)
		    {
		        posx = e.clientX + document.documentElement.scrollLeft;
		        posy = e.clientY + document.documentElement.scrollTop;;
		    }
			
			posy -= 20;

			if ( document.getElementById('hintDiv' ) ) {
				document.getElementById('hintDiv').innerHTML = msg;
				document.getElementById('hintDiv').style.left = posx + "px";
				document.getElementById('hintDiv').style.top = posy + "px";
				document.getElementById('hintDiv').style.display = 'block';
			}
		}

		function move_hint2(e) {
		    var posx = 0;
		    var posy = 0;
		    if (!e) var e = window.event;
		    if (e.pageX || e.pageY)
		    {
		        posx = e.pageX;
		        posy = e.pageY;
		    }
		    else if (e.clientX || e.clientY)
		    {
		        posx = e.clientX + document.documentElement.scrollLeft;
		        posy = e.clientY + document.documentElement.scrollTop;;
		    }
			
			posy -= 20;

			if ( document.getElementById('hintDiv' ) ) {
				document.getElementById('hintDiv').style.left = posx + "px";
				document.getElementById('hintDiv').style.top = posy + "px";
			}
		}


		function showAddF(friendName, friendId) {
			var w = 800; 
			var h = 600;
			if ( document.body.clientWidth ) {
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			} else if ( window.innerWidth ) {
				w = window.innerWidth;
				h = window.innerHeight;
			} else if ( document.documentElement.clientWidth ) {
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
			}
			if ( document.getElementById( 'fogWar' ) ) {
				outerWin = document.getElementById( 'fogWar' );
				outerWin.style.width = w + 'px';
				outerWin.style.height = h + 'px';
				outerWin.style.display = 'inline';
				innerWin = document.getElementById( 'FrontWindow2' );
				innerWin.style.top = 300 + 'px';
				innerWin.style.left = parseInt( ( w - parseInt( innerWin.style.width ) ) / 2 ) + 'px';
				innerWin.style.display = 'inline';
				document.getElementById('friendName').innerHTML = friendName;
				document.getElementById('friendId').innerHTML = friendId;
			}
		}
		
		
		function hideAddF() {
			outerWin = document.getElementById( 'fogWar' );
			innerWin = document.getElementById( 'FrontWindow2' );
			outerWin.style.display = 'none';
			innerWin.style.display = 'none';
		}

		function addFriend( friendId, msg ) {
			var w = 800; 
			var h = 600;
			if ( document.body.clientWidth ) {
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			} else if ( window.innerWidth ) {
				w = window.innerWidth;
				h = window.innerHeight;
			} else if ( document.documentElement.clientWidth ) {
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
			}
			innerWin = document.getElementById( 'FrontWindow1' );
			innerWin.style.top = 300 + 'px';
			innerWin.style.left = parseInt( ( w - parseInt( innerWin.style.width ) ) / 2 ) + 'px';
			innerWin.style.display = 'inline';
			if ( msg == 'Тук можете да напишете Вашето съобщение до приятеля Ви.' ) {
				msg = '';
			}
			makeRequest( 'ajax/addFriend.php?id=' + friendId + '&msg=' + encodeURI( msg ), 'AlertWindow1' );
			 setTimeout('window.location.reload()', 2000);
		}
		
		
		function showInviteOnlineWindow(recno,text) {
			var w = 800; 
			var h = 600;
			if ( document.body.clientWidth ) {
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			} else if ( window.innerWidth ) {
				w = window.innerWidth;
				h = window.innerHeight;
			} else if ( document.documentElement.clientWidth ) {
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
			}
			if ( document.getElementById( 'fogWar' ) ) {
				outerWin = document.getElementById( 'fogWar' );
				outerWin.style.width = w + 'px';
				outerWin.style.height = h + 'px';
				outerWin.style.display = 'inline';
				innerWin = document.getElementById( 'inviteOnlineWindow' );
				innerWin.style.top = 300 + 'px';
				innerWin.style.left = parseInt( ( w - 410 ) / 2 ) + 'px';
				innerWin.style.display = 'inline';
			}
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'none';
			}
			document.getElementById('inviteOnlineRecno').value = recno;
			document.getElementById('inviteOnlineText').innerHTML = text;
		}
		
		function sendOnlineInvitation(id) {
			makeRequest2( 'ajax/inviteOnline.php?id=' + id, 'inviteOnlineWindow', 'setTimeout(\'window.location.reload()\', 2000);' );
		}

		function hideInviteOnlineWindow() {
			outerWin = document.getElementById( 'fogWar' );
			innerWin = document.getElementById( 'inviteOnlineWindow' );
			outerWin.style.display = 'none';
			innerWin.style.display = 'none';
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'block';
			}
		}

		function showWallWindow(x,y) {
			$(function() { 
			    var api = $("#wallOverlay").overlay({api:true}); 
			 
			    // define function that opens the overlay 
			    window.openOverlay = function() { 
				api.load(); 
			    } 
			 
			});
		}

		

		
		function showWallDelWindow(recno,text) {
			var w = 800; 
			var h = 600;
			if ( document.body.clientWidth ) {
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			} else if ( window.innerWidth ) {
				w = window.innerWidth;
				h = window.innerHeight;
			} else if ( document.documentElement.clientWidth ) {
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
			}
			if ( document.getElementById( 'fogWar' ) ) {
				outerWin = document.getElementById( 'fogWar' );
				outerWin.style.width = w + 'px';
				outerWin.style.height = h + 'px';
				outerWin.style.display = 'inline';
				innerWin = document.getElementById( 'wallDelWindow' );
				innerWin.style.top = 300 + 'px';
				innerWin.style.left = parseInt( ( w - 320 ) / 2 ) + 'px';
				innerWin.style.display = 'inline';
			}
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'none';
			}
			document.getElementById('wpDelRecno').value = recno;
		}

		function hideWallDelWindow() {
			outerWin = document.getElementById( 'fogWar' );
			innerWin = document.getElementById( 'wallDelWindow' );
			outerWin.style.display = 'none';
			innerWin.style.display = 'none';
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'block';
			}
		}
		

		
		function showBlockUser(recno,text) {
			var w = 800; 
			var h = 600;
			if ( document.body.clientWidth ) {
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			} else if ( window.innerWidth ) {
				w = window.innerWidth;
				h = window.innerHeight;
			} else if ( document.documentElement.clientWidth ) {
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
			}
			if ( document.getElementById( 'fogWar' ) ) {
				outerWin = document.getElementById( 'fogWar' );
				outerWin.style.width = w + 'px';
				outerWin.style.height = h + 'px';
				outerWin.style.display = 'inline';
				innerWin = document.getElementById( 'blockUserWindow' );
				innerWin.style.top = 300 + 'px';
				innerWin.style.left = parseInt( ( w - 320 ) / 2 ) + 'px';
				innerWin.style.display = 'inline';
			}
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'none';
			}
			document.getElementById('blockedUserName').innerHTML = text;
			document.getElementById('buRecno').value = recno;
		}

		function hideBlockUser() {
			outerWin = document.getElementById( 'fogWar' );
			innerWin = document.getElementById( 'blockUserWindow' );
			outerWin.style.display = 'none';
			innerWin.style.display = 'none';
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'block';
			}
		}
		
		function showVideoWallWindow(recno,text) {
			var w = 800; 
			var h = 600;
			if ( document.body.clientWidth ) {
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			} else if ( window.innerWidth ) {
				w = window.innerWidth;
				h = window.innerHeight;
			} else if ( document.documentElement.clientWidth ) {
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
			}
			if ( document.getElementById( 'fogWar' ) ) {
				outerWin = document.getElementById( 'fogWar' );
				outerWin.style.width = w + 'px';
				outerWin.style.height = h + 'px';
				outerWin.style.display = 'inline';
				innerWin = document.getElementById( 'wallVideoWindow' );
				innerWin.style.top = 300 + 'px';
				innerWin.style.left = parseInt( ( w - 460 ) / 2 ) + 'px';
				innerWin.style.height = '340px';
				innerWin.style.display = 'inline';
				document.getElementById('wallWindow').style.display = 'none';
				document.getElementById('wallPicWindow').style.display = 'none';
			}
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'none';
			}
		}

		function hideVideoWallWindow() {
			outerWin = document.getElementById( 'fogWar' );
			innerWin = document.getElementById( 'wallVideoWindow' );
			outerWin.style.display = 'none';
			innerWin.style.display = 'none';
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'block';
			}
		}
		
		function showPicWallWindow(recno,text) {
			var w = 800; 
			var h = 600;
			if ( document.body.clientWidth ) {
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			} else if ( window.innerWidth ) {
				w = window.innerWidth;
				h = window.innerHeight;
			} else if ( document.documentElement.clientWidth ) {
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
			}
			if ( document.getElementById( 'fogWar' ) ) {
				outerWin = document.getElementById( 'fogWar' );
				outerWin.style.width = w + 'px';
				outerWin.style.height = h + 'px';
				outerWin.style.display = 'inline';
				innerWin = document.getElementById( 'wallPicWindow' );
				innerWin.style.top = 300 + 'px';
				innerWin.style.left = parseInt( ( w - 460 ) / 2 ) + 'px';
				innerWin.style.height = '250px';
				innerWin.style.display = 'inline';
				document.getElementById('wallWindow').style.display = 'none';
				document.getElementById('wallVideoWindow').style.display = 'none';
			}
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'none';
			}
		}

		function hidePicWallWindow() {
			outerWin = document.getElementById( 'fogWar' );
			innerWin = document.getElementById( 'wallPicWindow' );
			outerWin.style.display = 'none';
			innerWin.style.display = 'none';
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'block';
			}
		}
		
		function toggleImgHeight( img ) {
			if ( img.style.height ) {
				if ( img.style.height == '90px' ) {
					img.style.height = '';
				}
			} else {
				img.style.height = '90px';
			}

		}
		
		
		function showNoPic() {
			var w = 800; 
			var h = 600;
			if ( document.body.clientWidth ) {
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			} else if ( window.innerWidth ) {
				w = window.innerWidth;
				h = window.innerHeight;
			} else if ( document.documentElement.clientWidth ) {
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
			}
			if ( document.getElementById( 'fogWar' ) ) {
				outerWin = document.getElementById( 'fogWar' );
				outerWin.style.width = w + 'px';
				outerWin.style.height = h + 'px';
				outerWin.style.display = 'inline';
				innerWin = document.getElementById( 'noPicWindow' );
				innerWin.style.top = 300 + 'px';
				innerWin.style.left = parseInt( ( w - 432 ) / 2 ) + 'px';
				innerWin.style.display = 'inline';
			}
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'none';
			}
		}

		function hideNoPic() {
			outerWin = document.getElementById( 'fogWar' );
			innerWin = document.getElementById( 'noPicWindow' );
			outerWin.style.display = 'none';
			innerWin.style.display = 'none';
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'block';
			}
		}

		
		function weatherChange(cont) {
			makeRequest2( 'ajax/toggleSetting.php?key=weatherStation&value=' + cont.value, 'wsnulldiv', 'document.getElementById(\'wsForm\').submit();' );
			return false;
		}

		function start_playerv( movie ) {
			var so = new SWFObject('flvplayer1.swf','playerv1' ,'410','352','7');
			so.addParam("allowfullscreen","true");
			so.addParam("wmode","opaque");
			so.addVariable("autostart", "true");
			so.addVariable("file",movie);
			so.addVariable("overstretch","false");
			so.write('playerv');
//			document.getElementById('WV').style.display = 'none';
//			document.getElementById('WC').style.display = 'none';
			document.getElementById('playerv').style.display = 'block'; 
		}

		
		function showVidDel(recno) {
			var w = 800; 
			var h = 600;
			if ( window.innerWidth ) {
				w = window.innerWidth;
				h = window.innerHeight;
			} else if ( document.body.clientWidth ) {
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			} else if ( document.documentElement.clientWidth ) {
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
			}
			if ( document.getElementById( 'fogWar' ) ) {
				outerWin = document.getElementById( 'fogWar' );
				outerWin.style.width = w + 'px';
				outerWin.style.height = h + 'px';
				outerWin.style.display = 'inline';
				innerWin = document.getElementById( 'videoDelWin' );
				innerWin.style.top = 300 + 'px';
				innerWin.style.left = parseInt( ( w - 320 ) / 2 ) + 'px';
				innerWin.style.display = 'inline';
			}
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'none';
			}
//			document.getElementById('blockedUserName').innerHTML = text;
			document.getElementById('vdRecno').value = recno;
		}

		function hideVidDel() {
			outerWin = document.getElementById( 'fogWar' );
			innerWin = document.getElementById( 'videoDelWin' );
			outerWin.style.display = 'none';
			innerWin.style.display = 'none';
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'block';
			}
		}


		
		function showMappWin() {
			var w = 800; 
			var h = 600;
			if ( document.body.clientWidth ) {
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			} else if ( window.innerWidth ) {
				w = window.innerWidth;
				h = window.innerHeight;
			} else if ( document.documentElement.clientWidth ) {
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
			}
			if ( document.getElementById( 'fogWar' ) ) {
				outerWin = document.getElementById( 'fogWar' );
				outerWin.style.width = w + 'px';
				outerWin.style.height = h + 'px';
				outerWin.style.display = 'inline';
				innerWin = document.getElementById( 'mappWindow' );
				innerWin.style.top = 300 + 'px';
				innerWin.style.left = parseInt( ( w - 432 ) / 2 ) + 'px';
				innerWin.style.display = 'inline';
			}
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'none';
			}
//			document.getElementById('blockedUserName').innerHTML = text;
//			document.getElementById('vdRecno').value = recno;
		}

		function hideMappWin() {
			outerWin = document.getElementById( 'fogWar' );
			innerWin = document.getElementById( 'mappWindow' );
			outerWin.style.display = 'none';
			innerWin.style.display = 'none';
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'block';
			}
		}
		
	function toggleWallComments( pid ) {
		if ( document.getElementById( 'wallComments' + pid ) ) {
			var cmwin = document.getElementById( 'wallComments' + pid );
			var wlwin = document.getElementById( 'wallLink' + pid );
			if ( cmwin.style.display == 'block' ) {
				cmwin.style.display = 'none';
				wlwin.innerHTML = '- покажи';
			} else {
				cmwin.style.display = 'block';
				wlwin.innerHTML = '- скрий';
			}
		}
	}

	function start_player8( id, movie ) {
		var so = new SWFObject('flvplayer1.swf','player8' + id ,'410','352','7');
		so.addParam("allowfullscreen","true");
		so.addParam("wmode","opaque");
		so.addVariable("autostart", "true");
		so.addVariable("file",movie);
		so.addVariable("overstretch","false");
		so.write('playera8' + id );
		document.getElementById('WV' + id).style.display = 'none';
		document.getElementById('WC' + id).style.display = 'none';
		document.getElementById('playera8' + id).style.display = 'block'; 
	}

		function start_player_title( movie, title ) {
			var so = new SWFObject('flvplayer1.swf','playerv1' ,'410','352','7');
			so.addParam("allowfullscreen","true");
			so.addParam("wmode","opaque");
			so.addVariable("autostart", "true");
			so.addVariable("file",movie);
			so.addVariable("overstretch","false");
			so.write('playerv');
			document.getElementById('playerVdiv1').style.display = 'block'; 
			document.getElementById('playerVdiv2').style.display = 'block'; 
			document.getElementById('playerVdiv2').innerHTML = title; 
			document.getElementById('playerv').style.display = 'block'; 
		}

		
		function actualComment( groupId, reply_to ) {
			var w = 800; 
			var h = 600;
			if ( document.body.clientWidth ) {
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			} else if ( window.innerWidth ) {
				w = window.innerWidth;
				h = window.innerHeight;
			} else if ( document.documentElement.clientWidth ) {
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
			}
			if ( document.getElementById( 'fogWar' ) ) {
				outerWin = document.getElementById( 'fogWar' );
				outerWin.style.width = w + 'px';
				outerWin.style.height = h + 'px';
				outerWin.style.display = 'inline';
				innerWin = document.getElementById( 'groupWallWindow' );
				innerWin.style.top = 300 + 'px';
				innerWin.style.left = parseInt( ( w - 460 ) / 2 ) + 'px';
				innerWin.style.display = 'inline';
				innerWin.innerHTML = '';
				innerWin.style.height = '170px';
				makeRequest( 'ajax/mod_ActualComment.php?groupId=' + groupId + '&replyTo=' + reply_to, 'groupWallWindow');
			}
		}
		
		function actualCommentCancel( groupId, recno ) {
			outerWin = document.getElementById( 'fogWar' );
			innerWin = document.getElementById( 'groupWallWindow' );
			outerWin.style.display = 'none';
			innerWin.style.display = 'none';
		}
		
		function showGroupWallWindow(recno,parent) {
			var w = 800; 
			var h = 600;
			if ( document.body.clientWidth ) {
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			} else if ( window.innerWidth ) {
				w = window.innerWidth;
				h = window.innerHeight;
			} else if ( document.documentElement.clientWidth ) {
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
			}
			if ( document.getElementById( 'fogWar' ) ) {
				outerWin = document.getElementById( 'fogWar' );
				outerWin.style.width = w + 'px';
				outerWin.style.height = h + 'px';
				outerWin.style.display = 'inline';
				innerWin = document.getElementById( 'groupWallWindow' );
				innerWin.style.top = 300 + 'px';
				innerWin.style.left = parseInt( ( w - 460 ) / 2 ) + 'px';
				innerWin.style.display = 'inline';
				document.getElementById('groupWallVideoWindow').style.display = 'none';
				document.getElementById('groupWallPicWindow').style.display = 'none';
			}
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'none';
			}
			document.getElementById('gwpSubject').value = '';
			document.getElementById('gwpMessage').value = '';
			document.getElementById('gwallId').value = recno;
			document.getElementById('gwallParentId').value = parent;
			if ( parent != 0 && document.getElementById( 'gwValidity' ) ) {
				document.getElementById('gwValidity').style.display = 'none';
			}
			if ( parent == 0 && document.getElementById( 'gwValidity' ) ) {
				document.getElementById('gwValidity').style.display = 'block';
			}
			document.getElementById('wpvSubject').value = '';
			document.getElementById('wallvId').value = recno;
			document.getElementById('wallvParentId').value = parent;
			document.getElementById('wppSubject').value = '';
			document.getElementById('wallpId').value = recno;
			document.getElementById('wallpParentId').value = parent;
			if ( recno == 374 ) {
					document.getElementById('gwpMessage').style.visibility = 'hidden';
					document.getElementById('gwallType').style.visibility = 'hidden';
					document.getElementById('gwpMsg1').style.visibility = 'hidden';
					document.getElementById('gwpMsg2').style.visibility = 'hidden';
					document.getElementById('gwpMsg3').style.visibility = 'hidden';
					document.getElementById('gwpMessage').style.display = 'none';
					document.getElementById('gwallType').style.display = 'none';
					document.getElementById('gwpMsg1').style.display = 'none';
					document.getElementById('gwpMsg2').style.display = 'none';
					document.getElementById('gwpMsg3').style.display = 'none';
			}
		}

		function hideGroupWallWindow() {
			outerWin = document.getElementById( 'fogWar' );
			innerWin = document.getElementById( 'groupWallWindow' );
			outerWin.style.display = 'none';
			innerWin.style.display = 'none';
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'block';
			}
		}
		
		function showVideoGroupWallWindow(recno,text) {
			var w = 800; 
			var h = 600;
			if ( document.body.clientWidth ) {
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			} else if ( window.innerWidth ) {
				w = window.innerWidth;
				h = window.innerHeight;
			} else if ( document.documentElement.clientWidth ) {
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
			}
			if ( document.getElementById( 'fogWar' ) ) {
				outerWin = document.getElementById( 'fogWar' );
				outerWin.style.width = w + 'px';
				outerWin.style.height = h + 'px';
				outerWin.style.display = 'inline';
				innerWin = document.getElementById( 'groupWallVideoWindow' );
				innerWin.style.top = 300 + 'px';
				innerWin.style.left = parseInt( ( w - 460 ) / 2 ) + 'px';
				innerWin.style.height = '340px';
				innerWin.style.display = 'inline';
				document.getElementById('groupWallWindow').style.display = 'none';
				document.getElementById('groupWallPicWindow').style.display = 'none';
			}
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'none';
			}
		}

		function hideVideoGroupWallWindow() {
			outerWin = document.getElementById( 'fogWar' );
			innerWin = document.getElementById( 'groupWallVideoWindow' );
			outerWin.style.display = 'none';
			innerWin.style.display = 'none';
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'block';
			}
		}
		
		function showPicGroupWallWindow(recno,text) {
			var w = 800; 
			var h = 600;
			if ( document.body.clientWidth ) {
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			} else if ( window.innerWidth ) {
				w = window.innerWidth;
				h = window.innerHeight;
			} else if ( document.documentElement.clientWidth ) {
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
			}
			if ( document.getElementById( 'fogWar' ) ) {
				outerWin = document.getElementById( 'fogWar' );
				outerWin.style.width = w + 'px';
				outerWin.style.height = h + 'px';
				outerWin.style.display = 'inline';
				innerWin = document.getElementById( 'groupWallPicWindow' );
				innerWin.style.top = 300 + 'px';
				innerWin.style.left = parseInt( ( w - 460 ) / 2 ) + 'px';
				innerWin.style.height = '250px';
				innerWin.style.display = 'inline';
				document.getElementById('groupWallWindow').style.display = 'none';
				document.getElementById('groupWallVideoWindow').style.display = 'none';
			}
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'none';
			}
		}

		function hidePicGroupWallWindow() {
			outerWin = document.getElementById( 'fogWar' );
			innerWin = document.getElementById( 'groupWallPicWindow' );
			outerWin.style.display = 'none';
			innerWin.style.display = 'none';
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'block';
			}
		}
		
		function showGroupWallDelWindow(recno,group_id) {
			var w = 800; 
			var h = 600;
			if ( document.body.clientWidth ) {
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			} else if ( window.innerWidth ) {
				w = window.innerWidth;
				h = window.innerHeight;
			} else if ( document.documentElement.clientWidth ) {
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
			}
			if ( document.getElementById( 'fogWar' ) ) {
				outerWin = document.getElementById( 'fogWar' );
				outerWin.style.width = w + 'px';
				outerWin.style.height = h + 'px';
				outerWin.style.display = 'inline';
				innerWin = document.getElementById( 'groupWallDelWindow' );
				innerWin.style.top = 300 + 'px';
				innerWin.style.left = parseInt( ( w - 320 ) / 2 ) + 'px';
				innerWin.style.display = 'inline';
			}
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'none';
			}
			document.getElementById('wpDelRecno').value = recno;
			document.getElementById('gfWallIdDel').value = group_id;
		}

		function hideGroupWallDelWindow() {
			outerWin = document.getElementById( 'fogWar' );
			innerWin = document.getElementById( 'groupWallDelWindow' );
			outerWin.style.display = 'none';
			innerWin.style.display = 'none';
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'block';
			}
		}
		
		function dbSubmit() {
			var radval = 'empty';
			for( var i = 0; i < document.wineForm.wineDB.length; i++ ) {
				if ( document.wineForm.wineDB[i].checked ) {
					radval = document.wineForm.wineDB[i].value;
				}
			}
			makeRequest( 'ajax/pollMod.php?vote=' + radval, 'pollModAjax' );
		}

		function yepSubmit(yepB, yepS) {
			if ( yepB.checked ) {
				var status = yepS.value;
				// status = status.replace(/\+/g, '%2B');
				nw = window.open('http://yep.bg/dotstatus.php?status=' + encodeURI(status),'Edit',''); 
				nw.opener=self;
			}
			return true;
		}
if(typeof(window.external) != 'undefined'){

//yes, this is evil browser sniffing, but only IE has this bug

document.getElementsByName = function(name, tag){
    if(!tag){
        tag = '*';
    }
    var elems = document.getElementsByTagName(tag);
    var res = []
    for(var i=0;i<elems.length;i++){
        att = elems[i].getAttribute('name');
        if(att == name) {
            res.push(elems[i]);
        }
    }
    return res;
}

}

                function toggleVis(postfix) {
                        var els = document.getElementsByName('toShow' + postfix);
                        var els2 = document.getElementsByName('toHide' + postfix);
                        for( var i = 0; i < els.length; i++ ) {
                                els[i].className = 'toHide';
                                els[i].name = 'toHide' + postfix;
                        }
                        for( var i = 0; i < els2.length; i++ ) {
                                els2[i].className = 'toShow';
                                els2[i].name = 'toShow' + postfix;
                        }
                }
	
		function showStatusWallWindow(uid,recno) {
			var w = 800; 
			var h = 600;
			if ( document.body.clientWidth ) {
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			} else if ( window.innerWidth ) {
				w = window.innerWidth;
				h = window.innerHeight;
			} else if ( document.documentElement.clientWidth ) {
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
			}
			if ( document.getElementById( 'fogWar' ) ) {
				outerWin = document.getElementById( 'fogWar' );
				outerWin.style.width = w + 'px';
				outerWin.style.height = h + 'px';
				outerWin.style.display = 'inline';
				innerWin = document.getElementById( 'statusWallWindow' );
				innerWin.style.top = 300 + 'px';
				innerWin.style.left = parseInt( ( w - 460 ) / 2 ) + 'px';
				innerWin.style.display = 'inline';
			}
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'none';
			}
			document.getElementById('scUid').value = uid;
			document.getElementById('scRecno').value = recno;
			document.getElementById('scText').value = '';
		}

		function hideStatusWallWindow() {
			outerWin = document.getElementById( 'fogWar' );
			innerWin = document.getElementById( 'statusWallWindow' );
			outerWin.style.display = 'none';
			innerWin.style.display = 'none';
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'block';
			}
		}
		
		function sudokuInp( el ) {
			var defVal = el.innerHTML;
			if ( defVal == '&nbsp;' ) {
				defVal = '';
			}
			var newEnt = prompt( 'Въведете цифра от 1 до 9', defVal);
			var newVal = parseInt(newEnt);
			if (newEnt != '' && newEnt != null) {
			if ( newVal > 0 && newVal < 10 ) {
				el.innerHTML = newVal;
				makeRequest( 'ajax/modSudoku.php?id=' + el.id + '&value=' + newVal, 'modSudokuAjax' );
			} else {
				newVal = '&nbsp;';
				el.innerHTML = newVal;
				makeRequest( 'ajax/modSudoku.php?id=' + el.id + '&value=' + newVal, 'modSudokuAjax' );
			}
			}

		}
		
		function sudokuClear() {
			makeRequest( 'ajax/modSudoku.php?action=clear', 'modSudokuAjax' );
		}
	
		function sudokuCheck() {
			var i = 0; var j = 0; var k = 0; var l = 0;
			var err = 0;
			for( j = 1; j < 10; j++ ) {
				for( i = 1; i < 10; i++ ) {
					document.getElementById('cell' + j + i).style.background = '#fff';
					var z = parseInt(document.getElementById('cell' + j + i).innerHTML);
					if ( z < 1 || z > 9 || isNaN ( z ) ) {
						err = 1;
					}
				}
			}
			for( j = 1; j < 10; j++ ) {
				for( i = 1; i < 10; i++ ) {
					for( k = i + 1; k < 10; k++ ) {
						var cellX = parseInt(document.getElementById('cell' + j + i).innerHTML);
						var cellY = parseInt(document.getElementById('cell' + j + k).innerHTML);
						if ( cellX > 0 && cellX < 10 && cellY > 0 && cellY < 10 && cellX == cellY && !isNaN(cellX) && !isNaN(cellY)) {
							document.getElementById('cell' + j + i).style.background = '#f00';
							document.getElementById('cell' + j + k).style.background = '#f00';
							err = 1;
						}
					}
				}
			}

			for( i = 1; i < 10; i++ ) {
				for( j = 1; j < 10; j++ ) {
					for( k = j + 1; k < 10; k++ ) {
						var cellX = parseInt(document.getElementById('cell' + j + i).innerHTML);
						var cellY = parseInt(document.getElementById('cell' + k + i).innerHTML);
						if ( cellX > 0 && cellX < 10 && cellY > 0 && cellY < 10 && cellX == cellY && !isNaN(cellX) && !isNaN(cellY) ) {
							document.getElementById('cell' + j + i).style.background = '#f00';
							document.getElementById('cell' + k + i).style.background = '#f00';
							err = 1;
						}
					}
				}
			}
			for( j = 1; j < 4; j++ ) {
				for( i = 1; i < 4; i++ ) {
					for( l = j; l < 4; l++ ) {
						for( k = i + 1; k < 4; k++ ) {
							var cellX = parseInt(document.getElementById('cell' + j + i).innerHTML);
							var cellY = parseInt(document.getElementById('cell' + l + k).innerHTML);
							if ( cellX > 0 && cellX < 10 && cellY > 0 && cellY < 10 && cellX == cellY && !isNaN(cellX) && !isNaN(cellY) ) {
								document.getElementById('cell' + j + i).style.background = '#f00';
								document.getElementById('cell' + l + k).style.background = '#f00';
								err = 1;
							}
						}
					}
				}
			}
			if ( err == 0 ) {
				for( j = 1; j < 10; j++ ) {
					for( i = 1; i < 10; i++ ) {
						document.getElementById('cell' + j + i).style.background = '#0f0';
					}
				}
			}
			return false;
		}

	function refreshNewNewsMod(href_what, news_count, fromE) {
		makeRequest2( 'ajax/newNewsMod.php?news_what=' + href_what + '&news_count=' + news_count + '&fromE=' + fromE, 'newNewsMod3', "setTimeout( 'refreshNewNewsMod()', 900000 )" );
	}
		function mod_extras_refresh() {
                  dragsort.makeListSortable(document.getElementById("numeric"),
                              verticalOnly, saveOrder);
			makeRequest2( 'ajax/mod_extras.php?1=1', 'extrasModAjax', 'prepareHints();' );
		}

        function verticalOnly(item) {
                item.toolManDragGroup.verticalOnly()
        }

        function speak(id, what) {
                var element = document.getElementById(id);
                element.innerHTML = 'Clicked ' + what;
        }

        function saveOrder(item) {
                var group = item.toolManDragGroup
                var list = group.element.parentNode
                var id = list.getAttribute("id")
                if (id == null) return
                group.register('dragend', function() {
                        ToolMan.cookies().set("list-" + id,
                                        junkdrawer.serializeList(list), 365)
                })
        }
function sleep(time_s){
      time_s = time_s * 1000;
      var sleeping = true;
      var now = new Date();
      var alarm;
      var startingMSeconds = now.getTime();
      while(sleeping){
         alarm = new Date();
         alarmMSeconds = alarm.getTime();
         if(alarmMSeconds - startingMSeconds > time_s){ sleeping = false; }
      }      
   }
		function showStatusCommentDelWindow(recno) {
			var w = 800; 
			var h = 600;
			if ( document.body.clientWidth ) {
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			} else if ( window.innerWidth ) {
				w = window.innerWidth;
				h = window.innerHeight;
			} else if ( document.documentElement.clientWidth ) {
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
			}
			if ( document.getElementById( 'fogWar' ) ) {
				outerWin = document.getElementById( 'fogWar' );
				outerWin.style.width = w + 'px';
				outerWin.style.height = h + 'px';
				outerWin.style.display = 'inline';
				innerWin = document.getElementById( 'statusCommentDelWindow' );
				innerWin.style.top = 300 + 'px';
				innerWin.style.left = parseInt( ( w - 320 ) / 2 ) + 'px';
				innerWin.style.display = 'inline';
			}
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'none';
			}
			document.getElementById('scDelRecno').value = recno;
		}

		function hideStatusCommentDelWindow() {
			outerWin = document.getElementById( 'fogWar' );
			innerWin = document.getElementById( 'statusCommentDelWindow' );
			outerWin.style.display = 'none';
			innerWin.style.display = 'none';
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'block';
			}
		}
		
        function stopEvent(ev) {
                ev.cancelBubble = true;
        }
	function attachLink() {
		var url = $("#attachLinkUrl").attr('value');
		var id = $("#attachLinkImgId").attr('value');
		var wallId = $("#tuWallLinkWallId").attr('value');
		var parentId = $("#tuWallLinkParentId").attr('value');
//		$("#attachLinkBtn").attr("disabled","true");
		$("#attachLinkAjax").load("ajax/mod_attachLink.php?url=" + url + 
				'&imgId=' + id + 
				'&wallId=' + wallId +
				'&parentId=' + parentId +
				'&s=' + Number(new Date()) );
	}
	function tuWallWrite() {
		$("#tuWallWrite").load("ajax/mod_tuWallWrite.php?s=" + Number(new Date()) );
	}
	function tuWallPoll() {
		$("#tuWallPollAjax").load("ajax/mod_tuWallPoll.php?s=" + Number(new Date()) );
	}
	function tuWallPic() {
		$("#tuWallPicAjax").load("ajax/mod_tuWallPic.php?s=" + Number(new Date()) );
	}
	function tuWallVideo() {
		$("#tuWallVideoAjax").load("ajax/mod_tuWallVideo.php?s=" + Number(new Date()) );
	}


		function showVideoEdit(recno,name) {
			var w = 800; 
			var h = 600;
			if ( document.body.clientWidth ) {
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			} else if ( window.innerWidth ) {
				w = window.innerWidth;
				h = window.innerHeight;
			} else if ( document.documentElement.clientWidth ) {
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
			}
			if ( document.getElementById( 'fogWar' ) ) {
				outerWin = document.getElementById( 'fogWar' );
				outerWin.style.width = w + 'px';
				outerWin.style.height = h + 'px';
				outerWin.style.display = 'inline';
				innerWin = document.getElementById( 'videoEditWindow' );
				innerWin.style.top = 300 + 'px';
				innerWin.style.left = parseInt( ( w - 320 ) / 2 ) + 'px';
				innerWin.style.display = 'inline';
			}
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'none';
			}
			document.getElementById('videoEditRecno').value = recno;
			document.getElementById('videoNameInp').value = name;
		}

		function hideVideoEdit() {
			outerWin = document.getElementById( 'fogWar' );
			innerWin = document.getElementById( 'videoEditWindow' );
			outerWin.style.display = 'none';
			innerWin.style.display = 'none';
			if ( document.getElementById( 'adDiv' ) ) {
			 document.getElementById( 'adDiv' ).style.display = 'block';
			}
		}
