//Image Preloader
newImage0 = new Image(511, 306);
newImage0.src = "http://machost/~toemaytoe/mindfile/images/gallery_temp.jpg";
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}
//To play logo swf on page load
function loadLogo() {
	var params = {
		wmode: "transparent"
	};
	swfobject.embedSWF("swf/logo.swf", "logo", "130", "90", "9.0.45", "swf/expressInstall.swf", false, params, false);
}
$(window).ready(function() {loadLogo()});


//Public variables for changing flashvars during different events
var filename;
var desc;
var credits;
var videoTitle;
var mov;

//Initial load of small video player when portfolio page loads
//Initial global flashvar values set in htmlHead.html for both players
var flashvars = {
	currentVideo: filename,
	videoTitle: videoTitle,
	videoDesc: desc,
	creditsText: credits
};
var params = {
	allowScriptAccess: "always",
	wmode: "transparent",
	allowfullscreen: "true"
};
function loadVideo() {
	flashvars.currentVideo = filename;
	flashvars.videoTitle = videoTitle;
	flashvars.videoDesc = desc;
	flashvars.creditsText = credits;
	flashvars.autoStart = autoStart;
	$("#video_player h1").text(videoTitle);
	$("#video_player_title a").attr("href", mov);
	swfobject.embedSWF("swf/videoPlayerSm.swf", "flashPlayer", "480", "295", "9.0.45", "swf/expressInstall.swf", flashvars, params, false);
}
$(window).ready(function() {loadVideo()});


//For portfolio page icon events
//loadSwf Globally resets flashvars from galleryClick event and reloads small video player
function loadSwf(){
	flashvars.currentVideo = filename;
	flashvars.videoTitle = videoTitle;
	flashvars.videoDesc = desc;
	flashvars.creditsText = credits;
	flashvars.autoStart = true;
	swfobject.embedSWF("swf/videoPlayerSm.swf", "flashPlayer", "480", "295", "9.0.45", "swf/expressInstall.swf", flashvars, params, false);
	$("#video_player h1").text(videoTitle);
	if(mov == "") {
		$("#video_player_title a").hide();
	} else {
		$("#video_player_title a").attr("href", mov);
		$("#video_player_title a").show();
	}
	
}
//Slider icon onClick action sets new flashvars and runs loadSwf function
function galleryClick() {
	$("#gallery a").click(function() {
		filename = "flv/" + $(this).attr("name");
		desc = $(this).find("p").eq(0).text();
		mov = $(this).find("p").eq(1).text();
		videoTitle = $(this).find("h1").text();
		credits = $(this).find("h2").text();
		loadSwf();
	});
}
$(window).ready(function() {galleryClick()});


//For homepage icon events
//newFlashvars Globally resets flashvars from iconChange event
function newFlashvars() {
	flashvars.currentVideo = filename;
	flashvars.videoTitle = videoTitle;
	flashvars.videoDesc = desc;
	flashvars.creditsText = credits;
}
//homepage feature images change
function iconChange() {
	$("#home_banner_icons li").click(function() {
		var newFeature = $(this).attr("name");
		$("img.featuredImg").attr("src", "images/" + newFeature);
		
		filename = "flv/" + $(this).attr("title");
		desc = $(this).find("p").eq(0).text();
		mov = $(this).find("p").eq(1).text();
		credits = $(this).find("h2").text();
		videoTitle = $(this).find("h1").text();
		
		$("#home_banner_text h1").text(videoTitle);
		$("#home_banner_text p").text(desc);
		$("#home_banner a.thickbox").attr("title", videoTitle);
		if(mov == "") {
			$("#home_banner_links a:eq(1)").hide();
		} else {
			$("#home_banner_links a:eq(1)").attr("href", mov);
			$("#home_banner_links a:eq(1)").show();
		}
		
		newFlashvars();
	});
}
$(window).ready(function() {iconChange()});

