function message(){
	var d=document.form1.txt.value;
var l=d.length;  var p=0;
if (l>0) {  for(var i=0; i<l;  i++)
{  if((d.charAt (i)!=" ")&&(d.charAt (i)!=unescape("%0D"))&&(d.charAt (i)!=unescape("%0A"))) { p=1;  break;  }  } }
if(p==1) { document.form1.submit(); }
  else {alert('Вы забыли ввести реплику!');}
}

function podpis(){	var d=document.form1.im.value;
var l=d.length;  var p1=0;
if (l>0) {  for(var i=0; i<l;  i++)
{  if((d.charAt (i)!=" ")&&(d.charAt (i)!=unescape("%0D"))&&(d.charAt (i)!=unescape("%0A"))) { p1=1;  break;  }  } }
if(p1==0) {alert('Вы забыли ввести имя!');  }
if(p1==1)
 {d=document.form1.fam.value; l=d.length;  var p2=0;
  if (l>0) {  for(var i=0; i<l;  i++)
  {  if((d.charAt (i)!=" ")&&(d.charAt (i)!=unescape("%0D"))&&(d.charAt (i)!=unescape("%0A"))) { p2=1;  break;  }  } }
  if(p2==0) {alert('Вы забыли ввести фамилию!');  }
  if(p2==1)
	 {d=document.form1.otch.value; l=d.length;  var p3=0;
      if (l>0) {  for(var i=0; i<l;  i++)
      {if((d.charAt (i)!=" ")&&(d.charAt (i)!=unescape("%0D"))&&(d.charAt (i)!=unescape("%0A"))) { p3=1;  break;  }  } }
       if(p3==0) {alert('Вы забыли ввести отчество!');  }
	   if(p3==1)
		 { d=document.form1.gorod.value; l=d.length;  var p4=0;
		   if (l>0) {  for(var i=0; i<l;  i++)
		   {if((d.charAt (i)!=" ")&&(d.charAt (i)!=unescape("%0D"))&&(d.charAt (i)!=unescape("%0A"))) { p4=1;  break;  }  } }
			if(p4==0) {alert('Вы забыли ввести город!');  }
			if(p4==1) 
			 {d=document.form1.delo.value; l=d.length;  var p5=0;
			  if (l>0) {  for(var i=0; i<l;  i++)
			  {if((d.charAt (i)!=" ")&&(d.charAt (i)!=unescape("%0D"))&&(d.charAt (i)!=unescape("%0A"))) { p5=1;  break;  }  } }
              if(p5==0) {alert('Вы забыли ввести род занятий!');  }
			  if(p5==1)
			   {d=document.form1.eml.value; l=d.length;  var p6=0;
                if (l>0) {  for(var i=0; i<l;  i++)
			    {if((d.charAt (i)!=" ")&&(d.charAt (i)!=unescape("%0D"))&&(d.charAt (i)!=unescape("%0A"))) { p6=1;  break;  }  } }
                if(p6==0) {alert('Вы забыли ввести e-mail!');  }
			   }
			 }
		 }
	 }
 } 
p1=p1*p2*p3*p4*p5*p6;
if(p1==1) {document.form1.submit();}
}

function Gr(theURL, r)
{       myWin = window.open("","",r+',scrollbars=no');
        myWin.document.open();
        myWin.document.write('<html><body leftmargin=0 topmargin=0 MARGINWIDTH=0 MARGINHEIGHT=0 onload="window.focus();">');
        myWin.document.write('<center><img src=' + theURL + ' '+ r+' border=0></center></body></html>');
        myWin.document.close();
}

function showPopup(url){
    wndW = 600;
    wndH = 500;
    wndX = (screen.availWidth-wndW)/2;
    wndY = (screen.availHeight-wndH)/2;
    this.popupWindow = window.open(url,"img_win_print","toolbar=yes,location=no,status=no,menubar=yes,scrollbars=yes,resizable,alwaysRaised,dependent,titlebar=no,width="+wndW+",height="+wndH+",left="+wndX+",top="+wndY);
}



function classImageControl(){
    this.imageList = new Array();
    this.navigationHeight = 38;
    
    this.currentlyShown = -1;
    
    this.oIframeBack = null;
    this.oDivBack = null;
    this.oDivMain = null;
    this.oDivLoading = null;
    this.oImage = null;

    this.oPreviousLink = null;
    this.oNextLink = null;
    this.oLinkSplitter = null;
    
    this.open = function(){
        this.imageList = new Array();
        for(var i = 0; i < arguments.length; i++){
            this.imageList[this.imageList.length] = arguments[i];
        }
        
        if(this.imageList.length > 0){
            if(this.oIframeBack == null){
                var iframeBack = document.createElement('iframe');
                iframeBack.className = 'imageListBack';
                this.oIframeBack = document.body.appendChild(iframeBack);
                
                var divBack = document.createElement('div');
                divBack.className = 'imageListBack';
                divBack.onclick = function(currentObject){return function(){currentObject.close()}}(this);
                this.oDivBack = document.body.appendChild(divBack);
                
                var divMain = document.createElement('div');
                divMain.className = 'imageList';
                // Add image
                var mainImage = document.createElement('img')
                mainImage.className = 'imageList';
                this.oImage = divMain.appendChild(mainImage);
                // Add break
                divMain.appendChild(document.createElement('br'));
                // Add right close link
                var linkClose = document.createElement('a');
                linkClose.className = 'imageList imageListClose';
                linkClose.innerHTML = '&nbsp; закрыть';
                linkClose.onclick = function(currentObject){return function(){currentObject.close()}}(this);
                divMain.appendChild(linkClose);
                // Add delimeter between left edge and arrows
                var beforeControls = document.createElement('span');
                beforeControls.innerHTML = '&nbsp;&nbsp;';
                divMain.appendChild(beforeControls);
                // Link for previous item
                var linkPrevious = document.createElement('a');
                linkPrevious.className = 'imageList';
                linkPrevious.innerHTML = '&larr; предыдущая';
                linkPrevious.onclick = function(currentObject){return function(){currentObject.showPreviousImage()}}(this);
                this.oPreviousLink = divMain.appendChild(linkPrevious);
                // Add delimeter between arrows
                var betweenArrows = document.createElement('span');
                betweenArrows.innerHTML = '&nbsp;&nbsp;';
                this.oLinkSplitter= divMain.appendChild(betweenArrows);
                // Link for next item
                var linkNext = document.createElement('a');
                linkNext.className = 'imageList';
                linkNext.innerHTML = 'следующая &rarr;';
                linkNext.onclick = function(currentObject){return function(){currentObject.showNextImage()}}(this);
                this.oNextLink = divMain.appendChild(linkNext);
                // Add "loading" div
                var divLoading = document.createElement('div');
                divLoading.className = 'imageListLoading';
                divLoading.innerHTML = 'Загрузка&hellip;';
                this.oDivLoading = divMain.appendChild(divLoading);
                // Append main div to body
                this.oDivMain = document.body.appendChild(divMain);
            }
            
            setTimeout(function(currentObject){return function(){currentObject.showImage(0)}}(this), 1);
            this.oImage.onload = function(currentObject){return function(){currentObject.oDivLoading.style.display = 'none'}}(this);
            window.onresize = function(currentObject){return function(){currentObject.updatePosition()}}(this);
        }
    }
    
    this.showImage = function(imageNumber){
        if(this.imageList.length <= 1){
            this.oPreviousLink.style.display = 'none';
            this.oLinkSplitter.style.display = 'none';
            this.oNextLink.style.display = 'none';
        }else if(imageNumber >= this.imageList.length-1){
            this.oPreviousLink.style.display = 'inline';
            this.oLinkSplitter.style.display = 'none';
            this.oNextLink.style.display = 'none';
        }else if(imageNumber == 0){
            this.oPreviousLink.style.display = 'none';
            this.oLinkSplitter.style.display = 'none';
            this.oNextLink.style.display = 'inline';
        }else{
            this.oPreviousLink.style.display = 'inline';
            this.oLinkSplitter.style.display = 'inline';
            this.oNextLink.style.display = 'inline';
        }
        
        if(this.imageList[imageNumber]){
            this.currentlyShown = imageNumber;
            this.updatePosition();
            
            this.oDivLoading.style.width = this.imageList[imageNumber][1] + 'px';
            this.oDivLoading.style.height = this.imageList[imageNumber][2] + 'px';
            this.oDivLoading.style.display = 'block';

            this.oIframeBack.style.display = 'block';
            this.oDivBack.style.display = 'block';
            this.oDivMain.style.display = 'block';
            
            this.oImage.src = this.imageList[imageNumber][0];
            this.oImage.style.width = this.imageList[imageNumber][1];
            this.oImage.style.height = this.imageList[imageNumber][2];
        }
    }
    
    this.showPreviousImage = function(){
        this.showImage(this.currentlyShown - 1);
    }
    
    this.showNextImage = function(){
        this.showImage(this.currentlyShown + 1);
    }
    
    this.close = function(){
        this.currentlyShown = -1;
        this.oIframeBack.style.display = 'none';
        this.oDivBack.style.display = 'none';
        this.oDivMain.style.display = 'none';
    }
    
    this.updatePosition = function(){
        if(this.currentlyShown >= 0){
            imageNumber = this.currentlyShown;
            this.imageList[imageNumber][1] = parseInt(this.imageList[imageNumber][1]);
            this.imageList[imageNumber][2] = parseInt(this.imageList[imageNumber][2]);
            var documentWidth = Math.max(document.body.clientWidth, document.body.scrollWidth);
            var documentHeight = Math.max(document.body.clientHeight, document.body.scrollHeight);
            var leftCoord = document.body.scrollLeft + (document.body.clientWidth - this.imageList[imageNumber][1]) / 2;
            var topCoord = document.body.scrollTop + (document.body.clientHeight - this.imageList[imageNumber][2] - this.navigationHeight) / 2;

            this.oIframeBack.style.width = documentWidth + 'px';
            this.oIframeBack.style.height = documentHeight + 'px';

            this.oDivBack.style.width = documentWidth + 'px';
            this.oDivBack.style.height = documentHeight + 'px';

            this.oDivMain.style.left = leftCoord + 'px';
            this.oDivMain.style.top = topCoord + 'px';
            this.oDivMain.style.width = this.imageList[imageNumber][1] + 'px';
            this.oDivMain.style.height = this.imageList[imageNumber][2] + this.navigationHeight + 'px';
        }
    }
}

var imageControl = new classImageControl();
