
// Declare Form Elements
	var _tblTabOne		 = null;
	var _txCompany		 = null;
	var _txURL			 = null;
	var _txAddress1		 = null;
	var _txAddress2		 = null;
	var _txCity			 = null;
	var _ddlState			 = null;
	var _txZipCode		 = null;
	var _txName			 = null;
	var _txPhone			 = null;
	var _txFax			 = null;
	var _txEMail			 = null;
	var _txMgrEMail		 = null;
	
	var _tblTabTwo		 = null;
	var _txPosCity		 = null;
	var _ddlPosState		 = null;
	var _ddlSetting		 = null;
	var _ddlType			 = null;
	var _txResponsibilities = null;
	var _txQualifications	 = null;
	
	var _tblTabThree		 = null;
	var _chkStipend		 = null;
	var _txStipend		 = null;
	var _txAppProcess		 = null;
	
	var _btnNext			 = null;
	var _btnBack			 = null;
	var _btnSubmit		 = null;
	
	var _dvMsg			= null;
// Declare Global Variables
	var _activeTab		= null;
	
	

/* EVENT: Page_OnLoad() {  function is generated by the code behind  }

	function Page_OnLoad()
	{
		Initialize();
		SetEvents();
		_activeTab	 = document.getElementById("tblTabOne");
	}
*/
/* METHOD: Initialize
*/
	function Initialize()
	{
		_tblTabOne			= document.getElementById("tblTabOne");
		_txCompany			= document.getElementById("txCompany");
		_txURL				= document.getElementById("txURL");
		_txAddress1			= document.getElementById("txAddress1");
		_txAddress2			= document.getElementById("txAddress2");
		_txCity				= document.getElementById("txCity");
		_ddlState			= document.getElementById("ddlState");
		_txZipCode			= document.getElementById("txZipCode");
		_txName				= document.getElementById("txName");
		_txPhone				= document.getElementById("txPhone");
		_txFax				= document.getElementById("txFax");
		_txEMail				= document.getElementById("txEMail");
		_txMgrEMail			= document.getElementById("txMgrEMail");
		
		_tblTabTwo			= document.getElementById("tblTabTwo");
		_txPosCity			= document.getElementById("txPosCity");
		_ddlPosState			= document.getElementById("ddlPosState");
		_ddlSetting			= document.getElementById("ddlSetting");
		_ddlType				= document.getElementById("ddlType");
		_txResponsibilities	= document.getElementById("txResponsibilities");
		_txQualifications		= document.getElementById("txQualifications");
		
		_tblTabThree			= document.getElementById("tblTabThree");
		_chkStipend			= document.getElementById("chkStipend");
		_txStipend			= document.getElementById("txStipend");
		_txAppProcess			= document.getElementById("txAppProcess");
		
		_btnNext				= document.getElementById("btnNext");
		_btnBack				= document.getElementById("btnBack");
		_btnSubmit			= document.getElementById("btnSubmit");
		_dvMsg				= document.getElementById("dvMsg");
		
		
		menubar_setPageHeight();
	}
	
/* METHOD: SetEvents
*/
	function SetEvents()
	{
		_txCompany.onkeyup 	= txCompany_OnKeyUp;
		_txURL.onkeyup		= txURL_OnKeyUp;
		_txAddress1.onkeyup	= txAddress1_OnKeyUp;
		_txCity.onkeyup		= txCity_OnKeyUp;
		_txZipCode.onkeyup	= txZipCode_OnKeyUp;
		_txPhone.onkeyup	= txPhone_OnKeyUp;
		_txFax.onkeyup		= txFax_OnKeyUp;
		_txEMail.onkeyup	= txEMail_OnKeyUp;
		_txMgrEMail.onkeyup	= txMgrEMail_OnKeyUp;
		
		_txPosCity.onkeyup			= txPosCity_OnKeyUp;
		_txResponsibilities.onkeyup	= txResponsibilities_OnKeyUp;
		_txQualifications.onkeyup	= txQualifications_OnKeyUp;
		
		_txStipend.onkeyup			= txStipend_OnKeyUp;
		_txAppProcess.onkeyup		= txAppProcess_OnKeyUp;
		_chkStipend.onchange		= _chkStipend_OnChange;
		_chkStipend.onclick    		= _chkStipend_OnChange;
	}
	
/* 	METHOD 	: SetFocus 
	REMARKS	: MSIE 8 on Windows XP appears to place the cusor at the BEGINNING 
			  of the text in a textarea box. When we replace focus after each 
			  keyup event this results in a backward typing effect. This function
			  will replace teh focus at the END of teh text.
*/
	function SetFocus( txtBox )
	{
		
	};	  
	
	
/* METHOD: btnFinish_Enable
*/
	function btnFinish_Enable( bEnabled )
	{
		if(bEnabled)
		{
            if(TabOne_IsValid(false) && TabTwo_IsValid(false) && TabThree_IsValid(false))
                _btnSubmit.disabled = false;
            else
                _btnSubmit.disabled = true;
		}
		else
		{
			_btnSubmit.disabled = true;
		}
	}
		
/* EVENT: btnNext_onClick
*/
	function btnNext_onClick()
	{
		if(_activeTab != null)
		{		
			switch(_activeTab.id)
			{
				case "tblTabOne":
					ActivateTabTwo();
					break;
				case "tblTabTwo":
					ActivateTabThree();
					break;
			}
		}
	}
	
/* EVENT: btnBack_OnClick
*/
	function btnBack_onClick()
	{
		if(_activeTab != null)
		{
			_activeTab.style.display = "none";		
			switch(_activeTab.id)
			{
				case "tblTabOne":
					break;
				case "tblTabTwo":
					_activeTab = document.getElementById("tblTabOne");
					ActivateTabOne();
					break;
				case "tblTabThree":
					_activeTab = document.getElementById("tblTabTwo");
					ActivateTabTwo();
					break;
			}			
			_activeTab.style.display = "";
		}
	}
	

	
/* TAB ONE EVENTS **************************************** */		
/* EVENT: txCompany_OnKeyUp
*/
	function txCompany_OnKeyUp()
	{
		btnFinish_Enable( true );
		ActivateTabOne();
		_txCompany.focus();
	}
	
/* EVENT: txURL_OnKeyUp
*/
	function txURL_OnKeyUp()
	{
		btnFinish_Enable( true );
		ActivateTabOne();
		_txURL.focus();
	}
	
/* EVENT: txAddress1_OnKeyUp
*/
	function txAddress1_OnKeyUp()
	{
		btnFinish_Enable( true );
		ActivateTabOne();
		_txAddress1.focus();
	}
	
/* EVENT: txCity_OnKeyUp
*/
	function txCity_OnKeyUp()
	{
		btnFinish_Enable( true );
		ActivateTabOne();
		_txCity.focus();
	}

/* EVENT: txZipCode_OnKeyUp
*/
	function txZipCode_OnKeyUp()
	{
		btnFinish_Enable( true );
		ActivateTabOne();
		_txZipCode.focus();
	}
	
/* EVENT: txPhone_OnKeyUp
*/
	function	txPhone_OnKeyUp()
	{
		btnFinish_Enable( true );
		ActivateTabOne();
		_txPhone.focus();
	}
	
/* EVENT: txFax_OnKeyUp
*/
	function	txFax_OnKeyUp()
	{
		btnFinish_Enable( true );
		ActivateTabOne();
		_txFax.focus();
	}
	
/* EVENT: txEMail_OnKeyUp
*/
	function	txEMail_OnKeyUp()
	{
		btnFinish_Enable( true );
		ActivateTabOne();
		_txEMail.focus();
	}
	
/* EVENT: txMgrEMail_OnKeyUp
*/
	function	txMgrEMail_OnKeyUp()
	{
		btnFinish_Enable( true );
		ActivateTabOne();
		_txMgrEMail.focus();
	}
	
	
	
/* TAB TWO EVENTS **************************************** */	
/* EVENT: txPosCity_OnKeyUp
*/
	function txPosCity_OnKeyUp()
	{
		btnFinish_Enable( true );
		ActivateTabTwo();
		_txPosCity.focus();
	}
	
/* EVENT: txResponsibilities_OnKeyUp
*/
	function txResponsibilities_OnKeyUp()
	{
		btnFinish_Enable( true );
		ActivateTabTwo();
		
		_txResponsibilities.focus();
	}
	
/* EVENT: txQualifications_OnKeyUp
*/
	function txQualifications_OnKeyUp()
	{
		btnFinish_Enable( true );
		ActivateTabTwo();
		_txQualifications.focus();
	}


	
/* TAB THREE EVENTS ************************************** */	
/* EVENT: txAppProcess_OnKeyUp
*/
	function txAppProcess_OnKeyUp()
	{
		btnFinish_Enable( true );
		ActivateTabThree();
		_txAppProcess.focus();
	}

/* EVENT: txStipend_OnKeyUp
*/	
	function txStipend_OnKeyUp()
	{
		btnFinish_Enable( true );
		ActivateTabThree();
		_txStipend.focus();
	}
	
/* EVENT: _chkStipend_OnChange
*/
	function _chkStipend_OnChange()
	{
		if(_chkStipend.checked)
		{
			_txStipend.className = "required";
			_txStipend.disabled  = false;
		}
		else
		{
			_txStipend.className = "";
			_txStipend.disabled  = true;
		}
		
		btnFinish_Enable( true );
		TabThree_IsValid(true);
	}
	
	
	
/* TAB ACTIVATION **************************************** */
/* METHOD: ActivateTabOne
*/
	function ActivateTabOne()
	{
		_btnBack.disabled 	= true;
		var oTagOne       = document.getElementById("tblTabOne");
		
		if(null != _activeTab && oTagOne != _activeTab){
			_activeTab.style.display = "none";
		}
		
		if( TabOne_IsValid(true) )
			_btnNext.disabled = false;
		else
		{
			_btnNext.disabled = true;
			_dvMsg.className  = "errMsg";
		}
		
		_activeTab	= document.getElementById("tblTabOne");
		_activeTab.style.display = "";
	}
	
/* METHOD: ActivateTabTwo
*/
	function ActivateTabTwo()
	{
		_btnBack.disabled = false;
		var oTagTwo       = document.getElementById("tblTabTwo");

		if(null != _activeTab && oTagTwo != _activeTab){
			_activeTab.style.display = "none";
		}
		
		if(TabTwo_IsValid(true))
			_btnNext.disabled = false;
		else
		{
			_btnNext.disabled = true;
			_dvMsg.className	= "errMsg";
		}
		_activeTab	= document.getElementById("tblTabTwo");
		_activeTab.style.display = "";
	}
	
/* METHOD: ActivateTabThree
*/
	function ActivateTabThree()
	{
		_btnNext.disabled = true;
		_btnBack.disabled = false;
		var oTagThree     = document.getElementById("tblTabThree");
		
		if(null != _activeTab && oTagThree != _activeTab){
			_activeTab.style.display = "none";
		}
		
		if(TabThree_IsValid(true))
			_dvMsg.className	= "errMsg";
			
		_activeTab	= document.getElementById("tblTabThree");
		_activeTab.style.display = "";
	}
	
	
	
/* TAB VALIDATION **************************************** */
/* METHOD: TabOneIsValid
*/
	function TabOne_IsValid(bShowMsg)
	{
		var isValid = true;
		var sErrMsg = "";
		
		if(_txCompany.value.isEmpty() )
		{
			isValid = false;
			sErrMsg += "<li>Company is Required</li>";
		}
		
		if(_txAddress1.value.isEmpty() )
		{
			isValid = false;
			sErrMsg += "<li>Address is Required</li>";
		}
		
		if(_txCity.value.isEmpty() )
		{
			isValid = false;
			sErrMsg += "<li>City is Required</li>";
		}
		
		if( !_txURL.value.isEmpty() && !_txURL.value.isURL())
		{
			isValid = false;
			sErrMsg += "<li>URL is Invalid</li>";
		}
		
		if( _txZipCode.value.isEmpty() )
		{
			isValid = false;
			sErrMsg += "<li>ZipCode is Required";
		}
		else if( !_txZipCode.value.isZipCode() )
		{
			isValid = false;
			sErrMsg += "<li>ZipCode is invalid</li>";
		}
		
		if( !_txPhone.value.isEmpty() && !_txPhone.value.isPhone())
		{
			isValid	= false;
			sErrMsg += "<li>Phone is invalid</li>";
		}
		
		if( !_txFax.value.isEmpty() && !_txFax.value.isPhone())
		{
			isValid	= false;
			sErrMsg += "<li>Fax is invalid</li>";
		}
		
		if( !_txEMail.value.isEmpty() && !_txEMail.value.isEmail())
		{
			isValid	= false;
			sErrMsg += "<li>EMail is invalid</li>";
		}
		
		if( !_txMgrEMail.value.isEmpty() && !_txMgrEMail.value.isEmail())
		{
			isValid	= false;
			sErrMsg += "<li>Mgr EMail is invalid</li>";
		}
		
	// display error message
		if(!isValid && bShowMsg)
		{    
			_dvMsg.innerHTML 		= sErrMsg;
			_dvMsg.className 		= "ErrMsg";
			_dvMsg.style.display 	= "block";
		}
		else
		{
			_dvMsg.style.display = "none";
		}	
		
		return(isValid);
	}
	
/* METHOD: TabTwoIsValid
*/
	function TabTwo_IsValid(bShowMsg)
	{
		var isValid = true;
		var sErrMsg = "";
		
		if(_txPosCity.value.isEmpty())
		{
			isValid = false;
			sErrMsg += "<li>City is required</li>";
		}
		
		if(_txResponsibilities.value.isEmpty())
		{
			isValid = false;
			sErrMsg += "<li>Resp. is required</li>";
		}
		
		if(_txQualifications.value.isEmpty())
		{
			isValid = false;
			sErrMsg += "<li>Qual. is required</li>";
		}
		
	// display error message
		if(!isValid && bShowMsg)
		{    
			_dvMsg.innerHTML 		= sErrMsg;
			_dvMsg.ClassName 		= "ErrMsg";
			_dvMsg.style.display 	= "block";
		}
		else
			_dvMsg.style.display = "none";
			
		return(isValid);
	}
	
/* METHOD: TabThreeIsValid
*/
	function TabThree_IsValid(bShowMsg)
	{
		var isValid = true;
		var sErrMsg = "";
	
		if(_chkStipend.checked && _txStipend.value.isEmpty())
		{
			isValid = false;
			sErrMsg += "<li>Stipend Details Required</li>";
		}
		
		if(_txAppProcess.value.isEmpty())
		{
			isValid = false;
			sErrMsg += "<li>Appl. Process Required</li>";
		}
	
	// display error message
		if(!isValid && bShowMsg)
		{    
			_dvMsg.innerHTML 		= sErrMsg;
			_dvMsg.ClassName 		= "ErrMsg";
			_dvMsg.style.display 	= "block";
		}
		else
			_dvMsg.style.display = "none";
			
		return(isValid);
	}
	
	
	
	
	
	
	
	
	
	