// JavaScript Document

var ImgUrl		= 'images/_share/';
var TargetDiv	= 'swfObjContainer';
var flashvars	= {skin:"video/SkinOverPlaySeekMute.swf"};
var params		= {wmode:'transparent'};
var attributes	= {};
var ie6 = $.browser.msie && $.browser.version == 6;
if (ie6) {
	$(document).ready(function(){
		$('#VideoContainer .VideoOverlay')
			.css({'background-image':'url(' + ImgUrl + 'VideoOverlay_'+VideoSource.DefaultVideo+'.jpg)'})
			.show()
		$('#VideoContainer .VideoOverlay a')
			.attr('href','javascript:j2f_playVideo(\''+VideoSource.DefaultVideo+'\')')
		j2f_commonFunct(VideoSource.DefaultVideo);
	})
} else {
	swfobject.embedSWF("video/videoPlayer.swf", TargetDiv, "586", "330", "10.0.0", "expressInstall.swf", flashvars, params, attributes);
}

var VideoSource = {
	DefaultVideo:'HydraclearTechnology',
	InitPlay:null,
	VideoPlaying:null,
	AcceleratedStabilizationDesign:['ASD_CTN.f4v', 'ASD'],
	EasyHandling:['Handling_CTN.f4v', 'Handling contacts'],
	HydraclearTechnology:['Hydraclear_CTN.f4v', 'Hydraclear technology'],
	HighestUVProtection:['UV_Protection_CTN.f4v', 'UV protection'],
	LacreonTechnology:['Lacreon_CTN.f4v', 'Lacreon technology'],
	SiliconeHydrogelMaterial:['Materials_CTN.f4v', 'Hydrogel material']
};
function f2j_initLoad() {
	if (ie6) {
		thisMovie("swfObjContainer").j2f_playVideo(VideoSource[VideoSource.InitPlay][0], VideoSource[VideoSource.InitPlay][1]);
		VideoSource.InitPlay = null;
	} else if (VideoSource.InitPlay) {
		j2f_playVideo(VideoSource.InitPlay);
		VideoSource.InitPlay = null;
	} else {
		thisMovie("swfObjContainer").j2f_loadVideo(VideoSource[VideoSource.DefaultVideo][0], VideoSource[VideoSource.DefaultVideo][1]);
		$('#VideoContainer .VideoOverlay')
			.css({'background-image':'url(' + ImgUrl + 'VideoOverlay_'+VideoSource.DefaultVideo+'.jpg)'})
			.show()
		$('#VideoContainer .VideoOverlay a')
			.attr('href','javascript:j2f_playVideo(\''+VideoSource.DefaultVideo+'\')')
		j2f_commonFunct(VideoSource.DefaultVideo);
	}
}
function j2f_caterVideo(video) {
	if ($.browser.msie) {
		j2f_playVideo(video);
	} else {
		if ($('object#'+TargetDiv+':visible').size() > 0) {
			j2f_playVideo(video);
		} else {
			VideoSource.InitPlay = video;
		}
	}
}
function j2f_loadVideo(video) {
	$('#VideoContainer .VideoOverlay')
		.css({'background-image':'url(' + ImgUrl + 'VideoOverlay_'+video+'.jpg)'})
		.show()
	$('#VideoContainer .VideoOverlay a')
		.attr('href','javascript:j2f_playVideo(\''+video+'\')')
	j2f_commonFunct(video);
	if (ie6) {
		$('object#'+TargetDiv).remove()
		$('<div id="'+TargetDiv+'"></div>').before('#VideoContainer .VideoDetails')
	} else {
		thisMovie("swfObjContainer").j2f_loadVideo(VideoSource[video][0], VideoSource[video][1]);
	}
}
function j2f_playVideo(video) {
	VideoSource.InitPlay = null;
	VideoSource.VideoPlaying = video;
	if (ie6) {
		VideoSource.InitPlay = video;
		swfobject.embedSWF("video/videoPlayer.swf", TargetDiv, "586", "469", "10.0.0", "expressInstall.swf", flashvars, params, attributes);
	} else {
		thisMovie("swfObjContainer").j2f_playVideo(VideoSource[video][0], VideoSource[video][1]);
	}
	$('#VideoContainer .VideoOverlay').hide()
	$('.VideoDetails .VideoTitle').html($('.VideoListItem[rel='+video+'] .VideoTitle').html())
	$('.VideoDetails .VideoDescription').html($('.VideoListItem[rel='+video+'] .VideoDescription').html())
	j2f_commonFunct(video);
}
function f2j_videoPlay(_videoID) {
	techVideo_eventTrackHit(_videoID+"-start");
	_gaq.push(['_trackEvent', 'HK - Technology Videos', 'Start', _videoID]);
}
function f2j_videoComplete(_videoID) {
	j2f_loadVideo(VideoSource.VideoPlaying);
	techVideo_eventTrackHit(_videoID+"-end");
	_gaq.push(['_trackEvent', 'HK - Technology Videos', 'End', _videoID]);
}
function thisMovie(movieName) {
	if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
}
function j2f_commonFunct(video) {
	$('.VideoDetails .VideoTitle').html($('.VideoListItem[rel='+video+'] .VideoTitle').html())
	$('.VideoDetails .VideoDescription').html($('.VideoListItem[rel='+video+'] .VideoDescription').html())
	$('.VideoListItem').removeClass('CurrentOn')
	$('.VideoListItem[rel='+video+']').addClass('CurrentOn')
	if ($('.VideoListItem img[src$=_Playing.jpg]').size() > 0) {
		var TempStr = $('.VideoListItem img[src$=_Playing.jpg]').attr('src').replace('_Playing.jpg','.jpg');
		$('.VideoListItem img[src$=_Playing.jpg]').attr('src',TempStr)
	}
	$('.VideoListItem[rel='+video+'] img').attr('src',$('.VideoListItem[rel='+video+'] img').attr('src').replace('.jpg','_Playing.jpg'))
}

