﻿var xmlDoc

function loadXMLDoc(url,page) {
    //stopMusic();
    xmlDoc=null
    // code for Mozilla, etc.
    if (window.XMLHttpRequest) { xmlDoc=new XMLHttpRequest() }
    // code for IE
    else if (window.ActiveXObject) { xmlDoc=new ActiveXObject("Microsoft.XMLHTTP") }
    if (xmlDoc!=null) {
        xmlDoc.onreadystatechange=onResponseSlideShow;
        xmlDoc.open("GET",url,true);
        xmlDoc.send(null);
    } else {
        alert("Your browser does not support XMLHTTP.")
    }
}

function checkReadyState(obj) {
    if(obj.readyState == 4) {
        if(obj.status == 200) {
            return true;
        } else {
            alert("Problem retrieving XML data");
        }
    }
}

function onResponseSlideShow() {
    if(checkReadyState(xmlDoc)) { loadSlideShow(); }
}

function addImg(img,path) {
    eval("document."+img+".src = path");
}

/*function showVideo() {
    stopMusic();
    document.getElementById("slideShowRight").style.display = "none";
    document.getElementById("flashContainer").style.visibility = "visible";
    window.document.vidPlayer.SetVariable("showVideo", "true");
}*/
function showVideo(videoPath, stopVideo, imgPath) {
	
	//alert("musicplaying : " + parent.bottomFrame.musicPlaying);
	//alert("stopVideo : " + stopVideo);
	
	/*if (stopVideo == "true"){
		//if (parent.bottomFrame.musicPlaying == true){
			//startMusic();
		//}
	} else {
		//stopMusic();
	}*/
	
	
	var so = new SWFObject("swf/videoPlayer.swf", "vidPlayer", "422", "341", "8");
	so.addParam("scale", "exactfit");
    so.addParam("wmode", "transparent");
	so.addVariable("stopVideo",stopVideo);
	so.addVariable("imgPath",imgPath);
	so.addVariable("videoPath",videoPath);
	
    document.getElementById("slideShowRight").style.display = "none";
    document.getElementById("flashContainer").style.visibility = "visible";
	document.getElementById('videoText').style.display="block";
	so.write("flashContainer");
}


function loadSlideShow()
{   
  	var response = xmlDoc.responseXML.documentElement;
    var slideShow = response.getElementsByTagName("picture");
    var tmp = "";
    for (i=0; i < slideShow.length; i+=1) {
        
        tmp += "<div class='thumb'>";
        tmp += "<a href='javascript:;' onclick='showMedium("+i+")'><img name='P" + i + "' src='images/trans.gif' border='0' alt='' /></a></div>";
    }
    
    document.getElementById('thumbnails').innerHTML=tmp;
    tmp = "";
    for (i=0; i < slideShow.length; i+=1) {
        pictureName = slideShow[i].getElementsByTagName('name')[0].firstChild.data;
        eval("document.P" + i + ".src = 'images/thumbnails/"+pictureName+"'");
    }
    document.getElementById('videoText').style.display="none";
    setTimeout("loadFlash();", 1000);
}

function showMedium(thePict) {
    document.getElementById('videoText').style.display="none";
    document.getElementById("flashContainer1").style.display = "none";
    document.getElementById("flashContainer2").style.display = "none";
    document.getElementById("flashContainer3").style.display = "none";
    document.getElementById("slideShowRight").style.display = "inline";
	
   // window.document.vidPlayer.SetVariable("stopVideo", "true");

    var response = xmlDoc.responseXML.documentElement;
    var slideShow = response.getElementsByTagName("picture");
    pictureName = slideShow[thePict].getElementsByTagName('name')[0].firstChild.data;
    window.setTimeout("addImg('medium','images/medium/"+pictureName+"')",1);    
}

function showVideo2() {
	
	//alert("musicplaying : " + parent.bottomFrame.musicPlaying);
	//alert("stopVideo : " + stopVideo);
	
	/*if (stopVideo == "true"){
		//if (parent.bottomFrame.musicPlaying == true){
			//startMusic();
		//}
	} else {
		//stopMusic();
	}*/
	
	document.getElementById("slideShowRight").style.display = "none";
    document.getElementById("flashContainer1").style.display = "block";
    document.getElementById("flashContainer2").style.display = "block";
    document.getElementById("flashContainer3").style.display = "block";
	document.getElementById('videoText').style.display="block";
	
}