﻿StopAjax();

function ShowPrint(){
    var tt=$get('pr');
    var mm=$get('ctl00_MainTab_header');
    if(mm!=null){
        tt.style.display='inline-block';
        mm.appendChild(tt);
    }
}

function getBodyScrollTop()
{
  return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}

function ShowErrorNullField(name, title){
    if(ClearSpace($get(name).value)==''){ShowError(name,title);return false; }
    return true;
}

function ShowError(name, title){
    var obj=$get('InfoError');
    obj.alt=title;
    obj.title=title;
    obj.style.visibility='visible';
    var size=$get(name).getBoundingClientRect();
    obj.style.top=size.top+getBodyScrollTop();
    obj.style.left =size.right+5;
}

function HideError(){
    var obj=$get('InfoError');
    obj.style.visibility='hidden';
}

function ClearSpace(str){
    while(str.indexOf(' ')>=0) str=str.replace(' ','');
    return str;
}

function GA(obj, name){
    return obj.attributes.getNamedItem(name).value;
}

function EndMain(sender, args) {
   if( sender!=null && args.get_error() ){
        alert('Ошибка сервера. Нажмите F5 для обновления');
        args.set_errorHandled(true);
   }
}


function StartAjax() {
    document.getElementById('ctl00_AjaxStart').disabled=false;
    document.getElementById('ctl00_AjaxStop').disabled=true;
}


function StopAjax() {
    document.getElementById('ctl00_AjaxStart').disabled=true;
    document.getElementById('ctl00_AjaxStop').disabled=false;
}

function SelectChange(obj){
    if(obj.selectedIndex==0) return;
    var mm=obj.options[obj.selectedIndex].value;
    if(mm.indexOf('javascript')>0)  window.execScript(mm);  else window.location=mm;
}


function TT(obj){
    obj.innerText=obj.innerText.replace('*','').replace('*','');
    var BodyRange=document.body.createTextRange();
    BodyRange.moveToElementText(obj);
    BodyRange.execCommand('Copy'); 
}

/*---------------------------------*/
/*                Фото галерея     */
/*---------------------------------*/

var MF=null;
var MFJ=null;
var MFI=null;
var old_image=null;

var MaxX=600;
var MaxY=400;

function InitPicture(){
    MF=document.getElementById('MainFoto');
    MFJ=document.getElementById('MainFotoAjax');
    MFI=document.getElementById('MainFotoInfo');
    old_image=document.getElementById('FirstFoto');
    if(old_image!=null) SetPicture(old_image);
}


function SetPicture(obj){
    old_image.style.borderColor='white';
    old_image.style.width='70px';
    MF.src='/design/ajax.gif';
    MFJ.src='/sm.ashx?guid='+GA(obj,'guid');
    //alert($(this));
      //  alert($(this).attr('guid'));

    MFI.innerHTML='<div><a href="/sm.ashx?guid='+GA(obj,'guid')+'" target="_blank"><img src="/design/expand.gif" style="border-width: 0px"> Оригинальное изображение '+GA(obj,'iSizeX')+'x'+GA(obj,'iSizeY')+' ('+GA(obj,'iSize')+')</a></div>';
    if(GA(obj,'text')!='') MFI.innerHTML='<div>'+GA(obj,'text')+'</div>'+MFI.innerHTML;
    obj.style.borderColor='black';
    obj.style.width='100px';
    old_image=obj;
}



function LoadPicture(){
    MF.src=MFJ.src;
}




