var G_checked = false;

window.onload = init;

function init()
{
	if (document.getElementById('popup_tour')) document.getElementById('popup_tour').onclick = function(){openWin(this.href,895,645,'');return false};
	if (document.getElementById('popup_tour1')) document.getElementById('popup_tour1').onclick = function(){openWin(this.href,895,645,'');return false};
	if (document.getElementById('popup_terms')) document.getElementById('popup_terms').onclick = function(){openWin(this.href,600,600,'scrollbars=yes');return false};
	if (document.getElementById('popup_privacy')) document.getElementById('popup_privacy').onclick = function(){openWin(this.href,600,600,'scrollbars=yes');return false};
	if (document.getElementById('chk_all'))
	{
		G_checked = (document.getElementById('chk_all').checked)? true : false;
		document.getElementById('chk_all').onclick = function(){chkToggle(this)};
		dom_checks = document.getElementById('chk_all').parentNode.parentNode.parentNode.parentNode.getElementsByTagName('tbody')[0].getElementsByTagName('input');
		for (var x = 0;x < dom_checks.length; x++)
			if (dom_checks[x].type=='checkbox')
				dom_checks[x].onclick = function(){chkOff(this)};
	}
}

function openWin(page,width,height,attr)
{
	window.open(page,'','width='+width+',height='+height+','+attr);
}

function chkToggle(dom_obj)
{
	dom_checks = dom_obj.parentNode.parentNode.parentNode.parentNode.getElementsByTagName('tbody')[0].getElementsByTagName('input');
	if (G_checked)
	{
		for (var x = 0;x < dom_checks.length; x++)
			if (dom_checks[x].type=='checkbox')
				dom_checks[x].checked = '';
		G_checked = false;
	}
	else
	{
		for (var x = 0;x < dom_checks.length; x++)
			if (dom_checks[x].type=='checkbox')
				dom_checks[x].checked = 'checked';
		G_checked = true;
	}
}

function chkOff(dom_obj)
{
	G_checked = false;
	dom_obj.parentNode.parentNode.parentNode.parentNode.getElementsByTagName('thead')[0].getElementsByTagName('input')[0].checked = '';
}
