function ufHideAll(){
	with(document.getElementById('unified_form_inner')){
		for(var i=children.length-1;i>=0;--i){
			if(children[i].tagName==='DIV'){
				children[i].style.display='none';
			}
		}
	}
}

function ufTabJoin(caller){
	caller.className='active';
	caller.nextSibling.className='';
	ufHideAll();
	with(document.getElementById('unified_form_join')){
		style.display='';
		firstChild.code.focus();
	}
}

function ufTabProductLogin(caller){
	caller.className='active';
	caller.previousSibling.className='';
	ufHideAll();
	with(document.getElementById('unified_form_login')){
		style.display='';
		firstChild.username.focus();
	}
	pudl_DynamicScript('https://v5.islonline.com/autologin/autologin.php?autologin');
}

function ufJoin(caller){
	if(typeof(ISLOnline)!=='undefined'&&ISLOnline.Join){
		setTimeout(function() { // ie6 workaround
			ISLOnline.Join.getSessionInfoByCode(
				caller.code.value,
				function(info){
					var e=document.getElementById('unified_form_info');
					e.firstChild.innerHTML=info.getInnerHTML();
					document.getElementById('unified_form_join').style.display='none'
					e.style.display='';
					e=e.getElementsByTagName('form')[0];
					var f=document.getElementById('unified_form_generic_button').cloneNode(true);
					f.style.display='';
					f.firstChild.onclick=function(){
						document.getElementById('unified_form_info').getElementsByTagName('form')[0].submit();
					}
					e=e.elements[1];
					f.firstChild.firstChild.nextSibling.appendChild(document.createTextNode(e.value));
//					e.parentNode.replaceChild(f,e);
				},
				function(error){
					ufErrorForward(caller.parentNode,error);
				}
			);
		}, 0);
	}
}

function ufProductLogin(caller){
	if(typeof(ISLOnline)!=='undefined'&&ISLOnline.Login){
		setTimeout(function() { // ie6 workaround
			ISLOnline.Login.login(
				caller.username.value,
				caller.password.value,
				function(info){
					var e=document.getElementById('unified_form_product');
					e.unified_form_info=info;
					with(document.getElementById('unified_form_user')){
						innerHTML='';
						appendChild(document.createTextNode(caller.username.value))};
						document.getElementById('unified_form_login').style.display='none';
						e.style.display='';
						if(!caller.autologin.checked)return;
						pudl_DynamicScript('https://v5.islonline.com/autologin/autologin.php?username='+encodeURIComponent(caller.username.value)+'&password='+encodeURIComponent(caller.password.value));
				},
				function(error){
					pudl_DynamicScript('https://v5.islonline.com/autologin/autologin.php?delete');
					ufErrorForward(caller.parentNode,error);
				}
			);
		}, 0);
	}
}

function ufSignOut(caller){
	ufHideAll();
	pudl_DynamicScript('https://v5.islonline.com/autologin/autologin.php?delete');
	with(document.getElementById('unified_form_login')){
		firstChild.autologin.checked='';
		style.display='';
	}
}

function ufProductPage(caller,service){
	if(typeof(ISLOnline)!=='undefined'&&ISLOnline.Login){
		setTimeout(function() { // ie6 workaround
			var div=caller.parentNode.parentNode;
			var info=div.unified_form_info;
			if(service==='ISL Light')info.getPage('isllight-start').redirect();
			else if(service==='ISL AlwaysOn')info.getPage('islalwayson-list').redirect();
			else if(service==='ISL Pronto')info.getPage('islpronto-usage').redirect();
			else if(service==='ISL Groop')info.getPage('islgroop-meetings').redirect();
		}, 0);
		return;
	}
	if(typeof(ISLOnline)!=='undefined'&&ISLOnline.Pages){
		setTimeout(function() { // ie6 workaround
			var div=caller.parentNode.parentNode;
			var info=div.unified_form_info;
			ISLOnline.Pages.getFavorites(
				info.getSessionId(),
				service,
				function(info){
					var e=document.getElementById('unified_form_info');
					e.firstChild.innerHTML=info.getInnerHTML();
					document.getElementById('unified_form_product').style.display='none'
					e.style.display='';
				},
				function(error){
					ufErrorForward(div,error);
				}
			);
		}, 0);
	}
}

function ufErrorForward(caller,error){
	var e=document.getElementById('unified_form_error');
	e.unified_form_back=caller;
	caller.style.display='none';
	e.style.display='';
	with(document.getElementById('unified_form_error_description')){
		innerHTML='';
		appendChild(document.createTextNode(error.getDescription()));
	}
}

function ufErrorBack(caller){
	with(document.getElementById('unified_form_error')){
		style.display='none';
		unified_form_back.style.display='';
	}
}

pudl_AddEventListener(window,'load',function(){try{document.getElementById('unified_form_join').firstChild.code.focus()}catch(e){}});