var scrolltimer;
var corporatescroll=0;
var crtPanel="";
var galleryPage=1;

function nextGallery() {
	if (galleryPage<totalPages) {
		galleryPage++;
		var newpos=(galleryPage-1)*515;
		$('#galerie-fereastra').animate( { marginLeft:"-"+newpos+"px" }, 500);
	}
	return false;
}

function lightboximage(path) {
	if ($('a#lightbox').length == 0) {
		$("body").append('<a id="lightbox" style="visibility: hidden; position: absolute; left: -9999px;"  href="'+path+'">calling js lightbox from flash</a>');
		$('a#lightbox').lightBox();
		// if it already exists but the path is different we will set the new path
	} else 
	if ($('a#lightbox').attr("href") != path) {
		$('a#lightbox').attr("href", path);
	}
	// now we will simulate the click here.
	$('a#lightbox').trigger("click");
}

function prevGallery() {
	if (galleryPage>1) {
		galleryPage--;
		var newpos=(galleryPage-1)*515;
		$('#galerie-fereastra').animate( { marginLeft:"-"+newpos+"px" }, 500);
	}
	return false;
}

function jumpGallery(newPage) {
	galleryPage=newPage;
	var newpos=(galleryPage-1)*515;
	$('#galerie-fereastra').animate( { marginLeft:"-"+newpos+"px" }, 500);
	return false;
}

function scrollcorporate(sign) {
	corporatescroll=corporatescroll+2*sign;
	document.getElementById('corporate_text').scrollTop=corporatescroll;
}

function hidePanel(panel) {
	$('#CatProduse').animate( { marginLeft:"15px" }, 500);
	$('#panel-'+panel).animate( { left:"200px" }, 500);
	return false;
}

function showPanel(panel) {
	if (crtPanel!="") document.getElementById('panel-'+crtPanel).style.display="none";
	document.getElementById('panel-'+panel).style.display="block";
	$('#CatProduse').animate( { marginLeft:"-200px" }, 500);
	$('#panel-'+panel).animate( { left:"15px" }, 500);
	crtPanel=panel;
	return false;
}

$(document).ready(function() {
	
	var myDiv = document.getElementById("Corporate");
	var myBut = document.getElementById("hide-crop");
	if ((myDiv.style.marginTop == '0px') || (myDiv.style.marginTop == '')) {
		myBut.style.backgroundPosition = 'top left';
	}
	


	$('a[@rel*=lightbox]').lightBox(); 

	$('#scrolldown').mouseover(function() {
		scrolltimer=setInterval('scrollcorporate(1)',20);
	});

	$('#scrolldown').click(function() {
		alert(document.getElementById('corporate_text').innerHeight);
	});

	$('#scrolldown').mouseout(function() {
		clearInterval(scrolltimer);
	});

	$('#scrollup').mouseover(function() {
		scrolltimer=setInterval('scrollcorporate(-1)',20);
	});

	$('#scrollup').mouseout(function() {
		clearInterval(scrolltimer);
	});

	
	$('#hide-crop').click(function() {
		
		var myDiv = document.getElementById("Corporate");
		var myBut = document.getElementById("hide-crop");
		
		
		if ((myDiv.style.marginTop == '0px')) {
			$('#Corporate').animate( { marginTop:"-340px" }, 500);
			myBut.style.backgroundPosition = 'bottom left';
		} else {
			$('#Corporate').animate( { marginTop:"0px" }, 500);
			myBut.style.backgroundPosition = 'top left';
		}

	});
	$('#SCategorii').click(function() {
		var CatProduse = document.getElementById("CatProduse");
		var Camere = document.getElementById("Camere");
		var Cautare = document.getElementById("Cautarea");

		var butCat = document.getElementById("SCategorii");
		var butCam = document.getElementById("SCamere");
		var butCaut = document.getElementById("SCauta");

		CatProduse.style.display = 'block';
		Camere.style.display = 'none';
		Cautare.style.display = 'none';	

		butCat.style.display = 'none';
		butCam.style.display = 'block';
		butCaut.style.display = 'block';
	});
	$('#SCamere').click(function() {
		var CatProduse = document.getElementById("CatProduse");
		var Camere = document.getElementById("Camere");
		var Cautare = document.getElementById("Cautarea");

		var butCat = document.getElementById("SCategorii");
		var butCam = document.getElementById("SCamere");
		var butCaut = document.getElementById("SCauta");

		CatProduse.style.display = 'none';
		Camere.style.display = 'block';
		Cautare.style.display = 'none';

		butCat.style.display = 'block';
		butCam.style.display = 'none';
		butCaut.style.display = 'block';
	});
	$('#SCauta').click(function() {
		var CatProduse = document.getElementById("CatProduse");
		var Camere = document.getElementById("Camere");
		var Cautare = document.getElementById("Cautarea");

		var butCat = document.getElementById("SCategorii");
		var butCam = document.getElementById("SCamere");
		var butCaut = document.getElementById("SCauta");

		CatProduse.style.display = 'none';
		Camere.style.display = 'none';
		Cautare.style.display = 'block';

		butCat.style.display = 'block';
		butCam.style.display = 'block';
		butCaut.style.display = 'none';
	});
});


          function toggleDisplay(id)
          {
            el = document.getElementById(id);
            if (el != undefined)
            {
              if (el.style.display == 'none')
                el.style.display = 'block';
              else
                el.style.display = 'none';              
            }
          }