function ChangePage(num){
    document.getElementById("pgid").value = num;
    document.getElementById("spgid").value = 0;
    document.getElementById("did").value = 0;
    document.getElementById("prm").value = 0;
    document.getElementById("spos").value = 0;
    document.getElementById("epos").value = 19;
    document.getElementById("mspos").value = 0;
    document.getElementById("mepos").value = 19;
    document.getElementById("tday").value = "";
    document.getElementById("tmnt").value = "";
    document.getElementById("tyer").value = "";
    document.WebControl.submit();    
}

function ChangeSubPage(num){
    document.getElementById("spgid").value = num;
    document.getElementById("did").value = 0;
    document.getElementById("prm").value = 0;
    document.getElementById("spos").value = 0;
    document.getElementById("epos").value = 19;
    document.getElementById("mspos").value = 0;
    document.getElementById("mepos").value = 19;
    document.getElementById("tday").value = "";
    document.getElementById("tmnt").value = "";
    document.getElementById("tyer").value = "";
    document.WebControl.submit();    
}

function Login(){
    if (document.getElementById("user").value == ""){
        alert("Вы не ввели имя пользователя !");
        document.getElementById("user").focus();
        return;
    }
    if (document.getElementById("paswd").value == ""){
        alert("Вы не ввели пароль !");
        document.getElementById("paswd").focus();
        return;
    }
    document.getElementById("action").value = -1;
    document.WebControl.submit();
}

function ChangeSlide(s,e){
    document.getElementById("spos").value = s;
    document.getElementById("epos").value = e;
    document.WebControl.submit();
}
function ChangeSlide2(s,e){
    document.getElementById("mspos").value = s;
    document.getElementById("mepos").value = e;
    document.WebControl.submit();
}

function OpenDocument(pgid,id){
     if (document.getElementById("pgid").value!=pgid){
        document.getElementById("spgid").value = 0;
        document.getElementById("did").value = 0;
        document.getElementById("prm").value = 0;
        document.getElementById("spos").value = 0;
        document.getElementById("epos").value = 19;
        document.getElementById("mspos").value = 0;
        document.getElementById("mepos").value = 19;
        document.getElementById("tday").value = "";
        document.getElementById("tmnt").value = "";
        document.getElementById("tyer").value = "";
     }
     document.getElementById("pgid").value = pgid;
     document.getElementById("did").value = id;
     document.WebControl.submit();
}
function CloseDocument(){
     document.getElementById("did").value = 0;
     document.WebControl.submit();
}

function ShowBiography(n){
    var d = showModalDialog("/showbiography.php?pid="+n, "", "dialogWidth:640px; dialogHeight:480px; status:no; help:no;");
}

function ShowHideList(num){
    if (document.getElementById("s"+num).className == "hid"){
        document.getElementById("p"+num).src = "/images/minus.gif";
        document.getElementById("p"+num).alt = "Свернуть";
        document.getElementById("s"+num).className = "vis";
    } else {
        document.getElementById("p"+num).src = "/images/plus2.gif";
        document.getElementById("p"+num).alt = "Развернуть";
        document.getElementById("s"+num).className = "hid";
    }
}

function SlideShow(n){
        try{
            var st = window.opener.status;
        } catch (sdasds) {
            window.opener=null;
        }
        if (window.opener==null){
            url = "gallery_slideshow.php?pid="+n;
            var wnd=window.open(url, "", "width=800, height=540, scrollbars=yes, resizable=yes, status=no,toolbar=no,menubar=no,location=no");
            window.opener = wnd;
        } else {
            window.opener.focus();
        }
}
function OpenGallery(pgid,id,param){
      if (document.getElementById("pgid").value!=pgid){
        document.getElementById("spgid").value = 0;
        document.getElementById("did").value = 0;
        document.getElementById("prm").value = 0;
        document.getElementById("spos").value = 0;
        document.getElementById("epos").value = 19;
        document.getElementById("tday").value = "";
        document.getElementById("tmnt").value = "";
        document.getElementById("tyer").value = "";
     }
     document.getElementById("pgid").value = pgid;
     document.getElementById("did").value = id;
     document.getElementById("prm").value = param;
     document.WebControl.submit();
}
function OpenImage(img){
var wnd = window.open("", "", "width=800, height=600, scrollbars=yes, resizable=yes, status=no,toolbar=no,menubar=no,location=no");
wnd.document.writeln("<html><head><title>Просмотр изображения</title>");
wnd.document.writeln("<LINK rev='stylesheet' href='/styles/styles.css' type='text/css' rel='STYLESHEET'>");
wnd.document.writeln("<script language='javascript'>function Init(){window.width=document.getElementById('preview').width+10;document.height=document.getElementById('preview').height;}</script></head>");
wnd.document.writeln("<body><img src='/images/"+img+"' border=0 id='preview' name='preview' alt='Закрыть окно' onclick='window.close();' onLoad='Init();'></body></html>");
}

function OpenPersDocument(pgid,id){
     if (document.getElementById("pgid").value!=pgid){
        document.getElementById("spgid").value = 0;
        document.getElementById("did").value = 0;
        document.getElementById("prm").value = 0;
        document.getElementById("spos").value = 0;
        document.getElementById("epos").value = 19;
        document.getElementById("tday").value = "";
        document.getElementById("tmnt").value = "";
        document.getElementById("tyer").value = "";
     }
     document.getElementById("pgid").value = pgid;
     document.getElementById("prm").value = id;
     document.WebControl.submit();
}
function SaveOpros(n,j){
    var err=0;
    for (i=0;i<j;i++){
        if (document.WebControl.req[i].checked){
            document.getElementById("oid").value = n;
            document.getElementById("rqid").value = document.WebControl.req[i].value;
            break;
        } else {
            err++;
        }
    }
    if (err==j){
        alert("Вы не выбрали ответ.");
    } else {
        document.getElementById("action").value = -9;
        document.WebControl.submit();
    }
}

function ShowOpros(n){
   var wnd=window.open("/show_opros.php?oid="+n, "", "width=640, height=480, scrollbars=yes, resizable=yes, status=no,toolbar=no,menubar=no,location=no");
}
function GetOpros(n){
   var wnd=window.open("/get_opros.php?oid="+n, "", "width=640, height=480, scrollbars=yes, resizable=yes, status=no,toolbar=no,menubar=no,location=no");
}

function SendMessage(){                
                if (document.getElementById("first").value==""){
                    document.getElementById("err").innerHTML = "Отравка не возможна.<br>Вы не ввели имя.<br><br>";
                    document.getElementById("err").style.display = "block";
                    document.getElementById("first").focus();
                    return;
                }
                if (document.getElementById("email").value==""){
                    document.getElementById("err").innerHTML = "Отравка не возможна.<br>Вы не E-Mail.<br><br>";
                    document.getElementById("err").style.display = "block";
                    document.getElementById("email").focus();
                    return;
                }
                if (document.getElementById("msg").value==""){
                    document.getElementById("err").innerHTML = "Отравка не возможна.<br>Вы не ввели сообщение.<br><br>";
                    document.getElementById("err").style.display = "block";
                    document.getElementById("msg").focus();
                    return;
                }
                document.getElementById("action").value = -10;
                document.WebControl.submit();
}

function Search(){
    if (document.getElementById("srch").value == ""){
        alert("Поиск не возможен.\nВы не ввели строку поиска.");
        document.getElementById("srch").focus();
        return;
    }
    ChangePage(-1);
}

function SendMessage2(){                
                if (document.getElementById("last").value==""){
                    document.getElementById("err").innerHTML = "Отравка не возможна.<br>Вы не ввели фамилию.<br><br>";
                    document.getElementById("err").style.display = "block";
                    document.getElementById("last").focus();
                    return;
                }                
                if (document.getElementById("first").value==""){
                    document.getElementById("err").innerHTML = "Отравка не возможна.<br>Вы не ввели имя.<br><br>";
                    document.getElementById("err").style.display = "block";
                    document.getElementById("first").focus();
                    return;
                }
                if (document.getElementById("otch").value==""){
                    document.getElementById("err").innerHTML = "Отравка не возможна.<br>Вы не ввели отчество.<br><br>";
                    document.getElementById("err").style.display = "block";
                    document.getElementById("otch").focus();
                    return;
                }
                if (document.getElementById("land").value==""){
                    document.getElementById("err").innerHTML = "Отравка не возможна.<br>Вы не ввели страну.<br><br>";
                    document.getElementById("err").style.display = "block";
                    document.getElementById("land").focus();
                    return;
                }
                if (document.getElementById("city").value==""){
                    document.getElementById("err").innerHTML = "Отравка не возможна.<br>Вы не ввели город.<br><br>";
                    document.getElementById("err").style.display = "block";
                    document.getElementById("city").focus();
                    return;
                }
                if (document.getElementById("org").value==""){
                    document.getElementById("err").innerHTML = "Отравка не возможна.<br>Вы не ввели название организации.<br><br>";
                    document.getElementById("err").style.display = "block";
                    document.getElementById("org").focus();
                    return;
                }
                if (document.getElementById("dolg").value==""){
                    document.getElementById("err").innerHTML = "Отравка не возможна.<br>Вы не ввели должность.<br><br>";
                    document.getElementById("err").style.display = "block";
                    document.getElementById("dolg").focus();
                    return;
                }
                if (document.getElementById("phone").value==""){
                    document.getElementById("err").innerHTML = "Отравка не возможна.<br>Вы не ввели телефон.<br><br>";
                    document.getElementById("err").style.display = "block";
                    document.getElementById("phone").focus();
                    return;
                }                
                if (document.getElementById("email").value==""){
                    document.getElementById("err").innerHTML = "Отравка не возможна.<br>Вы не E-Mail.<br><br>";
                    document.getElementById("err").style.display = "block";
                    document.getElementById("email").focus();
                    return;
                }
                document.getElementById("action").value = -11;
                document.WebControl.submit();
}

function SendMessage3(){                
                if (document.getElementById("last").value==""){
                    document.getElementById("err").innerHTML = "Отравка не возможна.<br>Вы не ввели фамилию.<br><br>";
                    document.getElementById("err").style.display = "block";
                    document.getElementById("last").focus();
                    return;
                }                
                if (document.getElementById("first").value==""){
                    document.getElementById("err").innerHTML = "Отравка не возможна.<br>Вы не ввели имя.<br><br>";
                    document.getElementById("err").style.display = "block";
                    document.getElementById("first").focus();
                    return;
                }
                if (document.getElementById("otch").value==""){
                    document.getElementById("err").innerHTML = "Отравка не возможна.<br>Вы не ввели отчество.<br><br>";
                    document.getElementById("err").style.display = "block";
                    document.getElementById("otch").focus();
                    return;
                }
                if (document.getElementById("land").value==""){
                    document.getElementById("err").innerHTML = "Отравка не возможна.<br>Вы не ввели страну.<br><br>";
                    document.getElementById("err").style.display = "block";
                    document.getElementById("land").focus();
                    return;
                }
                if (document.getElementById("city").value==""){
                    document.getElementById("err").innerHTML = "Отравка не возможна.<br>Вы не ввели город.<br><br>";
                    document.getElementById("err").style.display = "block";
                    document.getElementById("city").focus();
                    return;
                }
                if (document.getElementById("org").value==""){
                    document.getElementById("err").innerHTML = "Отравка не возможна.<br>Вы не ввели название организации.<br><br>";
                    document.getElementById("err").style.display = "block";
                    document.getElementById("org").focus();
                    return;
                }
                if (document.getElementById("dolg").value==""){
                    document.getElementById("err").innerHTML = "Отравка не возможна.<br>Вы не ввели должность.<br><br>";
                    document.getElementById("err").style.display = "block";
                    document.getElementById("dolg").focus();
                    return;
                }
                if (document.getElementById("phone").value==""){
                    document.getElementById("err").innerHTML = "Отравка не возможна.<br>Вы не ввели телефон.<br><br>";
                    document.getElementById("err").style.display = "block";
                    document.getElementById("phone").focus();
                    return;
                }                
                if (document.getElementById("email").value==""){
                    document.getElementById("err").innerHTML = "Отравка не возможна.<br>Вы не E-Mail.<br><br>";
                    document.getElementById("err").style.display = "block";
                    document.getElementById("email").focus();
                    return;
                }
                document.getElementById("action").value = -11;
                document.WebControl.submit();
}

function CreateSubject(num){
        try{
            var st = window.opener.status;
        } catch (sdasds) {
            window.opener=null;
        }
        if (window.opener==null){
            url = "ae_subject.php?fid="+num;
            var wnd=window.open(url, "", "width=600, height=400, scrollbars=no, resizable=no, status=no,toolbar=no,menubar=no,location=no");
            window.opener = wnd;
        } else {
            window.opener.focus();
        }
}
function OpenSubject(p,s,d){
    document.getElementById("pgid").value = p;
    document.getElementById("spgid").value = s;
    document.getElementById("did").value = d;
    document.getElementById("prm").value = 0;
    document.getElementById("mspos").value = 0;
    document.getElementById("mepos").value = 19;
    document.WebControl.submit();
}
function CreateMessage(d){
        try{
            var st = window.opener.status;
        } catch (sdasds) {
            window.opener=null;
        }
        if (window.opener==null){
            url = "ae_message.php?sid="+d;
            var wnd=window.open(url, "", "width=600, height=400, scrollbars=no, resizable=no, status=no,toolbar=no,menubar=no,location=no");
            window.opener = wnd;
        } else {
            window.opener.focus();
        }
}

function CreateMessageF(p,f,did,d,s){
        try{
            var st = window.opener.status;
        } catch (sdasds) {
            window.opener=null;
        }
        if (window.opener==null){
            url = "add_message.php?rid="+p+"&fid="+f+"&did="+did+"&sid="+d+"&s="+s;
            var wnd=window.open(url, "", "width=600, height=400, scrollbars=no, resizable=no, status=no,toolbar=no,menubar=no,location=no");
            window.opener = wnd;
        } else {
            window.opener.focus();
        }
}

function OpenVideo(pgid, id){
 /*   url = "open_video.php?f="+num;
    window.open(url, "", "width=600, height=400, scrollbars=no, resizable=no, status=no,toolbar=no,menubar=no,location=no");*/
    if (document.getElementById("pgid").value!=pgid){
        document.getElementById("spgid").value = 0;
        document.getElementById("did").value = 0;
        document.getElementById("prm").value = 0;
        document.getElementById("spos").value = 0;
        document.getElementById("epos").value = 19;
        document.getElementById("tday").value = "";
        document.getElementById("tmnt").value = "";
        document.getElementById("tyer").value = "";
     }
     document.getElementById("pgid").value = pgid;
     document.getElementById("did").value = id;     
     document.WebControl.submit();
}

function GetRegForm(){
    document.getElementById("action").value = -2;
    document.WebControl.submit();
}