
horiz = {
	currOpen: null,
	pageWidth: 663, 
	numSteps: 10,
	animating: 0,
	playerFile: "flash/4_3_Player.swf", 
	videoFiles: [
		"http://video.westernunion.com/0_0_India.flv",
		"http://video.westernunion.com/0_0_Guatemala.flv",
		"http://video.westernunion.com/0_0_Chinatown.flv",
		"http://video.westernunion.com/1_2_ChairmanPresident.flv",
		"http://video.westernunion.com/3_1_MexicanHometown.flv",
		"http://video.westernunion.com/3_1_Polish.flv",
		"http://video.westernunion.com/3_1_Somali.flv",
		"http://video.westernunion.com/3_2_Mexican_Austin.flv",
		"http://video.westernunion.com/3_2_Phillipines_riingen.flv",
		"http://video.westernunion.com/3_3_Brazil.flv",
		"http://video.westernunion.com/3_3_Phillipines.flv",
		"http://video.westernunion.com/3_6_MercyCorps.flv",
		"http://video.westernunion.com/4_0_China_Ong.flv",
		"http://video.westernunion.com/4_0_employee vid.flv",
		"http://video.westernunion.com/4_0_HongKong_Lai.flv",
		"http://video.westernunion.com/4_0_RobinHeller.flv",
		"http://video.westernunion.com/5_4_LuisPasillas.flv"

	],
	init: function(){
		horiz.setMenu();
		$("#page1").load("page1.html .pageDivInner", {}, function(){
			horiz.injectSWFObject(1);
		});
		
		
		$(".closed").css("width", "0px").css("display", "block");
		
		var x = $("div.pageDiv");
		for (var i=0; i<x.length; i++){
			if(x[i].className.indexOf("open") != -1){
				horiz.currOpen = i;
				$("#menuHeading"+(i+1)).addClass("current");
			}
		}
		
		horiz.showDebug();
	},
	injectSWFObject: function(wFile){
		var so = new SWFObject(horiz.playerFile, "flash1", "368", "276", "9", "#ffffff");
		so.addParam("allowScriptAccess", "sameDomain");
		so.addParam("allowFullScreen", "true");
		so.addParam("skinAutoHide", "true");
		so.addParam("auto-hide", "true");
		so.addParam("flashvars", "vidURL="+horiz.videoFiles[wFile-1]);
		so.write("flash1");

	},
	setMenu: function(){
		$("div.menuHeading a").mouseover(function(){
			horiz.thisClicked(this.parentNode.id);
			this.blur();
			return false;	
		});
	},
	thisClicked: function(wMenu){
		var clickIndex;
		var menus = $("div.menuHeading");
		for (var i=0; i<menus.length; i++){
			if(menus[i].id == wMenu){
				clickIndex = i;
				$("#menuHeading"+(i+1)).addClass("current");
			} else {
				$("#menuHeading"+(i+1)).removeClass("current");
			}
		}
		
		if((horiz.currOpen != clickIndex) && (horiz.animating == 0)) {
			horiz.animating = 1;
			horiz.showPage(clickIndex);
		}
	},
	showPage: function(wPage){
		horiz.stepLoop((horiz.currOpen+1), (wPage+1), 0, horiz.pageWidth/horiz.numSteps);
	},
	stepLoop: function(oldPage, newPage, currStep, stepSize){		
		document.getElementById("page"+oldPage).style.width = ((horiz.numSteps-(currStep+1))*stepSize)+"px";
		document.getElementById("page"+newPage).style.width = ((currStep+1)*stepSize)+"px";
		
		horiz.showDebug();
		
		if(currStep+1 < horiz.numSteps) {
			setTimeout('horiz.stepLoop('+oldPage+', '+newPage+', '+(currStep+1)+', '+stepSize+')', 10);
		} else {
			horiz.currOpen = newPage-1;
			horiz.animating = 0;
			horiz.showDebug();
			
			$("#page"+oldPage).empty()
			$("#page"+newPage).load("page"+newPage+".html .pageDivInner", {}, function(){
				horiz.injectSWFObject(newPage);
			});
		}
	},
	showDebug: function(){
		$("#debug").html("animating: "+horiz.animating+"<br />currOpen: "+horiz.currOpen+"<br />page1wid:"+$("#page1").width()+"<br />page2wid:"+$("#page2").width()+"<br />page3wid:"+$("#page3").width()+"<br />page4wid:"+$("#page4").width()+"<br />page5wid:"+$("#page5").width()+"<br />page6wid:"+$("#page6").width()+"<br />page7wid:"+$("#page7").width());
	}
};


