/* Code by De Facto Design */

browserBypass = false;

currentImgPath = "";
currentSwfPath = "";
currentName = "";
currentWidth = "";
currentHeight = "";
currentPlayer = "";

if (BrowserDetect.browser == "Safari" && BrowserDetect.version == "312.6") {
	browserBypass = true;
}

jQuery(document).ready(function($) {
	if (screen.width < 1024) {
		//$("#alert").html("<div id=\"message\"><p>Apologies, but this site is optimised for a monitor resolution of 1024x768.</p></div>");
		//$("#alert").hide();
		//$("#alert").fadeIn(1000);
	}
})

function slideshow(index,num) {
	viewportWidth = 355; // Width of the viewport and also the images in the portfolio slideshow pages.
	workBlock = "#scroll"+index;
	$(workBlock).stop().animate({left:-(viewportWidth*num)},1000, 'easeInOutCubic');
	temp = $(workBlock).parent().parent();
	temp2 = $(temp).find(".workText");
	temp3 = $(temp2).find("li");
	i = 0;
	temp3.each(function(){
		$(this).find("a").removeClass("selected");
		$(this).find("a").addClass("");
		if (i == num) {
			$(this).find("a").addClass("selected");
		}
		i++;
	});
}

function profile(num) {
	if (browserBypass == false) {
		viewportWidth = 355; // Width of the viewport and also the images in the portfolio slideshow pages.
		$("#profileList").stop().animate({left:-(viewportWidth*num)},1000, 'easeInOutCubic');
		
		temp = $(".rightcol").children().children();
		i = 0;
		temp.each(function(){
			
			currentItem = $(this).text();
			$(this).removeClass("selected");
			lastChr = currentItem.charCodeAt(currentItem.length-1);
			if (lastChr == 8212) {
				newText = currentItem.substr(0,currentItem.length-2);
				$(this).text(newText);
			}

			if (i == num) {
				$(this).append(" &mdash;");
				$(this).addClass("selected");
			}
			i++;
		});
	}
}

function videoControl(imgpath, swfpath, width, height, playerNum) {

	videoFinish();
	
	currentImgPath = imgpath;
	currentSwfPath = swfpath;
	currentName = "fp"+playerNum;
	currentWidth = width;
	currentHeight = height;

	//alert(currentPlayer);
	
	
	var so = new SWFObject(swfpath, "fp"+playerNum, width, height, "7", "#000000");
	so.addParam("wmode", "transparent");
	so.write("player"+playerNum);
	currentPlayer = playerNum;
	
	
}

function videoFinish(){
	$("#player"+currentPlayer).html("<a href=\"#\" onClick=\"videoControl('"+ currentImgPath +"', '"+ currentSwfPath +"', '"+ currentWidth +"', '"+ currentHeight +"','"+ currentPlayer +"'); return false;\"><img src=\""+ currentImgPath +"\" alt=\"\" width=\""+ currentWidth +"\" height=\""+ currentHeight +"\" /></a>");
	content.focus();
}
