//meniu
$(document).ready(function(){

	$(".coll_twob").height($(".coll_one").height());
	$("#s5 a").fancybox();
	$("#s6 a").fancybox();
		$("#tree_Electra").treeview({
				collapsed: true,
				animated: "medium",
				control:"#sidetreecontrol",
				prerendered: true,
				persist: "location"
			});
		$("#tree_EMS").treeview({
				collapsed: true,
				animated: "medium",
				control:"#sidetreecontrol",
				prerendered: true,
				persist: "location"
			});
		$("#tree_PCB").treeview({
				collapsed: true,
				animated: "medium",
				control:"#sidetreecontrol",
				prerendered: true,
				persist: "location"
			});

 $("ul.sf-menu").superfish({
            animation: {height:'show'},   // slide-down effect without fade-in
            delay:     1200               // 1.2 second delay on mouseout
        });
    $(".image").hover(
      function () {
        $("#image_" + $(this).attr("id")).show();
      },
      function () {
        $("#image_" + $(this).attr("id")).hide();
      }
    );

});


//scroll noutati

var headline_count;
var headline_interval;
var old_headline = 0;
var current_headline = 0;
var play_pause = 'pause';

$(document).ready(function(){
    headline_count = $("div.headline").size();

    // setup the first headline
    $("div.headline:eq("+current_headline+")").css('top', '5px');

    // setup the counter text
    $("#scroll_counter").text('1 of ' + headline_count);

    // call the rotate function at regular intervals
    headline_interval = setInterval(headline_rotate,10000);
/*
    $('#scrollup').hover(
        function() {
        clearInterval(headline_interval);
        },
        function() {
            headline_interval = setInterval(headline_rotate,5000);
            headline_rotate();
        }
    );
*/
    $('#scroll_play_pause').click(function(){
        if( play_pause == 'pause' ) {
            clearInterval(headline_interval);
            $(this).text('>');
            play_pause = 'play';
        } else {
            headline_interval = setInterval(headline_rotate,5000);
            headline_rotate();
            $(this).text('| |') ;
            play_pause = 'pause';
        }
    });

    $('#scroll_next').click(function(){
            clearInterval(headline_interval);
            headline_interval = setInterval(headline_rotate,5000);
            headline_rotate();
    });
});

function headline_rotate() {
  current_headline = (old_headline + 1) % headline_count;


  $("div.headline:eq(" + old_headline + ")")
	.animate({top: -205},"slow", function() {
	  $(this).css('top', '210px');
	});

  $("div.headline:eq(" + current_headline + ")")
	.animate({top: 5},"slow");

  old_headline = current_headline;

  // incriment the headline text
  $("#scroll_counter").text( (current_headline+1) + ' of ' + headline_count);

}
