/** BEGIN settings **/
var searchDefault = 'Enter keywords here...'; // Default text of the search input
var searchColor = '#000000'; // Color of text when focused
var videoWidth = '300'; // Width of the embedded video
var videoHeight = '225'; // Height of the embedded video
var autoSlide = true; // Whether featured posts will slide automatically or not.
var autoSlideSecs = 10; // Intervals of slide transition in seconds.
/** END settings **/



/** BEGIN global varibales **/
var obj = null;
var proj = 0;
var color = null;
var interval = null;
/** END global variables **/

/** BEGIN user-defined functions **/
function checkHover() {
	if (obj) obj.find('ul').fadeOut('fast');
}
function textSlideIn(proj) {
	jQuery('ul.text').children('li:eq('+proj+')').animate({ right: "-1px" }, 700);
}
function textSlideOut(proj) {
	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 nextSlide() {
	// 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
	proj++;
	var i = jQuery('ul.text li').size() - 1;
	if (proj>i) proj = 0;
	// Slide entrance
	setTimeout('photoFadeIn('+proj+')', 1000);		
	setTimeout('textSlideIn('+proj+')', 1500);
}
/** END user-defined functions **/

/** BEGIN jQuery actions **/
jQuery(function() {
	
	/** begin featured content **/
	if (autoSlide) interval = setInterval('nextSlide()', autoSlideSecs*1000);
	jQuery('.next').click(function() {
		clearInterval(interval);
		nextSlide();
		if (autoSlide) interval = setInterval('nextSlide()', autoSlideSecs*1000);
		return false;
	});
	/** end featured content **/
	
	/** begin submenu **/
	jQuery('#header ul > li').hover(
		function() {
			if (obj) {
				obj.find('ul').css('display', 'none');
				obj = null;
			}
			jQuery(this).find('ul').stop().fadeIn(500);
		},
		function() {
			obj = jQuery(this);
			setTimeout("checkHover()", 100);
		}
	);
	/** end submenu **/
	
	/** begin search form **/
	jQuery('#s').attr({ 'value' : searchDefault });
	jQuery('#s').focus(function() {
		var temp = jQuery(this).attr('value');
		color = jQuery(this).css('color');
		jQuery(this).css({ 'color' : searchColor });
		if (temp==searchDefault)
			jQuery(this).attr({ 'value' : '' })
	});
	jQuery('#s').blur(function() {
		if (jQuery(this).attr('value')=='') {
			jQuery(this).attr({ 'value' : searchDefault });
		}
		jQuery(this).css({ 'color' : color });
	});
	/** end search form **/
	
	/** begin youtube video **/
	var videoEmbedd = "<object width=\""+videoWidth+"\" height=\""+videoHeight+"\"><param name=\"movie\" value=\"http://www.youtube.com/v/"+youtubeID+"&amp;hl=en&amp;fs=1\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/v/"+youtubeID+"&amp;hl=en&amp;fs=1\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\""+videoWidth+"\" height=\""+videoHeight+"\"></embed></object>";
	jQuery('#youtube').html(videoEmbedd);
	/** end youtube video **/
	
});
/** END jQuery actions **/
