var D = YAHOO.util.Dom;
var E = YAHOO.util.Event;

function playMovie(key, heading, panel) { // swf index; clipcontainer heading; panel id where to go back while closing up
	var clips = ["cordlessbig_f8.swf"];
	if (heading) {
		D.get("videoClipHeading").innerHTML = heading;	
	}
	if (panel) {
		D.get("closeVideoClip").href = "#panel"+panel;
		location.hash = location.hash + "|" + key;	// if playMovie event came from some panel, then we know that hash has no movie key
	} else {
		D.get("closeVideoClip").href = "#panel1";
	}
	if (typeof YAHOO != "undefined" && typeof SWFObject != "undefined") {
	    var so = new SWFObject("/i/flash/mobility/prism/"+clips[key]+"", "Skype", "650", "365", 8, "#FFFFFF");
			so.write("videoClipContainer");
	}
}

function addHotlinkHandler() {
	var hashSplit = location.hash.split("|");
	var newHash = hashSplit[0];
	if (hashSplit[1].length > 0) { // if theres ID for asked movieclip remove it from hash
		playMovie(hashSplit[1]);
	}
}


E.onDOMReady(function() {
	var clearMovieContainer = function() {
		D.get("videoClipContainer").innerHTML = "";
		D.get("videoClipHeading").innerHTML = D.get("videoClipHeading").title;
    };
    E.addListener(D.get("closeVideoClip"), "click", clearMovieContainer);
	addHotlinkHandler();
});