var browser=navigator.userAgent.toLowerCase();
var isIE=((browser.indexOf("msie")!=-1) && (browser.indexOf("opera")==-1));

var addkommform=0;
function addkomm(id){
  if(!kommLoad){
    var dal=1;
    if(document.getElementById('kom-'+id)){
      if(addkommform && document.getElementById('kom-'+addkommform)){
        document.getElementById('kom-'+addkommform).removeChild(document.getElementById('form-'+addkommform));
        if(addkommform==id){
          addkommform=0;
          dal=0;
        }else{
          dal=1;
        }
      }
      if(addkommform!=id && dal){
        var form=document.createElement("div");
        form.setAttribute("id", "form-"+id);
        form.setAttribute("class", "new-addkomm");
        form.innerHTML=document.getElementById('form-0').innerHTML;
        document.getElementById('kom-'+id).appendChild(form);
        document.getElementsByName('nkom')[1].removeAttribute("value");
        document.getElementsByName('nkom')[1].setAttribute("value", id);
        document.getElementById('form-'+id).getElementsByTagName('textarea')[0].style.width="622px";
        document.getElementById('form-'+id).getElementsByTagName('textarea')[0].style.height="80px";
        document.getElementById('form-'+id).getElementsByTagName('textarea')[0].style.margin="5px 0 0 0";
        document.getElementById('form-'+id).getElementsByTagName('textarea')[0].focus();
        addkommform=id;
      }
    }
  }else{
    alert('Error!');
  }
}

function insertBBtag(tagName, id)
        {
        //document.getElementById('comment_textarea'+id).value=document.getElementById('comment_textarea'+id).value+'['+tagName+'][/'+tagName+']';
        var el = document.getElementById('comment_textarea'+id);

        if(isIE)
                {
                el.focus();
                document.selection.createRange().text='['+tagName+']'+document.selection.createRange().text+'[/'+tagName+']';
                }
        else
                {
                el.focus();
                var text = el.value.substring(0, el.selectionStart)+'['+tagName+']'+el.value.substring(el.selectionStart, el.selectionEnd)+'[/'+tagName+']'+el.value.substring(el.selectionEnd, el.value.length);
                el.value=text;
                }
        }

function insertBBtagImage(tagName, id)
        {
        window.open('bb_addimage.php?id='+id, 'addimage', 'top=150, left=200, height=100, width=400');
        }

var curformid=-1;
function ShowCommentsForm(id)
        {
        if(curformid!=-1)
                {
                document.getElementById('CommentsDIV_'+curformid).innerHTML='';
                }
        curformid=id;
        divHTML='<form name="form1" method="post" class="myform">'+
                 '<input name="ParentID" value="'+id+'" type="hidden">'+
                 '<textarea class="" name="Content" cols="50" rows="5" id="comment_textarea'+id+'"></textarea>'+
                 '<div class="kommbb" id="kommbb">'+
                 '<ul class="bbtag"><li class="start"></li><li><a href="javascript:void(0);" onclick="javascript:insertBBtag(\'b\', '+id+');"><img title="Выделить текст жирным" src="http://www.nnm.ru/img/default/bb/bold.gif" height="20" width="21"></a></li>             <li><a href="javascript:void(0);" onclick="javascript:insertBBtag(\'i\', '+id+');"><img title="Выделить текст курсивом" src="http://www.nnm.ru/img/default/bb/italic.gif" height="20" width="21"></a></li>              <li><a href="javascript:void(0);" onclick="javascript:insertBBtag(\'u\', '+id+');"><img title="Подчеркнуть текст" src="http://www.nnm.ru/img/default/bb/underline.gif" height="20" width="21"></a></li>              <li><a href="javascript:void(0);" onclick="javascript:insertBBtag(\'s\', '+id+');"><img title="Зачеркнуть текст" src="http://www.nnm.ru/img/default/bb/strike.gif" height="20" width="21"></a></li><li class="end"></li></ul><input type="submit" name="AddComment" value="Добавить" class="btn">              </div>           </form>';
        document.getElementById('CommentsDIV_'+id).innerHTML=divHTML;
        }

function OpenPrivateMessagesLent(user)
        {
        //window.open("/messagelent.php?user="+user, '', "height=200,width=400,status=yes,toolbar=no,menubar=no,location=no,left=200,top=200");
        window.open("/messagelent.php?user="+user, '', "height=600,width=500,status=yes,toolbar=no,menubar=no,location=no,left=200,top=100");
        }

function ShowFotos(user)
        {
        //window.open("/messagelent.php?user="+user, '', "height=200,width=400,status=yes,toolbar=no,menubar=no,location=no,left=200,top=200");
        window.open("/fotos.php?user="+user, '', "height=600,width=510,status=yes,toolbar=no,menubar=no,scrollbars=1,location=no,left=200,top=25");
        }

function changepage(page)
        {
        var form='form1';
        var elem = document.getElementById("page");
        elem.value = page;
        document[form].submit();
        }

function showhide(id)
	{
        var elem = document.getElementById(id);
        if(elem.style.display=='')
        	elem.style.display = 'none';
        else
        	elem.style.display = '';
	}

function tofav()
	{
 	if(navigator.appName.indexOf("Microsoft")!=-1)
        	javascript:window.external.AddFavorite('http://www.ruvr.ru/index.php?lng=rus','Мисс и Мистер РГГУ 2007')
        else if(navigator.appName.indexOf("Mozillа")!=-1 || navigator.appName.indexOf("Firefox")!=-1 || navigator.appName.indexOf("Netscape")!=-1)
        	alert('Доступно только в браузере Microsoft Explorer.\nНажмите Ctrl+D');
        else
        	{
                alert('Доступно только в браузере Microsoft Explorer');
		}
	}