/** BEGIN global varibales **/
var obj = null;
var proj = 0;
var color = null;
var interval = null;
var navVisible = false;
/** END global variables **/

/** BEGIN user-defined functions **/
function commentFilter() {
	if (jQuery('#urlfield').attr('value')==commentUrl) {
		jQuery('#urlfield').attr({ 'value' : '' });
		return false;
	}
}
function checkHover() {
	if (obj) obj.find('ul').fadeOut('fast');
}
function textSlideIn(proj) {
	if (navVisible) {
		jQuery('.next').stop().animate({ 'top' : '140' });
		jQuery('.prev').stop().animate({ 'top' : '140' });
	}
	jQuery('ul.text').children('li:eq('+proj+')').animate({ right: "-1px" }, 700);
}
function textSlideOut(proj) {
	if (navVisible) {
		jQuery('.next').stop().animate({ 'top' : '348' });
		jQuery('.prev').stop().animate({ 'top' : '348' });
	}
	jQuery('ul.text').children('li:eq('+proj+')').animate({ right: "-251px" }, 700);
}
function photoFadeIn(proj) {
	jQuery('ul.photo').children('li:eq('+proj+')').fadeIn(700);
}
function photoFadeOut(proj) {
	jQuery('ul.photo').children('li:eq('+proj+')').fadeOut(700);
}
function photoPutBehind(proj) {
	jQuery('ul.photo').children('li:eq('+proj+')').css('z-index', 0);
}
function moveSlide(where) {
	// Slide exit
	jQuery('ul.photo').children('li:eq('+proj+')').css("z-index", 2);
	setTimeout('photoFadeOut('+proj+')', 1000);
	setTimeout('photoPutBehind('+proj+')', 1500);
	textSlideOut(proj);
	// Increment and checking
	if (where=='next') proj++;
	else if (where=='prev') proj--;
	if (where=='next') { 
		var i = jQuery('ul.text li').size() - 1;
		if (proj>i) proj = 0;
	}
	else if (where=='prev') {
		if (proj<0) proj = jQuery('ul.text li').size() - 1;
	}
	// Slide entrance
	setTimeout('photoFadeIn('+proj+')', 1000);		
	setTimeout('textSlideIn('+proj+')', 1500);
}
function selectTab(tabID, index) {
	jQuery('#' + tabID + ' ul.tabs li a').removeClass('here');
	jQuery('#' + tabID + ' ul.tabs li:eq(' + index + ') a').addClass('here');
	jQuery('#' + tabID + ' .b div').css('display', 'none');
	jQuery('#' + tabID + ' .b div:eq(' + index + ')').css('display', 'block');
}

function addTab(tabID) {
	jQuery('#' + tabID).addClass('box');
	jQuery('#' + tabID).html('<div class="b">' + jQuery('#' + tabID).html() + '</div>');
	jQuery('#' + tabID + ' ul li').click(function() {
		jQuery('#' + tabID + ' ul li a').removeClass('here');
		jQuery(this).children('a').addClass('here');
		var index = jQuery('#' + tabID + ' ul li').index(jQuery(this));
		jQuery('#' + tabID + ' .b').children('div').css('display', 'none');
		jQuery('#' + tabID + ' .b').children('div:eq(' + index + ')').css('display', 'block');
		return false;
	});
	selectTab(tabID, 0);
}
/** END user-defined functions **/

document.write('<link rel="stylesheet" type="text/css" href="' + cssdir + 'javascript.css" />');
jQuery(window).load(function() {
	jQuery("#wrapper").css({ "display" : "block" });
	jQuery("#loader").remove();
	jQuery('.next').stop().animate({ 'top' : '348' });
	jQuery('.prev').stop().animate({ 'top' : '348' });
});



/** BEGIN jQuery actions **/
jQuery(function() {
	
	if (hideLoading) jQuery("body").append('<div id="loader">'+loadingMessage+'</div>'); else jQuery("#wrapper").css({ "display" : "block" });
	
	/** begin featured content **/
	if (autoSlide) interval = setInterval('moveSlide("next")', autoSlideSecs*1000);
	jQuery('.next').click(function() {
		clearInterval(interval);
		moveSlide('next');
		if (autoSlide) interval = setInterval('moveSlide("next")', autoSlideSecs*1000);
		return false;
	});
	jQuery('.prev').click(function() {
		clearInterval(interval);
		moveSlide('prev');
		if (autoSlide) interval = setInterval('moveSlide("next")', autoSlideSecs*1000);
		return false;
	});
	jQuery('.featured').hover(
		function() {
			navVisible = true;
			jQuery('.next').stop().animate({ 'top' : '140' });
			jQuery('.prev').stop().animate({ 'top' : '140' });
		},
		function() {
			navVisible = false;
			jQuery('.next').stop().animate({ 'top' : '348' });
			jQuery('.prev').stop().animate({ 'top' : '348' });
		}
	);
	/** end featured content **/
	
	/** begin submenu **/
	jQuery('#header ul > li').hover(
		function() {
			if (obj) {
				obj.children('ul:first')
					.css('display', 'none');
				obj = null;
			}
			jQuery(this).children('ul:first')
				.fadeIn();
		},
		function() {
			obj = jQuery(this);
			setTimeout("checkHover()", 1000);
		}
	);
	/** end submenu **/

		jQuery('.teaser').hover(function() {
		    // over

		    $('.teaser').children('img').stop().animate({
		        top: '-400px'
		    }, 500);

		},

function() {
    // out

    $('.teaser').children('img').stop().animate({
        top: '0'
    }, 500);

});
	
});
/** END jQuery actions **/
