// Different DOM s are used by different browsers
	// we handle variations by choosing 
	// between different supported implementations
	// of getID
var debug_dom = false;
function d_dbug(m){
	if(debug_dom) alert("debugging :"+m);
}

	var getObjById;
	var isIE;

	// macromedias findobj code
	// covers all bases - but does so every time you lookup an id
	// we therfore use it as a last resort for old browsers

	// note this does an almost exhaustive search of the id space ...
	// every time you look up an object by id
	// if you were going to look up a large number of objects
	// it would be better to get them ALL 1st & pre-load a cache
	// on which you hash [ your own - getElelemById ] to find your elem 

	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;
	}

	// (1) MSDOM scriptable support for id property
	//     IE4+
	// -   note some IE support WWWC DOM however they are still 
	//     better with uSoft's DOM

	if(!getObjById && document.all){
	isIE=true;
        getObjById = function (ID){ return document.all[ID]; };
		// "getID will use IE4+ doc.all";
	}

	// (2) WWWC DOM
	// -

	if(!getObjById && document.getElementById){
        getObjById = function (ID){ return document.getElementById(ID); };
		// "getID will use the WWC DOM";
	}
		
		
	// (3) NN4 layers & other level 0 DOMs 
	
	if(!getObjById){ // try everything else 
                    // we use macromedias DW findObj code
                    // .... as alast resort :-( helper function
        getObjById = function (ID){ return MM_findObj(ID, document); };
		// "getID will use NN4 / DOM level 0 [MM's findObj]";
	} // end if(NN layers)

	function getID(ID){
		var el = getObjById(ID);
		if(!el) d_dbug("No element for getID("+ID+")" );
		return el;
	}

	function setEl(ID, val){
		var el = getID(ID);
		if(el){ el.value = val; }

	}

	function getEl(ID){
		var el = getID(ID);
		if(el) return el.value;
		return null;
	}

	function isSetID(ID){
        var val = getEl(ID);
	return (val == null  || val=='' || val.length == 0 ) ? false : true;
	}

	function isNonZeroID(ID){
		var val = getEl(ID);
		var n   = Number(val);
		return n!=0;
	}
	
	function getObject(ID){
		var theObj = getID(ID);
		theObj = theObj.style ;
		return theObj;
	}

	function shiftTo(obj, x, y){
		var theObj = getObject(obj);
		if(theObj){
			var units = (typeof theObj.left == 'string') ? 
					"px" : "px";
			theObj.left = x + units;
			theObj.top  = y + units;
		} 
		window.moveTo(0,0);
	}
	
	function getSelection(id){
		var chooser = getID(id);
		alert(id+' = '+chooser.selectedIndex);
		return chooser.options[chooser.selectedIndex].value;
	}

	function setSelection(id, val){
		var chooser = getID(id);
		for(var i=0; i<chooser.options.length;i++)
			if(val==chooser.options[i].value)
				chooser.options[i].selected = true;
	}
	function getSelectionIdx(id){
		var chooser = getID(id);
		//alert(id+' = '+chooser.selectedIndex);
		return chooser ? chooser.selectedIndex : 0;
	}

	function setSelectionIdx(id, val){
		var chooser = getID(id);
		if(!chooser) return;
		for(var i=0; i<chooser.options.length;i++)
			if(val==i)
				chooser.options[i].selected = true;
	}
						
		

