﻿
function showVideo(video) {
    // check if SWF hasn't been removed, if this is the case, create a new alternative content container
    var c = document.getElementById("flashcontent");
    
    if (!c) {
	    var d = document.createElement("div");
	    d.setAttribute("id", "flashcontent");
	    document.getElementById("content-container").appendChild(d);
	    } else {
	    document.getElementById("alternativeContent").style.display="block";
    }
    
    // Flashvars with license key for forgeworld
    var flashvars = {};
	flashvars.config = "{'clip': '/Downloads/Product/FLV/" + video + "','key': '6838af9e434ffbfca84'}" 
    
    // Parameters
    var params = {};
    params.quality = "high";
    params.wmode = "transparent";
	params.allowfullscreen = "true";
	
    // Create SWF
    swfobject.embedSWF("/resources/flowplayer/flowplayer.tradeit-3.1.1.swf", "flashcontent", "500", "320", "9.0.0", "/Scripts/expressInstall.swf", flashvars, params);
    document.getElementById("mainimage").style.display="none";
}

function remove() {
    // if flash content exists remove it and display the main image div
    var c = document.getElementById("flashcontent");
    if (c){
        swfobject.removeSWF("flashcontent");
        document.getElementById("mainimage").style.display="block";
        document.getElementById("alternativeContent").style.display="none";
    }
}

function addHandler() {  
    var imagesDiv = document.getElementById("alternativeImages");

    if (imagesDiv != null) { 
        var arr = new Array();   
        arr = imagesDiv.getElementsByTagName("img");
        for(var i=0; i < arr.length; i++) {
            var tagObj = imagesDiv.getElementsByTagName("img").item(i);
            if (tagObj.className != "videoImage") {
    	        tagObj.onclick = function() {
                    remove();
                    return false;
                };  
            }         
        }
    }   
}

swfobject.addLoadEvent(addHandler);

