// JavaScript Document
<!--
var $ajax;

function MODIFIER( $url, $target, $targettype, $parameters ) {
  $ajax = XMLOBJECT();

  if( $ajax == null ) {
    alert( 'Browser does not support HTTP Request' );
	
	return;
  }
  
  var $submit = SUBMISSION();

  var $url = $url + $parameters + '&' + $submit + '&sid=' + Math.random();

  $ajax.onreadystatechange = function() {
	TARGET( $target, $targettype );
  }
  
  $ajax.open( 'GET', $url, true );
  $ajax.send( null );
}

function TARGET( $target, $targettype ) {
  if( $ajax.readyState == 1 ) {
    document.getElementById( 'msg' ).innerHTML = '<p><img src="common/images/timer.gif" alt="" /> Please wait while your request is being processed.</p>';
  } else if( $ajax.readyState == 4 || $ajax.readyState == 'complete' ) {
    document.getElementById( $target )[ $targettype ] = $ajax.responseText;
  }
}

function OPTIONSWAP( $url, $target ) {
  $ajax = XMLOBJECT();

  if( $ajax == null ) {
    alert( 'Browser does not support HTTP Request' );
	
	return;
  }

  var $url = $url + '?sid=' + Math.random();

  $ajax.onreadystatechange = function() {
	if( $ajax.readyState == 4 || $ajax.readyState == 'complete' ) {	  
	  var $xml = $ajax.responseXML.documentElement;
	  
	  var $select = document.getElementById( $target );
	
	  for( var $i = $select.options.length; $i > 0; $i-- ) {
	    $select.remove( $select.options[ $i ] );
	  }

	  var $replacements = $xml.getElementsByTagName( $target );

	  for( var $j = 0; $j < $replacements.length; $j++ ) {
	    // var $option = $select.options.add( new Option( $replacements[ $j ].getAttributeNode( 'value' ).nodeValue, null ) );
		//$option.innerText = $replacements[ $j ].getAttributeNode( 'desc' ).nodeValue;
		
		$select.options.add( new Option( $replacements[ $j ].getAttributeNode( 'desc' ).nodeValue, $replacements[ $j ].getAttributeNode( 'value' ).nodeValue ) );
		//$option.innerText = ;
	  }
	  
	  $select.options[ 0 ].focus;
	}
  }
  
  $ajax.open( 'GET', $url, true );
  $ajax.send( null );
}

function SUBMISSION() {
	var $string = '';

	for( var $i = 0; $i < document.forms.length; $i++ ) {
	
		for ( var $j = 0; $j < document.forms[ $i ].length; $j++ ) {
			if( document.forms[ $i ].elements[ $j ].name != undefined ) {
				if( document.forms[ $i ].elements[ $j ].type == 'checkbox' ) {
					if( document.forms[ $i ].elements[ $j ].checked == true ) {
						$string += document.forms[ $i ].elements[ $j ].name + '=' + document.forms[ $i ].elements[ $j ].value + ( $i < document.forms.length ? '&' : '' );
					}
				} else {
					$string += document.forms[ $i ].elements[ $j ].name + '=' + document.forms[ $i ].elements[ $j ].value + ( $i < document.forms.length ? '&' : '' );
				}
			}
		}
    }
	// alert( $string );
	return $string;
}

function XMLOBJECT() {
  var $ajax = null;
  
  // Works with Firefox, Opera 8.0+, and Safari
  try {
	$ajax = new XMLHttpRequest();
  }
  
  // Optional code for IE 6
  catch( $e ) {
    try {
	  $ajax = new ActiveXObject( 'Msxml2.XMLHTTP' );
	}
	
	// Optional code for IE 5
	catch( $e ) {
	  $ajax = new ActiveXObject( 'Microsoft.XMLHTTP' );
	}
  }
  
  return $ajax;
}

function SUBMISSION_OLD() {
	var $string = '';

	for( var $i = 0; $i < document.forms.length; $i++ ) {
		for ( var $j = 0; $j < document.forms[ $i ].length; $j++ ) {
			if( document.forms[ $i ].elements[ $j ].name != undefined ) {
				if( document.forms[ $i ].elements[ $j ].type == 'checkbox' ) {
					for( var $k = 0; $k < document.forms[ $i ].elements[ $j ].length; $k++ ) {
						if( document.forms[ $i ].elements[ $j ][ $k ].checked == true ) {
							$string += document.forms[ $i ].elements[ $j ].name + '=' + document.forms[ $i ].elements[ $j ].value + ( $i < document.forms.length ? '&' : '' );
						}
					}
				} else {
					$string += document.forms[ $i ].elements[ $j ].name + '=' + document.forms[ $i ].elements[ $j ].value + ( $i < document.forms.length ? '&' : '' );
				}
			}
		}
    }
	// alert( $string );
	return $string;
}
-->
