// $Id: script.js,v 1.3 2005/11/02 11:11:23 matveyev Exp $

function emailcheck(s) {
   str = new String(s);
   if ((str.indexOf("@", 0)!=-1)&&(str.indexOf(".", 0)!=-1)){
      i = str.length - str.lastIndexOf (".") - 1 ;
      if ((str.indexOf("@", 0)==0)||(str.indexOf(".", 0)==0)) return 0;
      if ( str.indexOf("@", 0)!=str.lastIndexOf("@",str.length)) return 0;
      if (i && (i <= 3)) return 1 ;
   }
   return 0 ;
}
function getctrl(name, doc) {
   var p,i,x; if (!doc) doc=document;
   if((p=name.indexOf("?"))>0&&parent.frames.length) {
      doc=parent.frames[name.substring(p+1)].document;
      name=nname.substring(0,p);
   }
   if(!(x=doc[name])&&doc.all) x=doc.all[name]; for (i=0;!x&&i<doc.forms.length;i++) x=doc.forms[i][name];
   for(i=0;!x&&doc.layers&&i<doc.layers.length;i++) x=getctrl(name,doc.layers[i].document);
   return x;
}
function winOpen(url,width,height,name,res) {
   if (width) w = ",width="+width; else w="";
   if (height) h = ",height="+height; else h="";
   if (!name) name="secondWindow";
   if (res) res=",resizable=yes "; else res='';
   return open(url, name,"menubar=no,scrollbars=yes,personalbar=no,titlebar=no,toolbar=no"+res+w+h);
}
function go(url) {
   //alert('window.location.href='+url);
   window.location.href=url;
   //document.open(url);
}
function insertInner(to,wh) {
   if (to.innerHtml) to.innerHtml=wh; else to.innerHTML=wh;
}
function dump(doc) {
   var tmp=doc+'\n';
   for (var i in doc) tmp+=i+', ';
   return tmp;
}
function checkAll(name, check, silent) {
   ctrl = getctrl(name);
   if (!ctrl) {
     if(!silent) alert('control '+name+' was not found!');
     return;
   }
   for (var i=0; i<ctrl.length; i++) {
      ctrl[i].checked=check;
   }
   ctrl.checked=check;
}
function getRValue(input, doc) {
   ctrl = getctrl(input, doc);
   if (!ctrl) alert('control '+input+' was not found!');
   for (var i=0; i<ctrl.length; i++) {
      if (ctrl[i].checked) {
         return ctrl[i].value;
      }
   }
   return -1;
}
function getCValue(input, unset, doc) {
   ctrl = getctrl(input, doc);
   if (!ctrl) alert('control '+input+' was not found!');
   ret='';
   for (var i=0; i<ctrl.length; i++) {
      if (ctrl[i].checked) {
         ret = ret+ctrl[i].value+';';
         if (unset) ctrl[i].checked=false;
      }
   }
   return ret;
}

function PopUpPic(pic,wi,hi) {
  wi=wi+20;
  hi=hi+30;
  openpopup = window.open(pic, "", "width="+wi+",height="+hi+",resizable=no");
  //openpopup = new window;
  //openpopup.document.write('<BODY bgcolor="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
  //alert(dump(openpopup.document));
  openpopup.focus();
}

function openConv(url) {
   ow = window.open(url, "conv_win","height=550,width=510,resizable=0,scrollbars=0");
   ow.focus();
}