/*
 * Asdika Productions Dynamic Pager 
 * The style in which I have written this chunk is decidely un-vbulletin like.
 * It simply jumps to a specific page in a thread or thread list. 
*/

AP_Pager = function(){ 
	// I really didn't want to have to write this bit, but it's done now.
	var ee = YAHOO.util.Event;
	var dd = YAHOO.util.Dom;
	return {
		init: function(e){
			theInputs = dd.getElementsByClassName('pagenav_itxt');
			if(theInputs.length > 0) currentPage = theInputs[0].value;
			for (var i=0; i < theInputs.length; i++) {
				theInputs[i].removeAttribute("disabled") };
			ee.on(theInputs, "keypress", AP_Pager.gotoPage);
			ee.on(theInputs, "focus", function(e){
				theTarget = ee.getTarget(e);
				theTarget.value = "";
			});
			ee.on(theInputs, "blur", function(e){
				theTarget = ee.getTarget(e);
				if(theTarget.value == "") theTarget.value = currentPage;
			});
		},
		gotoPage: function(e){
			theKey = ee.getCharCode(e);
			theTarget = ee.getTarget(e);
			thePageNumber = dd.get(theTarget).value;
			currentAddress = dd.getAncestorByTagName(theTarget, 'form').action
			if(theKey == 13){
				ee.stopEvent(e);
				if(parseInt(thePageNumber,10) > 0){
					window.location = currentAddress + "&page=" + thePageNumber;
				}
			}
		}//end gotopage
	}//end return
}();		
YAHOO.util.Event.on(window, "load", AP_Pager.init);

/*
 * Asdika Productions Member Menu
 * I am loathe to call it an improvement, but I completely broke 
 * the vBulletin version and am unwilling to regress the design.
*/

AP_Member = function(){ 
	var ee = YAHOO.util.Event;
	var dd = YAHOO.util.Dom;
	var ss = YAHOO.util.Selector;
	return {
		init: function(e){
			ee.on(ss.query("#posts .meta1 .button"), "mousedown", AP_Member.showMenu);
			//ee.on(ss.query("#posts .user-tools .close"), "click", AP_Member.closeMenu);
		},
		showMenu: function(e){
			ee.stopEvent(e);
			theTarget = ee.getTarget(e);
			openMenus = ss.query('#posts .meta1 .user-tools');
			for (var i=0; i < openMenus.length; i++) { openMenus[i].style.display = 'none'	}; // first closing all open menus
			theID = theTarget.id + "_menu"
			theMenu = dd.get(theID);
			theMenu.style.display = 'block'
		}
	}
}(); 
YAHOO.util.Event.on(window, "load", AP_Member.init);