﻿/*
copy and paste the ActionItems object to your page and set the values appropraitly
to call a function with no paramaters use
	functionName with no ()
to call a function with paramaters or a new function use 
	function(e){alert('Doing Stuff');functionName(e.value);}

example:
var ActionItems = {
	plan_btn:{up:'0 top', hov:'-88px top', dwn:'-176px top', click:doSomething },
	more_lnk:{url: "nextpage.php" },
	phone_inpt:{keyup: function(e){doSomething(e.value)} }
	links:{sel:'a', click:doSomething, stop:true }
}
*/
var j = jQuery.noConflict();

function ActivateActions(item)
{
	var o = ActionItems[item];
	var i = o.sel?j(o.sel):j("#"+item);
	if( o.hov || o.click || o.url ); i.css("cursor", "pointer");
	if( o.up )
		if(o.hov) i.hover( function(){ this.style.backgroundPosition = o.hov}, function(){this.style.backgroundPosition = o.up })
		else i.mouseout( function(){this.style.backgroundPosition = o.up} );
	if(o.dwn) i.mousedown( function(){this.style.backgroundPosition = o.dwn} );
	if(o.keyup) i.keyup( function(){o.keyup(this)} );
	if(o.url) i.click( function(){location=o.url; return false} );
	if(o.click) i.click( function(){o.click(this); if(o.stop)return false} );
}

j(document).ready( function(){if(ActionItems)for(var item in ActionItems)ActivateActions(item);} );


function jE(id)
{
	// returns the first element found in the selector if it exists
	// ex: $E('#click_btn')
	if( j(id)[0] )
		return j(id)[0];
	return 0;
}

function jF(id, val)
{
	//returns the form field value if it exists and sets the value if passed
	// ex: $F('#name_inpt', 'joe')
	var e = jE(id);
	if(!e)
		return;
	if( e.type == 'text' )
		if( val ) e.value = val;
		return e.value;
}
