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')
   {; }
 else {alert('Выберите пожалуйста файл JPEG');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<=ttlns;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<=ttlns;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);
   if(document.getElementById("video")) 
   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>';
   if(document.getElementById("picc"))
   document.getElementById("picc").src=pic[num].src;
}

function idstyle(id,s)
{
 document.getElementById(id).style.display=s;
}

function getstyle(id)
{
 return document.getElementById(id).style.display;
}

function getval(id)
{
 z=document.getElementById(id);
 if(z) return z.value;
 return '';
}

  function setval(id,v)
{
 z=document.getElementById(id);
 if(z) document.getElementById(id).value=v;
}

function click_it(id)
{
 //alert('click_it('+id+')');
 if(document.getElementById(id))
 document.getElementById(id).click();
}

function ischecked(a)
{
aa=a.split('|');
total=aa.length;

for(i=0;i<total;i++) if(ischk(aa[i])) return 1;
return 0;
}

function ischk(a)
{
 d=document.getElementById(a);
 if(!d.disabled) d=d.checked; else d=0;
 return d;
}