

function updateParent(parent,child,mode)
{
	var key = parent.options[parent.options.selectedIndex].value;
	
	if( JSBASE.isNumeric( key ) )
	{
		JSBASE.fetchUrl( processor+"?mode="+mode+"&key="+key , function( request ) {
			
			updateChild( request , child );
			
		} );
	}
}

function updateChild( request , child ) 
{
	if( request.readyState == 4 )
	{
		if( request.responseText != "" )
		{
			if( child.disabled ) child.disabled = false;
			child.options.length = 0;

			var data = request.responseText.split("\n");
			var option = 0;
			
			child.options[option] = new Option( "Select" , "null" );
			option++;		

			for( i = 0; i < data.length; i++ )
			{
				var division = data[i].split("|");
				child.options[option] = new Option( division[1] , division[0] );
				option++;				
			}
		}
	}
}

function radioOption( styleName , selectedId , type ) {
	var elements = document.getElementsByTagName("*");
	if( type ) type.value = selectedId;
	for( var i = 0; i < elements.length; i++ ) {
		if( elements[i].className == styleName ) {
			if( elements[i].id != selectedId ) elements[i].style.display = "none";
			else elements[i].style.display = "block";
		} 
	}
}

function mousePos(e) {

	var posx = 0;
	var posy = 0;

	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	return[posx,posy];
}

function showMessage(e) {

	var targ;
	
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;

	var messagePos = mousePos(e);
	
	if( JSBASE.isIe() ) {
		var selects = document.getElementsByTagName('select');
		for( e = 0; e < selects.length; e++ ) {
			selects[e].style.visibility = 'hidden';	
		}
	}
	
	openObject = document.createElement("div");
		
	openObject.className = "helpmessage";
	openObject.style.display = "block";
	
	openObject.style.top = ( yoffset + messagePos[1] )+"px";
	openObject.style.left = ( xoffset + messagePos[0] )+"px";
	
	openObject.appendChild( document.createTextNode(targ.title) );
	
	targ.title = "";
	
	JSBASE.insertIt( openObject , targ );
	
	fadeIn( openObject , 0 , 100 , 30 );
}

function fadeIn( el , start , end , delay )
{
	if( !elementOpacity ) {
		elementOpacity = parseFloat( start ); // make int 0.0
		JSBASE.setStyle( el , 'opacity' , ( elementOpacity / 100 ) );
	}
	
	elementOpacity += 10;
	JSBASE.setStyle( el , 'opacity' , ( elementOpacity / 100 ) );
		
	if( elementOpacity != end ) {	
		setTimeout( function() { 
			fadeIn( el , start , end , delay ); 
		} , delay );
	}
	
	if( elementOpacity == end ) {
		elementOpacity = null;
	}
}

function hideMessage(e) 
{
	var targ;
	
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;
	
	if( JSBASE.isIe() ) {
		var selects = document.getElementsByTagName('select');
		for( e = 0; e < selects.length; e++ ) {
			selects[e].style.visibility = 'visible';	
		}
	}
	
	targ.title = openObject.innerHTML;
	JSBASE.removeIt( openObject );
}

function repositionMessage(e)
{
	var targ;
	
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;

	var messagePos = mousePos(e);

	openObject.style.top = ( yoffset + messagePos[1] )+"px";
	openObject.style.left = ( xoffset + messagePos[0] )+"px";
}



