
function homeSignIn(){
	var ind=new Image();
	ind.src="http://cdn.buzznet.com/assets/indicator.gif";
	if(getValByName("username","main_login").toLowerCase()=="username" || !getValByName("username","main_login")){
		findObj("main_username").style.borderColor="#FF0000";
		return false;
	}
	if(!getValByName("password","main_login")){
		findObj("main_password").style.borderColor="#FF0000";
	}
	hideAll("loginFields","forgotLogin","homeSignInButtonContainer");
	toggleDisp("loginProgress","block");
	return true;
}


// show and hide div instructions for top story animation
var topStoryFlag = "firstClick";

var timeHeading0;
var timeHeading1;
var timeHeading2;
var timeBtnBar;

var elementId0;
var elementId1;
var elementId2;
var bar;
var barPx;

function showTopStory(storyId) {

	if (topStoryFlag == "firstClick") {
	topStoryFlag = "A";
	}

//h = hide, s = show
	
var hHeadingContId = "callOutHeadingCont_" + topStoryFlag;
//alert(hHeadingContId + " = hide Heading");
var sHeadingContId = "callOutHeadingCont_" + storyId;
//alert(sHeadingContId + " = show Heading");

var hHeadingId0 = "callOutHeading_" + topStoryFlag + "0";
var hHeadingId1 = "callOutHeading_" + topStoryFlag + "1";
var hHeadingId2 = "callOutHeading_" + topStoryFlag + "2";
//alert("turn off: " + hHeadingId0 + ", " + hHeadingId1 + ", " + hHeadingId2);

var sHeadingId0 = "callOutHeading_" + storyId + "0";
var sHeadingId1 = "callOutHeading_" + storyId + "1";
var sHeadingId2 = "callOutHeading_" + storyId + "2";
//alert("turn on: " + sHeadingId0 + ", " + sHeadingId1 + ", " + sHeadingId2);

var hFormContId = "callOutRegFormCont_" + topStoryFlag;
var sFormContId = "callOutRegFormCont_" + storyId;
//alert(hFormContId);
//alert(sFormContId);

var hFormId = "callOutRegForm_" + topStoryFlag;
var sFormId = "callOutRegForm_" + storyId;

var btnSlideBar = "callOutBtnSlideBar";

var hImageContId = "topStoryImageCont_" + topStoryFlag;
var sImageContId = "topStoryImageCont_" + storyId;
//alert(hImageId + ": hide Image")

var hImageId = "topStoryImage_" + topStoryFlag;
var sImageId = "topStoryImage_" + storyId;
//alert(sImageId + ": show Image")
	
	// heading containers
	document.getElementById(hHeadingContId).style.display = "none";
	document.getElementById(hHeadingContId).style.left = "-8000px";
	
	document.getElementById(sHeadingContId).style.display = "block";
	document.getElementById(sHeadingContId).style.left = "0px";
	
	// form containers
	document.getElementById(hFormContId).style.display = "none";
	document.getElementById(hFormContId).style.left = "-15000px";
	
	document.getElementById(sFormContId).style.display = "block";
	document.getElementById(sFormContId).style.left = "0px";
	
	// forms
	document.getElementById(hFormId).style.display = "none";
	document.getElementById(hFormId).style.left = "-14000px";
	
	document.getElementById(sFormId).style.display = "block";
	document.getElementById(sFormId).style.left = "0px";
	
	bar = btnSlideBar;

	// slide bar
	if  (storyId == "A") {
	
		if(topStoryFlag == "B") {
		barPx = "0";
		slideBtnBar();
		}
		if(topStoryFlag == "C") {
		barPx = "0";
		slideBtnBar();
		}
		if(topStoryFlag == "firstClick") {
		barPx = "0";
		slideBtnBar();
		}
		if(topStoryFlag == "A") {
		barPx = "0";
		slideBtnBar();
		}
	}
	
	if (storyId == "B") {
	
		if(topStoryFlag == "A") {
		barPx = "154";
		slideBtnBar();
		}
		if(topStoryFlag == "C") {
		barPx = "154";
		slideBtnBar();
		}
		if(topStoryFlag == "firstClick") {
		barPx = "154";
		slideBtnBar();
		}
	}
	
	if (storyId == "C") {
	
		if(topStoryFlag == "B") {
		barPx = "308";
		slideBtnBar();
		}
		if(topStoryFlag == "A") {
		barPx = "308";
		slideBtnBar();
		}
		if(topStoryFlag == "firstClick") {
		barPx = "308";
		slideBtnBar();
		}
	}
		
	//headings
	document.getElementById(hHeadingId0).style.left = "462px";
				element0 = sHeadingId0;
				
	document.getElementById(hHeadingId1).style.left= "462px";
				element1 = sHeadingId1;
				//timeHeading1 = setTimeout("slideBar1()", 1500);
	
	document.getElementById(hHeadingId2).style.left = "462px";
				element2 = sHeadingId2;
				//timeHeading2 = setTimeout("slideBar2()", 2500);
				
	// images
	document.getElementById(hImageContId).style.display = "none";
	document.getElementById(hImageContId).style.left = "-16000px";
	document.getElementById(hImageContId).style.visibility = "hidden";
	
	document.getElementById(sImageContId).style.display = "block";
	document.getElementById(sImageContId).style.left = "0px";
	document.getElementById(sImageContId).style.visibility = "visible";
	
	document.getElementById(hImageId).style.display = "none";
	document.getElementById(hImageId).style.left = "-16000px";
	document.getElementById(hImageId).style.visibility = "hidden";
	
	document.getElementById(sImageId).style.display = "block";
	document.getElementById(sImageId).style.left = "0px";
	document.getElementById(sImageId).style.visibility = "visible";
	
	topStoryFlag = storyId;
	//alert(topStoryFlag + "=topStoryFlag");
}

var animeTimer;

//anime is for the top story sliders animation
function anime(elementID, newLeft, newTop, newWidth,
      newHeight, time, callback)
{
  var el = document.getElementById(elementID);
  
 // alert(el.id + "foo");

  var cLeft = parseInt(el.style.left);
  var cTop = parseInt(el.style.top);
  var cWidth = parseInt(el.style.width);
  var cHeight = parseInt(el.style.height);
 
  var slideLimit = 1;
  if(time> 0)
    slideLimit = time/60;

  var fLeft = newLeft - cLeft;
  if(fLeft != 0)
    fLeft /= slideLimit;
 
  var fTop = newTop - cTop;
  if(fTop != 0)
    fTop /= slideLimit;
 
  var fWidth = newWidth - cWidth;
  if(fWidth != 0)
    fWidth /= slideLimit;
 
  var fHeight = newHeight - cHeight;
  if(fHeight != 0)
    fHeight /= slideLimit;
   
  actSlider(elementID, cLeft, newLeft, fLeft, cTop, newTop, fTop, cWidth, newWidth, fWidth, cHeight, newHeight, fHeight, callback);
}

function actSlider(eID, cLeft, nLeft, fLeft, cTop, nTop, fTop, cWidth, nWidth, fWidth, cHeight, nHeight, fHeight, callback) {
      
   var el = document.getElementById(eID).style;
   
   //if(el == null)
   //return;

  cLeft = slideSet(cLeft, nLeft, fLeft);
  cTop = slideSet(cTop, nTop, fTop);
  cWidth = slideSet(cWidth, nWidth, fWidth);
  cHeight = slideSet(cHeight, nHeight, fHeight);

  el.left = Math.round(cLeft) + 'px';
  el.top = Math.round(cTop) + 'px';
  el.width = Math.round(cWidth) + 'px';
  el.height = Math.round(cHeight) + 'px';
 
  if(cLeft == nLeft && cTop == nTop && cHeight == nHeight
    && cWidth == nWidth)
  {   
    clearTimeout(animeTimer);
    //alert(el);
    return;
  }
  animeTimer = setTimeout( 'actSlider("'+eID+'",'+cLeft+','+nLeft+','+fLeft+','+cTop+','+nTop+','+fTop+','+cWidth+','+nWidth+','+fWidth+','+cHeight+','+nHeight+','+fHeight+','+callback+')', 60);
}

function slideSet(slideSum, slidePoint, slideDist)
{
  if(slideDist == 0 || slideSum == slidePoint)
    return slidePoint;
 
  slideSum += slideDist;
  if((slideDist> 0 && slideSum>= slidePoint) || (slideDist <0 && slideSum <= slidePoint))
  {
    return slidePoint;
  }
  return slideSum;
}

function slideBar0()
{
   anime(element0, 0, 0, 462, 40, 250, null); 
   clearTimeout(timeHeading0);
}

function slideBar1()
{
   anime(element1, 0, 0, 462, 40, 250, null);
   clearTimeout(timeHeading1);
}

function slideBar2()
{
   anime(element2, 0, 0, 462, 40, 250, null);
   clearTimeout(timeHeading2);
}

function slideBtnBar()
{
	//alert(barPx);
 anime(bar, barPx, 0, 153, 5, 250, null);   

	timeHeading0 = setTimeout("slideBar0()", 550);
	timeHeading1 = setTimeout("slideBar1()", 1150);
	timeHeading2 = setTimeout("slideBar2()", 1750);
}


// dropDownRollUpA, B, C control the sequences for the List Charts
// to rotate through the lists automatically

var currentA = 0;
var currentB = 0;
var currentC = 0;
var clickFlag = 0;
var autoView = "True";

var intervalAutoViewA;
var intervalAutoViewB;
var intervalAutoViewC;


//automatically show the next list in sequence if user has not interacted (clicked) on any lists

function startAutoViewA(cnt) {
	if(autoView == "True") {
		//alert(cnt);
		intervalAutoViewA = setInterval("showNext('A', 'auto', " + cnt + ", 0)", 10000);
	}
	//clearTimeout(timerAutoViewA);
}

function startAutoViewB(cnt) {
	if(autoView == "True") {
		//alert(cnt);
		intervalAutoViewB = setInterval("showNext('B', 'auto', " + cnt + ", 0)", 10000);
	}
	//clearTimeout(timerAutoViewB);
}

function startAutoViewC(cnt) {
	if(autoView == "True") {
		//alert(cnt);
		intervalAutoViewC = setInterval("showNext('C', 'auto', " + cnt + ", 0)", 10000);
	}
	//clearTimeout(timerAutoViewC);
}

function showPrev(listId, listItem, totalList) {
		
var listC = "listChart_" + listId + listItem;

	autoView = "True"; // set autoView flag to false to stop the automatic rotation and call the timeout for the timer
	clearInterval(intervalAutoViewA);
	clearInterval(intervalAutoViewB);
	clearInterval(intervalAutoViewC);
	
	// turn off/hide the current list
	document.getElementById(listC).style.display = "none";
	document.getElementById(listC).style.visibility = "hidden";
	document.getElementById(listC).style.left = "-1000px";
	// hide  the current group first
	
	if (listItem == 0) // check if its zero
	{
		//alert(listItem + ":this is list zero");
		listId = "listChart_"+ listId + totalList;
		//turn on the previous element, in this case the last in the group because it's zero
		document.getElementById(listId).style.visibility = "visible";
		document.getElementById(listId).style.display = "block";
		document.getElementById(listId).style.left = "0px";
		// make the next one in the loop visible
	} else {
		//alert(listItem + ": this is not zero");
		var item = Math.ceil((listItem - 1));
		listId = "listChart_" + listId + item;
		//alert(listItem);
		document.getElementById(listId).style.visibility = "visible";
		document.getElementById(listId).style.display = "block";
		document.getElementById(listId).style.left = "0px";
	}
}

function showNext(listId, listItem, totalList, clickFlag) {

var listC = "listChart_" + listId + listItem;

	//detect clickFlag (if user clicked the Prev button or not), it not run the listAutomatically
	if (clickFlag == 0) {
			
		// detect and set the current list view for auto sequence
		if(listId == "A") {
            if(listItem == 'auto'){
                listItem = currentA;
            }
		//alert(currentA + "first pass");

			
			if(currentA == totalList)
			{
				var listAuto = "listChart_" + listId + currentA; 
				//alert(listAuto);
				document.getElementById(listAuto).style.display = "none";
				document.getElementById(listAuto).style.visibility = "hidden";
				document.getElementById(listAuto).style.left = "-1000px";
				
				listItem = 0; // it's the last in the list so set back to zero
				var listAuto = "listChart_" + listId + listItem;
				currentA = 0; 
				//alert(currentA = ":current A xxx");
				document.getElementById(listAuto).style.display = "block";
				document.getElementById(listAuto).style.visibility = "visible";
				document.getElementById(listAuto).style.left = "0px";
				
			} else {
			
				if(currentA >= "0") {
				
				var listAuto = "listChart_" + listId + listItem; 
				//alert(listAuto);
				document.getElementById(listAuto).style.display = "none";
				document.getElementById(listAuto).style.visibility = "hidden";
				document.getElementById(listAuto).style.left = "-1000px";		
					
				listItem = Math.ceil((listItem + 1));
				var listAuto = "listChart_" + listId + listItem; 
				currentA = listItem;
				//alert(currentA + ":current A value after recalculation");
				document.getElementById(listAuto).style.display = "block";
				document.getElementById(listAuto).style.visibility = "visible";
				document.getElementById(listAuto).style.left = "0px";
				}
			}
		}
		
		if(listId == "B") {
            if(listItem == 'auto'){
                listItem = currentB;
            }
			//alert(currentB + "first pass");

			if(currentB == totalList)
			{
				var listAuto = "listChart_" + listId + currentB; 
				//alert(listAuto);
				document.getElementById(listAuto).style.display = "none";
				document.getElementById(listAuto).style.visibility = "hidden";
				document.getElementById(listAuto).style.left = "-1000px";		
			
				listItem = 0; // it's the last in the list so set back to zero
				var listAuto = "listChart_" + listId + listItem;
				currentB = 0; 
				//alert(currentB = ":current B xxx");
				document.getElementById(listAuto).style.display = "block";
				document.getElementById(listAuto).style.visibility = "visible";
				document.getElementById(listAuto).style.left = "0px";
				
			} else {
			
				if(currentB >= "0") {
				
				var listAuto = "listChart_" + listId + listItem; 
				//alert(listAuto);
				document.getElementById(listAuto).style.display = "none";
				document.getElementById(listAuto).style.visibility = "hidden";
				document.getElementById(listAuto).style.left = "-1000px";	
				
				listItem = Math.ceil((listItem + 1));
				var listAuto = "listChart_" + listId + listItem; 
				currentB = listItem;
				//alert(currentB + ":current B value after recalculation");
				document.getElementById(listAuto).style.display = "block";
				document.getElementById(listAuto).style.visibility = "visible";
				document.getElementById(listAuto).style.left = "0px";
				}
			}
		}
		
		if(listId == "C") {
            if(listItem == 'auto'){
                listItem = currentC;
            }
			//alert(currentC + "first pass");
			
			if(currentC == totalList)
			{
			
				var listAuto = "listChart_" + listId + currentC; 
				//alert(listAuto);
				document.getElementById(listAuto).style.display = "none";
				document.getElementById(listAuto).style.visibility = "hidden";
				document.getElementById(listAuto).style.left = "-1000px";		
			
				listItem = 0; // it's the last in the list so set back to zero
				var listAuto = "listChart_" + listId + listItem;
				currentC = 0; 
				//alert(currentC = ":current C xxx");
				document.getElementById(listAuto).style.display = "block";
				document.getElementById(listAuto).style.visibility = "visible";
				document.getElementById(listAuto).style.left = "0px";
				
			} else {
			
				if(currentC >= "0") {
				
				var listAuto = "listChart_" + listId + listItem; 
				//alert(listAuto);
				document.getElementById(listAuto).style.display = "none";
				document.getElementById(listAuto).style.visibility = "hidden";
				document.getElementById(listAuto).style.left = "-1000px";	
				
				listItem = Math.ceil((listItem + 1));
				var listAuto = "listChart_" + listId + listItem; 
				currentC = listItem;
				//alert(currentC + ":current C value after recalculation");
				document.getElementById(listAuto).style.display = "block";
				document.getElementById(listAuto).style.visibility = "visible";
				document.getElementById(listAuto).style.left = "0px";
				}
			}
		}
					
	} else {
	
		autoView = "True"; // set autoView flag to false to stop the automatic rotation and call the timeout for the timer
		clearInterval(intervalAutoViewA);
		clearInterval(intervalAutoViewB);
		clearInterval(intervalAutoViewC);
	
		// turn off/hide the current list
		document.getElementById(listC).style.display = "none";
		document.getElementById(listC).style.visibility = "hidden";
		document.getElementById(listC).style.left = "-1000px";
					
		if (listItem == totalList) // check if its the last in the list
		{
			//alert(listItem + ":this is last in list so show zero");
			item = listId + "0";
			listId = "listChart_"+ item; 
			//alert(listId);
			//turn on the previous element, in this case the last in the group because it's zero
			document.getElementById(listId).style.visibility = "visible";
			document.getElementById(listId).style.display = "block";
			document.getElementById(listId).style.left = "0px";
			// make the next one in the loop visible
		} else {
		
			if (listItem >= "0") // check if its greater than or equal to the first list "zero"
			{
				//alert(listItem + ":this is greater than or equal to the first list 'zero'");
				var item = Math.ceil((listItem + 1));
				listId = "listChart_"+ listId + item;
				//alert(item = ": this may be zero ro greater but it's not the last");
				//alert(listId);
				document.getElementById(listId).style.visibility = "visible";
				document.getElementById(listId).style.display = "block";
				document.getElementById(listId).style.left = "0px";
			}
		}
	}
}


// animation dropDownRollUp functions trigger the loading and animation of the List Charts
var aniA;
var aniB;
var aniC;

function dropDownRollUpA(elm,toHeight,delay) {

// check for the status of animation sequence...

var pxHigh1  = parseInt(elm.style.height);
var pxLen1 = toHeight-pxHigh1;
var pxSum1 = pxHigh1+Math.ceil((pxLen1/4));
elm.style.height = pxSum1+'px';

	function x() {
	dropDownRollUpA(elm,toHeight,delay);
	}
		if(pxLen1 <= 0) {
		clearTimeout(timer1);
		resetHeightA(elm,toHeight,delay);
		return;
	}
	timer1 = setTimeout(x,delay);
}
				
function resetHeightA(elm,toHeight,delay) {
	//alert(elm.style.height);
	var pxHigh11  = parseInt(elm.style.height);
	var pxLen11 = toHeight-20;
	var pxSum11 = Math.ceil((pxLen11/4));
	elm.style.height = pxSum11+'px';
	 
	function x() {
	resetHeightA(elm,toHeight,delay);
				 
		if(pxLen11 = -20) {
		clearTimeout(timer11);
		aniA = true;
		//alert(aniA);
		document.getElementById('listChart_B0').style.visibility = "visible";
		document.getElementById('listChart_B0').style.display = "block";
		dropDownRollUpB(document.getElementById('listChartLabelCont_B0'), 40, 150);
		return;
	 }
	}
	timer11 = setTimeout(x,delay);
}

function dropDownRollUpB(elm,toHeight,delay) {
//check for the status of animation sequence...
//alert(elm.style.height);
var pxHigh2  = parseInt(elm.style.height);
var pxLen2 = toHeight-pxHigh2;
var pxSum2 = pxHigh2+Math.ceil((pxLen2/4));
elm.style.height = pxSum2+'px';
	
	function y() {
	dropDownRollUpB(elm,toHeight,delay);
	}
		if(pxLen2 <= 0) {
		clearTimeout(timer2);
		resetHeightB(elm,toHeight,delay);
		return;
	}
	timer2 = setTimeout(y,delay);
}
		
function resetHeightB(elm,toHeight,delay) {
//alert(elm.style.height);
var pxHigh22  = parseInt(elm.style.height);
var pxLen22 = toHeight-20;
var pxSum22 = Math.ceil((pxLen22/4));
elm.style.height = pxSum22+'px';
	 
	function y() {
	resetHeightB(elm,toHeight,delay);
				 
		if(pxLen22 = -20) {
		clearTimeout(timer22);
		aniB = true;
		//alert(aniB);
		document.getElementById('listChart_C0').style.visibility = "visible";
		document.getElementById('listChart_C0').style.display = "block";
		dropDownRollUpC(document.getElementById('listChartLabelCont_C0'), 40, 150);
		return;
		}
	}
	timer22 = setTimeout(y,delay);
}

function dropDownRollUpC(elm,toHeight,delay) {
//check for the status of animation sequence...
//alert(elm.style.height);
var pxHigh3  = parseInt(elm.style.height);
var pxLen3 = toHeight-pxHigh3;
var pxSum3 = pxHigh3+Math.ceil((pxLen3/4));
elm.style.height = pxSum3+'px';
	
	function z() {
	dropDownRollUpC(elm,toHeight,delay);
		}	 
		if(pxLen3 <= 0) {
		clearTimeout(timer3);
		resetHeightC(elm,toHeight,delay);
		return;
		
	}
	timer3=setTimeout(z,delay);
}
	
function resetHeightC(elm,toHeight,delay) {
//alert(elm.style.height);
var pxHigh33  = parseInt(elm.style.height);
var pxLen33 = toHeight-20;
var pxSum33 = Math.ceil((pxLen33/4));
elm.style.height = pxSum33+'px';

	function z() {
	resetHeightC(elm,toHeight,delay);
	
		if(pxLen33 = -20) {
		clearTimeout(timer33);
		aniC = true;
		//alert(aniC);
		timerAutoViewA = setTimeout("startAutoViewA()", 3000);
		timerAutoViewB = setTimeout("startAutoViewB()", 5000);
		timerAutoViewC = setTimeout("startAutoViewC()", 7000);
		return;
		}
	}
	timer33 = setTimeout(z,delay);
}

function autorotate(countA,countB,countC){
    timerA = setTimeout('startAutoViewA('+countA+')','0');
    timerB = setTimeout('startAutoViewB('+countB+')','500');
    timerC = setTimeout('startAutoViewC('+countC+')','1000');
}


//*******************  START Heroshot class  ***********************

function Heroshot(numrows){
    if(!Heroshot.Instances) Heroshot.Instances = new Array();
    this.id = Heroshot.Instances.length;
    Heroshot.Instances[this.id] = this;
    
    this._fmmnumrows = numrows;
    this._currentfmm = numrows;
    this._fmmnumrows;
    this._currentfmm;
    this._stepsize;
    this._fadecounter;
    this._fadetimer;
    this._rotatetimer;
    this._rotationspeed;
    this._rotateCounter = 0;
    this._stepsize = 6;
    this._rotationspeed = 8500;
    
    this._setOpacity = function(el,value){
        if(this._rotateCounter==1) {
            value = 100;
        }
        var object = document.getElementById(el).style;
        object.opacity = (value/100);
        object.MozOpacity = (value/100);
        object.filter = 'alpha(opacity='+value+')';
        return;
    }
    this._fmm_fade_loop = function(fmmId){ 
        if(this._fadecounter >= 100+this._stepsize){
            clearInterval(this._fadetimer);
            this._currentfmm = fmmId;
        }
        else{
            this._setOpacity("fmm"+fmmId,this._fadecounter);
            this._fadecounter = this._fadecounter + this._stepsize;
        }
        return;
    }
    this.fmm_display = function(fmmId,stoploop){
        if(typeof(stoploop)=="undefined") stoploop = false;
        if(fmmId != this._currentfmm){
            clearInterval(this._fadetimer);
            for(i=0;i<=this._fmmnumrows;i++){
                if(i != this._currentfmm){
                    this._setOpacity('fmm'+i,0);
                    document.getElementById('fmm'+i).style.zIndex=0;
                }
            }
            document.getElementById('fmm'+fmmId).style.zIndex=2;
            document.getElementById('fmm'+this._currentfmm).style.zIndex=1;
            this._fadecounter = 0;
            if(stoploop==true){
                clearTimeout(this._rotatetimer);
                this._stepsize = 20;
            }
            this._fadetimer = setInterval('Heroshot.Instances['+this.id+']._fmm_fade_loop('+fmmId+')',1);
        }
        return;
    }
    this.fmm_rotate = function(){
        this._rotateCounter++;
        clearTimeout(this._rotatetimer);
        clearInterval(this._fadetimer);
        if(this._currentfmm == this._fmmnumrows){
            this.fmm_display(0);
        } else {
            this.fmm_display(this._currentfmm+1);
        }
        this._rotatetimer = setTimeout('Heroshot.Instances['+this.id+'].fmm_rotate()',this._rotationspeed);
    }
}

//********************* END Heroshot Class *************************
