$(document).ready(function(){
    $("#nav-item > h2").hover(function () {
		if (String($(this).css("background-image")).match("nav-arrow.png") == null) {
	    	$(this).css('background','url(images/nav/nav-item-over.png) no-repeat top left');
		}
   	}, function () {
		if (String($(this).css("background-image")).match("nav-arrow.png") == null) {
			$(this).css('background', 'url(images/nav/nav-item.png) no-repeat top left');
		}
   	});
    $("#nav-item > h2").click(function () {
	    $("#nav-item > h2").css('background','url(images/nav/nav-item.png) no-repeat top left');
	    $(this).css('background','url(images/nav/nav-arrow.png) no-repeat top left');
   	});
    $("#core-content").html($("#cloud-content").html());
    $("#core-content > bkg").css('background','url(../images/portfolio/cloud-content-bkg.png) no-repeat left top');	  
});

function showCloudMobileOverview() {
	$("#cloud-content-verbiage").html($("#cloud-mobile-overview").html());
}

function showCloudMobileFeatures() {
	$("#cloud-content-verbiage").html($("#cloud-mobile-features").html());
}

function showCloudMobileScreencast() {
	$("#cloud-content-verbiage").html($("#cloud-mobile-screencast").html());
}

function showCloudMobileScreenshot(image) {
	$("#cloud-mobile-screenshot").html("<img src=\"images/portfolio/cloudmobile/"+image+".png\">");
	resetCloudMobileScreenshotCircles();
	$("#"+image).attr("src","images/portfolio/cloudmobile/dgCircle.png");
	
	var prev = getPrevCloudMobileScreenshot(image);
	var next = getNextCloudMobileScreenshot(image);
	if (prev != null) {
		$("#previous-screenshot").html("<a href=\"javascript:showCloudMobileScreenshot('"+prev+"');\"><img id=\"previous\" src=\"images/portfolio/cloudmobile/laCircle.png\" border=\"0\"></a>");
	} else {
		$("#previous-screenshot").html("<img id=\"previous\" src=\"images/portfolio/cloudmobile/circleNoArrow.png\" border=\"0\">");
	}
	if (next != null) {
		$("#next-screenshot").html("<a href=\"javascript:showCloudMobileScreenshot('"+next+"');\"><img id=\"next\" src=\"images/portfolio/cloudmobile/raCircle.png\" border=\"0\"></a>");
	} else {
		$("#next-screenshot").html("<img id=\"next\" src=\"images/portfolio/cloudmobile/circleNoArrow.png\" border=\"0\">");
	}
}

function getPrevCloudMobileScreenshot(str) {
	if (str == '01_home') {
		return null;
	}
	if (str == '02_account') {
		return '01_home';
	}
	if (str == '03_home_auth') {
		return '02_account';
	}
	if (str == '04_container_list') {
		return '03_home_auth';
	}
	if (str == '05_container_new') {
		return '04_container_list';
	}
	if (str == '05a_container_delete') {
		return '05_container_new';
	}
	if (str == '06_container_view') {
		return '05a_container_delete';
	}
	if (str == '07_object_list') {
		return '06_container_view';
	}
	if (str == '08_object_delete') {
		return '07_object_list';
	}
	if (str == '09_object_view') {
		return '08_object_delete';
	}
	if (str == '10_object_metadata') {
		return '09_object_view';
	}
	if (str == '11_about') {
		return '10_object_metadata';
	}
}

function getNextCloudMobileScreenshot(str) {
	if (str == '01_home') {
		return '02_account';
	}
	if (str == '02_account') {
		return '03_home_auth';
	}
	if (str == '03_home_auth') {
		return '04_container_list';
	}
	if (str == '04_container_list') {
		return '05_container_new';
	}
	if (str == '05_container_new') {
		return '05a_container_delete';
	}
	if (str == '05a_container_delete') {
		return '06_container_view';
	}
	if (str == '06_container_view') {
		return '07_object_list';
	}
	if (str == '07_object_list') {
		return '08_object_delete';
	}
	if (str == '08_object_delete') {
		return '09_object_view';
	}
	if (str == '09_object_view') {
		return '10_object_metadata';
	}
	if (str == '10_object_metadata') {
		return '11_about';
	}
	if (str == '11_about') {
		return null;
	}
}

function resetCloudMobileScreenshotCircles() {
	$("#01_home").attr("src","images/portfolio/cloudmobile/lgCircle.png");
	$("#02_account").attr("src","images/portfolio/cloudmobile/lgCircle.png");
	$("#03_home_auth").attr("src","images/portfolio/cloudmobile/lgCircle.png");
	$("#04_container_list").attr("src","images/portfolio/cloudmobile/lgCircle.png");
	$("#05_container_new").attr("src","images/portfolio/cloudmobile/lgCircle.png");
	$("#05a_container_delete").attr("src","images/portfolio/cloudmobile/lgCircle.png");
	$("#06_container_view").attr("src","images/portfolio/cloudmobile/lgCircle.png");
	$("#07_object_list").attr("src","images/portfolio/cloudmobile/lgCircle.png");
	$("#08_object_delete").attr("src","images/portfolio/cloudmobile/lgCircle.png");
	$("#09_object_view").attr("src","images/portfolio/cloudmobile/lgCircle.png");
	$("#10_object_metadata").attr("src","images/portfolio/cloudmobile/lgCircle.png");
	$("#11_about").attr("src","images/portfolio/cloudmobile/lgCircle.png");
}
