function submitForm()
{
	document.form1.submit();
}

function setRequestType(request_type)
{
	document.form1.request_type.value=request_type;
}

function textAreaMax(obj, nMaxLength)
{
	var szTemp = obj.value + "";

	if( (szTemp.length > 0) && (szTemp.length > nMaxLength) )
	{
		szTemp = szTemp.substring(0, nMaxLength);
		obj.value = szTemp;
	}
}

function setDropDown( whichField, newValue )
{
	var nLength = whichField.options.length;
	//alert(nLength);

	for(var i=0; i<nLength; i++)
	{
		//alert(whichField.options[i].value + " | " + newValue);
		if( whichField.options[i].value == newValue )
		{
			whichField.selectedIndex=i;
			return 0;
		}
	}

	return -1;
}

function deleteItem( szMsg )
{
	var szButtonInfo = "\n\nPlease click 'OK' to DELETE, or 'Cancel' to ABORT.";
	var c = confirm(szMsg + szButtonInfo);
	return c;
}

function superAlert( oField, szMsg )
{
	oField.focus();
	alert(szMsg);
}

function checkNumber( myField )
{
	var myValue = trim(myField.value);

	if( isNaN(myValue) == true )
	{
		myField.focus();
		alert( "Please Enter a Valid Number." );
		return -1;
	}
	else if( myValue < 0 )
	{
		myField.focus();
		alert( "Please Enter a Positive Integer." );
		return -1;
	}
	
	return 0;
}

function textCleaner( szTemp )
{
	var CLEAN_QUOTE = "'";
	var CLEAN_HYPHEN = "-";
	var quote1 = /[\"]/g; /* double quotes */
 	var quote2 = /[\“]/g;
	var quote3 = /[\”]/g;
	var longhyphen = /[\—]/g;

	szTemp = szTemp + "";
 	szTemp = szTemp.replace(quote1, CLEAN_QUOTE);
 	szTemp = szTemp.replace(quote2, CLEAN_QUOTE);
 	szTemp = szTemp.replace(quote3, CLEAN_QUOTE);
	szTemp = szTemp.replace(longhyphen, CLEAN_HYPHEN);

	return szTemp;
}

function fileNameCleaner( szTemp )
{
	var NO_QUOTES = "";
	var quote1 = /[\"]/g; /* double quotes */
 	var quote2 = /[\“]/g;
	var quote3 = /[\”]/g;
	var longhyphen = /[\—]/g;

	szTemp = szTemp + "";
 	szTemp = szTemp.replace(quote1, NO_QUOTES);
 	szTemp = szTemp.replace(quote2, NO_QUOTES);
 	szTemp = szTemp.replace(quote3, NO_QUOTES);

	return szTemp;
}

/*
	* Check for valid emails
		Rules for the email regular expression:
        * The start of the email must have at least one character before the @ sign.
        * There may be either a . or a -, but not together before the @ sign.
        * There must be an @ sign.
        * At least once character must follow the @ sign.
        * There may be either a . or a -, but not together in the address.
        * The address must end with a and either 2 or 3 characters.
		
		* return
			* 0 = success
			* 1 = failure -> invalid email
*/
function checkUserEmail(email)
{
	var reEmailValidation = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	var check;
	/* get the value of the email */
	var szEmail = email.value;
	
	check = reEmailValidation.test(szEmail);
	
	if(check == true)
    {
		return 0;
    }
	else
   	{
    	return 1;
    }
}

function myImageWriter(imageUrl)
{
    window.event.srcElement.src = imageUrl;
}

String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

function findPosX(obj) {
  var curleft = 0;

  if(obj.offsetParent) {
    while(1) {
      curleft += obj.offsetLeft;
      if(!obj.offsetParent)
        break;
      obj = obj.offsetParent;
    }
  } else if(obj.x) {
    curleft += obj.x;
  }

  return curleft;
}

function findPosY(obj) {
  var curtop = 0;

  if(obj.offsetParent) {
    while(1) {
      curtop += obj.offsetTop;
      if(!obj.offsetParent)
        break;
      obj = obj.offsetParent;
    }
  } else if(obj.y) {
    curtop += obj.y;
  }

  return curtop;
}

function findPos(obj) {
  var left = findPosX(obj);
  var top = findPosY(obj);

  return [left , top];
}

function findPosition( oElement ) {
  if( typeof( oElement.offsetParent ) != 'undefined' ) {
    for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) {
      posX += oElement.offsetLeft;
      posY += oElement.offsetTop;
    }
    return [ posX, posY ];
  } else {
    return [ oElement.x, oElement.y ];
  }
}

function moveX(obj, pos)
{
	if(document.getElementById)
	{
		var elem = document.getElementById(obj);
		elem.style.left = pos + "px";
	}
}

function moveY(obj, pos)
{
	if(document.getElementById)
	{
		var elem = document.getElementById(obj);
		elem.style.top = pos + "px";
	}
}