/*++++++++++++++++++++++++++++++++++

Javascript for DavidLawlor.com

Created by:	Colm McBarron (cmcbarron@gmail.com)

++++++++++++++++++++++++++++++++++*/

// config
var base_location = "/";
var project_title = "";


$(function(){
	observeProjectsLink();
	
	var totalgalleryitems = $(".jCarouselLite li").length;
	var startpos =Math.floor(Math.random()*(totalgalleryitems -1))
	
	$(".jCarouselLite").jCarouselLite({
	    btnNext: ".next",
	    btnPrev: ".prev",
		visible: 1,
		speed: 650
	});
	

	observeProjectButtons();
	
});


function observeProjectsLink() {
	$('#projects-link a:first').attr('href', 'javascript:showhideProjectList();');
}

function showhideProjectList() {
	if ($('#project-menu').length) {
		$('#project-menu').slideToggle();
		Cufon.refresh;
	} else {
		var page = base_location + 'projectlist.php';
		$.get(page, {},
		  function(data){
		    $("#midsection-inner").before(data);
			$('#project-menu').slideToggle();
			$('#projects-link').addClass('current-item');
			$('#home-link').removeClass('current-item');
			$('#testimonials-link').removeClass('current-item');
		  });
		
	}
}

function observeProjectButtons(project_title){
	
	$("#project-navigation a").mouseover(function(){
		$('#p-title').html($(this).children("img").attr("alt"));
	});
	
	$("#project-navigation a").mouseout(function(project_title){
		ptitle = $('img.active-project').attr("alt");
		$('#p-title').html(ptitle);
	})	
}

/*
function removeProjectMenu() {
	Element.remove('project-menu');
	observeProjectsLink();
}

function show_qv(array_id) {
	$('quickviewer-img').src = quickviewer_array[array_id][0];
	$('hp-project-desc').innerHTML = quickviewer_array[array_id][1];
	$('hp-project-link').href = quickviewer_array[array_id][2];
	$('next-btn').href = "javascript:show_qv('" + getNextLink(array_id) + "')";
	$('previous-btn').href = "javascript:show_qv('" + getPreviousLink(array_id) + "')";
}

function getNextLink(c_id) {
	var new_id = c_id -0 +1;
	return checkID(new_id);
}

function getPreviousLink(c_id) {
	var new_id = c_id -1;
	return checkID(new_id);
}

function checkID(new_id) {
	if (new_id >= quickviewer_array.length) {
		new_id = 0;
	} else if (new_id < 0) {
		new_id = (quickviewer_array.length -1);
	}
	return new_id;
}

function showtitle(t) {
	$('p-title').innerHTML = t;
}

*/
