
/*
 * AjaxObject is a hypothetical object that encapsulates the transaction
 *     request and callback logic.
 *
 * handleSuccess( ) provides success case logic
 * handleFailure( ) provides failure case logic
 * processResult( ) displays the results of the response from both the
 * success and failure handlers
 * call( ) calling this member starts the transaction request.
 */

var helpObject = {

	handleSuccess:function(o){
		// This member handles the success response
		// and passes the response object o to AjaxObject's
		// processResult member.
/* Please see the Success Case section for more
 * details on the response object's properties.
 * o.tId - unique id
 * o.status  - status code
 * o.statusText - Descr of code
 * o.getResponseHeader[ ]
 * o.getAllResponseHeaders
 * o.responseText
 * o.responseXML
 * o.argument
 */
// 		alert("Successful Call " + o.statusText);
// 		alert("["+o.argument[0]+"][" + o.argument[1] + "][" + o.argument + "]");
   		var dobj = document.getElementById( o.argument[0] );
   		var dobjTxt = document.getElementById( o.argument[1] );
   		var splitIdx = o.responseText.indexOf("--MESSAGE--",0);
//   		alert("Index :" + o.argument);
   		if ( splitIdx >= 0 ) {
    		dobjTxt.innerHTML = o.responseText.substring(0,splitIdx);
    		alert(o.responseText.substring(splitIdx+11));
    	} else {
    		dobjTxt.innerHTML = o.responseText;
			dobj.style.display = 'block';
    	}
	},

	handleFailure:function(o){
		alert("Failure Getting Help : " + o.statusText);
		// Failure handler
	}

};

/*
 * Define the callback object for success and failure
 * handlers as well as object scope.
 */
var helpcallback =
{
	success:helpObject.handleSuccess,
	failure:helpObject.handleFailure,
  	cache:false,
  	timeout: 5000,
  	argument: ['helpdiv','helptxt'], 
	scope: helpObject
};

function getHelp(t) {
	getHelpPos(t,'helpdiv','helptxt');
}

function getHelpPos(t,arg1, arg2) {
	//alert(":"+document.getElementById(arg1).style.display+":");
    if ( document.getElementById(arg1).style.display == 'none' || document.getElementById(arg1).style.display == '') {
		helpcallback.argument[0] = arg1;
		helpcallback.argument[1] = arg2;
		var cObj = YAHOO.util.Connect.asyncRequest('GET', '/cic/PR?app=9999&action=7&help='+t, helpcallback);
	} else {
		document.getElementById(arg1).style.display = 'none';
	}
}



