function mainGetCookie(name)
{
   var start = document.cookie.indexOf(name+"=",start+1);
   var len = start+name.length+1;
   if( (!start) && (name != document.cookie.substring(0,name.length)) )
   {
      return "";
   }
   if(start == -1)
   {
      return "";
   }
   var end = document.cookie.indexOf(";",len);
   if(end == -1)
   {
      end = document.cookie.length;
   }
   val = unescape(document.cookie.substring(len,end));
   if( val == "null" || val == null )
   {
      val = "";
   }
   return val;
}
function mainSetCookie(name,value)
{
   if( value == "" || value == null )
   {
      return;
   }
   var oCurDate = new Date();
   var oDate = new Date( oCurDate.getYear(), oCurDate.getMonth(), oCurDate.getDate()+7, oCurDate.getHours(), 0, 0 );
   document.cookie = name + "=" + escape(value) + "; path=/; expires=" + oDate.toGMTString() + ";";
}

function BuyRequest(id,type,price,min_price,volSize,name,weight,dfs)
{
   var newWnd = window.open("http://home-video.ru/buy-request.html?"+id+"&"+price+"&"+min_price+"&"+volSize+"&"+type+"&"+dfs+"&"+weight+"&"+escape(name)+"&"+mainGetCookie("rrr"), "hvcart", "resizable=no,toolbar=no,status=no,left=3000,top=3000,width=10,height=10");
   newWnd.blur();
}
function ToCart(id,type,price,min_price,volSize,name,weight,dfs)
{
   var newWnd = window.open("http://home-video.ru/tocart.html?"+id+"&"+price+"&"+min_price+"&"+volSize+"&"+type+"&"+dfs+"&"+weight+"&"+escape(name)+"&"+mainGetCookie("rrr"), "hvcart", "resizable=yes,left=3000,top=3000,width=10,height=10");
   mainSetCookie("rrr","ept");
   newWnd.blur();
}
function OpenCart()
{
   ToCart(0,0,0,0,0,'',0,0);
}
function OpenDFSCart()
{
   ToCart(0,0,0,0,0,'',0,1);
}

if( document.referrer.indexOf("home-video") < 0 )
{
   mainSetCookie("rrr",document.referrer);
}

var bNavigator = (navigator.appName == "Netscape");
var bFireFox = (navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 5);
if( bNavigator && !bFireFox )
{
   window.location.href = "http://home-video.ru/netscape.html";
}
else
{
   window.name = "main";
}

function replace(s, t, u)
{
   i = s.indexOf(t);
   if (i == -1)
   {
      return s;
   }
   r = s.substring(0,i) + u;
   if( (i + t.length) < s.length)
   {
      r += s.substring(i + t.length, s.length);
   }
   return r;
}

function OnSearch(text)
{
   text = text.toLowerCase();
   if( text == null || text == "" || text.length < 3 ){alert("Пожалуйста, задайте ключевые слова для поиска.\nКлючевые слова должны быть длиной не менее 3 символов!");return;}
   text = replace(text,"\"","");text = replace(text,"\'","");text = replace(text,"\"","");text = replace(text,"\'","");if( text == "o" || text == "о" || text == "O" || text == "О" ){text = "otello";}
   if( text=="k9" || text=="k-9" || text=="k 9" || text=="к-9" || text=="к 9" || text=="к9" ){ text="ka9"; }
   if( text=="k-19" || text=="k 19" || text=="к-19" || text=="к 19" || text=="к19" ){ text="k19"; }
   if( text=="a-ha" || text=="a ha" || text=="a/ha" ){ text="aha"; }
   if( text=="ac-dc" || text=="ac dc" || text=="acdc" ){ text="ac/dc"; }
   window.location.href = "/cgi-bin/search.cgi?text="+text;
}

function OnPSearch(text)
{
   text = text.toLowerCase();
   if( text == null || text == "" || text.length < 3 ){alert("Пожалуйста, задайте ключевые слова для поиска.\nКлючевые слова должны быть длиной не менее 3 символов!");return;}
   text = replace(text,"\"","");text = replace(text,"\'","");text = replace(text,"\"","");text = replace(text,"\'","");if( text == "o" || text == "о" || text == "O" || text == "О" ){text = "otello";}
   if( text=="k9" || text=="k-9" || text=="k 9" || text=="к-9" || text=="к 9" || text=="к9" ){ text="ka9"; }
   if( text=="k-19" || text=="k 19" || text=="к-19" || text=="к 19" || text=="к19" ){ text="k19"; }
   if( text=="a-ha" || text=="a ha" || text=="a/ha" ){ text="aha"; }
   if( text=="ac-dc" || text=="ac dc" || text=="acdc" ){ text="ac/dc"; }
   window.location.href = "/cgi-bin/searchp.cgi?text="+text;
}



nereidFadeObjects = new Object();
nereidFadeTimers = new Object();
function nereidFade(object, destOp, rate, delta){
if(!document.all) return;
if(object!="[object]"){setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",10);return;}
clearTimeout(nereidFadeTimers[object.sourceIndex]);
diff=destOp-object.filters.alpha.opacity;
direction=1;
if(object.filters.alpha.opacity>destOp){direction=-1;}
delta=Math.min(direction*diff,delta);
object.filters.alpha.opacity+=direction*delta;
if(object.filters.alpha.opacity!=destOp){nereidFadeObjects[object.sourceIndex]=object;nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);}
}
function addToFavorites(){
if(document.all){window.external.AddFavorite( document.location.href, document.title );}
else if(navigator.appName=="Netscape" && parseInt(navigator.appVersion)>=4){alert("В Netscape, чтобы добавить в \"Избранное\", нажмите Ctrl+D");}
else{alert("К сожалению не знаю как добавить в \"Избранное\" в вашем web-browser'e  :o(\nЧтобы добавить, используйте, пожалуйста, меню или \"горячие клавиши\" вашего web-browser'a...");}
}
function setLight(id){document.all[id].style.background="#99CC33";document.all[id].style.borderBottomStyle="ridge";}
function setDark(id){document.all[id].style.background="#F8FFF8";document.all[id].style.borderBottomStyle="groove";}
function hmnu(obj,m){ if(m=='1'){obj.style.background="#99CC33";obj.style.borderBottomStyle="ridge";obj.style.cursor="hand";} if(m=='0'){obj.style.background="#F8FFF8";obj.style.borderBottomStyle="groove";} }
