$(document).ready(function(){
	
	// Video Selector
	$('#coda-slider-1').codaSlider({
        slideEaseDuration: 1000,
        slideEaseFunction: "easeOutSine"
	});
							   
	$(".slogan div").click(function(){
    	window.location=$(this).find("a").attr("href");return false;
	});
	
	$('a[href*="youtube"]').each(function(_ind){ 
		$(this).addClass('lightbox');
		$(this).prepend("<span>&nbsp;</span>")
	});
	$('a[href*="vimeo"]').each(function(_ind){ 
		$(this).addClass('lightbox');
		$(this).prepend("<span>&nbsp;</span>")
	});
	
	
	$("a[class*='lightbox']").prettyPhoto({
		animationSpeed: 'fast', /* fast/slow/normal */
		padding: 40, /* padding for each side of the picture */
		opacity: 0.35, /* Value betwee 0 and 1 */
		showTitle: true, /* true/false */
		allowresize: true, /* true/false */
		counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
		theme: 'dark_rounded' /* light_rounded / dark_rounded / light_square / dark_square */
	});
	

	

});

function initNav()
{
	var nav = document.getElementById("nav");
	if(nav)
	{
		var lis = nav.getElementsByTagName("li");
		for (var i=0; i<lis.length; i++)
		{
			lis[i].onmouseover = function()
			{
				this.className += " hover";
			}
			lis[i].onmouseout = function()
			{
				this.className = this.className.replace(" hover", "");
			}
		}
	}
}

function initTabs(){
	var _body  = $('body');
	var _mainTabHold = $('.tab-heading');
	var _list = _mainTabHold.find('a');
	var _t = null;
	var _cur = _nxt = 0;
	var _autorun = 5000;

	_list.each(function(_ind){
		if($(this).hasClass('active')) _body.attr('class','bg-'+(_ind+1));
	});

	_list.click(function(){
		if(_t) clearInterval(_t);
		var _index = _list.index(this);
		
		_list.removeClass('active').eq(_index).addClass('active');
		_body.attr('class','bg-'+(_index+1));
		rotate();
		return false;
	});

	//rotate();
	function rotate(){
		if(_autorun){
			_t = setInterval(function(){
				_cur = _list.index(_list.filter('.active'));
				if(_cur == _list.length-1) _nxt=0;
				else _nxt = _cur+1;
				_list.eq(_nxt).trigger('click');
			},_autorun);
		};
	}

}

$(function(){
	//for IE6 menu
	if(typeof(document.body.style.maxHeight) == 'undefined') initNav();

	initTabs();
})

// clearing  inputs on focus
function doClear(theText) 
{
	if (theText.value == theText.defaultValue) 
	{
		theText.value = "";
	} 
}

//replace input value with default on blur
function doReset(theText)
{
	if (theText.value == "")
	{
		theText.value = theText.defaultValue;
	}
}

