﻿// $Id: hubpromobox.js 2365 2008-06-09 20:09:25Z michaelw $
var tpromo;
var tpromo2;
var divID = "promo";
var max = 4;
//var max = eval("document.aspnetForm."+divID+"maxcont").value;
var current = 1;
var previous = max;
var next = 1;
var promoid = 'titlepromo';
var nexttitleid = 'titlepromo2';

    //setNextPromo(max);
//    function showText()
//    {        
//        if (eval("document.aspnetForm.titlepromo2"))
//            document.getElementById('promoNext').innerText = eval("document.aspnetForm.titlepromo2").value;
//        
//    }
    
	function promoTimeout() {
		tpromo = setTimeout("NextContent('promo')", 10000);
		tpromo2 = setTimeout("promoTimeout()", 10000);
	}
	
	//?
	//SetInitialContent('promo'); 
	//not included in email, but I guess it contain code to intialize first promo
	//
	promoTimeout();
	function NextContent(divID) {
		try {
			var currcont = parseInt(eval("document.aspnetForm."+divID+"currcont").value);
			var maxcont = parseInt(eval("document.aspnetForm."+divID+"maxcont").value);

			if (currcont == 0) 
				currcont = 1;
			
			if (nextcont > maxcont)
				nextcont = 1;
				
		
			var nextcont = (currcont % maxcont) + 1
				
			eval("document.aspnetForm."+divID+"currcont").value = nextcont;
			
			target = divID+"Numbers";
			document.getElementById(target).innerHTML = "<strong>"+nextcont+"</strong> of "+maxcont+" ";
			
//			setNextPromo(currcont);
			target = divID+"Next";
			var temp = (nextcont % maxcont) + 1
			if (eval("document.aspnetForm.title"+divID+temp))
			    document.getElementById(target).innerHTML = eval("document.aspnetForm.title"+divID+temp).value;
			
			idcc = divID+currcont;
			idnc = divID+nextcont;
			for (i=1; i<=maxcont; i++) {
				idcc = divID+i;
				document.getElementById(idcc).style.display = 'none';
			}
			
			document.getElementById(idnc).style.display = 'block';
			
			//alert('ga tag here for ' + idnc);
			ga_taglinksForPromo(idnc);
//			if (divID == "spot" ) {
//				addEventsToLinks2(idnc); 
//				setNextPromo(currcont);

//			} else {
//				addEventsToLinks(divID + (nextcont -1));
//			}
			
		} catch (err) {
		//	
		} // Ignore errors
	}

	function PrevContent(divID) {
		var currcont = parseInt(eval("document.aspnetForm."+divID+"currcont").value);
		var maxcont = parseInt(eval("document.aspnetForm."+divID+"maxcont").value);
		
		if(currcont == 0)
			currcont = 1;
		if (currcont > maxcont)
			currcont = maxcont;
			
		var nextcont = currcont;
		var prevcont = currcont -  1;
		if (prevcont < 1)
			prevcont = maxcont;
		
//		setNextPromo(currcont);
		eval("document.aspnetForm."+divID+"currcont").value = prevcont;
		
		target = divID+"Numbers";
		document.getElementById(target).innerHTML = " <b>"+prevcont+"</b> of "+maxcont+" ";
		
		target = divID+"Next";
		if (eval("document.aspnetForm.title"+divID+nextcont))
		    document.getElementById(target).innerHTML = eval("document.aspnetForm.title"+divID+nextcont).value;
		
		idcc = divID+currcont;
		idnc = divID+prevcont;
		for (i=1; i<=maxcont; i++) {
			idcc = divID+i;
			document.getElementById(idcc).style.display = 'none';
		}
		document.getElementById(idnc).style.display = 'block';
		//alert('ga tag here for ' + idnc);
		ga_taglinksForPromo(idnc);
	}
	
	function setNextPromo(current) {
		// 1 = 3, 2 = 4, 3 = 1, 4 = 2
//		if ( current == 1 || current == 2 ) {		
//			next = current + 2;
//		} else {
//			next = current -2;
//		}
		try {
			//nexttitleid = promoid + next;			
			if (eval("document.aspnetForm.titlepromo2"))
			{
			    document.getElementById('promoNext').innerHTML = eval("document.aspnetForm.titlepromo2").value;// document.getElementById(nexttitleid).value;			
			}
			//current = next;
		} catch (err) {
			// ignore errors
		}
	}
	
