var popup_img;
function show_img_gd(id_image,width,height)
{
   var a
   var b
   var url
   vidWindowWidth=width;
   vidWindowHeight=height;
   a=(screen.height-vidWindowHeight)/5;
   b=(screen.width-vidWindowWidth)/2;
   features="top="+a+",left="+b+",width="+vidWindowWidth+",height="+vidWindowHeight+",toolbar=no,menubar=no,location=no,directories=no,scrollbars=no,resizable=no";
   url="/gallery/showorigin.php?id_photo="+id_image+"&style=origin";
   window.open(url,'',features,true);
   return false;
}

var popup_img;
function show_image(img_url) {
  if (popup_img && !popup_img.closed)
  {
    popup_img.close(); 
  }	
  popup_img = window.open('/shared/img_popup.php?img='+img_url,'Image','width=500,height=400,scrollbars=no,toolbar=no,location=no,status=no,resizable=yes,screenX=120,screenY=100');
}

function photo_info(id_photo,width,height)
{
   var a
   var b
   var url
   vidWindowWidth=width+150;
   vidWindowHeight=height+140;
   a=(screen.height-vidWindowHeight)/5;
   b=(screen.width-vidWindowWidth)/2;
   features="top="+a+",left="+b+",width="+vidWindowWidth+",height="+vidWindowHeight+",toolbar=no,menubar=no,location=no,directories=no,scrollbars=1,resizable=1";
   url="/shared/photoinfo.php?id_photo="+id_photo;
   window.open(url,'',features,true);
   return false;
}

function printpage()
{
  window.print();
}

function resize(width, height) { 
  if (navigator.userAgent.indexOf("Mac")!=-1 || 
      navigator.userAgent.indexOf("Gecko")!=-1 ||   
      navigator.userAgent.indexOf("Netscape")!=-1) 
    var offset = 0; 
  else     var offset = 4; 
  window.moveTo(50, 50); 
  window.resizeTo(width, height) 
} 

// Отправка письма
// Проверяются значения и открывается скрипт-отправки
function submitletter(name, phone, email, letter)
{
  if (name=="") 
  {
    alert("Не введено имя"); 
    return false;	
  }	
  if (letter=="") 
  {
    alert("Не введено сообщение"); 
    return false;
  }	

  if (email=="") 
  {
    alert("Введите обратный e-mail"); 
    return false;
  }	

  var a
  var b
  var url
  var wndNewWindow
  titl= "";
  vidWindowWidth=360;
  vidWindowHeight=250;
  a=(screen.height-vidWindowHeight)/2;
  b=(screen.width-vidWindowWidth)/2;
  features="top="+a+",left="+b+",width="+vidWindowWidth+",height="+vidWindowHeight+",toolbar=no,menubar=no,location=no,directories=no,scrollbars=no,resizable=no";
  url="/shared/send.php?name="+name+"&phone=" + phone + "&email=" + email + "&letter="+letter;
  name="";
  wndNewWindow = parent.open(url,name,features);
  
}


function getObject(obj) { 
    var theObj 
    if (document.layers) { 
        if (typeof obj == "string") { 
            return document.layers[obj]
        } else { 
            return obj 
        } 
    } 
    if (document.all) { 
        if (typeof obj == "string") { 
		   if(document.all(obj)!=null) return document.all(obj);
		   else return null;
        } else { 
            return obj; 
        } 
    } 
    if (document.getElementById) { 
        if (typeof obj == "string") { 
            return document.getElementById(obj) 
        } else { 
            return obj 
        } 
    } 
    return null 
} 

// Отображение объекта
function show(obj) { 
  var theObj = getObject(obj);
  if (typeof theObj.style.visibility != "undefined") 
                                       theObj.style.visibility = "visible" 
  if (typeof theObj.style.display != "undefined") theObj.style.display = "block" 	
}

// Функция для скрытия объектов
function hide(obj)
{ 
  var theObj = getObject(obj) 
  if (typeof theObj.style.visibility != "undefined") 
                                       theObj.style.visibility = "hidden"
  if (typeof theObj.style.display != "undefined") theObj.style.display = "none" 		 
} 

function setstyle(obj, newstyle)
{
  var theObj = getObject(obj) 
  if (typeof theObj != "undefined")  theObj.className = newstyle
}

// Вспоывающее изображение с последующим изменением размеров окна
function popup_image(img_url) {
  if (popup_img && !popup_img.closed)
  {
    popup_img.close(); 
  }	
  popup_img = window.open('/shared/img_popup.php?img='+img_url,'Image','width=500,height=450,scrollbars=no,toolbar=no,location=no,status=no,resizable=yes,screenX=120,screenY=100');
}

// Вспоывающее изображение с последующим изменением размеров окна для кэшированных изображений
function popup_image_cache(img_url) {
  if (popup_img && !popup_img.closed)
  {
    popup_img.close(); 
  }	
  popup_img = window.open('/shared/img_popup.php?cache=1&img='+img_url,'Image','width=500,height=450,scrollbars=no,toolbar=no,location=no,status=no,resizable=yes,screenX=120,screenY=100');
}