/* Setup jQuery
---------------------------------------------------------------- */
var $j = jQuery.noConflict();

$j(function(){
	$j('.popup').click(function (){
		popUpEnta($j(this).attr('href'));
		return false;
	});
	
	$j('.popWithSize').click(function (){
		PopUp($j(this).attr('href'),"Popped window",$j(this).attr('rel').split('|')[0],$j(this).attr('rel').split('|')[1],false);
		return false;
	});
	
    $j('.menu li').hover(
        function () {
            
            $j('#' + $j(this).attr('id') + '-sub').css('display','block');
        },
        function () {
            $j('#' + $j(this).attr('id') + '-sub').css('display','none');
        }
    );
});

function popUpEnta(URL) {
    day = new Date();
    id = day.getTime();
    var winl = (screen.width - 980) / 2;
	var wint = (screen.height - 600) / 2;
    window.open(URL, id, 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=980,height=600,left='+winl+',top='+wint);
}

function PopUp(mypage, myname, w, h, scroll){
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+'resizable';
	win = window.open(mypage, myname, winprops);

	if(parseInt(navigator.appVersion) >= 4){
		win.window.focus();
	}
}

function slideSwitch() {
    var $active = $j('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $j('#slideshow IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $j('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$j(function() {
    setInterval( "slideSwitch()", 5000 );
});
