﻿var debug = false;

// global jquery
$(document).ready(function() {
	// hide border on last menu item
	$("#menuItems li:last").css({ 'border-right': 'none' });
	$('div:has(a.more) > a.more').parent().css({ paddingBottom: "15px", position: "relative" });
	$('div:has(a.more) > a.more').css({ position: "absolute", right: "10px", bottom: "0px" });
	// equalize colunns in video block
	$("div#videoBlock > .tout").equalizeCols();
});

function writeToConsole(msg) {
	if (debug && typeof (console) != 'undefined') {
		console.log(msg);
	}
}
function sendToFriendPop(link) {
	if (link != "") {
		url = "http://www.cbn.com/sendtofriend/sendtofriend.aspx?link=" + link;
	}
	else {
		url = "http://www.cbn.com/sendtofriend/sendtofriend.aspx";
	}

	window.open(url, "sendtofriend", "status=no,height=340,width=540,scrollbars=yes,resizable=no,toolbar=0");
}
function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
	if (document.layers)	   //NN4+
	{
		alert("option1");
		document.layers[szDivID].visibility = iState ? "show" : "hide";
		document.layers[szDivID].moveToAbsolute(10, 10);
	}
	else if (document.getElementById)	  //gecko(NN6) + IE 5+
	{
		alert("option2");
		var obj = document.getElementById(szDivID);
		obj.style.visibility = iState ? "visible" : "hidden";
		obj.style.position = "absolute";
		obj.style.top = "10px";
		obj.style.left = "10px";
	}
	else if (document.all)	// IE 4
	{
		alert("option3");
		document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
		document.all[szDivID].style.position = "absolute";
		document.all[szDivID].style.top = "10px";
		document.all[szDivID].style.left = "10px";
	}
}

function randomAdLink(SIZE) {
	// create array to hold ad data  ([ad image],[alt text],[ad link])
	var adList = new Array(
        new Array("ShopCBN-EatThisNotThat", "Shop CBN", "http://www.cbn.com/shop"),
        new Array("Bible", "Online Bible", "http://bible.cbn.com/default.aspx"),
        new Array("News", "CBN News", "/cbnnews/index.aspx"),
        new Array("Podcasts-Guy", "PodCasts", "/podcast/index.aspx"),
        new Array("Bible_ReadingPlan", "Online Bible Reading Plan", "http://bible.cbn.com/default.aspx"),
        new Array("Podcasts-Girl2", "Podcasts", "/podcast/index.aspx"),
        new Array("Podcasts-Girl3", "Podcasts", "/podcast/index.aspx"),
        new Array("Podcasts-Guy2", "Podcasts", "/podcast/index.aspx"),
        new Array("Podcasts", "Podcasts", "/podcast/index.aspx"),
        new Array("Bible_woman2", "Online Bible", "http://bible.cbn.com/default.aspx"),
        new Array("Blogs", "Blogs", "/communitypublic/interactiveblogs.aspx"),
        new Array("Blogs2", "Blogs", "/communitypublic/interactiveblogs.aspx"),
        new Array("CBNTV", "CBN TV", "/media/index.aspx")
    );

	// randomly select an ad to display
	var adNum = Math.floor(Math.random() * adList.length);

	// add article ad below the article image
	var adLink = '<a href="' + adList[adNum][2] + '"><img src="http://downloads.cbn.com/ads/' + adList[adNum][0] + '_' + SIZE + '.jpg" alt="' + adList[adNum][1] + ' advertisement" border=0></a>';

	return adLink;
}
