
function small_screen(nrrw, shrt)
{
	if ((o = document.getElementById('onehundred'))) 
	{
		o.style.width = nrrw ? '898px' : '100%';
		o.style.height = shrt ? '520px' : '100%';
		o.parentNode.style.overflow = (nrrw || shrt) ? 'auto' : 'hidden';
	}
}

function click_package(checked, treatments)
{
	var i;
	
	var t = 0;
	
	for (i = 0; i < treatments.length; i++) 
	{
		document.getElementById('treatment_' + treatments[i]).checked = checked;
		document.getElementById('treatment_' + treatments[i]).disabled = checked;
	}
}

function click_treatment()
{
	var tbody = getFirstChildNode(document.getElementById('treatments'));
	var t = 0;
	var x;
	for (x = 0; x < tbody.childNodes.length; x++) 
	{
		var orow = tbody.childNodes[x];
		if (orow.nodeType != 1) 
			continue;
		
		var ocheck = orow.childNodes[1];
		var oprice = orow.childNodes[2];
		
		if (ocheck && ocheck.firstChild && ocheck.firstChild.checked && !ocheck.firstChild.disabled) 
		{
			var price = oprice.innerHTML;
			t += parseInt(price);
		}
	}
	
	document.getElementById('show_promotional').style.display = (t > 0 ? '' : 'none');
	
	var otot = document.getElementById('total_price');
	otot.innerHTML = t;
}



function getFirstChildNode(o)
{
	if (!o) 
		return null;
	var x;
	for (x = 0; x < o.childNodes.length; x++) 
	{
		if (o.childNodes[x].nodeType == 1) 
			return o.childNodes[x];
	}
	return null;
}

function show_flash_iframe(n)
{
	show_iframe(IFRAME_WEB + n);
}

function show_iframe(url)
{
	//alert('showing iframe '+url)
	var test_cont = document.getElementById('iframe_container');
	if (test_cont){alert('still in dom!');return;}
	
	var pres_cont = document.createElement('div');
	var body = document.getElementsByTagName('body')[0];
	pres_cont.id = 'iframe_container';
	pres_cont.style.position = 'fixed';
	pres_cont.style.zIndex = 99995;
	pres_cont.style.height = "100%";
	pres_cont.style.width = "100%";
	pres_cont.style.top = "0px";
	pres_cont.style.left = "0px";
	pres_cont.innerHTML = '<div style="position:fixed;width:100%;height:100%;opacity:0.8;filter:alpha(opacity=80);background:black;z-index:99996"></div>' +
	'<div style="position:fixed;width:32px;height:32px;top:50%;left:50%;margin:-253px 427px;z-index:99999;">' +
	'<a href="#" onclick="hide_iframe();return false;"><img src="' +
	ASSETS_WEB +
	'images/close_iframe.png" title="Close" border="0" /></a>' +
	'</div>' +
	'<div style="position:fixed;width:32px;height:32px;top:50%;left:50%;margin:253px 427px;text-align:right;z-index:99999;">' +
	'<button onclick="print_iframe()">Print</button>' +
	'</div>' +
	'<div style="position:fixed;width:878px;height:480px;top:50%;left:50%;margin:-240px -439px;z-index:99997;">' +
	'<iframe name="theiframe" id="theiframe" src="' +
	url +
	'" width="878" height="480" border="0" frameborder="0" style="background: transparent" allowtransparency="true" />' +
	'</div>';
	body.insertBefore(pres_cont, body.firstChild);
	
}

function print_iframe()
{
	frames.theiframe.focus();
	frames.theiframe.print()
}

function hide_iframe()
{
	var pres_cont = document.getElementById('iframe_container');
	if (!pres_cont)
	{
		alert('could not find');
		return;
	}
	
	pres_cont.parentNode.removeChild(pres_cont);
}



// converts buttons and links and inputs with the class "make3d" to 3d-ish versions to match the flash (see style sheet)

function make3d()
{
	make_buttons('make3d', 'made3d');
	make_buttons('make3dblue', 'made3dblue');
	make_buttons('make3dbluearrow', 'made3dbluearrow');
}

function make_buttons(o_class, n_class)
{
	var o_i = document.getElementsByTagName('INPUT');
	var i;
	
	for (i = o_i.length - 1; i >= 0; --i) 
	{
		var o = o_i[i];
		if (o.className != o_class) 
			continue;
		
		var b = document.createElement('button');
		b.className = o_class;
		b.innerHTML = '' + o.value + '';
		b.value = '' + o.value;
		
		if (o.type == 'submit') 
		{
			if (typeof o.onclick == 'function')
			{
				b.onclick2 = (o.onclick);
			}
			else
			{
				b.onclick2 = function () {return true};
			}
			b.onclick = function()
			{
				var r = this.onclick2();
				if ((r && typeof this.form.onsubmit == 'function' && this.form.onsubmit()) || (r && typeof this.form.onsubmit != 'function')) 
					this.form.submit();
				return r;
			};
		}
		o.parentNode.insertBefore(b, o);
		o.parentNode.removeChild(o);
	}
	
	var o_a = document.getElementsByTagName('A');
	
	for (i = o_a.length - 1; i >= 0; --i) 
	{
		var o = o_a[i];
		if (o.className != o_class) 
			continue;
		
		var b = document.createElement('button');
		b.className = o_class;
		b.innerHTML = '' + o.innerHTML + '';
		b.href = o.href;
		b.title = o.href;
		b.onclick = function()
		{
			window.location.href = this.href;
		};
		
		o.parentNode.insertBefore(b, o);
		o.parentNode.removeChild(o);
	}
	
	var o_b = document.getElementsByTagName('BUTTON');
	
	for (i = 0; i < o_b.length; ++i) 
	{
		var o = o_b[i];
		if (o.className != o_class) 
			continue;
		
		o.className = n_class;
		o.innerHTML = '<table class="t"><tr><td class="l"></td><td class="c">' + o.innerHTML + '</td><td class="r"></td></tr></table>';
	}
}

function sprintf()
{
	if (!arguments || arguments.length < 1 || !RegExp) 
	{
		return;
	}
	var str = arguments[0];
	var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/;
	var a = b = [], numSubstitutions = 0, numMatches = 0;
	while (a = re.exec(str)) 
	{
		var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4];
		var pPrecision = a[5], pType = a[6], rightPart = a[7];
		
		//alert(a + '\n' + [a[0], leftpart, pPad, pJustify, pMinLength, pPrecision);
		
		numMatches++;
		if (pType == '%') 
		{
			subst = '%';
		}
		else 
		{
			numSubstitutions++;
			if (numSubstitutions >= arguments.length) 
			{
				alert('Error! Not enough function arguments (' + (arguments.length - 1) + ', excluding the string)\nfor the number of substitution parameters in string (' + numSubstitutions + ' so far).');
			}
			var param = arguments[numSubstitutions];
			var pad = '';
			if (pPad && pPad.substr(0, 1) == "'") 
				pad = leftpart.substr(1, 1);
			else if (pPad) 
				pad = pPad;
			var justifyRight = true;
			if (pJustify && pJustify === "-") 
				justifyRight = false;
			var minLength = -1;
			if (pMinLength) 
				minLength = parseInt(pMinLength);
			var precision = -1;
			if (pPrecision && pType == 'f') 
				precision = parseInt(pPrecision.substring(1));
			var subst = param;
			if (pType == 'b') 
				subst = parseInt(param).toString(2);
			else if (pType == 'c') 
				subst = String.fromCharCode(parseInt(param));
			else if (pType == 'd') 
				subst = parseInt(param) ? parseInt(param) : 0;
			else if (pType == 'u') 
				subst = Math.abs(param);
			else if (pType == 'f') 
				subst = (precision > -1) ? Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10, precision) : parseFloat(param);
			else if (pType == 'o') 
				subst = parseInt(param).toString(8);
			else if (pType == 's') 
				subst = param;
			else if (pType == 'x') 
				subst = ('' + parseInt(param).toString(16)).toLowerCase();
			else if (pType == 'X') 
				subst = ('' + parseInt(param).toString(16)).toUpperCase();
		}
		str = leftpart + subst + rightPart;
	}
	return str;
}


function signup_decide_later()
{
	document.getElementById('radio1').checked = true;
	return true;
	
}
