// JavaScript Document
function startSlideshow(path)
{
	// alert('Path: ' + path);
   	// create and append overlay div to dom
    var myDiv = document.createElement('div');
    document.body.appendChild(myDiv);
    var div = myDiv.setAttribute('id','overlay');
    var overlay = document.getElementById('overlay');
    
    // create and append slideshow (swf) to dom
    var slideshowContent = document.createElement('div');
    document.body.appendChild(slideshowContent);
    var movie = slideshowContent.setAttribute('id','movie');
    var swf = document.getElementById('movie');
	
	// hide the slideshow until centered
	swf.style.display = 'none';
	
    swf.innerHTML = "<embed base='.' src='prototype-ss.swf' quality='best' scale='noborder' bgcolor='#666666' width='640' height='519' name='slideshow' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' FlashVars='xmlfile=" + path + ".xml" + "' /><a href='#' id='removePanel'>Click here to close the slideshow</a>";
    
    // center the slideshow in the viewport
    var slideshowHeight = 519;
    var slideshowWidth = 640;
    
    // get full height and width of window 
    if (window.innerWidth)
    {
        var totalY = window.scrollMaxY + window.innerHeight;
        var totalX = window.scrollMaxX + window.innerWidth;
    }
    else
    {
		var totalY = document.body.scrollHeight + document.documentElement.scrollTop;
		var totalX = document.body.scrollWidth + document.documentElement.scrollLeft;
    }
    
	// set overlay height and width
    overlay.style.height = totalY + 'px';
	
	
    
	// if brower is not ie
    if (window.innerWidth)
    {
		var windowHeight = window.innerHeight;
        var windowWidth = window.innerWidth;
        var centeredHeight = (windowHeight/2) - (slideshowHeight/2) + window.pageYOffset;
        var centeredWidth = (windowWidth/2) - (slideshowWidth/2) + window.pageXOffset;
	}
    
    // if browser is ie
    else 
    {
        var windowHeight = document.documentElement.clientHeight;
        var windowWidth = document.documentElement.clientWidth;
        var centeredHeight = (windowHeight/2) - (slideshowHeight/2) + document.documentElement.scrollTop;
        var centeredWidth = (windowWidth/2) - (slideshowWidth/2) + document.documentElement.scrollLeft;
        
        // fix overlay for ie 6
        if (typeof document.body.style.maxHeight == "undefined")
        {
            overlay.style.height = totalY;
        }
    }
	
    swf.style.marginTop = centeredHeight + 'px';
    swf.style.marginLeft = centeredWidth + 'px';	
	
	// show the slideshow
    swf.style.display = 'block';
	
    // remove the slideshow and overlay and show the start button
    overlay.onclick = function()
    {	
        // alert(this.parentNode.firstChild.nodeType);
        this.parentNode.removeChild(swf);
        this.parentNode.removeChild(overlay);
		return false;
        //button.style.display = 'inline';
    }
    var removePanel = document.getElementById('removePanel');
    removePanel.onclick = function()
    {
        var removePoint = this.parentNode.parentNode;
        removePoint.removeChild(overlay);
        removePoint.removeChild(swf);
		return false;
    }
    
}