
// Collection of SwiftyExpress JavaScript functions
//----------------------

function stateChanged() 
{ 
	if (xmlHttp.readyState!=4 && xmlHttp.readyState!="complete")
		return
		
	var newdiv=document.createElement("div")
	document.getElementById(containing).appendChild(newdiv) //append new div to another div
	newdiv.innerHTML = xmlHttp.responseText
	var x = document.getElementById(containing).getElementsByTagName("div")
	newdiv.setAttribute('id', 'div_' + x.length)
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		//Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	
	return xmlHttp;
}




function togglePrice(passme)
{
	var switcher = document.getElementById("price_hide");
	
	if (passme)
		switcher.style.display = "block";
	else
		switcher.style.display = "none";
}


function toggleDisplay(did)
{
	var switcher = document.getElementById(did);
	
	if (switcher.style.display == "none")
		switcher.style.display = "";
	else if (switcher.style.display == "")
		switcher.style.display = "none";
}

function hideDisplay(did)
{
	var switcher = document.getElementById(did);
	
	if (switcher.style.display == "")
		switcher.style.display = "none";
}



function openWindow(url)
{
	window.open(url, 'name', 'width=900px, height=700px, scrollbars=no, resizable=no, status=no');
}




function toggleAll(id)
{

	var setting = document.getElementById(id + '_any').checked != true;
	id = id + '_select-';
	var count = 1;
	var cur_id = id + count;

	while(box = document.getElementById(cur_id))
	{
		box.checked = setting;
		count++;
		cur_id = id + count;
	}
}




function toggleSelector(id)
{
	var basic = id;
	var selected = 0;
	var option = id + '_select-';
	var count = 1;		
	var cur_id = option + count;

	while(box = document.getElementById(cur_id))
	{
		if (box.checked == true)
			selected++;
		
		count++;
		cur_id = option + count;
	}

	document.getElementById(basic + '_any').checked = selected == 0;
}


