﻿$(document).ready(function() {
    var video = $('.video:first').attr("rel");
    var title = $('.video:first').attr("title");
    $('#video').html('<object width="320" height="265"><param name="movie" value="http://www.youtube.com/v/' + video + '&hl=en&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' + video + '&hl=en&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="320" height="265"></embed></object>');

    $(".video").click(function() {
        var video = $(this).attr("rel");
        $('#gallery').fadeIn('slow');
        $('#video').html('<object width="320" height="265"><param name="movie" value="http://www.youtube.com/v/' + video + '&hl=en&fs=1&rel=0&autoplay=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' + video + '&hl=en&fs=1&rel=0&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="320" height="265"></embed></object>');
        $('#title').html(title);

        return false;
    });
});

$(document).ready(function() {
    $("a.fancybox").fancybox({ 
		'frameWidth': 600,
		'frameHeight': 400
	});
});


function slideSwitch() {
    var $active = $('.news_tabs a.active');

    if ($active.length == 0) $active = $('.news_tabs a:last');

    var $next = $active.next().length ? $active.next()
        : $('.news_tabs a:first');

    $active.addClass('last-active');
	$active.removeClass('active last-active');
    $next.addClass('active');
    var intro = $next.attr("intro");
    var title = $next.attr("title");
    var newslink = $next.attr("newslink");	
	$(".news_in").html('<a class="title"  href="'+newslink+'">'+title+'</a>'+'<p class="intro_text">'+intro+'</p>'+'<a class="newslink" href="'+newslink+'">המשך...</a>');
}

$(function() {
    var $first = $('.news_tabs a:first');
    $first.addClass('active');
	var intro = $first.attr("intro");
	var title = $first.attr("title");
	var newslink = $first.attr("newslink");	
	$(".news_in").html('<p class="title">'+title+'</p>'+'<p class="intro_text">'+intro+'</p>'+'<a class="newslink" href="newslink">המשך...</a>');
    stop_interval = setInterval("slideSwitch()", 10000);

	$(".news_item").mouseover(function() {
			clearInterval(stop_interval);
			var intro = $(this).attr("intro");
			var title = $(this).attr("title");
			var newslink = $(this).attr("newslink");	
			$(".news_in").html('<a class="title"  href="'+newslink+'">'+title+'</a>'+'<p class="intro_text">'+intro+'</p>'+'<a class="newslink" href="'+newslink+'">המשך...</a>');
			$(".news_item").removeClass('active last-active');
			$(this).addClass('active');
        return false;
    });
});
