﻿var flashVersion;
var MinVersion = 7;

function getX(obj){
    return obj.offsetLeft + (obj.offsetParent ? getX(obj.offsetParent) : obj.x ? obj.x : 0);
}
function getY(obj){
    return obj.offsetTop + (obj.offsetParent ? getY(obj.offsetParent) : obj.y ? obj.y : 0);    
}
function openVideo(){
    //alert("yes");
	var HomeImg = document.getElementById("imgVideo");
	var FlashDiv = document.getElementById("videoDiv");
	var FlashHeight = 420;
	var FlashWidth = 720;
	var SWFPath = "player-viral.swf?id=" + Math.random;
	
	var FlashVars = "file=movies/FREEDOM_STONE.flv"; // Video File path from SWF file
	FlashVars += "&videoWidth=720";                        // Video Width
	FlashVars += "&videoHeight=400";                       // Video Height
	FlashVars += "&autoStart=true";                        // Autoplay Video or Not
	FlashVars += "&showPercent=true";	                   // Show Buffer Percentage
	FlashVars += "&ocSpeed=10";                            // Page Open Close Speed
	FlashVars += "&curlHeight=0";                          // Edge Curling of the image	
	FlashVars += "&turnRate=5";                            // Turning Animation Smoothness
	FlashVars += "&retFunc=closeVideo";                    // Function called after close animation
	det();
    if(flashVersion >= MinVersion){
        //FlashDiv.innerHTML = "";
        SWFobj = new deconcept.SWFObject(SWFPath,"",FlashWidth,FlashHeight,"8","#ffffff");        
        SWFobj.addParam("FlashVars",FlashVars);
        SWFobj.addParam("Movie",SWFPath);
        SWFobj.addParam("Src",SWFPath);
        SWFobj.addParam("WMode","Transparent");
        SWFobj.addParam("Loop","-1");
        SWFobj.addParam("Quality","High");
        SWFobj.addParam("Menu","0");
        SWFobj.addParam("AllowScriptAccess","sameDomain");
        SWFobj.addParam("Scale","ShowAll");
        SWFobj.addParam("DeviceFont","0");
        SWFobj.addParam("EmbedMovie","0");
        SWFobj.addParam("SeamlessTabbing","1");
        SWFobj.addParam("Profile","0");
        SWFobj.addParam("ProfilePort","0");
        SWFobj.addParam("allowfullscreen","true");
        SWFobj.write("vDiv");
        //alert(document.getElementById("vDiv").innerHTML);
	    //FlashDiv.style.left ="200px";
	    //FlashDiv.style.top = "200px";
    }else{
       var NoFlash = "<table border=0 cellpadding=5 cellspacing=0 width='100%' style='height:100%'><tr><td valign='top' colspan='3' style='width:100%' align='right'><span style='cursor:hand; color:#ffffff;' class='linkb' onClick='closeVideo();'><b>X</b></span></td>"
       NoFlash += "</tr><tr><td style='width:5%'></td><td valign='top' align='left' style='width:90%'><span class='defaultfont' style='color:white'>To watch this video you need Macromedia Flash Player Version" + MinVersion + " or higher.</span><br />"
       NoFlash += "<span class='defaultfont' style='color:white'> <a href='http://www.macromedia.com/go/getflashplayer' class='linkb' style='color:#ffffff' target='_blank'><b>Click here</b></a> to download free version of the Flash player.</span></td><td style='width:5%'></td>"
       NoFlash += "</tr></table>"
       FlashDiv.innerHTML = NoFlash;
       //var imgX = getX(HomeImg);
	   //var imgY = getY(HomeImg);
	   FlashDiv.style.left = 200 + "px";	
	   FlashDiv.style.top = 200 + "px";	
	   FlashDiv.style.background = "#000000";
	   FlashDiv.style.width = HomeImg.offsetWidth;
	   FlashDiv.style.height = HomeImg.offsetHeight;
	   FlashDiv.style.textAlign = "center";
    }		
	//FlashDiv.style.display = "block";
	winVideo1.Show();
}
function openVideo1(){
	var FlashDiv = document.getElementById("videoDiv1");
	
	var FlashHeight = 265;
	var FlashWidth = 320;
	det();
    if(flashVersion >= MinVersion){
        document.getElementById("vDiv1").innerHTML = "<embed src='http://cnettv.cnet.com/av/video/cbsnews/atlantis2/player-dest.swf' FlashVars='linkUrl=http://www.cbsnews.com/video/watch/?id=6228927n&tag=contentBody;housing&releaseURL=http://cnettv.cnet.com/av/video/cbsnews/atlantis2/player-dest.swf&videoId=50083944&partner=news&vert=News&si=254&autoPlayVid=false&name=cbsPlayer&allowScriptAccess=always&wmode=transparent&embedded=y&scale=noscale&rv=n&salign=tl' allowFullScreen='true' width='425' height='324' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed>"
        //alert("yes")
	    //FlashDiv.style.left = 300 + "px";
	    //FlashDiv.style.top = 200 + "px";
	
    }else{
       var NoFlash = "<table border=0 cellpadding=5 cellspacing=0 width='100%' style='height:100%'><tr><td valign='top' colspan='3' style='width:100%' align='right'><span style='cursor:hand; color:#ffffff;' class='linkb' onClick='closeVideo2();'><b>X</b></span></td>"
       NoFlash += "</tr><tr><td style='width:5%'></td><td valign='top' align='left' style='width:90%'><span class='defaultfont' style='color:white'>To watch this video you need Macromedia Flash Player Version" + MinVersion + " or higher.</span><br />"
       NoFlash += "<span class='defaultfont' style='color:white'> <a href='http://www.macromedia.com/go/getflashplayer' class='linkb' style='color:#ffffff' target='_blank'><b>Click here</b></a> to download free version of the Flash player.</span></td><td style='width:5%'></td>"
       NoFlash += "</tr></table>"
       FlashDiv.innerHTML = NoFlash;
       //var imgX = getX(HomeImg);
	   //var imgY = getY(HomeImg);
	   FlashDiv.style.left = 300 + "px";	
	   FlashDiv.style.top = 200 + "px";	
	   FlashDiv.style.background = "#000000";
	   FlashDiv.style.width = "300px";
	   //FlashDiv.style.height = HomeImg.offsetHeight;
	   FlashDiv.style.textAlign = "center";
    }		
	//FlashDiv.style.display = "block";
	winVideo.Show();
}
function closeVideo(){
    winVideo1.Hide();
	var FlashDiv = document.getElementById("videoDiv");
	//FlashDiv.style.display = "none";
	document.getElementById("vDiv").innerHTML = "";
}
function closeVideo1(){
    winVideo.Hide();
	var FlashDiv = document.getElementById("videoDiv1");
	//FlashDiv.style.display = "none";
	document.getElementById("vDiv1").innerHTML = "";
}
function closeVideo2(){
    winVideo.Hide();
	var FlashDiv = document.getElementById("videoDiv1");
	//FlashDiv.style.display = "none";
}
function setStatus(Percent){
    if(Percent=="LOADED"){
        window.defaultStatus = "";
    }else{
        window.defaultStatus = Percent + "% buffering completed...";
    }
}


function det(){
    if(navigator.plugins.length) { 
        flashVersion = 0;
        for (i=0; i < navigator.plugins.length; i++) { 
            var pluginIdent = navigator.plugins[i].description.split(" "); 
            if(pluginIdent[0] == "Shockwave" && pluginIdent[1] == "Flash") { 
                var versionArray = pluginIdent[2].split("."); 
                flashVersion = versionArray[0];
            }
        }
    }else{
        for(var i=MinVersion; i>0; i--){
            flashVersion = 0;
            try{
                var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
                flashVersion = i;
                return;
            }catch(e){}
        }
    }
}

function PreloadImage(Imgsrc){
    var imag = new Image();
    imag.src = Imgsrc;
}

function PreloadSWF(SWFPath){
    var Preloaddiv = document.getElementById("PreloadSWFDiv");
    if(!Preloaddiv){
        document.body.innerHTML += "<DIV id='PreloadSWFDiv' style='display:none;'></DIV>";
        Preloaddiv = document.getElementById("PreloadSWFDiv");
    }
    var SWFobj = new deconcept.SWFObject(SWFPath,"","300","300","8","#ffffff");
    SWFobj.addParam("Movie",SWFPath);
    SWFobj.addParam("Src",SWFPath);
    SWFobj.addParam("WMode","Transparent");
    SWFobj.addParam("Loop","-1");
    SWFobj.addParam("Quality","High");
    SWFobj.addParam("Menu","0");
    SWFobj.addParam("AllowScriptAccess","sameDomain");
    SWFobj.addParam("Scale","ShowAll");
    SWFobj.addParam("DeviceFont","0");
    SWFobj.addParam("EmbedMovie","0");
    SWFobj.addParam("SeamlessTabbing","1");
    SWFobj.addParam("Profile","0");
    SWFobj.addParam("ProfilePort","0");
    SWFobj.write("PreloadSWFDiv");
}


onerror = function(err,url,line){
    alert(err);
    return true;
}
