var Checked=new Array();
var Checkbox=new Array();

Checkbox[0]=new Image(13,13);
Checkbox[0].src='/imgs/uncheckedbox.gif';
Checkbox[1]=new Image(13,13);
Checkbox[1].src='/imgs/checkedbox.gif';

function CheckSearch()
  {
   if (document.SearchForm.SearchWord.value.length > 1)
      return true;
   else
     {
      alert ("Введите строку для поиска");
      return false;
     }
  }

function OpenC(theURL,winName,features)
  {
     var Win=window.open(theURL,winName,features);
     Win.focus();
     return false;
  }

function OpenCard(id, showcart)
  {
   var newURL="card.php?id="+id+"&showcart="+showcart;
   //Wid=window.open(newURL,id);
   Wid=window.open(newURL, id, 'toolbar=0,scrollbars=1,location=0,directories=0,status=0,menubar=0,width=771,height=505,border=thin,top=0,left=0,help=0');
   /*Wid.focus();*/
  }

function OpenReview(id, showcart)
  {
   var newURL="card.php?id="+id+"&showcart="+showcart+"&review=1#review";
   //Wid=window.open(newURL,id);
   Wid=window.open(newURL, id, 'toolbar=0,scrollbars=1,location=0,directories=0,status=0,menubar=0,width=590,height=505,border=thin,top=0,left=0,help=0');
   /*Wid.focus();*/
  }

function openphoto(URL,width,height)
  {
   var URL=URL;
   Widb=window.open(URL,'','toolbar=0,scrollbars=0,location=0,directories=0,status=0,menubar=0,width='+width+',height='+height+',border=thin,top=0,left=0,help=0');
  }

function openphoto2(URL,width,height)
  {
   var URL=URL;
   Widb=window.open(URL,'','toolbar=0,scrollbars=1,location=0,directories=0,status=0,menubar=0,width='+width+',height='+height+',border=thin,top=0,left=0,help=0');
  }
function OpenImage(id)
  {
   var newURLb="/Pdb/text.phtml?id="+id+"&big=1";
   Widb=window.open(newURLb,id+'_i','toolbar=0,scrollbars=0,location=0,directories=0,status=0,menubar=0,width=600,height=600,border=thin,top=0,left=0,help=0');
  }

function OpenGame2()
  {
   var newURLb="/game2/";
   Widb=window.open(newURLb,'game_2','toolbar=0,scrollbars=0,location=0,directories=0,status=0,menubar=0,width=750,height=660,border=thin,top=0,left=0,help=0');
  }


function OpenSaleGame()
  {
   var newURLb="/salegame/";
   Widb=window.open(newURLb,'salegame','toolbar=0,scrollbars=0,location=0,directories=0,status=0,menubar=0,width=655,height=600,border=thin,top=0,left=160,help=0');
  }

function Open3D(id,prefix,big)
  {
   if (big=='2') {
     var newURL="/Swf3/show.php?id=" + id + "&prefix=" + prefix;
     Widb=window.open(newURL,'main_big2','toolbar=0,scrollbars=0,location=0,directories=0,status=0,menubar=0,width=603,height=697,border=thin,top=0,left=0,help=0');
   }
   else if (big=='1') {
     var newURL="/Swf2/show.php?id=" + id + "&prefix=" + prefix;
     Widb=window.open(newURL,'main_big','toolbar=0,scrollbars=0,location=0,directories=0,status=0,menubar=0,width=600,height=600,border=thin,top=0,left=0,help=0');
   } else {
     var newURL="/Swf/show.php?id=" + id + "&prefix=" + prefix;
     Widb=window.open(newURL,'main','toolbar=0,scrollbars=0,location=0,directories=0,status=0,menubar=0,width=400,height=400,border=thin,top=0,left=0,help=0');
   }
  }

function Order(id)
  {
   var newURL="/cart.php?ids["+id+"]=1";
   if (window.opener)
     window.opener.location = newURL;
   else
     window.open (newURL,"main");
   return false;
  }

function OpenShop (num)
  {
   var URL="/?p=shop"+num;
   if (window.opener && !window.opener.closed)
     window.opener.location = URL;
   else
     window.opener = window.open (URL, "main");
   window.opener.focus();
  }

function CheckboxClicked (id)
  {
   if (Checked[id])
     {
      Checked[id]=0;
      document['check'+id].src=Checkbox[0].src;
     }
   else
     {
      Checked[id]=1;
      document['check'+id].src=Checkbox[1].src;
     }
  }

function Check(e)
{
  for (i=0;i<document.compare_form.elements.length;i++)
   {
     if (e==1 && document.compare_form.elements[i].type == 'hidden')
       {
        Checked[document.compare_form.elements[i].value]=1;
        document['check'+document.compare_form.elements[i].value].src=
          Checkbox[1].src;
       }
     if (e==2 && document.compare_form.elements[i].type == 'hidden')
       {
        Checked[document.compare_form.elements[i].value]=0;
        document['check'+document.compare_form.elements[i].value].src=
          Checkbox[0].src;
       }
     if (e==3 && document.compare_form.elements[i].type == 'hidden')
       {
        num=Checked[document.compare_form.elements[i].value];
        if (isNaN(num))
          num=0;
        Checked[document.compare_form.elements[i].value]=
          1-num;
        document['check'+document.compare_form.elements[i].value].src=
          Checkbox[1-num].src;
       }
   }
}


function Send_checked(form_name,opros)
  {
   var si = 0;
   var url = '?';
   var tmp = new Array();

   for (var i=0; i<document.form_name.elements.length; i++)
     if ( document.form_name.elements[i].type == 'hidden' &&
          Checked[document.form_name.elements[i].value] &&
          si<160
         )
       tmp[si++] = 'id_opros_browser[]='
               + document.form_name.elements[i].value;

   url = url + tmp.join('&') + '&opros_num=' +  opros;

   if (si >= 1)
     location.href=url;
   else
     window.alert("Выберите один из пунктов");
  }


function Compare()
  {
   var si = 0;
   var url = '/compare.php?';
   var tmp = new Array();

   for (var i=0; i<document.compare_form.elements.length; i++)
     if (document.compare_form.elements[i].type == 'hidden' &&
         Checked[document.compare_form.elements[i].value] && si<160)
       tmp[si++] = 'ids[]='
               + document.compare_form.elements[i].value;

   url = url + tmp.join('&');

   if (si > 1)
     window.open(url,'compare','resizable=yes,width=790,height=540,toolbar=no,scrollbars=yes,location=no,directories=no,status=no,menubar=no,top=no,left=no,help=no');
   else
     window.alert("Выберите товары для сравнения");
  }

function Compare_2()
  {
   var si = 0;
   var url = '/compare.php?';
   var tmp = new Array();

   for (var i=0; i<document.compare2_form.elements.length; i++)
     if (document.compare2_form.elements[i].type == 'hidden')
       tmp[si++] = 'ids[]='
               + document.compare2_form.elements[i].value;

   url = url + tmp.join('&');

     window.open(url,'compare','resizable=yes,width=790,height=540,toolbar=no,scrollbars=yes,location=no,directories=no,status=no,menubar=no,top=no,left=no,help=no');

  }

function LeaveSelected()
  {
   var si = 0;
   var url="/pricelist/?p=t&";
   var tmp = new Array();

   for (var i=0; i<document.compare_form.elements.length; i++)
     if (document.compare_form.elements[i].type == 'hidden' &&
         Checked[document.compare_form.elements[i].value] && si<160)
       tmp[si++] = 'ids[]='
                 + document.compare_form.elements[i].value;

   url = url + tmp.join('&');

   window.location=url;
  }

function OpenBrand ()
  {
   mark = document.brandform.mark.options[document.brandform.mark.options.selectedIndex].value;
   if (mark) window.location = "/classifier.php?mark=" + mark;
  }

function OpenCity ()
  {
   city = document.cityform.city.options[document.cityform.city.options.selectedIndex].value;
   if (city) window.location = city;
  }

function OpenAdvSearch ()
  {
   var newURL;
   newURL="http://www.mvideo.ru/pricelist/?p=search";
   Win=window.open(newURL, 'AdvSearch', 'toolbar=0,scrollbars=0,location=0,directories=0,status=0,menubar=0,width=570,height=260,border=thin,top=0,left=0,help=0');
   Win.focus();
  }

function OpenParamSearch (lvl,class_,group,mark)
  {
   var newURL;
   if (window.location.href.indexOf("/homeshop/")==-1)
     newURL="/pricelist/paramsearch.phtml?lvl="+lvl+"&class="+class_+"&group="+group+"&mark="+mark;
   else
     newURL="/homeshop/paramsearch.phtml?lvl="+lvl+"&class="+class_+"&group="+group+"&mark="+mark;
   Win=window.open(newURL, 'ParamSearch', 'toolbar=0,scrollbars=0,location=0,directories=0,status=0,menubar=0,width=450,height=400,border=thin,top=0,left=0,help=0');
   Win.focus();
  }

function OpenAdvAction(num)
  {
   var newURL="/adv-txt/?p="+num;
   if (window.opener)
     window.opener.location = newURL;
   else
     window.open (newURL,"main");
   return false;
  }

function OpenInOpener(newURL)
  {
   if (window.opener)
     window.opener.location = newURL;
   else
     window.open (newURL,"main");
   return false;
  }

function set_cookie(name, value, expires)
{
 if (!expires)
  {
   expires = new Date();
  }
 document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() +  "; path=/";
}

