/* register */
function tap_register() {
	document.getElementById("tap_register").style.display='';
	document.getElementById("tap_signin").style.display='none';
	document.getElementById("tap_openid").style.display='none';
}

function tap_signin() {
	document.getElementById("tap_register").style.display='none';
	document.getElementById("tap_signin").style.display='';
	document.getElementById("tap_openid").style.display='none';
}

function tap_openid() {
	document.getElementById("tap_register").style.display='none';
	document.getElementById("tap_signin").style.display='none';
	document.getElementById("tap_openid").style.display='';
}
function tap_close() {
	document.getElementById("tap_login").style.display='none';
	
	//return page to normal
}

function signin_signin() {
	document.getElementById("signin_signin").style.display='';
	document.getElementById("signin_openid").style.display='none';
}

function signin_openid() {
	document.getElementById("signin_signin").style.display='none';
	document.getElementById("signin_openid").style.display='';
}

function position_signin(node) {
	var signin=document.getElementById('tap_login');
	var main = document.getElementById('main');
	
	var y=xPageY(node)-240;
	if (y<0) y=0;
	signin.style.display='';
	signin.style.left = xPageX(main) + 'px';
	signin.style.top = y + 'px';
	urchinTracker('/register/popup');
}
function xPageY(e) {
	var y = 0;
	while (e) {
		if (this.xDef(e.offsetTop)) y += e.offsetTop;
		e = this.xDef(e.offsetParent) ? e.offsetParent : null;
	}
	return y;
}
function xPageX(e) {
	var x = 0;
	while (e) {
		if (this.xDef(e.offsetLeft)) x += e.offsetLeft;
		e = this.xDef(e.offsetParent) ? e.offsetParent : null;
	}
	return x;
}
function xDef() {
	for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
	return true;
}

/* tie button functionality */
function tb(e,element) {
	var key=-1;
	var button=document.MainForm.elements[element];
	if (e && e.which) key = e.which;
	else if (typeof(event)!="undefined") key = event.keyCode;
	
	switch(key) {
		case 13:	//enter
			button.click();
			return false;
			break;
		default:
			return true;
	}
}

function tb2(e) {
	if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13))
		return false;
	else
		return true;
}


/*add item to watchlist*/
function watchitem(id)
{
	ProductWiki.Web.UserControls.ContentWatchlist.WatchItem(id);
	document.getElementById('watchlist_off').style.display='none';
	document.getElementById('watchlist_on').style.display='';
}

/*remove item to watchlist*/
function unwatchitem(id)
{
	ProductWiki.Web.UserControls.ContentWatchlist.UnwatchItem(id);
	document.getElementById('watchlist_off').style.display='';
	document.getElementById('watchlist_on').style.display='none';
}

/*change navigation state*/
function changestate(url)
{
	ProductWiki.Web.UserControls.PathNavigator.ChangeState(url);
	window.location.href = window.location.href;
}