//
//JS for scrolling special promotions & programs in the home page
//    
    // the variable place is used to keep track of the position one's in when clicking through a module.
	var place =0;
	var place_new;    
			
	var timerID;	
	// functions to show and hide mouseover content
	function show(module, x){
		// fix test for broken IE footer links
		
		if (timerID){
			clearTimeout(timerID);
		}else{}

		x.style.display = 'block';
		if (module == 'promo'){
			// display promo stuff
			document.getElementById("promo_text").innerHTML = promo_parent[0][2];
		}else{
			// if promo stuff is around, get rid of it
				document.getElementById("promo_rollover").style.display = "none";
		}
	}	
	
	// click utility function. this function dynamically populates the contents from the parent arrays
		// note: need to pass which module as a parameter to this function as well.
	function utility(module, place){
		if (module == 'promo'){
			document.getElementById("promo_current").innerHTML = place+1;
			document.promo_mod_image.src = promo_parent[place][0];
			document.getElementById("promo_link").href = promo_parent[place][1];
			var gaOnclick = "pageTracker._trackPageview('Home: " + promo_parent[place][2] + "');";
			document.getElementById("promo_link").onclick = new Function(gaOnclick);
			document.getElementById("promo_text").innerHTML = promo_parent[place][2];
			document.getElementById("promo_description").innerHTML = promo_parent[place][3];
		} else 
		{
		document.getElementById("prog_current").innerHTML = place+1;
			document.prog_mod_image.src = prog_parent[place][0];
			document.getElementById("prog_link").href = prog_parent[place][1];
            var gaOnclick = "pageTracker._trackPageview('Home: " + prog_parent[place][2] + "');";
			document.getElementById("prog_link").onclick = new Function(gaOnclick);
			document.getElementById("prog_text").innerHTML = prog_parent[place][2];
			document.getElementById("prog_description").innerHTML = prog_parent[place][3];
		}
	}
	
	// function for click activity
	function click(module, direction)
	{    
		if (module == 'promo')
		{
			if (direction == 'left'){
				// direction left
				if (place == 0){
					place = promo_parent.length-1;
				}else{
					place--;
				}
			utility('promo', place);
			}else{
				// direction right
				if (place+1 >= promo_parent.length){
					place = 0;
				}else{
					place++;
				}
			utility('promo', place);
			}
		}
		else
		{
			if (direction == 'left'){
				// direction left
				if (place == 0){
					place = prog_parent.length-1;
				}else{
					place--;
				}
			utility('prog', place);
			}else{
				// direction right
				if (place+1 >= prog_parent.length){
					place = 0;
				}else{
					place++;
				}
			utility('prog', place);
			}
		}

	}
	
	
	function getElmtRef(strElmtId) {
		if (!document.getElementById) {
			return document.all[strElmtId];
		} else {
			return document.getElementById(strElmtId);
		}
	}
	
	//Quilogy Start Feb 2009
    //The following has been added to randomize the promotions & programs
    function initializeArrays()
    {
    promo_parent.sort(function() {return 0.5 - Math.random()}); //Promotions Array elements now randomized
    utility('promo', place); //Position the first promotion after randomizing

    prog_parent.sort(function() {return 0.5 - Math.random()}); //Promotions Array elements now randomized
    utility('prog', place); //Position the first program after randomizing
    }

    _spBodyOnLoadFunctionNames.push("initializeArrays");
    //Quilogy End Feb 2009
