g_abResourceSent = new Array( false, false, false, false, false );
	
function submitOnce( idResource, theForm )
{
	if ( idResource > 5 )
	{
		// Too big resource number, but better allow form send
		return true;
	}
		
	if ( ! ( g_abResourceSent[ idResource ] ) )
	{
		g_abResourceSent[ idResource ] = true;
			
		if ( typeof( theForm.btnToDisable ) == 'object')
		{
			// The image used as buttons can't be disabled
			theForm.btnToDisable.disabled = true;
		}
			
		return true;
	}	
	else
	{
		return false;
	}
}


function disableAllButtons( idResource, button )
{
	//Note: Be aware when applying this function together with function submitOnce on one page because they both make use of array g_abResourceSent.

	if ( idResource > g_abResourceSent.length-1 )
	{
		// Too big resource number, but better allow form send
		return true;
	}
	
	if ( ( typeof(Page_ClientValidate) == 'function') && !Page_ClientValidate() )
	{
		return false;
	}
	
	if ( ! ( g_abResourceSent[ idResource ] ) )
	{
		theForm = document.forms[ idResource ];
		
		for( var i=0; i<theForm.elements.length; i++ )
		{
			elm = theForm.elements[i];
			if ( (elm.tagName=='INPUT') && (elm.type=='submit') ) 
			{
				elm.disabled = true;
			}
		}
		
		g_abResourceSent[ idResource ] = true;
		
		return true;
	}	
	else
	{
		return false;
	}
}


	
function clickOnce( button )
{
	var IsPageValid = true
	if (typeof(Page_ClientValidate) == 'function')
	{
		IsPageValid = Page_ClientValidate(); 
	}

	if ( IsPageValid )
	{
		button.click();
		button.value = " Please wait, submitting ... "
		button.disabled = true;
	}
}



function message(txt)
{
	alert(txt);
	return false
}



function setSelectDefault(formID,elmName,defaultValue)
{
    for(var i=0;i<document.forms[formID].elements[elmName].length;i++)
		if(document.forms[0].elements[elmName].options[i].value==defaultValue)
			document.forms[0].elements[elmName].options[i].selected=true;
}



function NewWindow(mypage, myname, w, h, scroll) 
{
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	var win = null;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	
	if (parseInt(navigator.appVersion) >= 4) 
	{ 
		win.window.focus(); 
	}
}



function checkOne(theFormElement,message)
{
	if(theFormElement.value=="")
	{
		theFormElement.focus();
		alert(message);
		return false;
	}
	else return true;
}



function checkForm(theForm)
{
	var theElements=new Array(11)
	theElements[0]='BIFirstName'
	theElements[1]='BILastName'
	theElements[2]='BICountry'
	theElements[3]='BIState'
	theElements[4]='BICity'
	theElements[5]='BIZip'
	theElements[6]='BIEmail'
	theElements[7]='BIPhone'
	theElements[8]='BIAddress'
	theElements[9]='cardnumber'
	theElements[10]='BICCHolder'
	var messages=new Array(11)
	messages[0]='First Name'
	messages[1]='Last Name'
	messages[2]='Country'
	messages[3]='State'
	messages[4]='City'
	messages[5]='Zip'
	messages[6]='E-mail'
	messages[7]='Phone'
	messages[8]='Address'
	messages[9]='Credit Card No'
	messages[10]='Card Holder'
	for(var i=0;i<theElements.length;i++) return checkOne(theForm.elements[theElements[i]],'Please enter your '+messages[i]);
	return true;
}
