// --------------------------------------------

// checks the name of your browser

// isIE or isNN are boolean varibles identeficated this



isNN=navigator.appName.indexOf('Netscape')>=0;

isIE=navigator.appName.indexOf('Explorer')>=0;

 

var bV=parseInt(navigator.appVersion);

NS4=(document.layers) ? true : false;

IE4=((document.all)&&(bV>=4))?true:false;

ver4 = (NS4 || IE4) ? true : false;



// -------------------------------------------

// open extra window 

// usage: openWindow("test.htm") or openWindow("test.jpg", 200, 120)



function openWindow(filename, w, h)

{

    var nWidth;

	var nHeigth;

	

	if (h) nHeigth = h; else nHeigth = 500;

	if (w) nWidth = w; else nWidth = 700;

	

	var desktop = window.open(filename, "_blank", 

    "width="+nWidth+",height="+nHeigth+",toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes");

};



//-------------------------------------------

// inserts flash move into the document body

 

function insertFlash(filename, w, h)

{

	if (h) nHeigth = h; else nHeigth = 500;

	if (w) nWidth = w; else nWidth = 700;



 	document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0"');

	document.write(' ID=24 WIDTH='+ nWidth + 'HEIGHT=' + nHeigth + '>');

 	document.write('<PARAM NAME=movie VALUE="33.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#003399>');

	document.write('<EMBED src=' + filename + ' quality=high bgcolor=#003399  WIDTH='+ nWidth + 'HEIGHT=' + nHeigth + ' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">');

	document.write('</EMBED></OBJECT>');

};



//--------------------------------------------

// timeout close the window. You can change the action

// to use it U have to place in your HTML timer initiation

// nTimer = setTimeout("leave();", nTimerExpired);



var nTimer;

var nTimerExpired = 15000; // U have to change this time

// window.focus();

function leave()

{

 if (nTimer) clearTimeout(nTimer);

 window.close();

};



//-------------------------------------------------

// go to URL. 

function goToURL(url)

 {

  var sURL;

  if (url) sURL=url; else sURL="/";

  location.href=sURL;

 };



// --------------------------------------------------



function PutToCart(num, id)

{

	var nCell = "amount"+num;

	

	if (!num && !id)

	{

		window.open('/cgi-bin/korzina.pl', "Korzina","width=600,height=550,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes");

	this.blur();



	} else

	{

	window.open('/cgi-bin/korzina.pl?amount='+ document.forms["shop"].elements[nCell].value+'&zakaz_id='+ id, "Korzina","width=600,height=550,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes");

	

 

	if (document.forms["iscart"].opd.value=="yes") 

	{

	  this.focus();

	  alert("Товар помещен в корзину. Для просмотра используйте ссылку «Ваша корзина»");

	}

		else 

		{ 

		 document.forms["iscart"].opd.value="yes";

		 this.focus();

	  	 alert("Товар помещен в корзину. Для просмотра используйте ссылку «Ваша корзина»");

		}

	}

 };



// --- работа с картинками ---



function openImg(pic, title, wnd)

{ 

  var sTitle = title ? title : "Просмотр иллюстрации";

  var sWnd = wnd ? wnd : "_blank"; 



  if (pic)

  {



 var pWnd = window.open('',sWnd,'toolbar=no,location=no,status=no,menubar=no,scrollbars=no, fullscreen=no, resizable=yes, centered=yes');

   

 var wndCnt;

 

 wndCnt = "<html><head><title>"+ sTitle +"</title>"+

 "<SCRIPT>function resizer() {"+

 "if (document.images && (document.images['viewport'].readyState == 'complete')) {"+

 "window.blur();"+

 "var H0 = document.images['viewport'].height;"+

 "var W0 = document.images['viewport'].width;"+

 "var nH = (screen.availHeight < H0+30) ? screen.availHeight-30 : H0+30;"+

 "var nW = (screen.availWidth < W0+10) ? screen.availWidth-10 : W0+10;"+

 "var yRatio = nH / (document.images['viewport'].height+30);"+

 "var xRatio = nW / (document.images['viewport'].width+10);"+ 

 "var nRatio = (xRatio < yRatio) ? xRatio : yRatio;"+

 "document.images['viewport'].width = W0 * nRatio;"+ 

 "document.images['viewport'].height = H0 * nRatio;"+

 "window.resizeTo(document.images['viewport'].width+10, document.images['viewport'].height+10);"+

 "window.moveTo((screen.availWidth-document.images['viewport'].width)/2,(screen.availHeight-document.images['viewport'].height)/2);"+

 "window.focus();}"+

 "else setTimeout('resizer()', 200);}"+

 "</S"+"CRIPT>\n"+

 "</head><body topmargin=0 leftmargin=0>"+

 "<img src='"+pic+"' name='viewport'>"+

 "<script>resizer();</scr"+"ipt></body></html>";

 

 pWnd.document.open();

 pWnd.document.write(wndCnt);

 pWnd.document.close();

   } 

 }

 

 function openImgTag(pic, title, wnd)

{ 

  var sTitle = title ? title : "Просмотр иллюстрации";

  var sWnd = wnd ? wnd : "_blank"; 



  if (pic)

  {



 var pWnd = window.open('',sWnd,'toolbar=no,location=no,status=no,menubar=no,scrollbars=no, fullscreen=no, resizable=yes, centered=yes');

   

 var wndCnt;

 

 wndCnt = "<html><head><title>"+ sTitle +"</title>"+

 "<SCRIPT>function resizer() {"+

 "if (document.images && (document.images[0].readyState == 'complete')) {"+

 "window.blur();"+

 "var H0 = document.images[0].height;"+

 "var W0 = document.images[0].width;"+

 "var nH = (screen.availHeight < H0+50) ? screen.availHeight-50 : H0+50;"+

 "var nW = (screen.availWidth < W0+30) ? screen.availWidth-30 : W0+30;"+

 "var yRatio = nH / (document.images[0].height+50);"+

 "var xRatio = nW / (document.images[0].width+30);"+ 

 "var nRatio = (xRatio < yRatio) ? xRatio : yRatio;"+

 "document.images[0].width = W0 * nRatio;"+ 

 "document.images[0].height = H0 * nRatio;"+

 "window.resizeTo(document.images[0].width+10, document.images[0].height+30);"+

 "window.moveTo((screen.availWidth-document.images[0].width)/2,(screen.availHeight-document.images[0].height)/2);"+

 "window.focus();}"+

 "else setTimeout('resizer()', 200);}"+

 "</S"+"CRIPT>\n"+

 "</head><body topmargin=0 leftmargin=0>"+pic+

 "<script>resizer();</scr"+"ipt></body></html>";

 

 pWnd.document.open();

 pWnd.document.write(wndCnt);

 pWnd.document.close();

   } 

 }



// shows the image with scaling if it is bigger

 

function scaleImg(pic, limit)

{ 

  var nLimit = limit ? limit : 400; 



  if (pic)

  {

  if (document.images && (pic.readyState == 'complete'))

  {



    var H0 = pic.height;

 	var W0 = pic.width;

	var nH = (nLimit < H0) ? nLimit : H0;

	var nW = (nLimit < W0) ? nLimit : W0;

	var yRatio = nH / pic.height;

	var xRatio = nW / pic.width; 

	var nRatio = (xRatio < yRatio) ? xRatio : yRatio;

	pic.width = W0 * nRatio; 

	pic.height = H0 * nRatio;

	

   }

   else setTimeout('scaleImg('+pic+','+limit+')', 200);

  

  }

}

  
function vrfyMail(email)
{
 if ((email.value == "ваш@e-mail") || (email.value == "")) 
 {
  alert("Не заполнено поле c адресом электронной почты");
  email.focus();
  return false;
 }
 
 if (email.value.indexOf("@") != "-1" &&
     email.value.indexOf(".") != "-1")
   return true;
  else 
  {
  alert("Неверно заполнено поле c адресом электронной почты");
  email.focus();
  return false;
   }
}




// открытите/закрытие секций в админе



function sectionExp(item)

{

if (document.all)

 {

 var pSection=document.all[item];

  if (pSection)

   pSection.style.display = (pSection.style.display=="none" ? "block" : "none");

 }

}
