/*Function......:   NewWindow
* Purpose.......:   To open a window positioned to the center of the screen
* Parameters....:   url - page to open in window
*					name - window title
*					w - width of window
*					h - height of window
* Returns.......:   none*/
function NewWindow(url,name,w,h)
{
	var win = null;
	var x = (screen.width) ? (screen.width-w)/2 : 0;
	var y = (screen.height) ? (screen.height-h)/2 : 0;
	var settings ='height='+h+',width='+w+',top='+y+',left='+x+', resizable';
	win=window.open(url,name,settings);
	win.window.focus();
}


/*Function......:   DisplayDescription
* Purpose.......:   To display message in statusbar
* Parameters....:   val - string to be displayed
* Returns.......:   none*/
function DisplayDescription(val)
{
	//(val == '') ? document.frmDesc.desc.value='' : document.frmDesc.desc.value='Decsripton: '+val
	window.status=val
	return true;
}


/*Function......:   ShowProgress
* Purpose.......:   To display progress feedback to user in statusbar
* Parameters....:   none
* Returns.......:   none*/
function ShowProgress()
{	
	window.status='Request in progress....';	
	return true;
}


/*Function......:   ClearStatus
* Purpose.......:   To prevent URL from being displayed in the browser statusbar
* Parameters....:   none
* Returns.......:   none*/
function ClearStatus()
{
	window.status='';
	return true;
}

/*Function......:	setFocus
* Purpose.......:	place the cusror in the first available input field
* Parameters....:	none
* Return........:	none*/
function SetFocus()
{
	var field;
	if(document.forms[0] != null)
	{
		field = document.forms[0];
		for (i = 0; i < field.length; i++)
		{
			if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea")
				 || (field.elements[i].type.toString().charAt(0) == "s"))
			{
				document.forms[0].elements[i].focus();
				break;
	        }
	    }
	}
}


/*Name					:	clearForm
* Purpose				:	clear input fields
* Input Parameters		:	f	current form
* Return				:	none*/
function clearForm(f)
{
	// loop through from elements
	for(var i = 0; i < f.length; i++)	// Loop through elements on the form
	{
		var e = f.elements[i];
		e.value = "";
	}
}


/*Name					:	Redirect
* Purpose				:	to redirect to a given url
* Input Parameters		:	url - destination
* Return				:	none*/
function Redirect(url)
{
	top.location.href=url
}


/*Name					:	GoBack
* Purpose				:	to return to previous page
* Input Parameters		:	none
* Return				:	none*/
function GoBack()
{
	history.back();
}


/*Name					:	SubmitOnce
* Purpose				:	to prevent pressing the "Submit" button multiple times
* Input Parameters		:	none
* Return				:	none*/
function SubmitOnce(f)
{
	//if IE 4+ or NS 6+
	if (document.all||document.getElementById)
	{
		//check every element in the form, and hunt down "submit" and "reset"
		for (i=0;i<f.length;i++)
		{
			var tempobj=f.elements[i]
			if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
			//disable em
			tempobj.disabled=true
			return true;
		}
	}
}

var requestSubmitted = false;
/*Name					:	CheckSubmit
* Purpose				:	to prevent pressing the "Submit" button multiple times
* Input Parameters		:	none
* Return				:	none*/   
function CheckSubmit(f)
{
	window.status = 'Request in progess....'
	if(requestSubmitted == true)
	{
		alert("Your request is being processed... Please wait");
        return;
    }
      requestSubmitted = true;
      //document.body.style.cursor='wait'
      f.submit();
}