/* 
	http://sites.google.com/a/orbisdesign.com/lillibridge/projects/recent-facility-development-projects
*/
var xmlDoc = "http://spreadsheets.google.com/feeds/list/tcDrHD9CRDpuJgMVdcplwrw/od6/public/basic?alt=rss";
var xsltDoc = "/xslt/rfdp.xslt";
var linkId = "";
var linkIdHighlighted = "";  //hold previous
var strTitle = "";
var strDescription = "";
var strBigImage = "";
var strBuild = "";
var strPlace = "";
var strDesc2 = "";
var strDesc3 = "";
var strDesc4 = "";

$( ".selector" ).accordion({ autoHeight: false });
  
function runAccordion(){
	
	//getter
	var autoHeight = $( ".selector" ).accordion( "option", "autoHeight" );
	//setter
	$( ".selector" ).accordion( "option", "autoHeight", false );	
	
	$("#accordion").accordion();
}

function runAjax(){
	if(document.getElementById('TestOutput')){
		xmlhttpPost('/o2Net/Applications/TransformDoc/default.aspx?XmlDoc=' + window.xmlDoc + '&XsltDoc=' + window.xsltDoc + '',"TestOutput");
	}else{
		setTimeout('runAjax()',250);
	}
}

runAjax();

function loading(){
	document.images["clientBigImage"].src = '/images/trans.gif';	
}

function showClient(id,project,bigImage,description,build,place,desc2,desc3,desc4){
	
	
	linkId = id;
	strTitle = project;
	strBigImage = bigImage;
	strDescription = description;
	strBuild = build;
	strPlace = place;
	strDesc2 = desc2;
	strDesc3 = desc3;
	strDesc4 = desc4;
	setTimeout('displayClient()',50);
	//displayClient();
}
function displayClient(){
	if(document.getElementById('title')){
		document.getElementById('title').innerHTML = "<h2>" + formatContent(window.strTitle) + "</h2>";
		document.getElementById('desc').innerHTML = formatContent(window.strDescription);
		document.images["clientBigImage"].src = '/images/content/rfdp/' + window.strBigImage;
		document.getElementById('build').innerHTML = formatContent(window.strBuild);
		document.getElementById('place').innerHTML = formatContent(window.strPlace);
		document.getElementById('desc2').innerHTML = formatContent(window.strDesc2);
		document.getElementById('desc3').innerHTML = formatContent(window.strDesc3);
		document.getElementById('desc4').innerHTML = formatContent(window.strDesc4);
		highlightSelected(window.linkId);
		reDrawSifr();
	}else{
		setTimeout('displayClient()',250);
	}	
}
function highlightSelected(linkIdHighlight){
	if(linkIdHighlight != window.linkIdHighlighted && window.linkIdHighlighted != '' && window.linkIdHighlighted != null){
		document.getElementById(window.linkIdHighlighted).style.backgroundColor = '#fff';	//clear the last
	}
	linkIdHighlighted = linkIdHighlight;													//set this now
	document.getElementById(linkIdHighlight).style.backgroundColor = '#eee';
}
function formatContent(contentStr){
	var bulletStr = "";
	var contentStr1 = "";
	var contentStr2 = "";

	if(contentStr.indexOf("~") != -1){
		contentStr1 = contentStr.substring(0,contentStr.indexOf('~'));
		contentStr2 = contentStr.substring(contentStr.indexOf('~')); 
		
		bulletStr += contentStr1;
		bulletStr += '<ul>';
		bulletArray = contentStr2.split("~");
		
		for (y=0;y<=bulletArray.length-1;y=y+1)
		{
			if(bulletArray[y].length > 3){
				bulletStr += '<li>' + bulletArray[y] + '</li>';
			}
		}
		
		bulletStr += '</ul>';							
	
	}else{
		bulletStr += contentStr + '';
	}
	//Format commas
	bulletStr = bulletStr.replace(/\^/,"'");
	return bulletStr;	
}
function getQueryVariable(variable) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
  	}
	return "999";
}
function viewAll(){
	xmlhttpPost('/o2Net/Applications/TransformDoc/default.aspx?XmlDoc=' + window.xmlDoc + '&XsltDoc=' + window.xsltDoc + '&XmlVars=showAll|true',"TestOutput");
}
