ACM = ACM || {}

jQuery.noConflict();
$J = jQuery;

ACM.patchIE6 = {
	/* needed this for min-width and max-width layout functionality in IE6 */
	resizeDoc: function() {
		/* use this to identify IE 6 */
		/* IE < 7 don't understand min-width or max-width in CSS */
		if (typeof document.body.style.maxHeight == "undefined") {
			var doc = ACM.$Y.Dom.get('doc');
			var width = document.body.clientWidth;
			if (width < 990) doc.style.width = '960px';
			else if (width > 1230) doc.style.width = '1200px';
			else doc.style.width='auto';
		}
	},
	
	/* png image alpha transparency "support" */
	/* this is currently called within base.css (like in an XSS attack, but used for good instead of evil) */
	pngImg: function(p) {
		/* use this to identify IE 6 */
		/* IE < 7 don't understand min-width or max-width in CSS */
		/* yes, I *had* to repeat myself - thanks IE */
		if (typeof document.body.style.maxHeight == "undefined") {
			var imgsrc;
			var trans = "/images/spacer.gif";   
			if(typeof p.tested != undefined && !p.tested &&  typeof p.runtimeStyle != 'undefined') {
				imgsrc = p.src;
				if (/\.png$/.test(imgsrc.toLowerCase())) {
					p.src = trans;
					p.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + imgsrc + "',sizingMethod='scale')";
					p.tested = true;
				}
			}
		}
	},
	/* adds/removes a class onmouseover/onmouseout (respectively) for imitation of CSS :hover pseudo class */
	hover: function(nodeName, className) {
//		ACM.$Y.Event.onDOMReady(function() {
//			var kids = ACM.$C(className, nodeName, document.body);
//			for (var i in kids) {
//				ACM.$Y.Event.on(kids[i], 'mouseout', function() {
//					ACM.$Y.Dom.removeClass(this, 'hover');
//				});
//				ACM.$Y.Event.on(kids[i], 'mouseover', function() {
//					ACM.$Y.Dom.addClass(this, 'hover');
//				});
//			}
//		});
	},
	/* <label> doesn't work right in IE unless it has a FOR attribute - it *should* just know to focus any child inputs of the <label> */
	labels: function(node, args, e) {
		try {
			node.getElementsByTagName('select')[0].focus();
		} catch (err) {}
		try {
			var input = node.getElementsByTagName('input')[0];
			switch(input.type) {
			case 'checkbox':
			case 'radio':
				input.checked = (input.checked != 'checked' && input.checked != 'true') ? 'checked' : 'false';
				break;
			case 'text':
			case 'password':
				input.focus();
				break;
			}
		} catch (err) {}
	},
	jiggle: function(handle) {
		handle.style.zoom = 1.1; /* Jiggle the handle (like a toilet) */
		handle.style.zoom = 1; /* Back to normal! YEAH!! */
	}
};

//ACM.$Y.Event.on(window, 'resize', ACM.patchIE6.resizeDoc);
//ACM.$Y.Event.onAvailable('doc', ACM.patchIE6.resizeDoc);

/* ACM.patchIE6.hover('li', 'hoverable'); */
//ACM.delegate('click', 'LABEL', ACM.patchIE6.labels, null);