/* Showcase slider */
$(window).load(function() {
$('#nSlider').nivoSlider({
effect:'fade',
pauseTime:5000,
pauseOnHover:false,
captionOpacity:0,
controlNav:false,
});
});

/* Content slider */
$(document).ready(function () {
var $panels = $('#contentSlider .scrollContainer > div');
var $container = $('#contentSlider .scrollContainer');
var horizontal = true;
if (horizontal) {
$panels.css({
'float' : 'left',
'position' : 'relative'
});
$container.css('width', $panels[0].offsetWidth * $panels.length);
}

var $scroll = $('#contentSlider .scroll').css('overflow', 'hidden');

$scroll;

function selectNav() {
$(this)
.parents('ul:first')
.find('a').each(function(index) {
aClass = $(this).attr("class").split('Selected');
$(this).removeClass();
$(this).addClass(aClass[0]);
});

aClass = $(this).attr("class").split('Selected');
$(this).removeClass();
$(this).addClass(aClass[0]+'Selected');
}
$('#contentNav .navigation').find('a').click(selectNav);

function trigger(data) {
var el = $('#contentNav #navigation').find('a[href$="' + data.id + '"]').get(0);
selectNav.call(el);
}

if (window.location.hash) {
trigger({ id : window.location.hash.substr(1) });
} else {
$('ul.navigation a:first').click();
}

var offset = parseInt((horizontal ? 
$container.css('paddingTop') : 
$container.css('paddingLeft')) 
|| 0) * -1;

var scrollOptions = {
target: $scroll,
items: $panels,
navigation: '.navigation a',
prev: 'img.left', 
next: 'img.right',
axis: 'xy',
onAfter: trigger,
offset: offset,
duration: 500,
easing: 'swing'
};

$('#contentSlider').serialScroll(scrollOptions);
$.localScroll(scrollOptions); scrollOptions.duration = 1;
$.localScroll.hash(scrollOptions);


/* Contact form */
$('.text').focus(function () {
	if ($(this).val() == $(this).attr("title")) {
		$(this).val("");
	}
}).blur(function () {
	if ($(this).val() == "") {
		$(this).val($(this).attr("title"));
	}
});
});


function parseInfo(){
	if( request.readyState == 1 ) {
		document.getElementById('response').innerHTML = '<img src="img/loading.gif" alt="Loading..." />';
	}
	if(request.readyState == 4){
		var answer = request.responseText;
		document.getElementById('response').innerHTML = answer;
	}
}
