function mkadr()
{
 s01=parseInt(getval('s1'));
 brn01=parseInt(getval('brn1'));
 p01=parseInt(getval('p1'));
 r01=parseInt(getval('r1'));
 ssn=parseInt(getval('seas1'));
 ggg=parseInt(getval('grou1'));
 c1=parseInt(getval('cena1'));
 c2=parseInt(getval('cena2'));
 adrrr=imhere+'selsh';
 if(s01>0) adrrr+='/s1='+s01;
 if(p01>0) adrrr+='/p1='+p01;
 if(r01>0) adrrr+='/r1='+r01;
 if(ssn>0) adrrr+='/seas1='+ssn;
 if(ggg>0) adrrr+='/grou1='+ggg;
 if(c1>0) adrrr+='/cena1='+c1;
 if(c2>0) adrrr+='/cena2='+c2; 
 if(brn01>0) adrrr+='/brn1='+brn01;
 //alert(adrrr);
 document.getElementById('srchfrm').action=adrrr;
}

function getval(a)
{
 if(document.getElementById(a)) return document.getElementById(a).value;
 else return '';
}

function whcookie()
   { var height, width;

   if (document.all)
   height = document.body.offsetHeight, width =
   document.body.offsetWidth;
   else if (document.layers)
   height = window.innerHeight, width = window.innerWidth;
   document.cookie = "winh="+height;
   document.cookie = "winw="+width;
   }

 function trim(data) {
    return data.replace(/^\s*(.*?)\s*$/gi, '$1');
}
   
function buyshina(i)
{
 document.getElementById('num').value=i;
 document.getElementById('ty').value='s';
 document.getElementById('shtuk').value=document.getElementById('wantit'+i).value;
 document.getElementById('tomagaz').submit();
}

function buyshinabu(i)
{
 document.getElementById('num').value=i;
 document.getElementById('ty').value='sb';
 document.getElementById('shtuk').value=document.getElementById('wantit'+i).value;
 document.getElementById('tomagaz').submit();
}

function buydisk(i)
{
 document.getElementById('num').value=i;
 document.getElementById('ty').value='d';
 document.getElementById('shtuk').value=document.getElementById('wantit'+i).value;
 document.getElementById('tomagaz').submit();
}

function buykol(i)
{
 document.getElementById('num').value=i;
 document.getElementById('ty').value='k';
 document.getElementById('shtuk').value=document.getElementById('wantit'+i).value;
 document.getElementById('tomagaz').submit();
}

function bookmark(title, url) {
	// если название страницы не было чётко указано, возьмём заголовок текущей страницы
	if (title == undefined)
		title = document.title;

	// то же самое и с URL-ом
	if (url == undefined)
		url = top.location.href;

	if (window.sidebar) {
		// Firefox
		window.sidebar.addPanel(title, url, '');
	} else if (window.opera && window.print) {
		// Opera
		var t = document.createElement('a');
		t.setAttribute('rel', 'sidebar');
		t.setAttribute('href', url);
		t.setAttribute('title', title);
		t.click();
	} else {
		// IE
		window.external.AddFavorite(url, title);
	}
	//return false;
}


function opendit1(n,m){
 
var newImage = new Image();
   newImage.src = n;
   h=newImage.height+50;w=newImage.width+40;
   h=300;w=270;
   win111 = window.open('','win',
"width="+w+",height="+h+",resizable=no,scrollbars=yes,status=no");
win111.document.write('<html><head><title>'+m);

win111.document.write('</title><link rel=stylesheet type="text/css" href="./css/main.css"></head>');
win111.document.write('<body><center>');
win111.document.write('<img src="'+n+'" ');

win111.document.write(' border="0">');
win111.document.write('    <br>');
win111.document.write('  <a onclick="javascript:window.close();" href="">закрыть окно</a>');
win111.document.write('</center></body></html>');
}

function checkfile(v)
{
 arrayOfStrings = v.split(".");len=arrayOfStrings.length;
 s='';
 if(len!=0) {
  s=arrayOfStrings[len-1];
  s=s.toUpperCase();
  }
 if(s=='JPG' || s=='JPEG' || s=='GIF')
   {; }
 else {alert('Выберите пожалуйста файл JPEG или GIF');return false;}

return true;
}

function checkxls(v)
{
 arrayOfStrings = v.split(".");
 len=arrayOfStrings.length;
 s='';
 
 if(len!=0 && v!='') {
  s=arrayOfStrings[len-1];
  s=s.toUpperCase();
  
 if(s=='CSV')
   {; }
 else {alert('Выберите пожалуйста файл CSV');return false;}
}
return true;
}


function opendit(cod){
		var win=window.open(cod,'newwin'+Math.round(Math.random()*10000+1),'height=600,width=750,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
		/*win.blur();
		window.focus();*/
}

function chknums(cod){
  for(i=1;i<7;i++)
     {
	  aaa='item'+cod+'_'+i;
      if(!document.getElementById(aaa)) continue;
      val=document.getElementById(aaa).value;
	  //alert(aaa+'val='+val);
      for(j=0;j<val.length;j++)
          {c=val.charAt(j);
           if (c<'0' || c>'9')
              {
               alert('введите пожалуйста целое число.');
               document.getElementById(aaa).focus();
               return false;
              }}
	 }
    sum=0; 
    for(i=1;i<7;i++)
     {
	  aaa='item'+cod+'_'+i;
      if(!document.getElementById(aaa)) continue;
      val=document.getElementById(aaa).value;
      //if(val>0) return true;
      sum+=val;
	 }
   if(sum<1) {alert('введите пожалуйста количество товара.'); return false;}
   return true;
}

var timerID = null;
var timerRunning = false;
var num=1;
var pic=new Array(8);

function pic_preload()
{
for(i=1;i<7;i++) {
 pic[i] = new Image();
 pic[i].src="images/v"+i+".jpg";
}
}

function stopclock(){
   if(timerRunning)
      clearInterval(timerID);
   timerRunning = false;
}

function startclock(){
   // Make sure the clock is stopped
   stopclock();
   timerID = setInterval("showtime()",2000);
   timerRunning = true;
   pic_preload();
}

function showtime(){
   num++;
   //var num=Math.round(Math.random()*6+1);
   if(num>6) num=1;
   //alert(num%3+1);
   document.getElementById("video").innerHTML='<a href="index.php?page=video&v='+Math.round(num/2)+'" class="ntextlink"><img id="picc"  border="0" title="посмотреть видеоролик"><br><center><b>ПОСМОТРЕТЬ ВИДЕОРОЛИК</b></center></a>';
   document.getElementById("picc").src=pic[num].src;
}