//Sliding photo widget
var y;
var t;
var ourHeight = 0;
var yourHeight = 0;


function GetXmlHttpObject(){
	var xmlHttp=null;
	try{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e){
		try{	
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
function showPhotos(type, xml){
	var photos = null;
	switch(type){
		case "our":
			photos = "ourPhotosBody";
			break;
		case "your":
			photos = "yourPhotosBody";	
			break;
	}	
	
	//Set AJAX object
	xmlHttp=GetXmlHttpObject();		
	if (xmlHttp==null){
		document.getElementById(photos).innerHTML = "Browser does not support AJAX.  Please make sure that your browser is up to date and that JavaScript is enabled.";
		return;
	} 
	
	
	//Set URL
	var url="myCaptureXMLFeed.php?type="+type+"&xml="+xml+"&sid="+Math.random()
	
	
	//Set div to display photos in		
	switch(type){
		case "our":
			contract("your");
			expand("our");
			photos = "ourPhotosBody";
			xmlHttp.onreadystatechange=displayOur
			xmlHttp.open("GET",url,true)
			xmlHttp.send(null)
			break;
		case "your":
			contract("our");
			expand("your");		
			photos = "yourPhotosBody";
			xmlHttp.onreadystatechange=displayYour
			xmlHttp.open("GET",url,true)
			xmlHttp.send(null)			
			break;
	}
}
function displayOur(){	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		document.getElementById("ourPhotosBody").innerHTML=xmlHttp.responseText
	}
	else{
		document.getElementById("ourPhotosBody").innerHTML="<center><br /><br /><img src='ajax-loader2.gif' /></center>"
	}
}
function displayYour(){	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		document.getElementById("yourPhotosBody").innerHTML=xmlHttp.responseText
	}
	else{
		document.getElementById("yourPhotosBody").innerHTML="<center><br /><br /><img src='ajax-loader2.gif' /></center>"
	}
}







/* Expand Panels */
/* Expand random panel on page load */
function loadMedia(){
	x = 0;

	var rand = Math.floor(Math.random() * 2);
	
	switch(rand){
		case 0:
			showPhotos('our', '10483');
			break;
		case 1:
			showPhotos('your', '10484');
			break;
	}
}


//set max height
var maxPanelHeight = 240;

function expand(object){	
	switch(object){
		case 'your':
			y = yourHeight;
			expandYour();
			break;
		case 'our':
			y = ourHeight;
			expandOur();
			break;
	}	
}

function expandYour(){	
	document.getElementById('yourPhotosBody').style.fontSize="11px";
	document.getElementById('yourPhotosBody').style.visibility="visible";
	
	if(y<maxPanelHeight){
		y=y+5;
		document.getElementById('yourPhotosBody').style.height=y+"px";
		t=setTimeout("expandYour()",10);
	}
	else{
		yourHeight = y;
	}
}
function expandOur(){
	document.getElementById('ourPhotosBody').style.fontSize="11px";
	document.getElementById('ourPhotosBody').style.visibility="visible";
	
	if(y<maxPanelHeight){
		y=y+5;
		document.getElementById('ourPhotosBody').style.height=y+"px";
		t=setTimeout("expandOur()",10);
	}
	else{
		ourHeight = y;
	}
}


/* Contract Panels */
function contract(object){
	switch(object){
		case 'your':
			contractYour();
			break;
		case 'our':			
			contractOur();
			break;
	}	
}
function contractYour(){	
	document.getElementById('yourPhotosBody').style.fontSize="0px";
	document.getElementById('yourPhotosBody').style.visibility="hidden";

	if(yourHeight != 0){
		yourHeight=yourHeight-5;
		document.getElementById('yourPhotosBody').style.height=yourHeight+"px";
		t=setTimeout("contractYour()",10);
	}
}
function contractOur(){	
	document.getElementById('ourPhotosBody').style.fontSize="0px";
	document.getElementById('ourPhotosBody').style.visibility="hidden";

	if(ourHeight != 0){
		ourHeight=ourHeight-5;
		document.getElementById('ourPhotosBody').style.height=ourHeight+"px";
		t=setTimeout("contractOur()",10);
	}
}