var request = null;
var ss;
try {
	request = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
	request = new ActiveXObject("Msxml2.XMLHTTP");
	
} catch (othermicrosoft) {
try {
	request = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (failed) {
		request = null;
		}
	}
}

//var project_id=document.forms.comment.id.value;
var project_id=document.getElementById("pid").innerHTML;
// Create the slideshow object
ss = new slideshow("ss");

var url = "project_slides.php?project_id="+project_id;
request.open("GET", url, true);
request.onreadystatechange = updatePage1;
request.send(null);

 function updatePage1() {
    if (request.readyState == 4) {
		if(request.status == 200){
			var Photo_Info = request.responseText;
			Photo_Info=Photo_Info.split(",");
			
			/*var Photo_Id=new array();
			var Photo_Path=new array();
			for(var i=0;i<Photos.length;i++){
			Photo_Id=Photos[i];
			Photo_Id=Photos[i];
			}*/

			// Create the slides and add them to the slideshow.
			for(var i=0;i<Photo_Info.length;i++){
			Photos=Photo_Info[i].split("-");
			s = new slide();

			s.src = "admin/project_images/"+Photos[1];
			s.link = "admin/project_images/"+Photos[1];
			//	alert(s.link);

			s.title = "First slide";
			s.text = Photos[0];
			ss.add_slide(s);
			}

			// The following loop sets an attribute for all of the slides.
			// This is easier than setting the attributes individually.
			for (var i=0; i < ss.slides.length; i++) {
			s = ss.slides[i];
			s.target = "ss_popup";
			s.attr = "width=320,height=420,resizable=yes,scrollbars=yes";
			}

		}
	}
}
function activateSlideShow(){
if (document.images) {

  // Tell the slideshow which image object to use
  ss.image = document.images.ss_img;

  // Tell the slideshow the ID of the element
  // that will contain the text for the slide
  ss.textid = "ss_text";

  // Randomize the slideshow?
  // ss.shuffle();

  // Set up the select list with the slide titles
 // config_ss_select();

  // Update the image and the text for the slideshow
  //ss.update();

  // Auto-play the slideshow
  ss.play();
}

 }

function showImage(x){
	if(x==0) {
		document.getElementById("action").innerHTML="<a id='ss_stop' href='javascript: ss.pause(); showImage(1);'><img src='images/stop.gif' border='0' title='stop slideshow' align='bottom'></a>&nbsp;";
		//document.getElementById("nav_link").innerHTML="";
	}
	else if(x==1) 	{
		document.getElementById("action").innerHTML="<a id='ss_start'  href='javascript: activateSlideShow(); showImage(0);'><img src='images/play.gif' border='0' title='play slideshow' align='bottom'/></a>&nbsp;";
		// var project_id=document.forms.comment.id.value;
		// var photo_id=document.forms.comment.photo_id.value;
		 //loadNavLink(project_id,photo_id);

	}
}