var OverOpacity = Class.create({
	initialize : function(menu_element) {
		this.menu_element = $(menu_element); //make sure you have an extended element
		this.state = 0; // the state of the menu
		this.mouseover_callback =  this.mouseOver.bindAsEventListener(this); //callbacks
		this.mouseout_callback = this.mouseOut.bindAsEventListener(this);
		this.menu_element.observe('mouseover', this.mouseover_callback);
		this.menu_element.observe('mouseout', this.mouseout_callback);
		this.queue = Effect.Queues.get(this.menu_element.identify() + '-scope'); //create a queue with a unique name
	},
	mouseOver : function() {
		this.queue.each(function(ev) { ev.cancel(); });
		opacity = $(this.menu_element).getOpacity();
		new Effect.Opacity(this.menu_element, {duration: 0.4,from:opacity, to:0,
			queue : {scope : this.menu_element.identify() + '-scope',  
			limit : 1},
			afterFinish : function() { // using an effect callback to  make sure state is changes _after_ the last frame was renderd
				this.state = 1;
			}.bind(this)
		});
	},
	mouseOut : function() {
		this.queue.each(function(ev) { ev.cancel(); });
		opacity = $(this.menu_element).getOpacity();
		new Effect.Opacity(this.menu_element, {duration: 0.4,from:opacity, to:1,
			queue : {scope :  this.menu_element.identify() + '-scope',  
			limit : 1},
			afterFinish : function() {
				this.state = 0;
			}.bind(this)
		});
	}
});
function initBottomNavOvers(){
	$('bottomNavProblem').observe('mouseover',function(ele){bottomNavOver2("Problem")});
	$('bottomNavSolution').observe('mouseover',function(ele){bottomNavOver2("Solution")});
	$('bottomNavCatalog').observe('mouseover',function(ele){bottomNavOver2("Catalog")});
	
	$('bottomNavProblem').observe('mouseout',function(ele){bottomNavOut2("Problem")});
	$('bottomNavSolution').observe('mouseout',function(ele){bottomNavOut2("Solution")});
	$('bottomNavCatalog').observe('mouseout',function(ele){bottomNavOut2("Catalog")});
}
function bottomNavOver2(type){
	$("bottomNav"+type).addClassName("bottomnavon");
}
function bottomNavOut2(type){
	if(bottomNavCurrent!="bottomNav"+type)
		$("bottomNav"+type).removeClassName("bottomnavon");
}
function thisMovie(movieName){
	if (navigator.appName.indexOf("Microsoft") != -1){
		return window[movieName];
	}else {
		return document[movieName];
	}
}
function stopActionScript(){
	thisMovie("flashPlayer").stopForced();
}
function playActionScript(){
	thisMovie("flashPlayer").playForced();
}
function createPlayer(file,placeHolder){
	var so = new SWFObject('player.swf','flashPlayer',"428","241",'9');
	so.addParam('allowfullscreen','true');
	so.addParam('allowscriptaccess','always');
	so.addParam('wmode','transparent');
	so.addVariable("src",file);
	so.write(placeHolder);
}

function createPlayerEnhance(file,placeHolder,width,height){
    var so = new SWFObject('player.swf','flashPlayer',width,height,'9');
    so.addParam('allowfullscreen','true');
    so.addParam('allowscriptaccess','always');
    so.addParam('wmode','transparent');
    so.addVariable("src",file);
    so.write(placeHolder);
}


function createPlayerEn(file,placeHolder){
	var so = new SWFObject('player.swf',placeHolder,"428","303",'9');
	so.addParam('allowfullscreen','true');
	so.addParam('allowscriptaccess','always');
	so.addParam('wmode','transparent');
	so.addVariable("src",file);
	so.write(placeHolder);
}
function createPlayer2(file,placeHolder){
	var so = new SWFObject(file+'.swf','flashPlayer',"890","474",'9');
	so.addParam('allowfullscreen','true');
	so.addParam('allowscriptaccess','always');
	so.addParam('wmode','transparent');
	
	so.write(placeHolder);
}
function createFlashPlayer(file,placeHolder,width,height){
	var so = new SWFObject(file+'.swf','flashPlayer',width,height,'9');
	so.addParam('allowfullscreen','true');
	so.addParam('allowscriptaccess','always');
	if(placeHolder=="catalogPage")
		so.addParam('wmode','window');
	else
		so.addParam('wmode','transparent');
	so.addParam('devicefont','false');
	if(placeHolder=="techPage")
		so.addParam('flashvars','reflex=reflex&amp;frameshift=frameshift&amp;dlock=3dlock&amp;metagrip=metagrip&amp;walkAndLock=walkandlock');
	if(placeHolder=="indexFlash")
		so.addParam('flashvars','firstAccess='+firstAccessVar);
	so.write(placeHolder);
}


function createFlashFLV(file,placeHolder,width,height){
    var so = new SWFObject(file+'.flv','flashPlayer',width,height,'9');
    so.addParam('allowfullscreen','true');
    so.addParam('allowscriptaccess','always');
    if(placeHolder=="catalogPage")
        so.addParam('wmode','window');
    else
        so.addParam('wmode','transparent');
    so.addParam('devicefont','false');
    if(placeHolder=="techPage")
        so.addParam('flashvars','reflex=reflex&amp;frameshift=frameshift&amp;dlock=3dlock&amp;metagrip=metagrip&amp;walkAndLock=walkandlock');
    if(placeHolder=="indexFlash")
        so.addParam('flashvars','firstAccess='+firstAccessVar);
    so.write(placeHolder);
}




function openMinContact(){
	$("contactSent").style.display = "none";
	$("mincontactForm").style.display = "block";
	$("mincontactText").style.display = "block";
	$("mincontactFormDataForm").reset();
}
function openContact(){
	$("contactSent").style.display = "none";
	$("contactForm").style.display = "block";
	$("contactFormDataForm").reset();
}
function openFaq(){
	$("contactSent").style.display = "none";
	$("faqAddQuestionForm").style.display = "block";
	$("faqFormDataForm").reset();
}
function sendEnContactForm(evt){
	Event.stop(evt);
	formData = $("englishTopFormData").serialize();
	new Ajax.Request($("englishTopFormData").action, {
		method: 'post',
		postBody: formData,
		onComplete: function(resp) {
			txt = resp.responseText;
			switch(txt){
				case "Error Phone":
					alert("Please insert correct phone");
					break;
				case "Error Empty":
					alert("Please insert all required fields");
					/*$("contactError").innerHTML = "! אנא הזן את הפרטים";
					$("contactError").style.display = "block";*/
					break;
				case "Fine":
					url = homeUrl+"thankuen";
					window.location = (url);
					return;
					alert("The form successfully sent");
					/*$("contactError").innerHTML = "";
					$("contactError").style.display = "none";
					$("contactForm").style.display = "none";
					$("contactSent").style.display = "block";*/
					break;
			}
		}
	});
}
function sendRuContactForm(evt){
	Event.stop(evt);
	formData = $("englishTopFormData").serialize();
	new Ajax.Request($("englishTopFormData").action, {
		method: 'post',
		postBody: formData,
		onComplete: function(resp) {
			txt = resp.responseText;
			switch(txt){
				case "Error Phone":
					alert("Please insert correct phone");
					break;
				case "Error Empty":
					alert("Please insert all required fields");
					/*$("contactError").innerHTML = "! אנא הזן את הפרטים";
					$("contactError").style.display = "block";*/
					break;
				case "Fine":
					url = homeUrl+"thankuru";
					window.location = (url);
					return;
					alert("The form successfully sent");
					/*$("contactError").innerHTML = "";
					$("contactError").style.display = "none";
					$("contactForm").style.display = "none";
					$("contactSent").style.display = "block";*/
					break;
			}
		}
	});
}
function sendContactForm(evt){
	Event.stop(evt);
	formData = $("contactFormDataForm").serialize();
	new Ajax.Request($("contactFormDataForm").action, {
		method: 'post',
		postBody: formData,
		onComplete: function(resp) {
			txt = resp.responseText;
			switch(txt){
				case "Error Empty":
					$("contactError").innerHTML = "! אנא הזן את הפרטים";
					$("contactError").style.display = "block";
					break;
				case "Error Email":
					$("contactError").innerHTML = "! כתובת המייל שגויה";
					$("contactError").style.display = "block";
					break;
				case "Fine":
					url = homeUrl+"thanku";
					window.location = (url);
					return;
					$("contactError").innerHTML = "";
					$("contactError").style.display = "none";
					$("contactForm").style.display = "none";
					$("contactSent").style.display = "block";
					break;
			}
		}
	});
}
function sendFaqForm(evt){
	Event.stop(evt);
	formData = $("faqFormDataForm").serialize();
	new Ajax.Request($("faqFormDataForm").action, {
		method: 'post',
		postBody: formData,
		onComplete: function(resp) {
			txt = resp.responseText;
			switch(txt){
				case "Error Empty":
					$("contactError").innerHTML = "! אנא הזן את הפרטים";
					$("contactError").style.display = "block";
					break;
				case "Error Email":
					$("contactError").innerHTML = "! כתובת המייל שגויה";
					$("contactError").style.display = "block";
					break;
				case "Fine":
					url = homeUrl+"thankufaq";
					window.location = (url);
					return;
					$("contactError").innerHTML = "";
					$("contactError").style.display = "none";
					$("faqAddQuestionForm").style.display = "none";
					$("contactSent").style.display = "block";
					break;
			}
		}
	});
}
function sendMinContactForm(evt){
	Event.stop(evt);
	formData = $("mincontactFormDataForm").serialize();
	new Ajax.Request($("mincontactFormDataForm").action, {
		method: 'post',
		postBody: formData,
		onComplete: function(resp) {
			txt = resp.responseText;
			switch(txt){
				case "Error Empty":
					$("contactError").innerHTML = "! אנא הזן את הפרטים";
					$("contactError").style.display = "block";
					break;
				case "Fine":
					url = homeUrl+"thankumin";
					window.location = (url);
					return;
					$("contactError").innerHTML = "";
					$("contactError").style.display = "none";
					$("mincontactForm").style.display = "none";
					$("mincontactText").style.display = "none";
					$("contactSent").style.display = "block";
					break;
			}
		}
	});
}
function changeSolutionGalleryImage(image_number){
	$$("div .solutionPageGalleryImage").invoke("hide");
	$$("div .galleryImageNum").each(function(el){el.removeClassName("galleryImageNumSel")});
	images = $$(".solutionPageGalleryImage");
	$(images[image_number-1]).style.display = "block";
	galleryImageNum = $$(".galleryImageNum");
	$(galleryImageNum[image_number-1]).addClassName("galleryImageNumSel");
}
function changeGalleryType(type){
	if(type=="simulation"){
		if($("galleryLineText")){
			$("galleryImagesNums").style.display = "none";
			$("galleryLineText").removeClassName("lineSelText");
			$("solutionPageLeftGallery").style.display = "none";
		}
		if($("simulationLineText")){
			$("solutionPageLeftVideo").style.display = "block";
			$("simulationLineText").addClassName("lineSelText");
		}
		$("solutionLineContainer").removeClassName("linesel2");
	}
	else{
		if($("simulationLineText")){
			$("solutionPageLeftVideo").style.display = "none";
			$("simulationLineText").removeClassName("lineSelText");
		}
		if($("galleryLineText")){
			$("galleryImagesNums").style.display = "block";
			$("solutionPageLeftGallery").style.display = "block";
			$("galleryLineText").addClassName("lineSelText");
		}
		if($("simulationLineText"))
			$("solutionLineContainer").addClassName("linesel2");
	}
}
function changeEventGalleryType(type){
	if(type=="simulation"){
		if($("galleryLineText")){
			$("galleryImagesNums").style.display = "none";
			$("galleryLineText").removeClassName("lineSelText");
			$("eventItemGallImages").style.display = "none";
		}
		if($("simulationLineText")){
			$("eventItemGallVideo").style.display = "block";
			$("simulationLineText").addClassName("lineSelText");
		}
		$("solutionLineContainer").removeClassName("linesel2");
	}
	else{
		if($("simulationLineText")){
			$("eventItemGallVideo").style.display = "none";
			$("simulationLineText").removeClassName("lineSelText");
		}
		if($("galleryLineText")){
			$("galleryImagesNums").style.display = "block";
			$("eventItemGallImages").style.display = "block";
			$("galleryLineText").addClassName("lineSelText");
		}
		if($("simulationLineText"))
			$("solutionLineContainer").addClassName("linesel2");
	}
}
function changeEventGalleryType2(type){
	if(type=="simulation"){
		$("eventItemGallImages").style.display = "none";
		$("galleryImagesNums").style.display = "none";
		$("eventItemGallVideo").style.display = "block";
		$("solutionLineContainer").removeClassName("linesel2");
		$("galleryLineText").removeClassName("lineSelText");
		$("simulationLineText").addClassName("lineSelText");
	}
	else{
		$("eventItemGallVideo").style.display = "none";
		$("galleryImagesNums").style.display = "block";
		$("eventItemGallImages").style.display = "block";
		$("solutionLineContainer").addClassName("linesel2");
		$("simulationLineText").removeClassName("lineSelText");
		$("galleryLineText").addClassName("lineSelText");
	}
}
function initIndex(){
	/*$('bottomNavProblem').observe('mouseover',function(ele){showTooltip("Problem")});
	$('bottomNavSolution').observe('mouseover',function(ele){showTooltip("Solution")});
	$('bottomNavCatalog').observe('mouseover',function(ele){showTooltip("Catalog")});
	
	$('bottomNavProblem').observe('mouseout',function(ele){hideTooltip("Problem")});
	$('bottomNavSolution').observe('mouseout',function(ele){hideTooltip("Solution")});
	$('bottomNavCatalog').observe('mouseout',function(ele){hideTooltip("Catalog")});
	
	$('menuOverCatalog').observe('mouseover',function(ele){setMenuContinue("Catalog","false")});
	$('menuOverSolution').observe('mouseover',function(ele){setMenuContinue("Solution","false")});
	$('menuOverProblem').observe('mouseover',function(ele){setMenuContinue("Problem","false")});
	*/
	//$('menuOverCatalog').observe('mouseover',function(ele){showTooltip("Catalog")});
	//$('menuOverSolution').observe('mouseover',function(ele){showTooltip("Solution")});
	//$('menuOverProblem').observe('mouseover',function(ele){showTooltip("Problem")});
	
	//$('menuOverCatalog').observe('mouseout',function(ele){setMenuContinue("Catalog","true");hideTooltip("Catalog")});
	//$('menuOverSolution').observe('mouseout',function(ele){hideTooltip("Solution")});
	//$('menuOverProblem').observe('mouseout',function(ele){hideTooltip("Problem")});
}
function setMenuContinue(type,value){
	top = $("menuOver"+type).getStyle('top');
	//if(value=="false" && top=="0px"){
		//alert("here");
	//	value = "true";
	//}
	switch(type){
		case "Catalog":
			bottomNavCatalogContinue = value;
			break;
		case "Problem":
			bottomNavProblemContinue = value;
			break;
		case "Solution":
			bottomNavSolutionContinue = value;
			break;
	}
}
function getMenuContinue(type){
	switch(type){
		case "Catalog":
			continueCheck = bottomNavCatalogContinue;
			break;
		case "Problem":
			continueCheck = bottomNavProblemContinue;
			break;
		case "Solution":
			continueCheck = bottomNavSolutionContinue;
			break;
	}
	return continueCheck;
}
function showTooltip(type){
	$j(document).ready(function(){
		$j("div#menuOver"+type).slideDown();
	});
     //$j("menuOver"+type).slideDown("slow");
	//$("div.contentToChange p.firstparagraph:visible").slideUp("slow");
	//setTimeout("showTooltipReal('"+type+"')",100,"JavaScript")
}
function hideTooltip(type){
	$j(document).ready(function(){
		$j("div#menuOver"+type).slideUp();
	});
	//$("div.contentToChange p.firstparagraph:hidden").slideDown("slow");
	//$("div.contentToChange p.firstparagraph:visible").slideUp("slow");
	//setTimeout("hideTootipReal('"+type+"')",100,"JavaScript")
}
function showTooltipReal(type){
	continueCheck = getMenuContinue(type);
	if(continueCheck=="true"){
		setMenuContinue(type,"false");
		queue = Effect.Queues.get("menuOver"+type+"-scope");
		queue.each(function(ev) { ev.cancel(); });
		left = $("menuOver"+type).getStyle('left');
		top = $("menuOver"+type).getStyle('top');
		if(top=="0px"){
			setMenuContinue(type,"true");
		}
		new Effect.Move("menuOver"+type, { y: 0, x:left, mode: 'absolute',duration: 0.2,queue : {scope :  "menuOver"+type+"-scope", limit : 1},afterFinish:function(){
			setMenuContinue(type,"true");
		}});
		$("bottomNav"+type).addClassName("bottomnavon");
	}
}
function hideTootipReal(type){
	continueCheck = getMenuContinue(type);
	if(continueCheck=="true"){
	//	setMenuContinue(type,"false");
		queue = Effect.Queues.get("menuOver"+type+"-scope");
		queue.each(function(ev) { ev.cancel(); });
		left = $("menuOver"+type).getStyle('left');
		new Effect.Move("menuOver"+type, { y: 280, x:left, mode: 'absolute',duration: 0.2,queue : {scope :  "menuOver"+type+"-scope", limit : 1},afterFinish:function(){
			setMenuContinue(type,"true");
		}});
		$("bottomNav"+type).removeClassName("bottomnavon");
	}
}
function openPopup(name){
	new Ajax.Request(homeUrl+"getPopup", {
		method: 'GET',
		parameters: {
			popUpName:name
		},
		onComplete: function(resp) {
			txt = resp.responseText;
			if(txt!="Not Found"){
				$("problemPopupContainer").innerHTML = txt;
				$("problemPopupContainer").style.display = "block";
				$("bgblackposition").style.display = "block";
				$$('#problemPopupClose img')[0].observe('mouseover',function(ele){
					src = this.src;
					this.src = src.replace("problempopupclose","problempopupcloseover");
				});
				$$('#problemPopupClose img')[0].observe('mouseout',function(ele){
					src = this.src;
					this.src = src.replace("problempopupcloseover","problempopupclose");
				});
			}
		}
	});
}
function urlencode(str) {
	return str.replace(" ","%20");
}
function closePopup(){
	$("problemPopupContainer").style.display = "none";
	$("bgblackposition").style.display = "none";
}
function marginFooter(){
	var ps = $$("#footerLinks h3");
	pWidth = -45;
	for(var j=0;j<ps.length;j++){
		pWidth += ps[j].offsetWidth +50;
	}
	$("footerLinks").style.width = pWidth+'px';
}
function marginBottomNav(){
	var ps = $$("#bottomNavLinksInner h2");
    alert(ps.length);
	pWidth = -30;
	for(var j=0;j<ps.length;j++){
		pWidth += ps[j].offsetWidth +31;
	}
	$("bottomNavLinksInner").setStyle({width: pWidth+'px'});
}
function addToFav(){
	title = "Hermetix";
	url = "http://www.hermetix.co.il";
	if (window.sidebar) {
		// Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) {
		// IE Favorite
		window.external.AddFavorite( url, title);
	}
	else if(window.opera && window.print) {
		// Opera Hotlist
		return true; 
	}
}
function printpage(){
	window.print();
}
function closeComparePopup(){
	$("bgblackposition").style.display = "none";
	$("comparePopupContainer").style.display = "none";
}
function openComparePopup(file,alt){
	ext = getFileExt(file);
	$("bgblackposition").style.display = "block";
	switch(ext){
		case ".flv":
			openFlash(file,"popUpImageHolder");
			break;
		default:
			openImage(file,"popUpImageHolder",alt);
	}
	$("comparePopupContainer").style.display = "block";
}
function closeGalleryPopup(){
	$("bgblackposition").style.display = "none";
	$("galleryPopupContainer").style.display = "none";
	Event.stopObserving(window, 'resize', setNewDimensions);
}

function openImage(file,holder,alt){
	img = '<img id="bigImage" src="'+imgSrc+file+'" alt="'+alt+'" title="'+alt+'" style="height:420px;width:420px;" />';
	$("popUpImageHolder").setStyle({top: '30px'});
	$("comparePopupContainer").setStyle({margin: '-225px 0 0 0'});
	$("solutionPageLeftVideoBg").addClassName("compareImageBgPopup");
	$(holder).innerHTML = img;
}
function openFlash(file,holder){
	$("popUpImageHolder").setStyle({top: '57px'});
	$("comparePopupContainer").setStyle({margin: '-175px 0 0 0'});
	$("solutionPageLeftVideoBg").removeClassName("compareImageBgPopup");
	createPlayer(imgSrc+file,holder);
}
function getFileExt(file){
	var dot = file.lastIndexOf("."); 
	if( dot == -1 ) return ""; 
	return file.substr(dot,file.length); 
}
function changePage(action){
	oldCurrentPage = currentPage;
	switch(action){
		case "next":
			oldCurrentPage++;
			break;
		case "previous":
			oldCurrentPage--;
			break;
	}
	if(oldCurrentPage<1)
		oldCurrentPage = 1;
	if(oldCurrentPage>maxPages)
		oldCurrentPage = maxPages;
	if(currentPage!=oldCurrentPage)
		changeNewsPage(oldCurrentPage);
}
function changeNewsPage(page){
	if(currentPage!=page){
		if(page==1)
			$("eventLeftNewsPreviousInner").style.display = "none";
		else
			$("eventLeftNewsPreviousInner").style.display = "block";
		if(page==maxPages)
			$("eventLeftNewsNextInner").style.display = "none";
		else
			$("eventLeftNewsNextInner").style.display = "block";
		getNewsPage(page);
		$$(".newsBullet").each(function(ele){ele.removeClassName("newsBulletOn");});
		$$(".newsBullet")[page-1].addClassName("newsBulletOn");
		currentPage = page;
	}
}
function getNewsPage(page){
	if($$(".newsItem_"+page).length>0){
		moveNews(page-1);
	}
	else{
		new Ajax.Request(homeUrl+"getNewsPage/"+page, {
			method: 'post',
			onComplete: function(resp) {
				txt = resp.responseText;
				newsItems = $$("#newsInner .newsItem");
				newsItemsWidth = (newsItems.length+1)*247;
				$("newsInner").setStyle({width: newsItemsWidth+'px'});
				$("newsInner").insert(txt);
				moveNews(page-1);
			}
		});
	}
}
function moveNews(position){
	newXCoord = position*247*(-1);
	new Effect.Move("newsInner", { y: 0, x:newXCoord, mode: 'absolute',duration: 0.5});
}
function addBreadCrumbs(string){
	both = $$("#breadcrumbs .both")[0].remove();
	breadCrumbs = $$("#breadcrumbs .breadCrumb");
	breadCrumbs[breadCrumbs.length-1].innerHTML = '<a href="'+lastBreadCrumbLink+'">'+breadCrumbs[breadCrumbs.length-1].innerHTML+'</a>';
	newBreadCrumb = '<div class="right breadCrumbSep png"></div><div class="right breadCrumb">'+string+'</div><div class="both"></div>';
	$("breadcrumbs").insert(newBreadCrumb);
}
function resetBreadCrumbs(){
	breadCrumbs = $$("#breadcrumbs .breadCrumb");
	breadCrumbSep = $$("#breadcrumbs .breadCrumbSep");
	if(breadCrumbs.length>sizeofBreadCrumbs){
		for(i=sizeofBreadCrumbs;i<breadCrumbs.length;i++){
			$(breadCrumbs[i]).remove();
			$(breadCrumbSep[i-1]).remove();
		}
	}
	breadCrumbs[sizeofBreadCrumbs-1].innerHTML = lastBreadCrumbText;	
}
function galleryOnOver(){
	if($(this).childElements()[0].hasClassName('galleryBoxZoom'))
		$(this).childElements()[0].style.display = "block";
}
function galleryOnOut(){
	if($(this).childElements()[0].hasClassName('galleryBoxZoom'))
		$(this).childElements()[0].style.display = "none";
}
function galleryOpenImage(){
	$("bgblackposition").style.display = "block";
	$("galleryPopupContainer").style.display = "block";
	Effect.ScrollTo('wrapper');
}
function changeGalleryImage(imageNumber){
	currentImage = imageNumber;
	moveThumbsPosition(currentImage-1);
}
function moveThumbs(action){
	oldCurrentImage = currentImage;
	switch(action){
		case "next":
			oldCurrentImage++;
			break;
		case "previous":
			oldCurrentImage--;
			break;
	}
	if(oldCurrentImage<1){
		return;
	}
	moveThumbsPosition(oldCurrentImage-1);
}
function moveThumbsPosition(position){
	if(canMoveImage == true){
		galleryBoxes = $$(".galleryThumbsImage img");
		if(position>=galleryBoxes.length)
			return;
		galleryBoxImage = galleryBoxes[position];
		//$$(".galleryThumbsImage img").each(function(ele){ele.removeClassName("currentThumb");});
		//thumbBoxImage = $$(".galleryThumbsImage img")[position];
		//thumbBoxImage.addClassName("currentThumb");
		var img = new Element("img");
		img.src = galleryBoxImage.src;
		img.alt = galleryBoxImage.alt;
		img.title = galleryBoxImage.title;
		$("galleryPopUpImageHolder").update(img);
		if(position==0)
			$("galleryLeftArrowInner").style.display = "none";
		else
			$("galleryLeftArrowInner").style.display = "block";
		if((position+1)==maxImages)
			$("galleryRightArrowInner").style.display = "none";
		else
			$("galleryRightArrowInner").style.display = "block";
		//canMoveImage = false;
		
		thumbXCoord = position*93;
		leftContainer = $("galleryThumbs").getStyle('left');
		leftContainer = leftContainer.replace("px","");
		leftContainer = leftContainer*(-1);
		if((thumbXCoord-leftContainer)>279 || (thumbXCoord-leftContainer)<1){
			mode = "absolute";
			if(currentImage==position){
				thumbXCoord = 93;
				mode = "relative";
			}
			if((maxImages-position)>0 && (maxImages-position)<4 && mode=="absolute"){
				thumbXCoord = (maxImages-4)*93;
			}
			if(maxImages<5){
				thumbXCoord = 0;
			}
			canMoveImage = false
			new Effect.Move("galleryThumbs", { y: 0, x:-1*thumbXCoord, mode: mode,duration: 0.5,
				afterFinish:function(){
					canMoveImage = true;
					currentImage = (position+1);
				}
			});
		}
		else{
			currentImage = (position+1);
		}
	}
}
function galleryOpenProjectImages(project_id){
	setWrapperPosition($("galleryPopupContainer"));
	Event.observe("bgblackposition","click",closeGalleryPopup);
	Event.observe(window,"resize",setNewDimensions);
	new Ajax.Request(homeUrl+"getGalleryProjectImages/"+project_id, {
		method: 'post',
		onComplete: function(resp) {
			txt = resp.responseText;
			switch(txt){
				case "Error":
					break;
				default:
					$("galleryPopup").innerHTML = txt;
					maxImages = $$(".galleryThumbsImage").length;
					currentImage = 1;
					galleryOpenImage();
					
			}
		}
	});
}
function setNewDimensions(){
	setWrapperPosition($("galleryPopupContainer"));
}
function setWrapperPosition(ele){
	dimensions = getWindowSize();
	dim = ele.getDimensions();
	left	= (dimensions.width - dim.width) * 0.5;
	ele.setStyle({
		left: left+"px"
	});

}
function changeSearchGallery(){
	type = "";
	category = "";
	if($("selectType").value!="")
		type = $("selectType").value;
	if($("selectCategory").value!="")
		category = $("selectCategory").value;
	//if(category!="" || type!="")
	window.location = (lastBreadCrumbLink+"?type="+type+"&category="+category);
}
function changeLinkLocation(){
	link = $(this).select("a")[0];
	window.location = (link);
}
function getWindowSize(w){
	var array = [];
	w = w ? w : window;
	array.width = array[0] = w.innerWidth || (w.document.documentElement.clientWidth || w.document.body.clientWidth);
	array.height = array[1] = w.innerHeight || (w.document.documentElement.clientHeight || w.document.body.clientHeight);
	return array;
}
function closeToolBox(){
	$("bgtransparentposition").style.display = "none";
	$$(".toolboxInner").invoke('hide');
	$$(".toolboxTitleSel").each(function(ele){ele.removeClassName("toolboxTitleSel")});
	Event.stopObserving("bgtransparentposition", 'click', closeToolBox);
}

function changeToolBox(type){
	$$(".toolboxTitleSel").each(function(ele){ele.removeClassName("toolboxTitleSel")});
	if($("toolbox"+type+"Inner").style.display=="block"){
		closeToolBox();
		return;
	}
	//$("bgtransparentposition").style.display = "none";
	$("bgtransparentposition").style.display = "block";
	Event.observe("bgtransparentposition","click",closeToolBox);
	$$(".toolboxInner").invoke('hide');
	$("toolbox"+type+"Inner").style.display = "block";
	$("toolbox"+type+"Title").addClassName("toolboxTitleSel");
}
function sendFooterContactForm(evt){
	Event.stop(evt);
	formData = $("footerContactFormData").serialize();
	new Ajax.Request($("footerContactFormData").action, {
		method: 'post',
		postBody: formData,
		onComplete: function(resp) {
			txt = resp.responseText;
			switch(txt){
				case "Error Empty":
					$("footercontactError").innerHTML = "אנא הזן את הפרטים !";
					$("footercontactError").style.display = "block";
					break;
				case "Error Phone":
					$("footercontactError").innerHTML = "אנא הזן מספר טלפון תקין !";
					$("footercontactError").style.display = "block";
					break;
				case "Fine":
					url = homeUrl+"thankufooter";
					window.location = (url);
					return;
					$("toolboxcontactError").innerHTML = "הטופס נשלח בהצלחה";
					$("toolboxcontactError").style.display = "block";
					$("toolboxcontactformdata").reset();
					break;
			}
		}
	});
}
function sendToolContactForm(evt){
	Event.stop(evt);
	formData = $("toolboxcontactformdata").serialize();
	new Ajax.Request($("toolboxcontactformdata").action, {
		method: 'post',
		postBody: formData,
		onComplete: function(resp) {
			txt = resp.responseText;
			switch(txt){
				case "Error Empty":
					$("toolboxcontactError").innerHTML = "אנא הזן את הפרטים !";
					$("toolboxcontactError").style.display = "block";
					break;
				case "Error Phone":
					$("toolboxcontactError").innerHTML = "אנא הזן מספר טלפון תקין !";
					$("toolboxcontactError").style.display = "block";
					break;
				case "Fine":
					url = homeUrl+"thankutop";
					window.location = (url);
					return;
					$("toolboxcontactError").innerHTML = "הטופס נשלח בהצלחה";
					$("toolboxcontactError").style.display = "block";
					$("toolboxcontactformdata").reset();
					break;
			}
		}
	});
}
function sendToolCallForm(evt){
	Event.stop(evt);
	formData = $("toolboxcallformdata").serialize();
	new Ajax.Request($("toolboxcallformdata").action, {
		method: 'post',
		postBody: formData,
		onComplete: function(resp) {
			txt = resp.responseText;
			switch(txt){
				case "Error Empty":
					$("callError").innerHTML = "אנא הזן את הפרטים !";
					$("callError").style.display = "block";
					break;
				case "Error Phone":
					$("callError").innerHTML = "אנא הזן מספר טלפון תקין !";
					$("callError").style.display = "block";
					break;
				case "Fine":
					$("callError").innerHTML = "הטופס נשלח בהצלחה";
					$("callError").style.display = "block";
					$("toolboxcallformdata").reset();;
					break;
			}
		}
	});
}
function changeEn(ele){
	$$("div .tabSel").each(function(element){element.removeClassName("tabSel");});
	$$("div .contentSel").each(function(element){element.removeClassName("contentSel");});
	$(ele).addClassName("tabSel");
	idSel = $(ele).parentNode.id.replace("englishPageMainTab","");
	$("englishPageMainContent"+idSel).addClassName("contentSel");
	if(idSel!="Kinetix")
		createPlayerEn("envideos/"+idSel+".flv",idSel+"videohere");
}

function moveVideos(action){
	if(canMove==false)
		return;
	closeVideoFade();
	canMove = false;
	imageRow = currentImage;
	switch(action){
		case "right":
			newXCoord = 770;
			imageRow--;
			break;
		case "left":
			newXCoord = -770;
			imageRow++;
			break;
		default:
			return;
	}
	if(imageRow==maxImages)
		$j("#videosPageTopArrowLeftInner").css("display","none");
	else
		$j("#videosPageTopArrowLeftInner").css("display","block");
	if(imageRow==1)
		$j("#videosPageTopArrowRightInner").css("display","none");
	else
		$j("#videosPageTopArrowRightInner").css("display","block");
	if(imageRow>maxImages || imageRow<1){
		canMove = true;
		return;
	}
	
	currentright = parseInt($j("#videosPageTopVideosInner").css('right'));
	nextRight = parseInt(currentright)+parseInt(newXCoord);
	$j("#videosPageTopVideosInner").animate({
		right: nextRight+'px'
	}, 300, function() {
    	canMove = true;
		currentImage = imageRow;
  });
}
function playVideos(Main_Movie,HD_Movie){
	$j("#videosPagePlayer").css("zIndex","1008");
	//$j("#videosBgBlackFull").css("display","block");
	getMovieName("flashPlayer").callPlayBall(Main_Movie, HD_Movie); 
}
function getMovieName(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName]
	} else {
		 return document[movieName]
	}
}
function playVideo(videoNum){
	closeVideoFade();
	newX = "-"+(videoNum-1)*770+"px";
	$j("#videosPageTopVideosInner").css("right",newX);
	if(videoNum==maxImages)
		$j("#videosPageTopArrowLeftInner").css("display","none");
	else
		$j("#videosPageTopArrowLeftInner").css("display","block");
	if(videoNum==1)
		$j("#videosPageTopArrowRightInner").css("display","none");
	else
		$j("#videosPageTopArrowRightInner").css("display","block");
	currentImage = videoNum;
}
function playVideoNow(videoNum){
	//playVideo(videoNum);
}
function closeVideoFade(){
	playVideos("","");
	$j("#videosPagePlayer").css("zIndex","1");
	//alert("here");
}
