/*=============================================================================

			 	 TITLE:		One Alliance Core JavaScript Utilities
		  MODIFIED:		2006.08.25
		 AUTHOR(S): 	Graham Wheeler - NetMediaOne - www.netmediaone.com
		  REQUIRES:		Prototype 1.5.0 ( www.conio.com )
									Scriptaculous 1.6.1
									YAHOO! Event Utility

=============================================================================*/

var OA = window.OA || {

	version: "1.0.0",
	isIE: /MSIE/.test( navigator.userAgent.toUpperCase() ),
	partnerProfiles: $A( new Array() ),

	init: function() {
		
		$$(".PartnerProfile").each( function(el) {
			if ( el.getAttribute("bindto") != null ) {
				var boundTo = $( el.getAttribute("bindto") );
				Event.observe( boundTo, "mouseover", function(e) {
					OA.showProfile(this);
					Element.addClassName( Event.element(e), "Active" );
				}.bind(el), false );
				el.style.display = "none";
			}
		} );
		
	},
	
	showProfile: function(el) {
		OA.hideAllProfiles();
		$("sectionOverview").style.display = "none";
		el.style.display = "block";
	},
	
	hideAllProfiles: function() {
		$$(".PartnerProfile").each( function(p) {
			p.style.display = "none";
		} );
		$$("#subNav a").each( function(a) {
			Element.removeClassName(a, "Active");
		} );
		$("sectionOverview").style.display = "block";
	},
	
	imgOn: function( img ) {
		$(img).src = $(img).src.replace( "_off", "_on" );
	},
	
	imgOff: function( img ) {
		$(img).src = $(img).src.replace( "_on", "_off" );
	},
	
	findParentByClassName: function( el, className ) {
		var foundEl = "NULL";
		if ( Element.hasClassName( el.parentNode, className ) ) {
			foundEl = el.parentNode;
		}	else {
			foundEl = OA.findParentByClassName( el.parentNode, className );
		}
		return foundEl;
	},
	
	showMediaPlayer: function(aTag) {
		var player = window.open( aTag.href, "Media Player", "toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width=500,height=400,left=" + ((screen.width - 500) / 2) + ",top=" + ((screen.height - 400) / 2) );
		player.focus();
		return false;
	},
	
	//
	// getPageScroll()
	// Returns array with x,y page scroll values.
	// Core code from - quirksmode.org
	//
	getPageScroll: function() {
	
		var yScroll;
	
		if (self.pageYOffset) {
			yScroll = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
			yScroll = document.documentElement.scrollTop;
		} else if (document.body) {// all other Explorers
			yScroll = document.body.scrollTop;
		}
	
		arrayPageScroll = new Array('',yScroll) 
		return arrayPageScroll;
	},
	
	// -----------------------------------------------------------------------------------
	
	//
	// getPageSize()
	// Returns array with page width, height and window width, height
	// Core code from - quirksmode.org
	// Edit for Firefox by pHaez
	//
	getPageSize: function() {
		
		var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		if (self.innerHeight) {	// all except Explorer
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}
	
		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
		return arrayPageSize;
	}

};

Event.observe( window, "load", OA.init, false );
