/****************************************
|
| Entrepreneur London
| Created by: Kevin Biskaborn
| Copyright 2010 ScriptReaction
| http://www.scriptreaction.com
|
*****************************************
| Last Update: 	January 11, 2010
| Editor:		Kevin Biskaborn
****************************************/

var FrmCtrl_Master = {
	components: {
		response: {
			setNewValue: function ( responseString ){
				document.dataForm.response.value = responseString;
			},
			parseValues: function ( responseString ){
				var output = new Object();
				
				//split the string by incoming variable items
				var varArray = responseString.split( ";" );
				
				//delete the entry at the last index (empty)
				varArray.splice( varArray.length - 1, 1 );
				
				//create extraction containers
				var pieceArray = new Array();
				var varName = varValue = "";
				
				//cycle through all variables
				for( var i in varArray ){
					pieceArray 	= varArray[ i ].split( "=" );
					varName		= pieceArray[ 0 ];
					varValue	= pieceArray[ 1 ];
					
					//add the var to the output
					output[ varName ] = varValue;
				}
				
				return output;
			}
		},
		submitButton: {
			getButtonElement: function ( btnId ){
				return document.getElementById( btnId );
			},
			doEnable: function (){
				this.doEnable_onBtn( "dataSubmit" );
			},
			doDisable: function (){
				this.doDisable_onBtn( "dataSubmit" );
			},
			doEnable_onBtn: function ( btnId ){
				this.applyEnable( this.getButtonElement( btnId ) );
			},
			doDisable_onBtn: function ( btnId ){
				this.applyDisable( this.getButtonElement( btnId ) );
			},
			applyEnable: function ( btnElmt ){
				btnElmt.disabled 	= false;
				btnElmt.style.color = "#000000";
				//show focus arrows
				document.getElementById( "focus_next" ).style.visibility = "visible";
			},
			applyDisable: function ( btnElmt ){
				btnElmt.disabled 	= true;
				btnElmt.style.color = "#999999";
				//show focus arrows
				document.getElementById( "focus_next" ).style.visibility = "hidden";
			}
		},
		caseCode: {
			get_codeValue: function (){
				return document.getElementById( "code_payload" ).value;
			},
			get_btnById: function ( btnId ){
				return document.getElementById( "code_optbtn_" + btnId );
			},
			do_copy: {
				execute: function (){
					//
				}
			},
			do_print: {
				execute: function (){
					window.print();
				}
			},
			do_email: {
				execute: function ( inputEmail ){
					var btnElement = FrmCtrl_Master.components.caseCode.get_btnById( "email" );
					btnElement.disabled = true;
					btnElement.value = "Code email sent to: " + inputEmail + " ...";
					btnElement.style.color = "#999999";
				}
			}
		}
	}
}




