//stop right mouse click
function disable_right_click(e)
{
    var browser = navigator.appName.substring ( 0, 9 );
    var event_number = 0;
    if (browser=="Microsoft")
        event_number = event.button;
    else if (browser=="Netscape")
        event_number = e.which;

    if ( event_number==2 || event_number==3 )
        {
        alert ("Right Mouse Button Is Disabled");
        return (false);
        }

    return (true);
}

function check_mousekey ()
{
    var mouse_key = 93;
    var keycode = event.keyCode;

    if ( keycode == mouse_key )
        alert ( "Mouse Key Is Disabled" );
}

function trap_page_mouse_key_events ()
{
    var browser = navigator.appName.substring ( 0, 9 );

    document.onmousedown = disable_right_click;

    if ( browser == "Microsoft" )
        document.onkeydown = check_mousekey;
    else if ( browser == "Netscape" )
        document.captureEvents( Event.MOUSEDOWN );
}

window.onload = trap_page_mouse_key_events;
//end stop right mouse click

function replaceSubstring(inputString, fromString, toString) {
   // Goes through the inputString and replaces every occurrence of fromString with toString
   var temp = inputString;
   if (temp==null) { temp="" }
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      // Find a string that doesn't exist in the inputString to be used
      // as an "inbetween" string
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      } // Keep on going until we build an "inbetween" string that doesn't exist
      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      // Next, replace the "inbetween" string with the "toString"
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } // Ends the check to see if the string being replaced is part of the replacement string or not
   return temp; // Send the updated string back to the user
} // Ends the "replaceSubstring" function



function redirect(URLStr) { location = URLStr; }

//
// QueryString
//

function QueryString(key)
{
	var value = null;
	for (var i=0;i<QueryString.keys.length;i++)
	{
		if (QueryString.keys[i]==key)
		{
			value = QueryString.values[i];
			break;
		}
	}
	//value = unescape(value);
	return replaceSubstring(value, '+', ' ');
}
QueryString.keys = new Array();
QueryString.values = new Array();

function QueryString_Parse()
{
	//var query = window.location.search.substring(1);
	//var pairs = query.split("%26");
	var query = unescape(window.location.search.substring(1));
	var pairs = query.split("&");
	
	for (var i=0;i<pairs.length;i++)
	{
		var pos = pairs[i].indexOf('=');
		if (pos >= 0)
		{
			var argname = pairs[i].substring(0,pos);
			var value = pairs[i].substring(pos+1);
			QueryString.keys[QueryString.keys.length] = argname;
			QueryString.values[QueryString.values.length] = value;		
		}
	}

}

QueryString_Parse();

//common URL parameter vars
var inBody = replaceSubstring(QueryString("body"),'+', ' ')
var inSubject = replaceSubstring(QueryString("subject"),'+', ' ')
