// Determine browser.
/*
Rev 3.60  2007-06-24
 turnsig($$)
 intFromStr(s1) - extract the number from a string
 validation routine ret 0 if valid
 htHost: from location.href, essentially base_root, also defined is root
 mod vclose
 added closeAll
 mod openWin2 position
added flagSelectValue
fixed bug in getBase
fixed a bug in mkURL
log_string is global now
added top/left to openInfo
rename indexOf ->arIndexOf(item,list)
setcookie seems to add extra space at the end!! big screwy
*/
var vframe = self; //may need to generalize
var vers = navigator.appVersion;
var bver= Math.round(parseFloat(vers)*1000)/1000;
var agt=navigator.userAgent.toLowerCase();
var apn= navigator.appName;
var inp= []; //QS hash
var openwins= []; var hWin1= null;
window.loaded= false;
//----------------------------------//
// some constants:
var upload_contypes= new Array('txt','htm','html');
var upload_attachtypes= new Array('doc','rtf','pdf','ppt','swf');
var upload_imgtypes= new Array('gif','jpg','jpeg','png');

var isNN= 0
var isIE= apn.indexOf("Microsoft")>= 0 ||agt.indexOf("msie")>=0 ;
isGecko= (agt.indexOf('gecko') != -1);
isOpera= (agt.indexOf("opera")!=-1);
isNN= (apn.indexOf("Netscape")>=0);
isFOX= isNN&&agt.indexOf("mozilla")!=-1&&agt.indexOf("firefox")!=-1;
if(isFOX) isNN= false;

var isMinIE4 = (document.all) ? 1 : 0;
var isDOM2= document.getElementById && !isOpera;
var NN4 = false, NN6 = false, isMinNN6 = false;
br= new Object();

if(isFOX) {
 br.name="FOX"; br.vers=bver;
 if(vers.indexOf("Win") >=0)  os="WIN";
 else if (vers.indexOf("X11") >= 0) os="X11";
 else if (vers.indexOf("Mac") >= 0)  os="MAC";
 br.type="FOX"+bver;
 br.os = os;
} else if (isNN) {
 br.name="NS"; br.vers=bver;
 if(vers.indexOf("Win") >=0)  os="WIN";
 else if (vers.indexOf("X11") >= 0) os="X11";
 else if (vers.indexOf("Mac") >= 0)  os="MAC";
 br.type="NS"+bver;
 br.os = os;
 var isMinNN3 = isNN && bver >= 3 ? 1 : 0;
 var isMinNN4 = (isNN && bver >= 4) ? 1 : 0;
 if(isMinNN4) {
  if(document.getElementById) isMinNN6 = true;
  else NN4 = true;
 }
 NN3 = isMinNN3 && !isMinNN4
 NN6 = isMinNN6 && bver == 5;
}
else if(isIE) {
 br.name="MSIE";
 //br.vers= agt.substring((idx + 5),(idx + 6))
 //more precise
 vers1= vers.toLowerCase();
 a1= vers1.indexOf('msie');  a2= vers1.indexOf(';',a1);  b1= vers1.substring(a1+5,a2);
 br.vers= parseFloat(b1);
 if(agt.indexOf("windows") >= 0) os="WIN";
 br.os=os ;
 br.type="IE"+br.vers
 var isMinIE5 = (isMinIE4 && br.vers>=5.0);
 var IE4 = isMinIE4 && !isMinIE5;
 var isMinIE5_5=(isMinIE4 && br.vers>=5.5)?1:0;
}
else if(isGecko) {
 br.name='Gecko';
}
else if(isOpera) {

} else {
 br.name="UNK";
 br.vers="";
 br.os= "";
}

var imgs= document.images;
var t2000= 15823738;
//static globs
var ver3fix = false;
var origWidth,origHeight, mouseX=0, mouseY=0, pr_mouseX =0, pr_mouseY = 0;
var fullWin = null;
var vnames= null
var imgN = 0
var vimage = new Array();
var JSobjects = new Array()
var def_onmousemove = document.onmousemove
var JSlastIdx = -1;
var hInfo = null; //handle for chromeless windows
var busy = false; //semafor
var hMsg = null; //window to keep in focus
var bInit = false;

//actions
if(isMinNN4) document.onmousemove = getMousePosition;
if(isMinIE4) document.onmousemove = getMousePosition;
if (NN4) document.captureEvents(Event.MOUSEMOVE)

function push2Top() {
  if (self.parent.frames.length != 0)
  top.location.href = location.href;
}

function checkMe() {
  nn4reload(); setTimeout('checkMe()',500)
}

function allReload(){
 if(isMinNN4&&origWidth==window.innerWidth&&origHeight==window.innerHeight)return;
 if(isMinIE4)setTimeout('window.location.href = window.location.href',2000);
 else window.location.href=window.location.href;
 return false;
}

function nn4reload(){
  if(!NN4) return false;
  if(origWidth==window.innerWidth&&origHeight==window.innerHeight) return false;
  origWidth=window.innerWidth; origHeight=window.innerHeight;
  window.location.reload();
  return true;
}

var once= 0
function getMousePosition_old(e){
 if(isMinNN4){mouseX=e.pageX;mouseY=e.pageY;}
 else if(isMinIE4){ mouseX=window.event.clientX; mouseY=window.event.clientY;}
}

function getMousePosition(e){
 if(!e) e= window.event;
 mouseX= e.pageX || (e.clientX +
      (document.documentElement.scrollLeft || document.body.scrollLeft));
 mouseY= e.pageY || (e.clientY +
      (document.documentElement.scrollTop || document.body.scrollTop));
}

function getSessDome() {
 var dome= inp['dome'];
 if(typeof(dome)=='string' && dome.length() > 0) return dome;
 var c1= new Cookie(document,"vfx1056","","/")
 c1.load()
 dome= c1['dome'];
 if(!dome) dome='main';
 return dome;
}
//----------------->
function gotoname(name) {
 if(name.indexOf('#')==0) name= name.substring(1);
 loc= location.href; if((pos=loc.indexOf('#'))>0) loc= loc.substring(0,pos)
 location.hash= '#'+name
}

log_li= null;
//just to make it global for possible appending other stuff
var log_string="je="+navigator.javaEnabled()+"&sw="+screen.width+"&sh="+screen.height;

function sendit(gate) { 
// report environment - user history
 if (NN4) {
  document.cookie=1;
  //log_string is glob
  log_string+="&sd="+screen.pixelDepth+"&co="+
    (document.cookie?true:false)+"&ww="+innerWidth+"&wh="+innerHeight;
  log_np=navigator.plugins;
  for (log_i=log_np.length-1; log_i>=0; --log_i) {
   log_string+="&p=";
   log_string+=escape(log_np[log_i].name);
  }
 } else if(isMinIE4) {
  log_string+="&sd="+  screen.colorDepth+"&co="+ navigator.cookieEnabled+"&ww="+
  document.body.clientWidth+"&wh="+ document.body.clientHeight+
  "";

 } else if(isMinNN6) {
  log_string+="&sd="+  screen.colorDepth+"&co="+ navigator.cookieEnabled+"&ww="+
  window.innerWidth+"&wh="+ window.innerHeight+  "";
 }
 else {log_string+="&i=do_not_know";

 }
 log_string+="&sfl="+UseFlash+"&brn="+br.name+"&brtp="+br.type+"&os="+br.os;
 var to= mkURL(gate)+'?'+log_string
 log_li = new Image(); log_li.src = to;
}
//-------------->
function getCookie(strName) {
 var strCookie = document.cookie;
 if(strCookie.length == 0) return '';
 var strValue = '';
 var intStart = strCookie.indexOf(strName + '=');
 if(intStart > -1) {
 intStart += strName.length + 1;
 var intEnd = strCookie.indexOf(';', intStart);
 if(intEnd == -1) intEnd = strCookie.length;
  strValue = strCookie.substring(intStart, intEnd);
 }
 return  unescape(strValue);
}

function resetCookie() {
 document.cookie='; expires=Wednesday, 31-Dec-80 10:12:59 GMT; path=/';
}

function setCookie(name, value, path, expire) {
 one_hour= 3600*1000;
 if( typeof(expire) == 'undefined')  {// temp solution
   expire= (new Date(new Date().getTime()+24*30*one_hour)).toGMTString();
 } else { expire= trim(expire);
   date= new Date(); tm= date.getTime();
   if(expire.indexOf('+')==0) {n= expire.substring(1); tm+=one_hour*n;}
   if(expire.indexOf('-')==0) {n= expire.substring(1); tm-= one_hour*n;}
   date.setTime(tm); expire= date.toGMTString();
 }
 if( typeof(path) == 'undefined' || path == '') path ='/';

 var ck = name + '=' + escape(value);
 //ck+= (document.location.hostname == domain ? (';domain='+domain) : '')
 ck+= '; path='+path  + ';expires=' + expire;
 ck= trim(ck);
 //alert("setting cookie="+ck)
 document.cookie=ck;
}

function setCookie2(name,value,expires,path,domain,secure) {
 document.cookie = name + "=" +escape(value) +
 ( (expires) ? ";expires=" + expires.toGMTString() : "") +
   ( (path) ? ";path=" + path : "") +
   ( (domain) ? ";domain=" + domain : "") +
   ( (secure) ? ";secure" : "");
}

function deleteCookie(strName) {
	var dtmExp = new Date();
	dtmExp.setTime(dtmExp.getTime() - 3600000); // 1 hr ago
	setCookie(strName, '', '/', dtmExp.toGMTString())
}

function doWeKnowYou() {
  if(document.cookie.indexOf(ourkey+'=') != -1 ) return 1;
  else return 0;;
}

function logOffUser() {
 deleteCookie('user');
}
//------  Cookie object
function Cookie(doc,name,hours,path,domain,secure) {
 this.$document= doc; this.$name=name; this.$path=path;
 this.$expire= null; this.$domain= null; this.$secure= false;
 if(hours) this.$expire= new Date(new Date().getTime()+hours*3600000);
 else this.$expire = (new Date(2302,12,31));

 if(path) this.$path= path;
 if(domain) this.$domain= domain; else this.$domain= document.domain;
 if(secure) this.$secure= true;
}

//pieces will be attached to the Cookie instance and we do not know their names in advance
_Cookie_store = function() {
 var totval=''; var cookie;
 for (var prop in this) {
  if(prop.charAt(0) == '$' || ((typeof this[prop])=='function')) continue
  if(totval!="") totval+='&';
  totval+=prop+':'+escape(this[prop]);
 }

 cookie= this.$name+'='+totval;
 if(this.$expire) cookie+='; expires='+this.$expire.toGMTString();
 if(this.$path) cookie+='; path='+this.$path
 if(this.$domain) cookie+='; domain='+this.$domain
 if(this.$secure) cookie+='; secure';
 this.$document.cookie= cookie;
}

_Cookie_load= function() {
 var allcookies= this.$document.cookie;
 if(allcookies=='') return false
 var strValue = '';
 var intStart = allcookies.indexOf(this.$name+'=');
 if(intStart==-1) return false;
 intStart += this.$name.length + 1;
 var intEnd = allcookies.indexOf(';', intStart);
 if(intEnd == -1) intEnd = allcookies.length;
 var cookieval= allcookies.substring(intStart, intEnd);
 var a=cookieval.split('&');
 for(var ix=0;ix<a.length;ix++) a[ix]=a[ix].split(':');
 for(var ix=0;ix<a.length;ix++) this[a[ix][0]] = unescape(a[ix][1]);
 return true
}

_Cookie_clear= function() {
 for (var prop in this) {
  if(prop.charAt(0) == '$' || ((typeof this[prop])=='function')) continue
  this[prop]='';
 }
}

_Cookie_remove = function() {
 var cookie = this.$name+'=';
 if(this.$path) cookie+="; path="+this.$path
 if(this.$domain) cookie+="; domain="+this.$domain
 cookie+="; expires=Fri, 02-Jan-1970 00:00:00 GMT";
 this.$document.cookie= cookie
}

new Cookie();
Cookie.prototype.store= _Cookie_store
Cookie.prototype.load= _Cookie_load
Cookie.prototype.remove= _Cookie_remove
Cookie.prototype.clear= _Cookie_clear
//---  end cookie 

function getQSParam(name) {
 var value = '';
 var strQS = document.location.search;
 var intStart = strQS.indexOf(name + '=');
 if(intStart != -1) {
  var intEnd = strQS.indexOf('&', intStart);
  if(intEnd == -1) intEnd = strQS.length;
  value = strQS.substring(intStart + name.length + 1, intEnd);
 }
 return unescape(value);
}

function addToQS(strURL, name, value) {
	var c=(strURL.indexOf('?')==-1)?'?':'&';
 return strURL+c+name+'='+escape(value);
}
//============== operational stuff ======================
function make2Array(m,n) {
 this.length=n*m;
  for (var i=1; i<=m; i++) {
    this[i]= new Array(n);
 }
 return this;
}
//#-------------->
function getBase(url) {
 var base;
 var pos= url.indexOf('http://',0);  if(pos<0) pos= 0; else pos=7;
 var pos1= url.indexOf('/',pos);
 var pos2= url.indexOf('/',pos1+1);
 if(pos2< 0 || pos2== url.length -1) base= ""; else {base= url.substring(pos1+1,pos2-pos1-1)}
 return base;
}
//#------------------>
function getExt(s1) {
 if(s1.indexOf("\\")>=0) var sep="\\"; else sep="/";
 var ext,err=0;
 while(1) {
  p1= s1.lastIndexOf(sep); 
  if(p1<0) { err= 101; break;} //error
  s2= s1.substring(p1+1);
  p2= s2.lastIndexOf('.'); 
  if(p2<0) {err=102; break;}
  ext= s2.substring(p2+1);
  break;
 }
 if(err>0) return ''; else return ext;
}
//#--------
function go(page) {
 if(trim(page).length == 0) return
 page= mkURL(page);
 var test= page;
 if(page.charAt(0)=='/') test= "http://"+ location.host+ page; //just for testing
 //alert("go:test="+test+" loc="+location.href);
 if(location.href== test && (page.indexOf(".htm")>=0 || page.indexOf(".php")>=0)) {
  alert("You are already on this page");
  return;
 }
 if(page.indexOf('http:')>=0) {
   var sign = document.forms['msg'];
   if(typeof(sign)=='undefined') sign= document.forms['sign']
   if(typeof(sign)=='object' && typeof(sign.sid)=='object') mySid = sign.sid.value;
   else mySid = getQSParam('sid')
   if(!isEmpty(mySid)) page= addToQS(page, 'sid', mySid)
 }
 //alert("go is ready for::"+page)
 location.href= page;
}
//#-------------->
function vreplace(url) {
 url= mkURL(url)
 if(isMinIE4)  window.navigate(url)
 else if(isMinNN3)  window.location.replace(url);
 else location.href=url;
}

//--- window ops 
function vclose(url) {
 wo= window.opener;
 ru= url? url : htHost;
 if(wo && !wo.closed) { window.close(); if(window.focus) wo.focus(); }
 else location.href=ru;
}

function recommend() { openInfo(350,500,'recommend.htm');}

function openNew(loc) {
  fullWin = null;
  var w0 = screen.width-10;
  var winpar="toolbar=1,location=1,directories=0,status=1,menubar=1,scrollbars=1,";
  winpar+="resizable=1,width="+w0+",height=450";
  fullWin=window.open(loc,"newbrowser",winpar);
  if(fullWin!=null) {
   if(fullWin.opener==null) fullWin.opener=top;
   fullWin.opener.name="browser";
   if(window.focus) fullWin.focus();
  }
  if(window.onfocus) fullWin.focus();
  openwins['newbrowser']= fullWin;
}

// this is temp plug to keep existing code alive. We replace it w/ openWin
function MM_openBrWindow(theURL,winName,features) { //v1.2
  var hWin1= window.open(theURL,winName,features);
  openwins[winName]= hWin1;
}

function openWin2(W,H,loc,fname,hasScroll,hasMenu,resize) {
  //loc is full URL
  var W1 = ((W<0) ? 640 : W)
  var H1 = ((H<0) ? 450 : H)
  if(typeof(fname) == "undefined") fname = ""
  if(typeof(hasScroll) == "undefined") hasScroll=0;
  if(hasScroll != 0) hasScroll = 1;
  if(!hasScroll) scrollV='no'; else scrollV='yes'; //newer vers do not take 'auto'
  if(typeof(hasMenu) == "undefined") hasMenu = 0;
  if(hasMenu != 0) hasMenu = 1;
  //place at the center
  var sW= screen.width; if(!sW) sW= 800;  xc= Math.floor((sW-W)/2);
  var sH= screen.height; if(!sH) sH= 600;  yc= Math.floor((sH-H)/2);
  x0= Math.min(xc,100); 
  if(yc<75) y0= 5; else y0= yc;
  var winpar="top="+y0+",left="+x0+",toolbar=0,location=0,directories=0,status=0,menubar="+hasMenu+
",scrollbars="+scrollV+",titlebar=no";
 winpar+=",resizable="+resize+",width=" + W1 + ",height=" +H1;

 hWin1=window.open(loc,fname,winpar);
 if(hWin1!=null) {
  if(hWin1.opener==null) hWin1.opener=top;
  hWin1.opener.name="browser";
  if(window.focus) hWin1.focus();
  // for NN
  if(window.moveTo && br.name!='MSIE') hWin1.moveTo(x0,y0);
  openwins[fname]= hWin1;
 }
}
//------------->
function openWin(W,H,loc,fname,hasScroll,hasMenu) {
  openWin2(W,H,loc,fname,hasScroll,hasMenu,0);
}

function openInfo(W,H,doc) {
 var W1 = ((W<=0) ? 1280 : W) //fix that to use screen
 var H1 = ((H<=0) ? 968 : H)
 var left= Math.floor((screen.width-W1)/2);
 var top= Math.floor((screen.height-H1)/2);
 var winpar="toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,titlebar=0,";
 winpar += "width=" + W1 + ",height=" +H1+",top="+top+",left="+left;
 var loc= mkURL(doc);
 hInfo= openwins['info1'];
 if(hInfo != null && !hInfo.closed) hInfo.close(); hInfo= null;
 hInfo=window.open(loc,"info1",winpar);
 if(hInfo!=null) {
  if(hInfo.opener==null) hInfo.opener=top;
  hInfo.opener.name="browser";
  if(window.onfocus) hInfo.focus();
 }
 openwins['info1']= hInfo;
}

function message(W,H,msg,swtch) {
  // semantics: W,H - client sizes, swtch - staytime in sec
  var  t= Math.min(60,Math.max(swtch,12));
  t *=1000; H+=10;
  if(W<=0) W= 280; if(H<=0) H= 200;
  var x0= 280; var y0= 260;
  var tw="<html><head><title>Message</title><META content=\"text/html; charset=windows-1251\" http-equiv=Content-Type></head><body bgcolor=#e5e5e5 onload=setTimeout('window.close(self)',";
  tw+=t + ")><center>";
  s1="<a href=# onclick='window.close();'><font color=#111111 size=2>Close when "; s1+="ready</a></font>";
  tw+="<table width=100% border=0><tr><td valign=center><font face=\"Vedana,Tahoma,Arial\" color=#444444 size=2><b>"+msg+
"</td></tr></table>"+s1+"</body></html>";
  var winpar="toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,titlebar=no,resizable=0,";
  winpar+= attrTo(x0,y0);
  winpar += "width="+W+",height="+H;
  //var loc=mkURL("/etc/blank.htm"); not in use today
  hMsg=window.open("","message",winpar);
  hMsg.document.open();
  hMsg.document.write(tw);
  hMsg.document.close();
  focusOn(hMsg);
  return hMsg;
}

function vxopw(url) { //open in full window popup
 var sW= screen.width; if(!sW) sW= 800; 
 var sH= screen.height; if(!sH) sH= 600; 
 openWin2(sW,sH,url,'win1',1,0,1);
}
//---------------->
function closeAll() {
 for(name in openwins) {var w=openwins[name]; if(!w.closed) w.close(); }
}
//---------------->
function attrTo(x0,y0) {
 if(isMinIE4) var out="left="+x0+",top="+y0+",";
 if(isMinNN4) var out="screenX="+x0+",screenY="+y0+",";
 return out;
}

squash= function() {
 var tmp = ""+ this.toString();
 var end = this.length;
 if(!end) return "";
 var ret= "";
 for(i=0;i<end;i++) {var c= this.charAt(i); if(c!=' ' && c!='\t' && c!='\n') ret+=c; }
 return ret;
}

new String();
String.prototype.squash= squash;

function trim(s) {
 var tmp = ""+s;
 var start = 0;
 var end = tmp.length;
 if (tmp == "") return tmp;
 while (tmp.substring(start, start + 1) == " ") start++;
 if (start >= end) return("");
 while (tmp.substring(end - 1, end) == " ") end--;
 return tmp.substring(start, end)
}

function arIndexOf(item, list) {
 var i, found;
 found = -1;
 for (i = 0; i < list.length; i++) {
  if (trim(""+item) == list[i]) {found = i; break;}
 }
 return (found);
}

function p(s) {document.writeln(s);}

function preloadImages() {//should become obsolete
  var s;
  for(i=0;i<imgN;i++) {
    vimage[i]= new Array(2);
    if((s=trim(vnames[i*2+0])) != "") {vimage[i][0]= new Image(); vimage[i][0].src = mkURL(s);}
    if((s=trim(vnames[i*2+1])) != "") {vimage[i][1]= new Image(); vimage[i][1].src = mkURL(s); }
  }
}

function sw(idx,opt) { //should become obsolete in favour of sw2
 if(!bInit || idx<0 || idx >= imgN) return true;
 if(!document.images) return true;
	opt= Math.min(opt, vimage[idx].length);
	var s="a"+idx;
	document.images[s].src= vimage[idx][opt].src;
	return true;
}

function imgTicker(cnt, names, imgs) { //should become obsolete in favour of sw2
 if(!document.images) return true;
 if(typeof(names)!= 'object' || typeof(imgs) != 'object') return;
 if(names.length<2 || imgs.length<2) return
 // too bad, everything is OK
 cnt++; if(cnt>=imgs.length) cnt= 0;
 var j= cnt;
 for(i=0; i<  names.length; i++) {
  document.images[names[i]].src= imgs[j].src;
  j++; if(j>=imgs.length) j= 0;
 }
 return cnt;
}

function preloadImages2(ar1,ar2,name) {
 var L= ar1.length; if(L==0) return
 if('object' != typeof(ar2)) ar2= new Array();
 ar2[name]= new Array();
 var s;
 for(ix=0;ix<L;ix++) {
  if((s=trim(ar1[ix]))!= "") {ar2[name][ix]= new Image(); ar2[name][ix].src = mkURL(s);
  }
 }
}

function sw2(n,name,ix) { // images[name], vimage.name)array), index into the latter
 //if(!bInit || ix<0 || typeof(vimage[name])=='undefined') return false;
 if(ix<0 || 'undefined'==typeof(vimage[name])) return true;

 if(!document.images) return true;
 var imgN= vimage[name].length; if(ix>=imgN) ix= 0;
 var src= vimage[name][ix].src;
 // alert("sw2: new src="+src);
 document.images[n].src= src;
 return true;
}

function turnsig(n,how) {
 var which='q'+n; 
 var img= document.images[which];
 //if(typeof(img)!='object') alert("error with "+n);
 if(typeof(img)!='object') return false;

 switch(how) {
  case 0: img.src= soff; break;
  case 1: img.src= son; break;
  default: break;
 }
 return true;
}

function MM_findObj(n, d) { //v4.0
 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 && document.getElementById) x=document.getElementById(n); return x;
}

var tFocus = null

/*
function focusOn(h) { // not usable - jerky
  if( typeof h != "object" || h == null || !window.focus ) return
  hFocus = h;
  tFocus = setTimeout('keepFocus()',500);
}

function keepFocus() { // stop this
 if(hFocus == null || hFocus.closed) { focusOff(); return; }
 hFocus.focus();
 tFocus = setTimeout('keepFocus()',500);
}

function focusOff() {
  clearTimeout(tFocus);
  hFocus = null;
}
*/
function isEmpty(v) {
  r = false;
  if('undefined'==typeof(v)) return true;
  v1= v.replace(/&nbsp;/g,"");
  if(trim(v1)== '') r= true;
  return r;
}

function jointoURL(a1,a2){var s="";
 //create encoded query string of the 2 arrays
 var l= Math.min(a1.length,a2.length);
 for(var i=0;i<l;i++) s+=escape(a1[i])+'='+escape(a2[i])+'&';
 s= s.substring(0,s.length-1); return s;
}
//-------------->
function loadQS() {
 var q= window.location.search.substring(1);
 if(typeof(q)!='undefined') {
  mapQS(q,inp);
  if(typeof(f=document.forms['msg'])!='undefined' && !f.sid.value && inp['sid']) f.sid.value=inp['sid'];
 }
}
//-------------->
function mkURL(str) {
 var u = trim(str);
 var ap =1;
 if(typeof(path)=='undefined') path="";
 if(u.indexOf('http://') == 0 || u.indexOf('ftp://') == 0 || u.indexOf('mailto:') == 0) ap=0;
 if(!ap) return u;
 if(u.charAt(0) == '/') return (root+u.substring(1));
 // should not depend on path  assignment
 else u = htHost+path+u; //relative to subdomain host
 return u;
}
//-------------->
function mapQS(s1,ph){
 var t = s1.split("&");
 if(t.length == 0) return;
 for(var i=0; i< t.length; i++) {
   var e= t[i].split("=");
   if(e.length< 2) { 
    ph[t[i]] = '';
   } else {
   e1 = e.shift(); e2 = e.join('=');
   e1 = unescape(e1); e2 = unescape(e2);
   ph[e1] = e2;
  }
 }
}

function unmapQS(ph) {
 var s1= '';
 for(k in ph) s1= addToQS(s1,k,ph[k]);
 return  s1;
}

function random(n1,n2) {
  var n = n2 - n1;
  if(n<0) {n= -n; n1 = n2;}
  rand.seed = (rand.seed*rand.a+rand.c)%rand.m
  var r = rand.seed/rand.m; //in 0->1 interval
  var R = Math.floor((n+1)*r); if(R==n+1) R--;
  return (R+n1);
}

rand= new Object()
rand.m = 714025; rand.a = 4096;  rand.c = 150889;
rand.seed = (new Date()).getTime()%rand.m;

//exists in 1.2
function push() {
 var args= push.arguments
 var L= args.length;  if(L==0) return null
 var a= args[0];  if(L==1) return a
 if('object' != typeof(a)) return null
 var L1= a.length
 for(ix=1;ix<L;ix++) a[L1+ix-1]= args[ix]
 return a;
}
//-------------------->
function setSessDome(dome) {
 if(!dome) return
 var c1= new Cookie(document,"vfx1056","","/")
 c1.load()
 c1['dome']= dome;
 c1.store()
}
//-------------->
function chkAgreed(val) {
 var hours= 8760;
 var c1= new Cookie(document,"vfx1056",hours,"/")
 c1.load()
 if(!val) val= 0;
 if(val) c1['agreed']= val;
 if(val>0) closeAll(); // or just info1 window
 else {
  location.href= mkURL("/etc/exit.php?why=notagreed");
 }
}
// Flash related
function hookFStoIE(id) {
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1
 && navigator.userAgent.indexOf("Windows") != -1
 && navigator.userAgent.indexOf("Windows 3.1") == -1 && UseFlash)
 {
  document.write('<SCRIPT LANGUAGE=VBScript\>\n');
  document.write('on error resume next \n');
  document.write('Sub '+id+'_FSCommand(ByVal command, ByVal args)\n');
  document.write('  call '+id+'_DoFSCommand(command, args)\n');
  document.write('end sub\n');
  document.write('</SCRIPT\> \n');
 }
}

function asDate(y,m,d) {
 var time;
 if(typeof(d)=='undefined') time= new Date();
 else time= new Date(y,m-1,d);
 var lmonth=months[time.getMonth()][0];
 var date= time.getDate();
 var year= time.getYear();
 if (year < 2000)  year = year + 1900;
 return " "+ lmonth + " "+date + ", " + year+" ";
}
// construct func calls
/*   sample
var sFunc= 'checkme';

function checkme(a1,a2) {
 alert("here "+a1);
}
*/
//---------->
function makeFcall() {
 //makeFcall(sFunc,'bobby','terry');
 var args= makeFcall.arguments; if(args.length==0) return '';
 f= args[0];  var out=f+'(';  var fst= 1;
 for(var i=1; i<args.length; i++) {
  if(fst) fst=0; else out+=",";
  out+="'"+args[i]+"'";
 }
 out+=");";
 ret= eval(out);
 return ret;
}

// ---     form work
function createSelectOptions(select,opsarr,from) {
 // opsarr legend: text, value, default(?) selected 
 // from: index to start from
 //opsarr->> text, value,curdef,curSel
 if(!from) from= 0;
 select.options.length= from;
 if(select==null || typeof(opsarr)!='object'|| opsarr.length<1) return 0
 alreadyDef= 0; alreadySel= 0;
 for(var i=0;i< opsarr.length;i++) {
  curDef= alreadyDef>0? 0 : opsarr[i][2];
  curSel= alreadySel>0? 0 : opsarr[i][3];
  if(alreadyDef==0) alreadyDef= curDef; //make sure only one selected
  if(alreadySel==0) alreadySel= curSel;
  //new Option(text,value,defaultSelected, selected
  select.options[from++]= new Option(opsarr[i][0],opsarr[i][1],curDef,curSel);
 }
 return opsarr.length;
}

function intFromStr(s1) {
 if(isEmpty(s1)) return '';
 var s2='',ch;
 s1=''+s1;
 for(var i=0;i<s1.length;i++) { 
  if((ch=s1.charAt(i))+0>=0 && ch<=9) s2+=ch;
 }
 return s2;
}

var mondays= new Array(31,28,31,30,31,30,31,31,30,31,30,31);
/*  sample code
reloadWith(hash)
 var u= location.href
 for(k in hash) u= addToQS(u,k,hash[k]);
 vreplace(u);
}
// global array where F1 is a specific  ind, can be generated with a PHP code
var setValsF1= {x1:[1,3,4],x2:[1],x2:[2],x3:[1,3]}
*/

function getValue(obj){
// gets first non-zero value of radio/checkboxes
 if(!obj) return false;
 n=obj.length;
 if(isNaN(obj.length)){
  //	alert(n);
  if(obj.checked) return obj.value;
 }
 else{
  for(a=0;a<n;a++){
   if(obj[a].checked) return obj[a].value;
  }
 }
 return false;
}// function getValue(obj)

function select_change(o) {
 i= o.selectedIndex; if(i==0) return false; v= o.options[i].value; top.location.href= v;return false;
}
/*
function setCookie(name,value,expires){document.cookie=name+"="+escape(value)+"; expires="+expires.toGMTString()+"; path=/";}

function deleteCookie(name){var expdate=new Date();
  expdate.setTime(expdate.getTime()-(86400*1000*1));
  setCookie(name,"",expdate);
}

function goUrl(Selected) {
 var newURL = Selected.options[Selected.selectedIndex].value ;
 if (newURL!=" ") {
			document.location.href = newURL;
 }
}
<SELECT 
      style="VERTICAL-ALIGN: middle; WIDTH: 180px; HEIGHT: 22px" 
      onchange=goUrl(this) name=Url><OPTION value=/1,,,00.html?gusrc=gpd 
        selected>Guardian Unlimited home<OPTION 
*/

