
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function wopen(page){
//  open(page,title,"scrollbars=no,width=510,height=550");
  return open(page,'ProductView',"scrollbars=yes,width=516,height=550");
}

function iopen(page){
//  open(page,title,"scrollbars=no,width=510,height=550");
  open(page,'InstImage',"scrollbars=yes,width=515,height=550");
}

function checkdel(id){
  if (confirm("Are you sure you want to delete this item?")) {
    document.location='index.php?cpage=admin&aac=delitem&iid='+id;
  }
}
function checkdelcat(id){
  if (confirm("Are you sure you want to delete this item?")) {
    document.location='index.php?cpage=admin&aac=delcatalogue&iid='+id;
  }
}

function checkitem(item){
  b=true;
  for(i=0;i<items.length;i++){
    if(items[i]==item) {
      alert("This item already exists!\nChoose different item name.");
      b=false;
      break;
    }
  }
  return b;
}

function showtables(c,t,ta){
  table1.style.display=c?"":"none";
  table3.style.display=ta?"":"none";
  uk_table1.style.display=c?"":"none";
  uk_table3.style.display=ta?"":"none";
}

function selClick(v){
  switch(v){
    case 'frame':
      document.imgform.S.disabled=1;
      document.imgform.T.disabled=1;
      document.imgform.F.disabled=0;
      document.imgform.S.style.display='none';
      document.imgform.T.style.display='none';
      document.imgform.F.style.display='';
      change_sel(FImg,FImg[document.imgform.F.selectedIndex],FDescr[document.imgform.T.selectedIndex]);
    break;
    case 'seat':
      document.imgform.F.disabled=1;
      document.imgform.T.disabled=1;
      document.imgform.S.disabled=0;
      document.imgform.T.style.display='none';
      document.imgform.F.style.display='none';
      document.imgform.S.style.display='';
      change_sel(SImg,SImg[document.imgform.S.selectedIndex],SDescr[document.imgform.T.selectedIndex]);
    break;
    case 'table':
      document.imgform.F.disabled=1;
      document.imgform.S.disabled=1;
      document.imgform.T.disabled=0;
      document.imgform.F.style.display='none';
      document.imgform.S.style.display='none';
      document.imgform.T.style.display='';
      change_sel(TImg,TImg[document.imgform.T.selectedIndex],TDescr[document.imgform.T.selectedIndex]);
    break;
  }
}

function CheckFinishImgUpload(){
  if(document.rnew.checked && document.imgform.img.value==''){
    alert('Click broswe to select image for uploading!');
    return false;
  }
  return true;
}

function f_change_img(){
  if(document.imgform.img.value!=''){
    document.images.the_image.src=document.imgform.img.value;
  }
}
function f_new(){
  document.imgform.img_name.disabled=1;
  document.imgform.img.disabled=0;
  document.imgform.del_button.disabled=1;
    if(document.imgform.img.value=='') document.imgform.the_image.src='../images/no_image.gif';
    else {
      document.imgform.the_image.src=document.imgform.img.value;
    }
}
function f_ex(){
  document.imgform.img_name.disabled=0;
  document.imgform.img.disabled=1;
  document.imgform.the_image.src='../images/finish/'+document.imgform.img_name.value;
  document.imgform.del_button.disabled=0;
}
function select_new(){
  document.imgform.rex.checked=false;
  document.imgform.rnew.checked=true;
}
function select_ex(){
  document.imgform.rnew.checked=false;
  document.imgform.rex.checked=true;
}
function change_sel(x,n,d){
  if(n==''){
    select_new();
    f_new();
  }
  else{
    select_ex();
    for(i=0;i<x.length;i++){
      if(document.imgform.img_name.options[i].value==n) {
        document.imgform.img_name.options[i].selected=true;
        break;
      }else document.imgform.img_name.options[i].selected=false;
    }//for
    f_ex();
  }
  document.imgform.descr.value=d;
}
function bglight(f){
  f.style.background='#FFFAFF';
}
function bgdark(f){
  f.style.background='#EFE3F7';
}
