window.onload = function() { 
   // document.body.onclick=function(){showPopUnder();return true;};
   var popuplinks = '';
   var popuplinks = document.getElementsByTagName( 'a' );
   for( var i=0; i < popuplinks.length; i++ ) {
      var link = popuplinks[i];
      if( link.className == 'popup' ) {
         link.onclick=function(){openPopUnder();return false;};
      }
   }//while
   
   
	if( document.getElementById( 'search-inp' ) ) {
		document.getElementById( 'search-inp' ).onfocus = function() { if( this.value=='поиск' ) { this.value=''; } };
		document.getElementById( 'search-inp' ).onblur  = function() { if( this.value=='' ) { this.value='поиск'; } };
	}
}

function OpenWin(pageUrl,nameWin,widthWin,heightWin,sbar) {
	hScreen=screen.availHeight; wScreen=screen.availWidth;
	if (widthWin||heightWin) { (widthWin>wScreen)?widthWin=wScreen-200:null; (heightWin>hScreen)?heightWin=hScreen-100:null; }
if (nameWin=="modal") {
	(widthWin)?null:widthWin=wScreen-200; (heightWin)?null:heightWin=hScreen-100;
		pWin="dialogWidth:"+widthWin+"px; "+"dialogHeight:"+heightWin+"px; center:1;help:0;scroll:0;status:0;"
	null_p=window.showModalDialog(pageUrl,"",pWin);
} else {
	(widthWin)?null:widthWin=wScreen-160; (heightWin)?null:heightWin=hScreen-200;
	xPos=(wScreen-widthWin)/2; yPos=(hScreen-heightWin)/2;
	(sbar)?null:sbar=0; (nameWin)?null:nameWin="wintxt";
	pWin="left=200,top=250,width="+widthWin+",height="+heightWin+",scrollbars="+sbar;
	window.open(pageUrl,nameWin,pWin); } }
   
   
function ShowBigImg(imgsrc) {
    if(document.images && document.getElementById('bigimg')) {
      var filter = /(-s)/;
      var newsrc = '';
      if( newsrc = imgsrc.replace( filter, '' ) ) {
         //alert(newsrc);
         document.getElementById('bigimg').src = newsrc;
      }
    }
}

function toggle(obj) {
	var el = document.getElementById(obj);
	el.style.display = (el.style.display != 'none' ? 'none' : '' );
}





//Pop-under window- By JavaScript Kit
//Credit notice must stay intact for use
//Visit http://javascriptkit.com for this script

//specify page to pop-under
var popunderPath="/popup/index.html"

//specify popunder window features
//set 1 to enable a particular feature, 0 to disable
var winfeatures="width=700,height=700,scrollbars=1,resizable=0,toolbar=0,location=0,menubar=1,status=1,directories=0"

//Pop-under only once per browser session? (0=no, 1=yes)
//Specifying 0 will cause popunder to load every time page is loaded
var once_per_session=1;


function getCookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // if cookie exists
      offset += search.length
      end = document.cookie.indexOf(";", offset);
      if (end == -1)
         end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}//getCookie

function showPopUnder() {
   if (once_per_session==0) {
      openPopUnder();
      return;
   }
   if( getCookie('popunder') == '' ){
      openPopUnder();
      document.cookie="popunder=yes; path=/";
   }
}//showPopUnder

function openPopUnder() {
   win2=window.open( popunderPath,"",winfeatures );
   // if we want popunder
   // win2.blur();
   // window.focus();
   
   // передаем referers через win2.name
   win2.name=getCookieReferersString();
   
}//openPopUnder



// получение referers из кук
function getCookieReferersString() {
   // var referers = [];
   var referers = '';
   var pairs = document.cookie.split(';');
   while( pairs.length ) {
      var pair = pairs.shift().split('=');
      if( pair[0].indexOf('HOST') == 0 ) {
         referers = pair[0] + ': ' + pair[1] + ';';
         // referers.push(pair)
      }
   }//while
   
   return referers;
}//getCookieReferers
