﻿
function rnd(f,t){
	var a=0,b=0,c=0;
	if(f!=t)with(Math){
		a=min(f,t);
		b=max(f,t);
		c=b-a;
		c=floor(c*random()*pow(10,floor(4*random()))*10000)%(c+1)+a
	}else c=f;
	return(c)
}

function right(t,l){
	return t.substring(t.length-l,t.length)
}

function hex(d){
	var hs="0123456789ABCDEF";
	var l=d%16;
	var h=(d-l)/16;
	return (""+hs.charAt(h)+hs.charAt(l))
}

function isIE(){
	return (navigator.appName=="Microsoft Internet Explorer")
}

function FindObj(n,d){
	try{
		if(typeof(n)=="string"){
			d=d?d.document:document;
			return d.getElementById(n)
		}else{
			return n;
		}
	}catch(e){
		return null
	}
}

function URLEncode(u){
	if(typeof(encodeURIComponent)=="function"){
		return encodeURIComponent(u);
	}else{
		return u;
	}
}


function CopyCode(o){
	if(isIE()){
		var r=document.body.createTextRange();
		r.moveToElementText(FindObj(o));
		r.scrollIntoView();
		r.select();
		r.execCommand("Copy");
		r.collapse(false);
		//alert("Contents highlighted and copied to clipboard!");
	}else{
		FindObj(o).select();
		FindObj(o).focus();
		alert("Please press Ctrl+C to copy.")
	}
	return false
}

var aT=0,aW=0,aH=0,aL=null;aTo=0,aWo=0;
function aInit(){
	if(!aL)aL=FindObj("aL").style;
	aT = (document.compatMode.toLowerCase()=="css1compat")?document.documentElement.scrollTop:document.body.scrollTop;
	aW = document.body.offsetWidth;
	if(aT!=aTo){
		if(aT+600<aH)aL.top=aT+"px";
		aTo=aT;
	}
	if(aW!=aWo){
		aL.display=(aW>900)?"block":"none";
		aWo=aW;
		aH=document.body.offsetHeight;
	}
	window.setTimeout("aInit()", 100);
}

var oForm;
function FormReset(v){
	var o=document.getElementsByTagName("input");
	for(i=0; i<o.length; i++) {
		if(o[i].type=="submit"){
			o[i].disabled=(v?"":"disabled");
		}
	}
}
function FormSubmit(o){
	FormReset(0);
	oForm=o;
	return 1;
}
function FormGo(u,m){
	var s="",i=u.indexOf("#");
	if(i!=-1){
		s=u.substring(i,u.length);
		u=u.substring(0,i);
	}
	u+=((u.indexOf("?")==-1)?"?":"&")+Math.random()+".arcog."+Math.random();
	top.location.replace(u+s);
	if(m)alert(m);
}
function FormError(o,e){
	FormReset(1);
	alert(e);
	if(o!="XXX"){
		try{
			if(oForm){
				oForm.item(o).focus()
			}else{
				FindObj(o).focus()
			}
		}catch(e){}
	}
}

//document.domain = "arcog.com";
