if ( typeof docportal == "undefined" ) { docportal = new Object(); }


/* Maven and Flash player functions */
docportal.play = function() {
   docportal.thisMovie("cbcplayer").play();
};

docportal.pause = function() {
   docportal.thisMovie("cbcplayer").pause();
};

/* Find the movie in the DOM */
docportal.thisMovie = function(movieName) {
   if (navigator.appName.indexOf("Microsoft") != -1) {
      return window[movieName];
   } else {
      return document[movieName];
   }
};

docportal.mavenPop = function( fileName, windowName, width, height ) {
   docportal.pause();
   window.open( fileName, windowName, 'scrollbars=no,width=' + width + ',height=' + height ).focus();
};

/* all links with rel="external" open in new window...call onload */
docportal.externalLinks = function() {
	if ( !document.getElementsByTagName ) return;
	var anchors = document.getElementsByTagName( 'a' );
	for ( var i = 0; i < anchors.length; i++ ) {
		var anchor = anchors[i];
		if ( anchor.getAttribute( 'href' ) && anchor.getAttribute( 'rel' ) == 'external') {
			anchor.target = "_blank";
		}
	}
};

/* all tables with class="dataTable" get rows with alternating styles...call onload */
docportal.stripes = function() {
	var tables = YAHOO.util.Dom.getElementsByClassName('dataTable', 'table');
	if ( tables || nodeType == 1 ) {
		for ( i = 0; i < tables.length; i++ ) {
			var tbodys = tables[i].getElementsByTagName('tbody');
			if ( tbodys || nodeType == 1 ) {
				for ( j = 0; j < tbodys.length; j++ ){
					var rows = tbodys[j].getElementsByTagName('tr');
					for ( k = 1; k < rows.length; k += 2 ) {
						YAHOO.util.Dom.addClass( rows[k], 'alt' );
					}
				}
			}
		}
	}
};

/* Slideshow script */
slideshow = {
	current:0,
	init:function(){
		if(document.getElementById && document.createTextNode){
			var list = document.getElementById('slideshow');
			if(list){
				slideshow.items = list.getElementsByTagName('li');
				slideshow.all = slideshow.items.length;
				if(slideshow.all > 1){
					YAHOO.util.Dom.addClass(list, 'js');
					slideshow.createNav(list);
				}
			}
		}
		slideshow.show();
	},
	createNav:function(o){
		var theNav = document.createElement('div');
		YAHOO.util.Dom.addClass(theNav, 'deckNav');
		slideshow.prev = document.createElement('a');
		YAHOO.util.Dom.addClass(slideshow.prev, 'previous');
		slideshow.prev.setAttribute('href', '#');
		var templabel = document.createTextNode(slideshow.labels.previous);
		slideshow.prev.appendChild(templabel);
		YAHOO.util.Event.addListener(slideshow.prev, "click", slideshow.show);
		theNav.appendChild(slideshow.prev);

		slideshow.count = document.createElement('span');
		YAHOO.util.Dom.addClass(slideshow.count, 'progress');
		templabel = document.createTextNode( (slideshow.current+1) + slideshow.labels.counterDivider + slideshow.all);
		slideshow.count.appendChild(templabel);
		theNav.appendChild(slideshow.count);

		slideshow.next = document.createElement('a');
		YAHOO.util.Dom.addClass(slideshow.next, 'next');
		slideshow.next.setAttribute('href', '#');
		var templabel = document.createTextNode(slideshow.labels.next);
		slideshow.next.appendChild(templabel);
		YAHOO.util.Event.addListener(slideshow.next, "click", slideshow.show);
		theNav.appendChild(slideshow.next);

		x = o.parentNode;
		y = x.nextSibling;
		y.appendChild(theNav, o);
		//o.parentNode.insertBefore(theNav, o);
	},
	show:function(e){
		if(this === slideshow.next || this === slideshow.prev){
			YAHOO.util.Dom.removeClass(slideshow.items[slideshow.current], 'current');
			var addto = this === slideshow.next ? 1 : -1;
			slideshow.current = slideshow.current + addto;
			if(slideshow.current < 0){
				slideshow.current = (slideshow.all-1);
			}
			if(slideshow.current > slideshow.all-1){
				slideshow.current = 0;
			}
		}
		var templabel = document.createTextNode( (slideshow.current+1) + slideshow.labels.counterDivider + slideshow.all);
		slideshow.count.replaceChild(templabel, slideshow.count.firstChild);
		YAHOO.util.Dom.addClass(slideshow.items[slideshow.current], 'current');
		slideshow.cancelClick(e);
	},
	cancelClick:function(e){
		if (window.event){
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		}
		if (e && e.stopPropagation && e.preventDefault){
			e.stopPropagation();
			e.preventDefault();
		}
	}
}

slideshow.deck1 = { showID:'slideshow' }
slideshow.labels = {	previous:' ', next:' ', counterDivider:' of ' }
//email script
function emailToFriend() {
	var _subject = document.title;
	var _body = "A note about CBC Docs \n\r";
	var _url = window.location.href;
	window.location.replace("mailto:?subject=" + _subject + "&body=" + _body + _url);
}

