
/*
here you place the ids of every element you want.
var ids = new Array('CPEChampions','CSIChampions','LiveChampions','EnterpriseSearch','CircleofExcellence','MSUDiversity','ServicesGRGP','2004AwardArchieve','2005AwardArchieve','2006AwardArchieve','2007AwardArchieve');
var ids = new Array();
*/
var ids = new Array('Position1','Position2','Position3','Position4','Position5','Position6','Position7','solutionSubContent','salesSubContent');

var salesids = new Array( 'SalesPosition1', 'SalesPosition2', 'SalesPosition3', 'SalesPosition4', 'SalesPosition5', 'SalesPosition6', 'SalesPosition7', 'SalesPosition8', 'SalesPosition9', 'SalesPosition10', 'SalesPosition11', 'SalesPosition12', 'SalesPosition13', 'SalesPosition13');

/*var marketingids = new Array('MarketingPosition1', 'MarketingPosition2', 'MarketingPosition3', 'MarketingPosition4', 'MarketingPosition5', 'MarketingPosition6', 'MarketingPosition7', 'MarketingPosition8', 'MarketingPosition8', 'MarketingPosition9', 'MarketingPosition10', 'MarketingPosition11', 'MarketingPosition12');

var customerserviceids = new Array('CustomerServicePosition1', 'CustomerServicePosition2', 'CustomerServicePosition3', 'CustomerServicePosition4', 'CustomerServicePosition5', 'CustomerServicePosition6', 'CustomerServicePosition7', 'CustomerServicePosition8', 'CustomerServicePosition8');

var heroids = new Array('HeroPosition1', 'HeroPosition2', 'HeroPosition3', 'HeroPosition4', 'HeroPosition5', 'HeroPosition6', 'HeroPosition7', 'HeroPosition8', 'HeroPosition9', 'HeroPosition10', 'HeroPosition11');


var t2linkids = new Array('Tier2Link1','Tier2Link2','Tier2Link3','Tier2Link4','Tier2Link5','Tier2Link6','Tier2Link7');

var t2ids = new Array('Tier2Position1','Tier2Position2','Tier2Position3','Tier2Position4');

var hpStories = new Array('Ad0','Ad1', 'Ad2', 'Ad3', 'Ad4','Ad5');*/
var linkids = new Array('Link1', 'Link2', 'Link3', 'Link4', 'Link5', 'Link6', 'Link7', 'Link8','Link9', 'Link10', 'Link11', 'Link12', 'Link13');

var hpStories = new Array('Ad01', 'Ad02', 'Ad03');

var hpStoriesDelay = 3000;





function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if (opacStart > opacEnd) {
        for (i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')", (timer * speed));
            timer++;
        }
    } else if (opacStart < opacEnd) {
        for (i = opacStart; i <= opacEnd; i++) {
            setTimeout("changeOpac(" + i + ",'" + id + "')", (timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
    //if an element is invisible, make it visible, else make it ivisible
    if (document.getElementById(id).style.opacity == 0) {
        opacity(id, 0, 100, millisec);
    } else {
        opacity(id, 100, 0, millisec);
    }
}

function blendimage(divid, imageid, imagefile, millisec) {
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //set the current image as background
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";

    //make image transparent
    changeOpac(0, imageid);

    //make new image
    document.getElementById(imageid).src = imagefile;

    //fade in image
    for (i = 0; i <= 100; i++) {
        setTimeout("changeOpac(" + i + ",'" + imageid + "')", (timer * speed));
        timer++;
    }
}

function currentOpac(id, opacEnd, millisec) {
    //standard opacity is 100
    var currentOpac = 100;

    //if the element has an opacity set, get it
    if (document.getElementById(id).style.opacity < 100) {
        currentOpac = document.getElementById(id).style.opacity * 100;
    }

    //call for the function that changes the opacity
    opacity(id, currentOpac, opacEnd, millisec)
}

var TimeToFade = 3000.0;
var FadeActive = true;

function stopFade() {
    FadeActive = false;
}

function startFade() {
    FadeActive = true;
    
}

function rotateStory() {
    var indexNextStory = 0;
    var currentStory;
    currentStory = readCookie('CurrentStory');
    
    
    for (var i = 0; i < hpStories.length; i++) {
        if (currentStory == hpStories[i]) {
            indexNextStory = i + 1;
        }
    }
    if (indexNextStory >= hpStories.length) {
        indexNextStory = 0;
    }
    if (FadeActive == true) {

        switchStories(hpStories[indexNextStory]);
        /*fade(hpStories[indexNextStory]);*/
        
        /*shiftOpacity(hpStories[indexNextStory], 2000);*/
        
        createCookie("CurrentStory", hpStories[indexNextStory], 10);
        setTimeout('rotateStory()',hpStoriesDelay);
    } else {
        setTimeout('rotateStory()', hpStoriesDelay);
    }
}

function switchStories(id) {
    hideallSalesids(hpStories);
    /*hideallimgs(id);*/
    
    /*
    var object = document.getElementById(id).style;
    object.opacity = 0;
    object.MozOpacity = 0;
    object.KhtmlOpacity = 0;
    object.filter = "alpha(opacity=" + 0 + ")";
    */
    showdiv(id);
    /*showhideimage(id);*/
}

function setlinkColor(id)
{ setlinkcolorWhite();
   
  
   setlinkcolorBlue(id, '#112e58')
  
}


function setlinkcolorBlue(id, newcolor)
{
    if (document.getElementById) { /* DOM3 = IE5, NS6 */
		document.getElementById(id).style.color = newcolor;
		
	}
	else {
		if (document.layers) { /* Netscape 4*/
			document.id.color = newcolor;
			
		}
		else { /* IE 4*/
			document.all.id.style.color = newcolor;
		}
	}

}

function setlinkcolorWhite(){
	/* loop through the array and hide each element by id */
		
	for (var i=0;i<=linkids.length;i++){

	    if(document.getElementById(linkids[i]) != null){
	   	        if (document.getElementById) {
	   	    /* DOM3 = IE5, NS6 */	   	    	   
		            document.getElementById(linkids[i]).style.color = '#fff';
            		
	            }
	            else {

		            if (document.layers) { /* Netscape 4*/
			            document.linkids[i].color = '#fff';
            			
		            }
		            else { /* IE 4*/
			            document.all.linkids[i].style.color = '#fff';
			            
		            }
	            }
	   	        //linkids[i].style.color = '#fff';
		    }
            
	}		  
}

function displayMenuActive(){
    var currentNav;
    currentNav = readCookie('CurrentNav');
    if (currentNav != null){
        switchid(currentNav);
    }
}
function displayIntroActive(){
    var currentBT;
    currentBT = readCookie('blueTableContent');
    if (currentBT != null){
        switchintroid(currentBT);
    }
}

function switchid(id){	
	hideallids(id);
	/*hideallimgs(id);*/
	showdiv(id);
	/*showhideimage(id);*/
}

function switchSalesPosition(id) {
    hideallSalesids(salesids);
    /*hideallimgs(id);*/
    showdiv(id);
    /*showhideimage(id);*/
}
function switchMarketingPosition(id) {
    hideallMarketingids(marketingids);
    /*hideallimgs(id);*/
    showdiv(id);
    /*showhideimage(id);*/
}

function switchCustomerServicePosition(id) {
    hideallMarketingids(customerserviceids);
    /*hideallimgs(id);*/
    showdiv(id);
    /*showhideimage(id);*/
}

function switchHeroPosition(id) {
    hideallSalesids(heroids);
    /*hideallimgs(id);*/
    showdiv(id);
    /*showhideimage(id);*/
}

function switchTier2Hero(id){	
	hideallT2ids(id, t2ids);
	/*hideallimgs(id);*/
	showdiv(id);
	/*showhideimage(id);*/
}

function switchintroid(id){	
	showhideintro(id);
	showhideintroimage(id);
}

function showhide(id){
    if (document.getElementById) { /* DOM3 = IE5, NS6 */
	    if(document.getElementById(id) != null){
	        if(document.getElementById(id).style.display == 'none'){
	            showdiv(id);
	            createCookie("CurrentNav",id,10);    
	        }else{
                hidediv(id);
                eraseCookie("CurrentNav");    
	        }
		}
	}
	else {
		if(document.id != null){
	        if(document.id.display == 'none'){
	            showdiv(id);
	        }else{
	            hidediv(id);
	        }
	    }
    }
}


function showhideintro(id){
    if (document.getElementById) { /* DOM3 = IE5, NS6 */
	    if(document.getElementById(id) != null){
	        if(document.getElementById(id).style.display == 'none'){
	            showdiv(id);
	            createCookie("blueTableContent",id,10);    
	        }else{
                hidediv(id);
                eraseCookie("blueTableContent");    
                
	        }
		}
	}
	else {
		if(document.id != null){
	        if(document.id.display == 'none'){
	            showdiv(id);
	        }else{
	            hidediv(id);
	        }
	    }
    }
}

function hideallids(id){
	/* loop through the array and hide each element by id */
	for (var i=0;i<ids.length;i++){
	    if(ids[i] != id)
	    {
	        if(document.getElementById(ids[i]) != null){
	   	        hidediv(ids[i]);
		    }
		}
	}		  
}
function hideallSalesids(ids) {
    /* loop through the array and hide each element by id */
    for (var i = 0; i < ids.length; i++) {
        if (document.getElementById(ids[i]) != null) {
            hidediv(ids[i]);
        }
    }
}

function hideallMarketingids(ids) {
    /* loop through the array and hide each element by id */
    for (var i = 0; i < ids.length; i++) {
        if (document.getElementById(ids[i]) != null) {
            hidediv(ids[i]);
        }
    }
}
function hideallT2ids(id, ids) {
	/* loop through the array and hide each element by id */
	for (var i=0;i<ids.length;i++){
	    if(ids[i] != id)
	    {
	        if(document.getElementById(ids[i]) != null){
	   	        hidediv(ids[i]);
		    }
		}
	}		  
}
function hideallimgs(id){
	/*loop through the array and hide each element by id */
	for (var i=0;i<ids.length;i++){
	    if(ids[i] != id)
	    {
	        if(document.getElementById(ids[i]) != null){
    		    showhideimage(ids[i]);
		    }
		}
	}		  
}

function hidediv(id) {
	/*safe function to hide an element with a specified id*/
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { /* Netscape 4 */
			document.id.display = 'none';
		}
		else { /* IE 4 */
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	/* safe function to show an element with a specified id */
		  
	if (document.getElementById) { /* DOM3 = IE5, NS6 */
		document.getElementById(id).style.display = 'block';
		/*document.getElementById(id).style.zIndex=100;*/
		
		
	}
	else {
		if (document.layers) { /* Netscape 4*/
			document.id.display = 'block';
			/*document.id.zIndex=100;*/
		}
		else { /* IE 4*/
			document.all.id.style.display = 'block';
        	/*document.all.id.stule.zIndex=100;*/
		}
	}
}


function showhideimage(id){
    
    if (document.getElementById) { /* DOM3 = IE5, NS6*/
        if(document.getElementById(id) != null){
	  
            if(document.getElementById(id).style.display == 'none')
            {
		        document.getElementById(id+'Img').src = '/images/plus.gif';
		    }else
		    {
		        document.getElementById(id+'Img').src = '/images/minus.gif';
		    }
	    }
	}
	else {
		if (document.layers) { /* Netscape 4*/
	    	if(document.id != null){
	  
		        if(document.id.display == 'none')
		        {
			        document[id+'Img'].src = '/images/plus.gif';
			    }else
			    {
			        document[id+'Img'].src = '/images/minus.gif';
			    }
			}
		}
		else { /* IE 4 */
		    if(document.all.id != null){
		        if(document.all.id.style.display == 'none')
		        {
			        document.all[id+'Img'].src = '/images/plus.gif';
			    }
			    else
			    {
			        document.all[id+'Img'].src = '/images/minus.gif';
			    }
			}
		}
	}
}

function showhideintroimage(id){
    
    if (document.getElementById) { /* DOM3 = IE5, NS6*/
        if(document.getElementById(id) != null){
	  
            if(document.getElementById(id).style.display == 'none')
            {
		        document.getElementById(id+'Img').src = '/images/intro_BTN_expand_19x19.gif';
		    }else
		    {
		        document.getElementById(id+'Img').src = '/images/intro_BTN_collapse_19x19.gif';
		    }
	    }
	}
	else {
		if (document.layers) { /* Netscape 4*/
	    	if(document.id != null){
	  
		        if(document.id.display == 'none')
		        {
			        document[id+'Img'].src = '/images/intro_BTN_expand_19x19.gif';
			    }else
			    {
			        document[id+'Img'].src = '/images/intro_BTN_collapse_19x19.gif';
			    }
			}
		}
		else { /* IE 4 */
		    if(document.all.id != null){
		        if(document.all.id.style.display == 'none')
		        {
			        document.all[id+'Img'].src = '/images/intro_BTN_expand_19x19.gif.gif';
			    }
			    else
			    {
			        document.all[id+'Img'].src = '/images/intro_BTN_collapse_19x19.gif.gif';
			    }
			}
		}
	}
}
function createCookie(name,value,days) {
    if (days) 
    {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else
	{ 
	    expires = "";
	}
	document.cookie = name+"="+value+expires+"; path=/";
	
}

function readCookie(name) {
    var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function resetDotNetScrollPosition()
{
    var scrollX = document.getElementById('__SCROLLPOSITIONX');
    var scrollY = document.getElementById('__SCROLLPOSITIONY');

    if(scrollX != null && scrollY != null)
    {
        scrollX.value = 0;
        scrollY.value = 0;
    }
}    
