// <![CDATA[
var news = ["tab-mv","tab-me","tab-mb","tab-mostviewed","tab-mostemailed","tab-mostblogged"];

function showTab(tg,at,tc,ln){
	ln.blur();
	$ = function(e){e = document.getElementById(e); return e;};
	for (i in tg) {$(tg[i]).className = $(tg[i]).className.replace(/active/,"taboff");}
	$(at).className = $(at).className.replace(/taboff/,"active");
	$(tc).className = $(tc).className.replace(/taboff/,"active");
}

var yv_regs = ['yv-regs-bc','yv-regs-cal','yv-regs-edm','yv-regs-mb','yv-regs-mtl','yv-regs-nb','yv-regs-nl','yv-regs-no','yv-regs-ns','yv-regs-ott','yv-regs-pei','yv-regs-sask','yv-regs-tor'];
var yv_regs_li = ['yv-bc','yv-cal','yv-edm','yv-mb','yv-mtl','yv-nb','yv-nl','yv-no','yv-ns','yv-ott','yv-pei','yv-sask','yv-tor'];

function show_yv_reg(elem_id,obj) {
	clear_yv_reg(yv_regs,yv_regs_li);
	obj.parentNode.className = "active";
	document.getElementById(elem_id).className = "content on";
	document.getElementById(elem_id).blur();
}
function clear_yv_reg(arr,arr_li) {
	for (i in arr) document.getElementById(arr[i]).className = "content";
	for (i in arr_li) document.getElementById(arr_li[i]).className = "";
}





YAHOO.yourvoice = function() {
	return {
		start_app : function() {
		},
		load_data : function(connectionQueue) {
			cq = 0;
			var success	= function(o) {
				YAHOO.util.Event.onAvailable(connectionQueue[cq].connection.htmlobj,function() {
					connectionQueue[cq].connection.render_e(o.responseText,connectionQueue[cq].connection);
					queueCycle();
				})
			};
			var failure	= function(o) {
				if(connectionQueue.length == cq) {
					YAHOO.util.Dom.setStyle(connectionQueue[cq].htmlobj,'display','none');
				} else {
					connectionQueue[cq].connection.render_fe(o.responseText,connectionQueue[cq].connection);
					queueCycle();
				}
			};
			var queueCycle = function(qcount) {
				if(connectionQueue[cq+1]) {
					cq++;
					var cObj = YAHOO.util.Connect.asyncRequest('GET',connectionQueue[cq].url,callback);
				}
			};
			var callback = { success : success, failure : failure};
			var cObj = YAHOO.util.Connect.asyncRequest('GET',connectionQueue[cq].url,callback);
		}
	};
}();

comment_handler = function() {
	$comments = new Array();
	return {
		init : function() {
			$T_ch = this;
		},
		render_comments : function(_str,_render_obj) {
			var response = eval("("+_str+")");
			var linkset = '';
			for (i in response.comments) {
				$comments.push({url:response.comments[i].url,user:response.comments[i].user,quote:response.comments[i].quote,article_title:response.comments[i].article_title});
				linkset += '<img id="comment-'+i+'" src="/news/yourvoice/img/scr-dot.gif" alt="'+i+'" class="dot" />';
			}
			YAHOO.util.Event.onAvailable(_render_obj.ready_container, function() {
				document.getElementById(_render_obj.ready_container).innerHTML = linkset;
				$T_ch.show_comment(0);
			});
		},
		show_comment : function(_commentIndex) {
			var elems = document.getElementById('commentitems').getElementsByTagName('IMG');
			var current_comment = elems[_commentIndex];

			if (current_comment) {
				for (i=0;i < elems.length;i++) document.getElementById('comment-'+i).src = "/news/yourvoice/img/scr-dot.gif";
				document.getElementById('commentreader').getElementsByTagName('SPAN')[0].innerHTML = $comments[_commentIndex].user;
				document.getElementById('commentbody').innerHTML = '<img id="quoteleft" src="/includes/gfx/comments/comment_quoteleft.gif" />'+$comments[_commentIndex].quote+'<img id="quoteright" src="/includes/gfx/comments/comment_quoteright.gif" />';
				current_comment.src = "/news/yourvoice/img/scr-dot-mo.gif";

				if ((_commentIndex+1) == 1) document.getElementById('bt-scr-back').innerHTML = '<img src="img/scr-back.gif" alt="&gt;"/>';
				else document.getElementById('bt-scr-back').innerHTML = '<a href="#" onclick="YAHOO.yourvoice.blogComments.show_comment('+(_commentIndex-1)+')"><img src="img/scr-back.gif" alt="&gt;"/></a>';

				if ((_commentIndex+1) == elems.length) document.getElementById('bt-scr-next').innerHTML = '<img src="img/scr-next.gif" alt="&gt;"/>';
				else document.getElementById('bt-scr-next').innerHTML = '<a href="#" onclick="YAHOO.yourvoice.blogComments.show_comment('+(_commentIndex+1)+')"><img src="img/scr-next.gif" alt="&gt;"/></a>';
			}
		},
		render_fail : function(_str,_render_obj) {
			YAHOO.util.Dom.setStyle(_render_obj.htmlobj,'display','none');
		}
	}
}();


/***********************************************
* Random Content (from DIVs) script- by JavaScript Kit (www.javascriptkit.com)
* This notice must stay intact for usage
* Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and 100s more
***********************************************/

if (document.getElementById)
document.documentElement.className = 'jsclass'; //hide content for DOM capable browsers


var randomcontentdisplay={
	divholders:new Object(),
	masterclass: "randomcontent",

	init:function(){
		if (!document.getElementById)
			return
		var alldivs=document.getElementsByTagName("div")
		var randomcontentsearch=new RegExp(this.masterclass+"\\s+(group\\d+)", "i") //check for CSS class="randomcontent groupX" (x=integer)
		for (var i=0; i<alldivs.length; i++){
			if (randomcontentsearch.test(alldivs[i].className)){
				if (typeof this.divholders[RegExp.$1]=="undefined") //if array to hold this group of divs doesn't exist yet
					this.divholders[RegExp.$1]=new Array() //create array first
					this.divholders[RegExp.$1].push(alldivs[i]) //add this div to the array
			}
		}
	this.showone()
	},

	showone:function(){
		for (group in this.divholders){ //loop thru each array within object
			var chosenOne=Math.floor(Math.random()*this.divholders[group].length) //randomly pick one entry from array
			this.divholders[group][chosenOne].style.display="block" //display content corresponding to the chosen entry
		}
	}
}


// ]]>
