// JavaScript Document
// Copyright 2008 - White Donkey
jQuery(document).ready(function(){
	// Destroy all Humans....
	//$("img").bind("contextmenu", function() { return false; } );
	jQuery("body").bind("contextmenu", function() { alert("The contents of this web site are protected by copyright and may not be used without permission. We aggressively pursue all unauthorized use of our intellectual properties. For information regarding authorized usage please call."); return false; } );
	jQuery(".noClick").bind("mousedown", function() { alert("The contents of this web site are protected by copyright and may not be used without permission. We aggressively pursue all unauthorized use of our intellectual properties. For information regarding authorized usage please call."); return false; } );
	// Setup Category Menu
	if( jQuery("#content-holder") && jQuery("#sidebar") && jQuery("#page-content") ) {
		jQuery("#page-content").css('min-height', jQuery("#sidebar").height() );
	}
	if( jQuery("#catMenuHolder") ) {
		jQuery("#catMenuHolder").hide();
		if( jQuery("#naviCategory")[0] ) {
			var navCatEl = jQuery("#naviCategory")[0];
			var newTop = (navCatEl.offsetTop + (navCatEl.offsetHeight*0.75));
			var newLeft = navCatEl.offsetLeft + jQuery("#naviCategory").padding().left;
			jQuery("#catMenuHolder").css("top", newTop + "px");
			jQuery("#catMenuHolder").css("left",  newLeft + "px");
		}
		jQuery("#naviCategory").hover(function(){
			jQuery("#catMenuHolder").show();
			//jQuery("#flashBadge").hide();
			jQuery("#substitute_badge").show();
		}, function(){ 
			jQuery("#catMenuHolder").hide(); 
			//jQuery("#flashBadge").show();
			jQuery("#substitute_badge").hide();
			}
		);
		jQuery("#catMenuHolder").hover(function(){
			jQuery("#catMenuHolder").show(); 
			//jQuery("#flashBadge").hide();
			jQuery("#substitute_badge").show();
		}, function(){
			jQuery("#catMenuHolder").hide();
			//jQuery("#flashBadge").show();
			jQuery("#substitute_badge").hide();
		});
	}
	
});

function page_overlay(overlayTitle, url, overlayCloseButton) {
	page_overlayInstall(overlayTitle, url, overlayCloseButton);	
}

function page_overlayInstall(overlayTitle, url, overlayCloseButton) {
	if( url == "" ) { url = "about:blank"; }
	jQuery("body").append("<div id='windowOverlayHolder'></div>");
	jQuery("#windowOverlayHolder").append("<div id='windowOverlayBackground'></div>");
	jQuery("#windowOverlayHolder").append("<iframe id='windowOverlayFrame' frameborder='0' hspace='0' src='"+url+"'></iframe>");
	jQuery("#windowOverlayHolder").append("<div id='windowOverlayTitle'>"+overlayTitle+"</div>");
	
	
	if( overlayCloseButton ) {
		// if you don't put the close button then there is no way to close the box without custom code.
		jQuery("#windowOverlayTitle").append("<span onclick='page_overlayRemove();' id='windowOverlayCloseButton'>Close</span>");
	}
	moos_overlayResize();
	Event.observe(window, 'resize', function() { moos_overlayResize(); }, false );
}

function page_overlayResize() {
	if( $('windowOverlayHolder') != undefined ) {
		var framePadding = 25;
		var top = framePadding;
		var left = framePadding;
		var height = ( $('windowOverlayHolder').getHeight() - (2 * framePadding) );
		var width = ( $('windowOverlayHolder').getWidth() - (2 * framePadding) );
		if( $('windowOverlayTitle') != undefined ) {
			$('windowOverlayTitle').style.width = (width - 4) +"px";
			$('windowOverlayTitle').style.top = framePadding+"px";
			$('windowOverlayTitle').style.left = framePadding+"px";
			top = (framePadding + $('windowOverlayTitle').getHeight());
			height = (height - $('windowOverlayTitle').getHeight());
		}
		$('windowOverlayFrame').style.left = left +"px";
		$('windowOverlayFrame').style.top = top +"px";
		$('windowOverlayFrame').style.width = width+"px";
		$('windowOverlayFrame').style.height = height+"px";
	}
}

function page_overlayRemove() {
	$('windowOverlayHolder').remove();
}


/*
 * JSizes - JQuery plugin v0.32
 *
 * Licensed under the revised BSD License.
 * Copyright 2008, Bram Stein
 * All rights reserved.
 */
(function(B){var A=function(C){return parseInt(C,10)||0};B.each(["min","max"],function(D,C){B.fn[C+"Size"]=function(G){var F,E;if(G){if(G.width){this.css(C+"-width",G.width)}if(G.height){this.css(C+"-height",G.height)}return this}else{F=this.css(C+"-width");E=this.css(C+"-height");return{width:(C==="max"&&(F===undefined||F==="none"||A(F)===-1)&&Number.MAX_VALUE)||A(F),height:(C==="max"&&(E===undefined||E==="none"||A(E)===-1)&&Number.MAX_VALUE)||A(E)}}}});B.fn.isVisible=function(){return this.css("visibility")!=="hidden"&&this.css("display")!=="none"};B.each(["border","margin","padding"],function(D,C){B.fn[C]=function(E){if(E){if(E.top){this.css(C+"-top"+(C==="border"?"-width":""),E.top)}if(E.bottom){this.css(C+"-bottom"+(C==="border"?"-width":""),E.bottom)}if(E.left){this.css(C+"-left"+(C==="border"?"-width":""),E.left)}if(E.right){this.css(C+"-right"+(C==="border"?"-width":""),E.right)}return this}else{return{top:A(this.css(C+"-top"+(C==="border"?"-width":""))),bottom:A(this.css(C+"-bottom"+(C==="border"?"-width":""))),left:A(this.css(C+"-left"+(C==="border"?"-width":""))),right:A(this.css(C+"-right"+(C==="border"?"-width":"")))}}}})})(jQuery);