$(document).ready(function(){
	//Add click options to any images referenced
	$("a.play").add("a.play2").each(function ()
	{
		var id = $(this).attr('title');
		$("#" + id).addClass("aClickVideo");
	});
						  
	//Click To Play
	$("a.play").click(function ()
	{
		var id = $(this).attr('title');
		var src = $(this).attr('alt');
		var image = $("#" + id).children('img').attr('src');
		$("#" + id).css({'width':'660px', 'height':'372px', 'background':'url(' + image + ') top left no-repeat'});
		$("#" + id).html('');
		$("#" + id).flash(
		{ src: 'page_vids/vid_player.swf',
				  width: 660,
				  height: 372,
				  wmode: 'transparent',
				  flashvars: {videoId: src}
		});
		
	});
	
	$("a.play2").click(function ()
	{
		var id = $(this).attr('title');
		var src = $(this).attr('alt');
		var image = $("#" + id).children('img').attr('src');
		$("#" + id).css({'width':'375px', 'height':'211px', 'background':'url(' + image + ') top left no-repeat'});
		$("#" + id).html('');
		$("#" + id).flash(
		{ src: 'page_vids/vid_player2.swf',
				  width: 375,
				  height: 211,
				  wmode: 'transparent',
				  flashvars: {videoId: src}
		});
	});
	
	$("div.aClickVideo").click(function ()
	{
		var id = $(this).attr('id');
		$("a.play").add("a.play2").each(function ()
		{
			if($(this).attr('title') == id)
				$(this).click();
		});
	});
	
	
			
	//Contact Form
	$("#contactForm input[type=text]").add("#contactForm textarea").focus(function ()
	{
		if($(this).val() == "")
		{
			$(this).css({'background':'none'});
		}
	}).blur(function ()
	{
		if($(this).val() == '')
		{
			$(this).css({'background':'url(img/contact_' + $(this).attr('name') + '.gif) top right no-repeat'});
		}
	});
	
	$("#contactForm input[type=text]").add("#contactForm textarea").each(function ()
	{
		if($(this).val() == '')
		{
			$(this).css({'background':'url(img/contact_' + $(this).attr('name') + '.gif) top right no-repeat'});
		}
	});

						   
						   
	//PNG FIX
	$(document).pngFix();
	
	if($("#videoPlayer").length != 0)
	{
		//Video player
		var videoInfoRaw = $("#videoPlayer").html().replace(/<!-- /, '').replace(/ -->/, '');
		var videoInfo = videoInfoRaw.split(",");
		var videoId = videoInfo[0];
		//Row1
		var l1a = videoInfo[1];
		var l1b = videoInfo[2];
		var l1c = videoInfo[3];
		var l1d = videoInfo[4];
		var l1e = videoInfo[5];
		var l1f = videoInfo[6];
		var l1g = videoInfo[7];
		//Row2
		var l2a = videoInfo[8];
		var l2b = videoInfo[9];
		var l2c = videoInfo[10];
		var l2d = videoInfo[11];
		var l2e = videoInfo[12];
		var l2f = videoInfo[13];
		var l2g = videoInfo[14];
		//Row3
		var l3a = videoInfo[15];
		var l3b = videoInfo[16];
		var l3c = videoInfo[17];
		var l3d = videoInfo[18];
		var l3e = videoInfo[19];
		var l3f = videoInfo[20];
		var l3g = videoInfo[21];
		//Row4
		var l4a = videoInfo[22];
		var l4b = videoInfo[23];
		var l4c = videoInfo[24];
		var l4d = videoInfo[25];
		var l4e = videoInfo[26];
		var l4f = videoInfo[27];
		var l4g = videoInfo[28];
		//Row5
		var l5a = videoInfo[29];
		var l5b = videoInfo[30];
		var l5c = videoInfo[31];
		var l5d = videoInfo[32];
		var l5e = videoInfo[33];
		var l5f = videoInfo[34];
		var l5g = videoInfo[35];
		
		$("#videoPlayer").flash(
				{ src: 'flash/movie_player.swf',
				  width: 720,
				  height: 467,
				  wmode: 'transparent',
				  flashvars: {videoId: videoId, 
				  l1a: l1a,
				  l1b: l1b,
				  l1c: l1c,
				  l1d: l1d,
				  l1e: l1e,
				  l1f: l1f,
				  l1g: l1g,
	
				  l2a: l2a,
				  l2b: l2b,
				  l2c: l2c,
				  l2d: l2d,
				  l2e: l2e,
				  l2f: l2f,
				  l2g: l2g,
	
				  l3a: l3a,
				  l3b: l3b,
				  l3c: l3c,
				  l3d: l3d,
				  l3e: l3e,
				  l3f: l3f,
				  l3g: l3g,
	
				  l4a: l4a,
				  l4b: l4b,
				  l4c: l4c,
				  l4d: l4d,
				  l4e: l4e,
				  l4f: l4f,
				  l4g: l4g,
				  
				  l5a: l5a,
				  l5b: l5b,
				  l5c: l5c,
				  l5d: l5d,
				  l5e: l5e,
				  l5f: l5f,
				  l5g: l5g
				}
				  }
			);	
	}
});
