// JavaScript Document

/// **********************************************************************************************************************************************
/// 													handle Navigation 
/// **********************************************************************************************************************************************
		var PreImageHolder
		var NextImageHolder
		var ImgScroller
		var heightChange
		var FullNavChange
		
		function initProject() {
			
			// Hide Info Div 
			heightChange = new Fx.Style('InfoBackground', 'height', {duration:1000});
			heightChange.set(0);
			document.getElementById("InfoBackground").style.visibility ="visible"
			
			initDownNav(false)
							 	
			initScrollerHolder()
			initNavPreNext(1,0)
			initScrollerText("Info")
			
			if ($("FirstIndx").value != "") {
				replaceDot($("imgItem"+$("FirstIndx").value),"blue","red","projects_red-dot.png")
			}
		}


		function initScrollerText(txtID) {
			if ($(txtID).scrollHeight > $(txtID).offsetHeight) {
				TextScroller = new Fx.Scroll(txtID, {
					wait: false,
					duration: ($(txtID).scrollHeight - $(txtID).offsetHeight)*15,
					transition: Fx.Transitions.Quad.easeInOut
						,onComplete: function() {
							if ($(txtID).scrollTop >0) {
								removeScrollerFromDir("Down")
							} else {
								removeScrollerFromDir("Up")
							}
						}
				});
				initTextBtn("Down")
			}
		}
		 
		function initTextBtn(Dir) {
			if ($("btnText"+Dir).innerHTML == "" || $("btnText"+Dir).innerHTML == null) {
				if (Dir == "Down") {
					endArrowPng = "_up";
				} else {
					endArrowPng = "";					
				}
				$("btnText"+Dir).innerHTML = "<img border='0' id='imgBtnText"+Dir+"' src='images/Arrow"+endArrowPng+".png'/>";
				$("btnText"+Dir).className = "btnCursor"
				if (Dir == "Down") {
					document.getElementById("btnText"+Dir).onmouseover = function () {
						initTextBtn("Up"); 
						TextScroller.toBottom();
						changePic("imgBtnText"+Dir,"images/Arrow_roll.png")
						backImg = "images/Arrow_up.png"
					}
				} else {
					document.getElementById("btnText"+Dir).onmouseover = function () {initTextBtn("Down"); TextScroller.toTop();changePic("imgBtnText"+Dir,"images/Arrow_up_roll.png");backImg = "images/Arrow.png"}
				}
				document.getElementById("btnText"+Dir).onmouseout = function () { TextScroller.stop(); changePic("imgBtnText"+Dir,backImg)}
			}
			correctPNG()
		}
		
		function removeScrollerFromDir(Dir) {
			$("btnText"+Dir).innerHTML = "" 
			$("btnText"+Dir).onmouseover = "" 
			$("btnText"+Dir).onmouseout = "" 
			$("btnText"+Dir).className = "" 
		}

		function LoadItem(NewItemIndx,NewImage,MovieLoader) {
			if (CrrIndex != NewItemIndx) {
				replaceDot($("imgItem"+CrrIndex),"red","blue","projects_blue-dot.png")
				replaceDot($("imgItem"+NewItemIndx),"blue","red","projects_red-dot.png")
				if (NewImage!="") {
					imgTag = "<img src='images/Users/"+NewImage+"'>"
				} else {
					imgTag = MovieLoader
				}
				if (CrrIndex > NewItemIndx) {
					NextImageHolder.innerHTML = imgTag
					ImgScroller.scrollTo(NextImageHolder.parentNode.offsetLeft,0)
				} else {
					PreImageHolder.innerHTML = imgTag
					ImgScroller.scrollTo(PreImageHolder.parentNode.offsetLeft,0)
				}
				CrrIndex = NewItemIndx
				initNavPreNext(0,0)
			}
		}

/// **********************************************************************************************************************************************

		function ShowFullInfo() {
			heightChange.stop()
			heightChange.start(parseInt(document.getElementById("InfoBackground").style.height), 559);
		}
		
		function CloseFullInfo() {
			heightChange.stop()
			heightChange.start(parseInt(document.getElementById("InfoBackground").style.height),0);
		}
/// **********************************************************************************************************************************************
/// 						handle left and right flashes communication
/// **********************************************************************************************************************************************

	var crrY ,crrX,addToBubble
	function SmallrollOver(args) {
		// show pic of item
		var argsArr=new Array()
		argsArr = args.split(",")
		var bubbleObj = document.getElementById("bubbleDiv")
		crrY = parseInt(argsArr[2])
		crrX = parseInt(argsArr[1])
		bubbleObj.style.top = (crrY-65)+"px";
		BeginSide = argsArr[0]
		if (lang == "Heb") {
			if (BeginSide == "true") { 
				bubbleObj.style.right = (-46-crrX+986)+"px";
			} else {
				bubbleObj.style.right = (169-46-crrX+addToBubble)+"px";
			}
		} else {
			if (BeginSide == "true") { 
				bubbleObj.style.left = crrX+"px";
			} else {
				bubbleObj.style.left = (crrX-169+986-addToBubble)+"px";
			}
		}
		document.getElementById("bubbleIn").width = "180"

		getMovieName("bubbleIn").callSmallRollIn(lang,BeginSide)
		lang = lang
  }


 // sometime the roll out is not been called because the mouse roll to fast, this function will check if the mouse is still in the 'area'
// function CheckIfRollOut() {
// 	 if (document.clientX < crrX-10	 || document.clientX > crrX +10 || document.clientY < crrY-10	 || document.clientY > crrY +10
//	 setTimeout(CheckIfRollOut,1000);
//}
  function initFlashes(FirstMenuID) {
  	if (FirstMenuID == "1" || FirstMenuID == "2") {
		widthFlash = 135-1
		if (lang == "Eng") {
			$("RightflashDiv").style.left  = parseInt(850+ 135+1)+"px"
		} else {
			$("RightflashDiv").style.right  = parseInt(850+ 135+1)+"px"
		}
		addToBubble = 0
	} else {
		widthFlash = 170-1
		if (lang == "Eng") {
			$("RightflashDiv").style.left  = parseInt(777+ 170+1)+"px"
		} else {
			$("RightflashDiv").style.right  = parseInt(777+ 170+1)+"px"
		}
		addToBubble = 35
	}
	
	if (version<7) { // just for ie version less then 7
		$("RightflashDiv").style.width = widthFlash+"px"
		$("LeftflashDiv").style.width = widthFlash+"px"
		$("RightflashDiv").style.height = $("openBody").scrollHeight+"px"
		$("LeftflashDiv").style.height = $("openBody").scrollHeight+"px"
	}
	
  	if (lang == "Heb") {
		var so = new SWFObject("small_balls.swf?BeginSide=false", "smallBallsLeft", widthFlash, "100%", "8", "");
	} else {
		var so = new SWFObject("small_balls.swf?BeginSide=true", "smallBallsLeft", widthFlash, "100%", "8", "");
	}
	so.addParam("quality", "high");
	so.addParam("wmode", "transparent");
	so.write("LeftflashDiv");
	
  	if (lang == "Heb") {
		var so = new SWFObject("small_balls.swf?BeginSide=true", "smallBallsRight", widthFlash, "100%", "8", "");
	} else {
		var so = new SWFObject("small_balls.swf?BeginSide=false", "smallBallsRight", widthFlash, "100%", "8", "");
	}
	so.addParam("quality", "high");
	so.addParam("wmode", "transparent");
	so.write("RightflashDiv");
	   
	var so = new SWFObject("bubble.swf", "bubbleIn", "180", "131", "8", "");
	so.addParam("quality", "high");
	so.addParam("wmode", "transparent");
	so.write("bubbleDiv");
	HideSmallBubble()		
  }
  
	function SmallrollOut () { 
		// show pic of item
		HideSmallBubble()		
		getMovieName("smallBallsLeft").callSmallRollOut()
		getMovieName("smallBallsRight").callSmallRollOut()
	}

	function HideSmallBubble() {
		var bubbleObj = document.getElementById("bubbleDiv")
		document.getElementById("bubbleIn").width = "1px"
		if (lang == "Heb") {
			bubbleObj.style.right = "301px"
			bubbleObj.style.top = "200px"
		} else {
			bubbleObj.style.left = "301px"
			bubbleObj.style.top = "200px"
		}
	}
