

if (!NEA) var NEA = {};

/* extend NEA object w/ panel code */
NEA.Panel = {
	imgPath : "/_res/panel/images",
	moreImg : "/panel-menu-off.png",
	imgH	: 17,
	imgW	: 170,
	panelOn : false,
	panelSp : "normal"
}

NEA.Panel.set = function(tf){
	var h = jQuery('#nea-panel').height();

	if (tf) {
		jQuery('#nea-panel').animate({
			minHeight: "show",
			height: "show"
		}, NEA.Panel.panelSp);
		
		jQuery('#panel-menu').animate({
			top: (parseInt(h) + 13)
		},NEA.Panel.panelSp);
		NEA.Panel.panelOn = true;
	}
	else {
		jQuery('#nea-panel').animate({
			minHeight: "hide",
			height: "hide"
		}, NEA.Panel.panelSp);
		
		jQuery('#panel-menu').animate({
			top: 3
		},NEA.Panel.panelSp);
		NEA.Panel.panelOn = false;
	}
}

if (!NEA.png) NEA.png = {};

// courtesy of http://ajaxcookbook.org/png-alpha-transparency/
NEA.png.createPNGImage = function(src, width, height) {
    if (navigator.userAgent.indexOf("MSIE") != -1) {
        var element = document.createElement("div");
        element.style.filter = "progid:DXImageTransform.Microsoft." +
                               "AlphaImageLoader(src='" + src + "')";
    	// element.style.filters(1) = "DXImageTransform.Microsoft.Alpha".Opacity[50];

	} else {
        var element = document.createElement("img");
        element.src = src;
    }
    element.style.width = width + "px";
    element.style.height = height + "px";
    return element;
}

jQuery(document).ready(function(){

// insert panel menu linkage
// this is IE only conditional compilation for PNG support in less than IE7
/*@cc_on
   /*@if (@_jscript_version < 5.7)

	if (jQuery.browser.msie) {
		jQuery('#nea-panel-menu').prepend("<p id='panel-menu'></p>");
		var element = NEA.png.createPNGImage(NEA.Panel.imgPath + NEA.Panel.moreImg, NEA.Panel.imgW, NEA.Panel.imgH);
		var place = jQuery("#panel-menu").get(0);
			if (place) place.appendChild(element);
	}
	else
   /*@end
@*/
	jQuery('#nea-panel-menu').prepend("<p id='panel-menu'><img src='" + NEA.Panel.imgPath + NEA.Panel.moreImg + "' height=" + NEA.Panel.imgH + " width=" + NEA.Panel.imgW + " /><\/p>");

	// toggle panel menu
	jQuery('#panel-menu').click(function(e){
		NEA.Panel.panelOn ? NEA.Panel.set(false) : NEA.Panel.set(true);
		e.stopPropagation(); // todo: is this needed?
	});
	// this hides panel menu on document click
	jQuery(document).click(function(e){
		if (NEA.Panel.panelOn) { NEA.Panel.set(false); }
	});
	
});



