//learnMoreText variable to be updated for Our MFPs pages printer rollover copy
var learnMoreText='Click to learn more &raquo;';

var theCounter=0;
var tempPageName='';
var tempSet=false;
function loadFunctions(){
	$("#bottomnav img").hover(function(){
		$(this).css('margin-top','-63px');									   
	},function(){
		if(!$(this).parent('a').hasClass('on')){
			$(this).css('margin-top','0');					
		}					   
	});
	$("#bottomnavHome img").hover(function(){
		$(this).css('margin-top','-63px');									   
	},function(){
		if(!$(this).parent('a').hasClass('on')){
			$(this).css('margin-top','0');					
		}					   
	});
	shareLink();
	readyIcons();
	readyPrinters();
	setupContact();
}
function bottomNav(obj,state){
	if(state=="over"){
		$("#bottomnav img").each(function(){
			if(!$(this).parent('a').hasClass('on')){
				$(this).css('margin-top','0');	
			}
		});
		$("#bottomnavHome img").each(function(){
			if(!$(this).parent('a').hasClass('on')){
				$(this).css('margin-top','0');	
			}
		});
		$(obj).css('margin-top','-63px');	
	} else {
		if(!$(obj).parent('a').hasClass('on')){
			$(obj).css('margin-top','0');
		} else {
			$(obj).css('margin-top','-63px');
		}
	}
}
function shareLink(){
	//loop up to 10 times until the social stuff has loaded
	theCounter++;
	if($("#social_column1_1").length>0 && theCounter<10){
		$("#shareLink").attr("href","javascript: loadScript('1');");
	} else {
		setTimeout("shareLink()",50);	
	}
}
//this function will be called by the Flash
function rollButton(theButton){
	$("#bottomnav img").removeClass('on');
	$("#bottomnavHome img").removeClass('on');
	switch(theButton){
		case 'helpbtn':
			$("#helpbtn").addClass('on');
			break;
		case 'approachbtn':
			$("#approachbtn").addClass('on');
			break;
		case 'mfpbtn':
			$("#mfpbtn").addClass('on');
			break;
	}
}
function openpop(){
	$("#popup").fadeIn();	
}
function closepop(){
	$("#popup").fadeOut();	
}
function readyIcons(){
	if($(".icon").length>0){
		$(".icon").mouseover(function(){
			if($(".solution").length>0){
				$(this).next(".solution").fadeIn();							  
			} else {
				$(this).next("span").next(".approachdetail").fadeIn(); 
			}
		}).mouseout(function(){
			if($(".solution").length>0){
				$(".solution").hide();
			} else {
				$(".approachdetail").hide();
			}
		});
	}
}
var mouseIsIn=false;
function readyPrinters(){
	var tempTag;
	var printerTitle="";
	if($(".printers").length>0){
		$(".printer").mouseover(function(e){
			mouseIsIn=true;
			printerTitle=$(this).children("a").html();
			$(this).children("a").html(learnMoreText);
			$(this).children("a").css("color","#FFFFFF");
			if(tempTag!=printerTitle){
				$(".printdetail").hide();	
			}
			$(this).children(".printdetail").fadeIn();
			tempTag=printerTitle;
		}).mouseout(function(e){
			$(this).children("a").html(printerTitle);
			$(this).children("a").css("color","#4584aa");
			mouseIsIn=false;
			setTimeout(putMouseOut,500);
		});
	}
}
function putMouseOut(){
	if(mouseIsIn==false){
		$(".printdetail").fadeOut();
	}
}
function closeprint(){
	$(".printdetail").fadeOut();
}
function setFooterLinks(){
	$("#helpbtn").attr("href","javascript:SWFAddress.setValue('casestudy/3M');");
	$("#approachbtn").attr("href","javascript:SWFAddress.setValue('our_approach');");
	$("#mfpbtn").attr("href","javascript:SWFAddress.setValue('our_mfps');");
	$("#homebtn").children("a").attr("href","javascript:SWFAddress.setValue('/');");
}
var mouseInC=false;
function setupContact(){
	$("#contactbtn").mouseover(function(){
		if(tempPageName!=s_pageName&&tempSet==false){
			tempPageName=s_pageName;
			s_pageName="IPG|us|en|PPG|Contact Rollover";
			tempSet=true;
		}
		mouseInC=true;
		$("#contactRoll").fadeIn();
		$("#contact_img").attr("src","img/contact_btn_on.jpg");
	}).mouseout(function(){
		mouseInC=false;
		setTimeout(putMouseOutC,500);
	});
	$("#homebtn").mouseover(function(){
		$("#home_img").attr("src","img/home_btn_on.jpg");								 
	}).mouseout(function(){
		$("#home_img").attr("src","img/home_btn.jpg");								 
	});
	$("#sharebtn").mouseover(function(){
		$("#share_img").attr("src","img/share_btn_on.jpg");								  
	}).mouseout(function(){
		$("#share_img").attr("src","img/share_btn.jpg");								  
	});
}
function putMouseOutC(){
	if(mouseInC==false){
		if(s_pageName!=tempPageName&&tempSet==true){
			s_pageName=tempPageName;
			tempPageName='';
			tempSet=false;
		}
		$("#contactRoll").hide();
		$("#contact_img").attr("src","img/contact_btn.jpg");	
	}
}
function forceContact(state){
	if(state=='on'){
		if(tempPageName!=s_pageName&&tempSet==false){
			tempPageName=s_pageName;
			s_pageName="IPG|us|en|PPG|Contact Rollover";
			tempSet=true;
		}
		mouseInC=true;
		$("#contactRoll").fadeIn();
		$("#contact_img").attr("src","img/contact_btn_on.jpg");
	} else {
		mouseInC=false;
		setTimeout(putMouseOutC,500);
	}
}
function forceButton(id,state){
	if(state=='on'){
		if(id.indexOf("home")>-1){
			$("#home_img").attr("src","img/home_btn_on.jpg");								 	
		} else {
			$("#share_img").attr("src","img/share_btn_on.jpg");								  						 
		}
	} else {
		if(id.indexOf("home")>-1){
			$("#home_img").attr("src","img/home_btn.jpg");								 	
		} else {
			$("#share_img").attr("src","img/share_btn.jpg");								  						 
		}
	}
}
function setFooterTo(footerText){
	$("#theLegal").html(footerText);
}
function setBottomNav(theBtn){
	$("#bottomnav a").each(function(){
		if($(this).attr("id")!=theBtn){
			$(this).removeClass("on");
			$(this).children('img').css("margin-top","0");
		}
	});
	$("#bottomnavHome a").each(function(){
		if($(this).attr("id")!=theBtn){
			$(this).removeClass("on");
			$(this).children('img').css("margin-top","0");
		}
	});
	if($("#"+theBtn).length>0){
		$("#"+theBtn).addClass("on");	
		$("#"+theBtn).children("img").css("margin-top","-63px");
	}
}
function showLead(){
	$("#lead").fadeIn();
}
function closeLead(){
	$("#lead").fadeOut();
}
function showLiveEvent(){
	$("#webcast").show();
	setTimeout(callRotation,5000);
}
function hideLiveEvent(){
	$("#webcast").hide();
}
function showSiteNavigation(){
	$("#topButtonsHome").show();
	$("#bottomnavHome").show();
	$("#paybackfooterHome").show();
}
function showEco(){
	$("#ecoSol").fadeIn(500);
}
function closeEco(){
	$("#ecoSol").fadeOut(500);
}
var promoLinks=new Array();
promoLinks[0]='http://www.hp.com/hpinfo/newsroom/press/2009/091116xa.html';
promoLinks[1]='http://inputcreatesoutput.com';
var promoSrc=new Array();
promoSrc[0]='img/hp1inmps.jpg';
promoSrc[1]='img/halvorson.jpg';
var promoAlt=new Array();
promoAlt[0]='Customers name HP #1 in MPS';
promoAlt[1]='INPUT OUTPUT - LIVE - 11/18, 2:30 PM ET - Kaiser Permanentes CEO George Halvorson discusses how IT is making the biggest impact on health care reform. JOINT THE CONVERSATION &raquo;';
var activePromo=0;
function toggleNumber(theImg,state){
	if(!($(theImg).hasClass("on"))){
		if(state=="on"){
			var thisSrc=$(theImg).attr("src");
			if(thisSrc.indexOf("_on")<0){
				thisSrc=thisSrc.replace(".gif","_on.gif");
				$(theImg).attr("src",thisSrc);
				
			}
		} else {
			var thisSrc=$(theImg).attr("src");
			if(thisSrc.indexOf("_on")>-1){
				thisSrc=thisSrc.replace("_on.gif",".gif");
				$(theImg).attr("src",thisSrc);
			}
		}
	}
}
function movepromo(dir){
	if(dir=="left"){
		if(activePromo==0){
			activePromo=promoSrc.length-1;
		} else {
			activePromo--;	
		}
	} else {
		if(activePromo==promoSrc.length-1){
			activePromo=0;
		} else {
			activePromo++;	
		}
	}
	showPromo(activePromo);
}
var promoTimer;
var timerOn=false;
function showPromo(theIndex){
	//if(timerOn==false){
		clearTimeout(promoTimer);
	//}
	activePromo=theIndex;
	var webNav=$(".webnav_num");
	if($("#webcast_nav").children("a").children(".on").length>0){
		var navSrc=$("#webcast_nav").children("a").children(".on").attr("src");
		if(navSrc.indexOf("_on")>-1){
			navSrc=navSrc.replace("_on.gif",".gif");
			$("#webcast_nav").children("a").children(".on").attr("src",navSrc);
			$("#webcast_nav").children("a").children(".on").removeClass("on");
		}
	}
	$(webNav[theIndex]).addClass("on");
	var navSrc=$(webNav[theIndex]).attr("src");
	if(navSrc.indexOf("_on")<0){
		navSrc=navSrc.replace(".gif","_on.gif");
		$(webNav[theIndex]).attr("src",navSrc);
	}
	$("#webcast #promoLink").attr("href",promoLinks[theIndex]);
	$("#webcast #promoImg").attr("src",promoSrc[theIndex]);
	$("#webcast #promoImg").attr("alt",promoAlt[theIndex]);
	promoTimer=setTimeout(callRotation,7000);
}
function callRotation(){
	movepromo('right');
	timerOn=true;
}
function clearTimer(){
	clearTimeout(promoTimer);
	timerOn=false;
}