/* ----------------------------
*  ACLIB, version 0.3
*  (c) 2009 Atogy Corporation
*  http://www.atogy.com/
*------------------------------ */

///////////////////////   HELPER FUNCTIONS   /////////////////////
	function loadComplete(transport) {
		$('nav2').className='navSel';
	}

	function showResult(elem,content) {
   		$(elem).update(content);
	}

	function buildPortlet(elem,content) {
		var newContent="<DIV id=elem+'d'><DIV id=elem+'h'> xxx </DIV><DIV id =elem+'b'>" + content + "</DIV></DIV>";

   		showResult(elem, newContent);
	}

	function isValidEmail(str) {
		return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
	}


///////////////////////   CLIP LOADING FUNCTIONS   /////////////////////

	function getClip(url,placeHolderID){
//alert("getClip: "+placeHolderID);
		var params = '';
		var u = new Ajax.Updater({success:placeHolderID},url,{
			method: 'get', // post get
			parameters: params,
			encoding: 'UTF-8', //UTF-8
                        evalScripts: true,
			insertion: Insertion.Top  //Insertion.After Insertion.Before Insertion.Top Insertion.Bottom
			//onCreate: processCreate,
			//onLoading: processLoading,
			//onSuccess: processSuccess,
			//onFailure: processFailure,
			//onComplete: loadComplete
 
            });
	}

	function getClipAndModify(url,placeHolderID,doModify){
//alert("getClipAndModify: "+placeHolderID);
            /*{success: placeHolderID} means that the container div will only be 
		updated if thers is a successful response to the XMLhttpRequest call. */
		var params = '';
		var u=new Ajax.Updater({success:placeHolderID},url,{
			method: 'get', // post get
			parameters: params,
			encoding: 'UTF-8', //UTF-8
                        evalScripts: true,
			//insertion: Insertion.Bottom,
                        //Insertion.After Insertion.Before Insertion.Top Insertion.Bottom
			//onCreate: processCreate,
			//onLoading: processLoading,
			//onSuccess: doModify,
			//onFailure: processFailure,
			onComplete: doModify
 
            });
	}


	function getPortClip(url,placeHolderID){
		var params = '';
		var u=new Ajax.Request(url,{
			method: 'get', // post get
			parameters: params,
			encoding: 'UTF-8', //UTF-8
                        evalScripts: true,
			//insertion: Insertion.Bottom,//Insertion.After Insertion.Before Insertion.Top Insertion.Bottom
			//onCreate: processCreate,
			//onLoading: processLoading,
			//onSuccess: processSuccess,
			onSuccess: function(transport){
   				var response = transport.responseText || "no response text";
				buildPortlet(placeHolderID,response);
			},

			//onFailure: processFailure,
			onComplete: loadComplete
 
            });
	}
