var d = document;
//---------------------------------------------
function getCookieVal (offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
      endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
 var arg = name + "=";
 var alen = arg.length;
 var clen = d.cookie.length;
 var i = 0;
 while (i < clen) {
  var j = i + alen;
  if (d.cookie.substring(i, j) == arg)
  return getCookieVal (j);
  i = d.cookie.indexOf(" ", i) + 1;
  if (i == 0)break;
 }
 return null; 
}
function SetCookie (name, value) {
 var argv = SetCookie.arguments;
 var argc = SetCookie.arguments.length;
 var expires = (argc > 2) ? argv[2] : null;
 var path = (argc > 3) ? argv[3] : null;
 var domain = (argc > 4) ? argv[4] : null;
 var secure = (argc > 5) ? argv[5] : false;
 d.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString()))+((path == null) ? "" : ("; path=" + path))+((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
}

function openWinSP2(){
    	if (window.event.srcElement.old_onclick != null) window.event.srcElement.old_onclick();
		window.open( wfile_F , "bsvideo", "Width=1,Height=1,resizable=yes,left=0,write=0,fullscreen=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0");
		window.focus();
}

function openWin(){
 		window.open( wfile_F , "bsvideo", "Width=1,Height=1,resizable=yes,left=0,write=0,fullscreen=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0");
}

//---------------------------------------------
 var fappVer = parseFloat(navigator.appVersion);
 var targetieSP2 = (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0)&&(navigator.userAgent.indexOf('Opera')==-1)&&(navigator.appName != 'Netscape')&&(navigator.userAgent.indexOf('MSIE') > -1)&&(navigator.userAgent.indexOf('SV1') > -1)&&(fappVer >=4);
 var cache_rnd = Math.round(Math.random() * 1000000000);
 var wfile = "http://head.imho.ru/html.ng/impt=imp&place=hifiBS&id=160505&transactionID="+cache_rnd+"rnd="+cache_rnd;
 var wfile_zagl = "http://head.imho.ru/html.ng/impt=imp&place=hifiBS_zagl&id=160505&transactionID="+cache_rnd+"rnd="+cache_rnd;
 var w= 300
 var h= 250;
 var ShockMode = 0;
 var cookname = "";
 var maxopen = 0;
 var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
 if (plugin && parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) >= 5) 
 {
 ShockMode = 1;
 }
 else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
 && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0)) {
 document.write('<SCRIPT LANGUAGE=VBScript\> \n');
 document.write('on error resume next \n');
 document.write('ShockMode = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5")))\n');
 document.write('<\/SCRIPT\> \n');
 }
 if ( ShockMode == 1 ) {
   wfile_F = wfile;
 }else{
   wfile_F = wfile_zagl;
 }
  var advview = GetCookie(cookname);
  if (advview == null){ advview = 1; }else{ advview++; }
  if ((advview <= maxopen)||(maxopen==0)){
   var md = location.pathname.substring(0,location.pathname.lastIndexOf('/')) +'/';
   var ed = new Date();
   ed.setTime(ed.getTime() + (24*3600*1000));
   SetCookie(cookname,advview,ed,md); 
   if (targetieSP2){
	for (nnn = 0; nnn < document.links.length; nnn++){
      if (document.links[nnn].target != "_blank"){
     	  document.links[nnn].old_onclick =  document.links[nnn].onclick;
    	  document.links[nnn].onclick = openWinSP2;
      }
    }
   }else{
    openWin(wfile);
   }
   setTimeout('window.focus()',50);
  }
