
// used by the incremental list loading Sample
var controller = null;
function insertProgress()
{
	var progContainer = document.getElementById("progressCont");
	var can = document.createElement("canvas");
	can.setAttribute("height", 100);
	can.setAttribute("width", 100);
	can.setAttribute("style", "background:#transparent;");
	progContainer.appendChild(can);

	controller = getLoading(can.getContext("2d"), 12, {x:20, y:20}, 6, {width: 2, height: 5}, {red: 50, green: 79, blue: 133});
}
// used by the incremental list loading Sample
function loadMore()
{
	var progContainer = document.getElementById("progressCont");
	// remove progress indicator
	if(progContainer.firstChild)
	{
		controller.stop();
		progContainer.removeChild(progContainer.firstChild);
	}

	// insert progress indicator
	var progContainer = document.getElementById("progressCont");
	var can = document.createElement("canvas");
	can.setAttribute("height", 100);
	can.setAttribute("width", 100);
	can.setAttribute("style", "background:#transparent;");
	progContainer.appendChild(can);

	controller = getLoading(can.getContext("2d"), 12, {x:20, y:20}, 6, {width: 2, height: 5}, {red: 50, green: 79, blue: 133});
	
	setTimeout("appendItems()", 1000);
}
// used by the incremental list loading Sample
function appendItems()
{

	var moreItemLI = document.getElementById("moreListItem");
	var ulElem = moreItemLI.parentNode;
	
	childCount = ulElem.getAttribute("count");
	
	// remove more item
	ulElem.removeChild(moreItemLI);
	// append more items
	for(var appendCount=0;appendCount < 5;appendCount++)
	{
		var newLi = document.createElement("Li");
		var newAnchor = document.createElement("A");
		newAnchor.setAttribute("href","#");
		newAnchor.innerHTML = "Item " + (++childCount) + "";
		newLi.appendChild(newAnchor);
		ulElem.appendChild(newLi);
	}
	//put back more item
	ulElem.appendChild(moreItemLI);
	ulElem.setAttribute("count", childCount);
	
	var progContainer = document.getElementById("progressCont");
	// remove progress indicator
	if(progContainer.firstChild)
	{
		controller.stop();
		progContainer.removeChild(progContainer.firstChild);
	}
}
// used by the toggle button in the button samples
function toggleBtn(which)
{
	which.className = (which.className.indexOf('togButtonOff') > 0) ? 'togButton togButtonOn noHighlight' : 'togButton togButtonOff noHighlight';
}
// used by the orientation sample
if("orientation" in window)
{
	setTimeout("updateOrientation()",10000);
}
// used by the orientation sample
function updateOrientation()
{
	var displayStr = "Orientation " + "(" + window.orientation + "): ";
	
	switch(window.orientation)
	{	
		case 0:
			displayStr += "Portrait";
		break;
		
		case -90:
			displayStr +=  "Landscape (right, screen turned clockwise)";
		break;
		
		case 90:
			displayStr += "Landscape (left, screen turned counterclockwise)";
		break;
		
		case 180:
			displayStr += "Portrait (upside-down portrait)";
		break;
		
	}
	document.getElementById("orientationBucket").innerHTML = displayStr;
}

var startDate = null;

// used by the window sample
var win = null;
function showChild() {
	
	var loc = "child.html";	
	var winStr = "resizable=1,status=yes,scrollbars=yes,toolbar=no,location=no,menu=no";
	var winName = "iPhone";
	win = window.open(loc, winName , winStr);
}

// used by the window sample
function windowCheck() {
	try 
	{
		if(!win.name) {
			alert("Child is Closed");	
			return false;
		}
	}
	catch(e) {
		alert("Child is Closed");	
		return false;
	}
	return true;
}

