// Определяем тип браузера
function BrowserCheck(){
  var b=navigator.appName
  if(b=="Netscape") this.b="ns"
  else if(b=="Microsoft Internet Explorer") this.b="ie"
  else this.b=b
  this.version= navigator.appVersion
  this.v=parseInt(this.version)
  this.ns=(this.b=="ns" && this.v>=4)
  this.ns4=(this.b=="ns" && this.v==4)
  this.ns5=(this.b=="ns" && this.v>=5)
  this.ie=(this.b=="ie" && this.v>=4)
  this.ie4=(this.version.indexOf('MSIE 4')>0)
  this.ie5=(this.version.indexOf('MSIE 5')>0)
  return this.b;
}

 function send(formname)
 {
   window.document.forms[formname].submit();
 }

function show_img(img,width,height,admin,id_point)
{
   var a
   var b
   var url

   vidWindowWidth=width;
   vidWindowHeight=height+95;
   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";
   if (id_point=="") id_point=0;
   if (admin!='true') url="../utils/show.php?img="+img+"&id_point="+id_point;
   else url="../../utils/show.php?img="+img+"&id_point="+id_point;
   window.open(url,'',features,true);
}

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).style ;
		   else return null;
        } else { 
            return obj.style 
        } 
    } 
    if (document.getElementById) { 
        if (typeof obj == "string") { 
            return document.getElementById(obj).style 
        } else { 
            return obj.style 
        } 
    } 
    return null 
} 

// Отображение объекта
function show(obj) { 
    var theObj = getObject(obj);
    theObj.visibility = "visible" 
    theObj.display = "block" 	
} 
// Скрытие объекта
function hide(obj)
{ 
    var theObj = getObject(obj) 
    theObj.visibility = "hidden";
    theObj.display = "none" 		 
} 

// Отображение развиваемых качеств, скрытие групп
function showmerits(obj)
{
  hide("group");
  hide("age");  
  show("merits");
  var theObj = getObject("zag");
  if(theObj!=null) 
  {
    theObj.visibility = "hidden";
    theObj.display = "none" 		 
  }
  theObj = getObject("comment");
  if(theObj!=null) 
  {
    theObj.visibility = "hidden";
    theObj.display = "none" 		 
  }
}

// Отображение групп, скрытие развиваемых качеств
function showgroup(obj)
{
  hide("merits");
  hide("age");  
  show("group");
}

// Отображение групп, скрытие развиваемых качеств
function showage(obj)
{
  hide("merits");
  hide("group");  

  var theObj = getObject("zag");
  if(theObj!=null) 
  {
    theObj.visibility = "hidden";
    theObj.display = "none" 		 
  }
  theObj = getObject("comment");
  if(theObj!=null) 
  {
    theObj.visibility = "hidden";
    theObj.display = "none" 		 
  }
  
  show("age");
}

// Отправка данных для корзины
function submit(id_point)
{
  var a
  var b
  var url
  var wndNewWindow
  titl= "";
  vidWindowWidth=330;
  vidWindowHeight=240;
  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="../shop/addtoy.php?id_point="+id_point;
  name="";
  wndNewWindow = parent.open(url,name,features);
}

// Отправка формы с заказом.
// Проверяются значения и открывается скрипт-отправки
function submitorder(last_name, first_name, second_name, mail_index, phone, email, cont, oblast, town, street, house, flat, city_code, phone_type, deliverytxt, delivery, good_time, agree)
{
  if (last_name=="")
  {
    alert("Не введена Фамилия");
    return false;
  }
  if (first_name=="")
  {
    alert("Не введено Имя");
    return false;
  }
  if (second_name=="")
  {
    alert("Не введено Отчество");
    return false;
  }

  if (mail_index=="")
  {
    alert("Не введен почтовый индекс");
    return false;
  }

  if (oblast=="")
  {
    alert("Не введена область доставки");
    return false;
  }
  if (town=="")
  {
    alert("Не введен город доставки");
    return false;
  }
  if (street=="")
  {
    alert("Не введена улица");
    return false;
  }
  if (house=="")
  {
    alert("Не введен дом");
    return false;
  }
  if (flat=="")
  {
    alert("Не введена квартира");
    return false;
  }
  if (phone=="" || email=="")
  {
    alert("Не введен телефон или e-mail");
    return false;
  }
  if (city_code=="")
  {
    alert("Не введен код города");
    return false;
  }
   
  if (document.order.agree.checked==false)
  {
    alert("Пожалуйста, ознакомьтесь с правилами работы Интернет-магазина");
    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="order.php?last_name="+last_name+"&first_name="+first_name+"&second_name="+second_name+"&mail_index="+mail_index+"&phone=" + phone + "&phone_type=" + phone_type +"&good_time=" + good_time +"&email=" + email + "&oblast="+oblast+ "&town="+town+"&street="+street+"&house="+house+"&flat="+flat+"&city_code="+city_code+"&contact="+cont+"&delivery="+delivery+"&deliverytxt="+deliverytxt;
//  alert(url);
  name="";
  wndNewWindow = parent.open(url,name,features);

}

// Отправка мнения об игрушке
function submitanswer(first_name, messag, id_point)
{

  if (first_name=="")
  {
    alert("Не введено Имя");
    return false;
  }
  if (messag=="")
  {
    alert("Не оставлено мнение");
    return false;
  }

  var a
  var b
  var url
  var wndNewWindow
  titl= "";
  vidWindowWidth=360;
  vidWindowHeight=150;
  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="../shop/answer.php?first_name="+first_name+"&messag="+messag+"&id_point="+id_point;
//  alert(url);
  name="";
  wndNewWindow = parent.open(url,name,features);

}

// Перемещение мышки над кнопкой
function over(obj)
{
  var d=new getObject(obj)
  x=d.left;
  if (x=="") x=0;
  else x=x.substring(0,x.length-2)
  d.left=parseInt(x);
  y=d.top;
  if (y=="") y=0
  else y=y.substring(0,y.length-2)
  d.top=parseInt(y)+1;
}

// Перемещение мышки над кнопкой
function out(obj)
{
  var d=new getObject(obj)
  x=d.left;
  if (x=="") x=0;
  else x=x.substring(0,x.length-2)
  d.left=parseInt(x);
  y=d.top;
  if (y=="") y=0
  else y=y.substring(0,y.length-2)
  d.top=parseInt(y)-1;
}

// Отправка письма
// Проверяются значения и открывается скрипт-отправки
function submitletter(name, phone, email, letter)
{
  if (name=="") 
  {
    alert("Не введено имя"); 
    return false;	
  }	
  if (letter=="") 
  {
    alert("Не введен вопрос"); 
    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="../utils/send.php?name="+name+"&phone=" + phone + "&email=" + email + "&letter="+letter;
  name="";
  wndNewWindow = parent.open(url,name,features);
  
}

// Отправка письма
// Проверяются значения и открывается скрипт-отправки
function submitkonkurs(name, phone, email, index, address)
{
  if (name=="") 
  {
    alert("Не введено имя (ФИО)"); 
    return false;	
  }	
  if (phone=="" && email=="") 
  {
    alert("Заполните хотя бы одно из полей: телефон или e-mail"); 
    return false;
  }	

  if (index=="") 
  {
    alert("Не введен почтовый индекс"); 
    return false;
  }

  if (address=="") 
  {
    alert("Не введен почтовый адрес"); 
    return false;
  }
    
  return true;
}

// Отображение картинки во всплывающем окне
function showpicture(image, title){
  window.open('../utils/showpicture.php?image='+image+'&title='+title,'','Toolbar=0,Location=0,Directories=0,Status=0,Menubar=0,Scrollbars=0,Resizable=0,Width=650,Height=500,left=150, top=150');
}


function resize() { 
  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(400, 370) 
} 
