// JavaScript Document
function parseUrl() {
	return location.pathname;
}

function TCtoSec(timecode) {
	var totalSeconds = 0;
	
	try {
		var hours = timecode.substring(0, timecode.indexOf(":"));
		var minutes = timecode.substring(timecode.indexOf(":") + 1, timecode.lastIndexOf(":"));
		var seconds = timecode.substr(timecode.lastIndexOf(":") + 1);
		
		hours = (hours.indexOf("0") == 0) ? parseInt(hours.substr(1)) : parseInt(hours);
		minutes = (minutes.indexOf("0") == 0) ? parseInt(minutes.substr(1)) : parseInt(minutes);
		seconds = (seconds.indexOf("0") == 0) ? parseInt(seconds.substr(1)) : parseInt(seconds);
		
		totalSeconds += seconds;
		totalSeconds += minutes * 60;
		totalSeconds += hours * 60 * 60;
		
		//alert(timecode + "\n" + hours + " " + minutes + " " + seconds + "\n" + totalSeconds);
	} catch (e) {
		// nothing
		alert(e.message);
	}
	
	return totalSeconds;
}

function gotoPosition(timecode) {
	location.href = location.pathname + "?p=" + TCtoSec(timecode);
}

function loadVideo(marker, timecode) {
	if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer") {
		seekToMarker(marker);
	} else {
		gotoPosition(timecode);
	}
}
