
$(document).ready(function(){

	/*EXTERNAL LINKS start ***********************************************************/
	$('a[@rel$="external"]').click(function(){
		this.target = "_blank";
	});	
	/*EXTERNAL LINKS end *************************************************************/

	/*NAVIGATION start ***************************************************************/
	$('#nav ul ul').hide();
	//hover show 2nd level
	$('#nav ul > li').hover(function() {
		$('ul:first', this).show();
	},
	function() {$('ul:first', this).hide();});
	//hover 3rd level
	$('#nav ul li li').hover(function() {
		$('ul:first', this).each(function() {
			$(this).show();
		});
	},
	function() {$('ul:first', this).hide();});
	//hover 4th level
	$('#nav ul li li li').hover(function() {
		$('ul:first', this).each(function() {
			$(this).show();
		});
	},
	function() {$('ul:first', this).hide();});
	/*NAVIGATION end ****************************************************************/
	
	/* SIFR**********/
    $('h2.sifr-text').flash(
        { 
            src: '/includes/media/font-vladimir-script.swf', 
            flashvars: { 
                css: [
                    '* { color:#C34462; }',
                    'a { color: #C34462; text-decoration: none; }',
                    'a:hover { text-decoration: underline; }'
                ].join(' ')
            }
        },
        { version: 8 },
        function(htmlOptions) {
            htmlOptions.flashvars.txt = this.innerHTML;
            this.innerHTML = '<div>'+this.innerHTML+'</div>';
            var $alt = $(this.firstChild);
            htmlOptions.width = $alt.width();
            htmlOptions.height = 32;// don't know why this won't work $alt.height()
            $alt.addClass('alt');
            $(this)
                .addClass('flash-replaced')
                .prepend($.fn.flash.transform(htmlOptions));						
        }
    );
    $('h3.sifr-text').flash(
        { 
            src: '/includes/media/font-vladimir-script.swf', 
            flashvars: { 
                css: [
                    '* { color:#A09767; }',
                    'a { color: #A09767; text-decoration: none; }',
                    'a:hover { text-decoration: underline; }'
                ].join(' ')
            }
        },
        { version: 8 },
        function(htmlOptions) {
            htmlOptions.flashvars.txt = this.innerHTML;
            this.innerHTML = '<div>'+this.innerHTML+'</div>';
            var $alt = $(this.firstChild);
            htmlOptions.width = $alt.width();
            htmlOptions.height = 32;// don't know why this won't work $alt.height()
            $alt.addClass('alt');
            $(this)
                .addClass('flash-replaced')
                .prepend($.fn.flash.transform(htmlOptions));						
        }
    );		
    $('h1.title').flash(
        { 
            src: '/includes/media/font-vladimir-script.swf', 
            flashvars: { 
                css: [
                    '* { color:#A09767; }',
                    'a { color: #A09767; text-decoration: none; }',
                    'a:hover { text-decoration: underline; }'
                ].join(' ')
            }
        },
        { version: 8 },
        function(htmlOptions) {
            htmlOptions.flashvars.txt = this.innerHTML;
            this.innerHTML = '<div>'+this.innerHTML+'</div>';
            var $alt = $(this.firstChild);
            htmlOptions.width = $alt.width();
            htmlOptions.height = 46;// don't know why this won't work $alt.height()
            $alt.addClass('alt');
            $(this)
                .addClass('flash-replaced')
                .prepend($.fn.flash.transform(htmlOptions));						
        }
    );
		/* SIFR********/
		
		/* SLIDESHOW start **************************************************************/
		setInterval( "slideSwitch()", 5000 );
		/* SLIDESHOW end ****************************************************************/	
		
}); //close document.ready

/* SLIDESHOW function start *********************************************************/
function slideSwitch() {
	var $active = $('#slideshow a.active');

	if ( $active.length == 0 ) $active = $('#slideshow a:last');

	var $next =  $active.next().length ? $active.next()
			: $('#slideshow a:first');

	$active.addClass('last-active');

	$next.css({opacity: 0.0})
			.addClass('active')
			.animate({opacity: 1.0}, 1500, function() {
			 $active.removeClass('active last-active');
	});
}
/* SLIDESHOW function end ***********************************************************/	

