<!-- hide from non JavaScript Browser

var mainsource = ""
var loader = new Image();
loader.src = "images/icons/loader.gif";

function swapImageBack(name)
{
	document.images[name].src = mainsource;
	return true;		
}

function swapImage(name)
{
	mainsource = document.images[name].src;
	var strlength = document.images[name].src.length;
	var srcpath = document.images[name].src.substring(0,strlength-4);
	var ext = document.images[name].src.substring(strlength-4,strlength);
	document.images[name].src = srcpath.concat("_roll",ext);
	return true;
}

function showhide(fieldcheck, obj) {
	
	obj = document.getElementById(obj);
	
	if(document.cgform[fieldcheck].options[0].selected == false)
	{
		obj.style.color = "#333333";
	} 
	else
	{
		obj.style.color = "#CCCCCC";
	}
}	

function calcSurchargePercent(surcharge)
{
	var mytotal = 0;
	for(i = 1; i <= 10; i++)
	{
		mytotal = mytotal + Math.pow(surcharge,i);	
	}
	return mytotal;
}

function calcTotal(pub, priv, minslots, slotinc, variablesurch, fixedsurch)
{
	var count = 0;
	for(i = 0; i <= document.cgform.slots.options.length; i++)
	{
		if(document.cgform.slots.options[i].selected == true)
		{
			count = i;
			break;
		}
	}
	
	slotnum = count * slotinc + minslots;
	var tot = 0.00;
	var subtot = 0.00;
	var surcharge = 0.00;
	var term = 0;
	
	
	for(i = 0; i <= document.cgform.term.options.length; i++)
	{
		if(document.cgform.term.options[i].selected == true)
		{
			term = document.cgform.term.options[i].value;
			break;
		}
	}
			
	if(document.cgform.servertype.options[0].selected == true)
	{			
		tot = slotnum * pub;		
	}
	else
	{
		tot = slotnum * priv;
	}
	
	tot = tot * term;
	subtot = tot;
	
	surcharge = (tot + fixedsurch) * calcSurchargePercent(variablesurch) + fixedsurch;
	tot = subtot + surcharge;
		
	subtot = subtot.toFixed(2);
	document.cgform.subtotal.value = "$" + subtot;
	surcharge = surcharge.toFixed(2);
	document.cgform.surcharge.value = "$" + surcharge;
	tot = tot.toFixed(2);
	
	if(term == 1)
		term = "";
	
	document.cgform.total.value = "$" + tot + "/" + term +"mo";
}

function makeVisible(id)
{
	var x = document.getElementById(id);
	x.style.visibility = "visible";
}

function makeHidden(id)
{
	var x = document.getElementById(id);
	x.style.visibility = "hidden";
}

function isVisible(id)
{
	var ret = false;
	var x = document.getElementById(id);
	
	if(x.style.visibility == "visible")
	{
		ret = true;
	}
	return ret;
}

function toggleVisibility(id)
{
	if(isVisible(id))
	{			
		makeHidden(id);
	}
	else
	{
		makeVisible(id);	
	}
}

function toggleDrop(id, boxid, confirmid)
{
	var x = document.getElementById(boxid);
	if(isVisible(id) || isVisible(confirmid))
	{
		makeHidden(id);
		makeHidden(confirmid);
		x.style.background = "url(../images/admin/drop_arrow.gif)";
	}
	else
	{
		makeVisible(id);
		x.style.background = "url(../images/admin/drop_cross.gif)";
	}
}

function toggleDrop(id, boxid)
{
	var x = document.getElementById(boxid);
	if(isVisible(id))
	{
		makeHidden(id);
		x.style.background = "url(../images/admin/drop_arrow.gif)";
	}
	else
	{
		makeVisible(id);
		x.style.background = "url(../images/admin/drop_cross.gif)";
	}
}

function showDropConfirm(id, listid)
{
	makeHidden(listid);
	makeVisible(id);
}

function closeDropConfirm(id, listid)
{
	makeVisible(id);
	makeHidden(listid);
}

function show_loader(id)
{
	var img = document.getElementById(id);
	img.src = "images/icons/loader.gif";
}

function textAreaScrollBottom(id)
{
	var textarea = document.getElementById(id);	
	textarea.scrollTop = textarea.scrollHeight - textarea.clientHeight;
	textarea.focus();
	alert(textarea.clientHeight);
}

function emptyField(id)
{
	var x = document.getElementById(id);
	x.value = "";	
}

function setContent(id, content)
{
	document.getElementById(id).innerHTML = content;
}


//setFormContent
//id		> the id of the element whose content will be changed
//form 		> the name of the form
//field 	> the name of the select field within the form
//content	> an array of HTML content to be set based upon options within the form
function setFormContent(id, form, field, content)
{
	setContent(id, content[document.forms[form][field].selectedIndex]);
}
// - stop hiding          -->