var currentHouseCallsChapter = "2294";
var currentHouseCallsCategory = "51";
function openHouseCalls() {
	var houseCallsUrl = "/primetime/bigbrother5/insider/index.php?chap=" + currentHouseCallsChapter + "&cat=" + currentHouseCallsCategory + "&hc=1";
	openWin(houseCallsUrl,758,517,'insWin','no');
}

	//Variables for EmbedFlash function*******************************************
//****************************************************************************
var v_bio_nav="/primetime/bigbrother5/swf/bio_nav.swf";
var v_voting="/primetime/bigbrother5/swf/voting.swf";
var v_pop_results="/primetime/bigbrother5/swf/pop_results.swf";
var v_grand_prize="/primetime/bigbrother5/swf/grand_prize.swf";
var v_house_tour="/primetime/bigbrother5/swf/house_tour.swf";
var v_top_right="/primetime/bigbrother5/swf/top_right.swf";
//Image substitution
var v_bio_nav_image="/primetime/bigbrother5/images/swf/bio_nav.gif";
var v_voting_image="/primetime/bigbrother5/images/swf/voting.gif";
var v_pop_results_image="/primetime/bigbrother5/images/swf/pop_results.gif";
var v_grand_prize_image="/primetime/bigbrother5/images/swf/grand_prize.gif";
var v_house_tour_image="/primetime/bigbrother5/images/swf/house_tour.gif";
var v_top_right_image="/primetime/bigbrother5/images/swf/top_right.gif";
//var v_macromedia="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash target='_blank'";


//***************************************************************************
//Right Navigation for the Freeze Frames Pages**********************************

function extrason(fNumber) {
	document.images[fNumber].src = "/primetime/bigbrother5/show/w" + wnumber + "/photos/freeze_on.gif";
}

//***************************************************************************
//Tertiary Navigation for Fantasy League**************************************
if(document.images){
	for (i=1; i<=4; i++){ 
	eval("fantnav"+i+"_on = new Image()");eval("fantnav"+i+"_on.src = '/primetime/bigbrother5/images/fantasy/nav/fantnav"+i+"_on.gif'");
	}
}

function fantasy_nav_on(fantnumber) {
	document.images["fantnav" + fantnumber].src = eval("fantnav" + fantnumber + "_on.src");
}


//*******************************************************************************
//Right side dropdown navigation for fantasy league
function houseguestPoints() {
	Item = pointsby.houseguest.selectedIndex;
	if(pointsby.houseguest.options[Item].value != '--- Choose Houseguest ---') document.location = pointsby.houseguest.options[Item].value;
}

function categoryPoints() {
	Item = pointsby.category.selectedIndex;
	if(pointsby.category.options[Item].value != '--- Choose Houseguest ---') document.location = pointsby.category.options[Item].value;
}



//***************************************************************************
//Right Navigation for the Show Pages*****************************************

for (i=1; i<8; i++){ 
eval("wk"+i+"_on = new Image()");eval("wk"+i+"_on.src = '/primetime/bigbrother5/images/show/nav/wk"+i+"_on.gif'");
eval("wk"+i+"t_on = new Image()");eval("wk"+i+"t_on.src = '/primetime/bigbrother5/photos/shownav/wk"+i+"t_on.gif'");
eval("wk"+i+"w_on = new Image()");eval("wk"+i+"w_on.src = '/primetime/bigbrother5/photos/shownav/wk"+i+"w_on.gif'");
eval("wk"+i+"f_on = new Image()");eval("wk"+i+"f_on.src = '/primetime/bigbrother5/photos/shownav/wk"+i+"f_on.gif'");
}

stayOn = new Array()
stayOn[1] = "#FEDF95";
stayOn[2] = "#FEDF95";
stayOn[3] = "#FEDF95";
stayOn[4] = "#FEDF95";
stayOn[5] = "#FEDF95";
stayOn[6] = "#FEDF95";
stayOn[7] = "#FEDF95";
stayOn[8] = "#FEDF95";
stayOn[9] = "#FEDF95";
stayOn[10] = "#FEDF95";
stayOn[11] = "#FEDF95";
stayOn[12] = "#FEDF95";
stayOn[13] = "#FEDF95";

function change(id, newClass, theTDrow, tdToStay) {
	document.images['nav_'+theTDrow].src = '/primetime/bigbrother5/images/show/nav/wk'+tdToStay+'_on.gif'

	identity=document.getElementById(id);
	identity.className=newClass;
	
	if(bb5_IE)eval('document.all.'+theTDrow+'.style.backgroundColor="#FFF4C8"');
	if(bb5_NS)eval('document.'+theTDrow+'.backgroundColor="#FFF4C8"');
	if(bb5_N6)
	{
	bb5_td = document.getElementById(theTDrow);
	bb5_td.style.backgroundColor = "#FFF4C8";
	}
	
	stayOn[tdToStay] = "#FFF4C8"
}

//***************************************************************************
//Right Navigation for the Freeze Pages*****************************************

function changeFreeze(id, newClass) {
	identity=document.getElementById(id);
	identity.className=newClass;
}

//****************************************************************************
//topnav drop menu************************************************************
// all functions and variables were given bb5_ appended to the front to *******
// dinstinguish them from any functions and variables in core.js**************

if(document.images){
for (i=1; i<=7; i++)
{
eval("topnav_"+i+"_off = new Image()");eval("topnav_"+i+"_off.src = '/primetime/bigbrother5/images/topnav/topnav_"+i+"_off.gif'");
eval("topnav_"+i+"_on = new Image()");eval("topnav_"+i+"_on.src = '/primetime/bigbrother5/images/topnav/topnav_"+i+"_on.gif'");
}

}

function bb5_imgOn(Num) {
bb5_SubNavHideAll()
if (document.images) {
document.images["topnav_" +Num].src = eval("topnav_" +Num+ "_on.src")
}
}

function bb5_imgOff(Num) {
if (document.images) {
document.images["topnav_" +Num].src = eval("topnav_" +Num+ "_off.src")
}
}

//***START SUBNAVIGATION CODE*****************
var bb5_NS = (document.layers) ? 1 : 0;
var bb5_IE = (document.all && document.getElementById) ? 1 : 0;
var bb5_N6 = (!document.all && document.getElementById) ? 1 : 0;
var bb5_hideMenu = null;

function bb5_SubNavHide(paramDiv){
if(bb5_IE)eval('document.all.'+paramDiv+'.style.visibility="hidden"');
if(bb5_NS)eval('document.'+paramDiv+'.visibility="hidden"');
if(bb5_N6)
	{
	bb5_elm = document.getElementById(paramDiv);
	bb5_elm.style.visibility = "hidden";
	}
}

function bb5_SubNavShow(paramDiv){
bb5_SubNavHideAll();
if(bb5_IE)eval('document.all.'+paramDiv+'.style.visibility="visible"');
if(bb5_NS)eval('document.'+paramDiv+'.visibility="visible"');
if(bb5_N6)
	{
	bb5_elm = document.getElementById(paramDiv);
	bb5_elm.style.visibility = "visible";
	}
}

function bb5_SubNavHideAll(){
bb5_SubNavHide('subnav_1');
bb5_SubNavHide('subnav_2');
bb5_SubNavHide('subnav_3');
bb5_SubNavHide('subnav_5');
bb5_SubNavHide('subnav_6');
bb5_SubNavHide('subnav_legend');
}
//***END SUBNAVIGATION CODE*****************




//***********************************************************************
//Chat redirect script***************************************************
function gochat() {
var popurl="http://forums.prospero.com/n/pfx/forum.aspx?webtag=cbsbb&nav=chat";
winpops=window.open(popurl,"","width=680,height=540,");
}
//***********************************************************************




//Poll function*****************************************************
function vote(address,pollName){
var qID = 0
var radioGrp = document.forms[pollName].q1;
	for (var i = 0; i < radioGrp.length; i++){
		if (radioGrp[i].checked) {qID = radioGrp[i].value}}
	if (qID == 0) {
		alert('Please select an answer before voting.');
	} else {
		var whandle = window.open( address + qID, "pollWin", "width=510,height=420,menubar=0,location=0,scrollbars=0", "0" );
		whandle.focus();
	}
}
//**********************************************************************



//////////////////////////////////////////////////////////////////////////////////////////////
//Live Stream redirect script***************************************************
//*****************************************************************************
document.write('<OBJECT ID="IERPCtl" WIDTH=0 HEIGHT=0 CLASSID="CLSID:FDC7A535-4070-4B92-A0EA-D9994BCC0DC5"></OBJECT>');


function isRealOne() {

        RealOneInst = 'undetermined';
        
        var agt=navigator.userAgent.toLowerCase();
        var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                        && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                        && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
        if (is_nav) {
                IERPCtl = 0;
        }
        
	

      
        if (navigator.plugins) {
                if ((navigator.userAgent.charAt(8)) >= ('3'))
                {
                var nPlayerInstalled=2;
                var i=0;
                while (navigator.plugins[i])
                        {
                        if ((navigator.plugins[i].name) == 'RealOne Player Version Plugin')
                                {
                                        nPlayerInstalled=1;
                                        szPlayerVersion=navigator.plugins[i].description;
                                        break;
                                }
                        i++;
                        }
        
                        if ( nPlayerInstalled == 2 )
                        {
                                var nRPVersion = IERPCtl.RealPlayerVersion;
                                if ( nRPVersion == null )
                                {
                                nPlayerInstalled=2;
                                } else {
                                nPlayerInstalled=1;
                                }
                        }
                }       

                if (nPlayerInstalled == 1)
                {
                RealOneInst = 'installed';  
                } 
                if (nPlayerInstalled == 2)
                {
                RealOneInst = 'notinstalled';
                }
        } else {
        RealOneInst = 'undetermined';
        }
        if (RealOneInst == 'installed') {
                if (agt.indexOf("(r1 ") != -1) {
                        RealOneInst = 'using';
                }
        }

        return RealOneInst;     
		
}

		
function loadlink(page,premium) {

	var checkbrowser = isRealOne();

	if (checkbrowser == 'using') {
	     window.location = (page);
	}

	if (checkbrowser == 'installed') {
	     window.location = (page);
	}

	if (checkbrowser =='undetermined' || checkbrowser =='notinstalled') {

		
		if (navigator.userAgent.indexOf("Mac") != -1) {
			
		document.location = "http://www.real.com/partners/bigbrother/?pcode=cbs&cpath=R1R&rsrc=cbs.bb5";	
		}
		else {if (navigator.userAgent.indexOf("95") != -1) {
		document.location = "http://www.real.com/partners/bigbrother/?pcode=cbs&cpath=R1R&rsrc=cbs.bb5";
		}
		else {if (navigator.userAgent.indexOf("Linux") != -1) {
		window.open('/primetime/bigbrother5/popups/otherOS.html','r1popup','width=250,height=180,toolbar=no,scrollbars=no,resizable=no,directories=no,location=no,status=no,menubar=no');	
		}
		else {
			if (premium == 'yes') {
			document.location = "http://www.real.com/partners/bigbrother/?pcode=cbs&cpath=R1R&rsrc=cbs.bb5";
			}
	
			if (premium == 'no') {
			//do nothing
			//window.open('/primetime/bigbrother3/popups/free.html','r1popup','width=250,height=160,toolbar=no,scrollbars=no,resizable=no,directories=no,location=no,status=no,menubar=no');
			}
		};
	    };
		};


	}

}

function golivestream() {
	//window.open('/primetime/bigbrother5/popups/247_closed.html','247','width=510,height=300,toolbar=no,scrollbars=no,resizable=no,directories=no,location=no,status=no,menubar=no');
	loadlink('http://start.real.com/rd?pid=bb5&url=bb5_start.smil&pcode=cbs&cpath=CNT&rsrc=cbs.bb5','yes');
}

//Poll function*****************************************************
var rand1 = 0;
var useRand1 = 0;
var useRand2 = 0;
var useRand3 = 0;

main_image = new Array;
main_image[1] = new Image();
main_image[1].src = "/primetime/bigbrother5/images/callouts/callout_housecalls.jpg";
main_image[2] = new Image();
main_image[2].src = "/primetime/bigbrother5/images/callouts/callout_24.jpg";
main_image[3] = new Image();
main_image[3].src = "/primetime/bigbrother5/images/callouts/callout_fantasy.jpg";

main_image2 = new Array;
main_image2[1] = new Image();
main_image2[1].src = "/primetime/bigbrother5/images/callouts/callout_chat.jpg";
main_image2[2] = new Image();
main_image2[2].src = "/primetime/bigbrother5/images/callouts/callout_eliminated.jpg";
main_image2[3] = new Image();
main_image2[3].src = "/primetime/bigbrother5/images/callouts/callout_grand_prize.jpg";
main_image2[4] = new Image();
main_image2[4].src = "/primetime/bigbrother5/images/callouts/callout_love_leave.jpg";

main_image3 = new Array;
main_image3[1] = new Image();
main_image3[1].src = "/primetime/bigbrother5/images/callouts/callout_preview.jpg";
main_image3[2] = new Image();
main_image3[2].src = "/primetime/bigbrother5/images/callouts/callout_bulletin.jpg";
main_image3[3] = new Image();
main_image3[3].src = "/primetime/bigbrother5/images/callouts/callout_interview.jpg";
main_image3[4] = new Image();
main_image3[4].src = "/primetime/bigbrother5/images/callouts/callout_house_tour.jpg";

var droplinks=new Array();
droplinks[1]="/primetime/bigbrother5/video/housecalls.shtml"
droplinks[2]="javascript:golivestream();"
droplinks[3]="/primetime/bigbrother5/fantasy/index.php"

var droplinks2=new Array();
droplinks2[1]="javascript:gochat();"
droplinks2[2]="/primetime/bigbrother5/polls/index.shtml"
droplinks2[3]="/primetime/bigbrother5/polls/index.shtml"
droplinks2[4]="/primetime/bigbrother5/polls/index.shtml"

var droplinks3=new Array();
droplinks3[1]="javascript:openWin('/video/video_mod.html?pt_video_big_brother5_promo.shtml',700,517,'littleWin','no');"
droplinks3[2]="javascript:openWin('/primetime/bigbrother5/newsletter/entryform.html',510,350,'newsletter','no');"
droplinks3[3]="javascript:openWin('/video/video_mod.html?pt_video_bigbrother5_epk.shtml',700,517,'littleWin','no');"
droplinks3[4]="/primetime/bigbrother5/extras/housetour.shtml"

function swapPic1() {
	var imgnum = main_image.length - 1;
	do {
		var randnum = Math.random();
		rand1 = Math.round((imgnum - 1) * randnum) + 1;
	} while (rand1 == useRand1);
	useRand1 = rand1;
	document.co_01.src = main_image[useRand1].src;
}

function rotatelink(){
	window.location=droplinks[rand1]
}

function swapPic2() {
	var imgnum = main_image2.length - 1;
	do {
		var randnum2 = Math.random();
		rand2 = Math.round((imgnum - 1) * randnum2) + 1;
	} while (rand2 == useRand2);
	useRand2 = rand2;
	document.co_02.src = main_image2[useRand2].src;
}

function rotatelink2(){
	window.location=droplinks2[rand2]
}

function swapPic3() {
	var imgnum = main_image3.length - 1;
	do {
		var randnum3 = Math.random();
		rand3 = Math.round((imgnum - 1) * randnum3) + 1;
	} while (rand3 == useRand3);
	useRand3 = rand3;
	document.co_03.src = main_image3[useRand3].src;
}

function rotatelink3(){
	window.location=droplinks3[rand3]
}

function rotateCallouts(){
setTimeout("swapPic1()",5000);
setTimeout("swapPic2()",5000);
setTimeout("swapPic3()",5000);
}

document.onload= rotateCallouts();

// this is for dynamic positioning of the dhtml nav
function dhtmlPos(siteNavHeight) {
	cbsHeader = 50;
	if(document.getElementById('divAdTop') != null) 	{
		var thiselement = document.getElementById('divAdTop');
		vAdTop = thiselement.offsetTop; 
	}
	if(vAdTop==null||vAdTop=="") {
		var vAdTop = 1;
	}
	if(document.getElementById('subnav_1') != null)
		document.getElementById('subnav_1').style.top = vAdTop + cbsHeader + siteNavHeight;
	if(document.getElementById('subnav_2') != null)
		document.getElementById('subnav_2').style.top = vAdTop + cbsHeader + siteNavHeight;
	if(document.getElementById('subnav_3') != null)
		document.getElementById('subnav_3').style.top = vAdTop + cbsHeader + siteNavHeight;
	if(document.getElementById('subnav_4') != null)
		 document.getElementById('subnav_4').style.top = vAdTop + cbsHeader + siteNavHeight;
	if(document.getElementById('subnav_5') != null)
		document.getElementById('subnav_5').style.top = vAdTop + cbsHeader + siteNavHeight;
	if(document.getElementById('subnav_6') != null)
		document.getElementById('subnav_6').style.top = vAdTop + cbsHeader + siteNavHeight;
	if(document.getElementById('subnav_legend') != null)
		document.getElementById('subnav_legend').style.top = vAdTop + cbsHeader + 110;

}