addLoadEvent(init);

/* --------------------
	Initialize
----------------------- */

function init(){

	// Cookie Check
	// -------------------- //
	
	var login_cookie = document.cookie;
	if(login_cookie == 'login=business'){
		var login_frame_container_personal = get('login_frame_container_personal');
		var login_frame_container_business = get('login_frame_container_business');
			var select_login = get('select_login');
				select_login.options[1].selected = 'selected';	
			login_frame_container_business.style.display = 'block';
			login_frame_container_personal.style.display = 'none';
	}

	// Navigation Setup 
	// -------------------- //
	
	var b = getElementsByClassName(document, 'div', 'button');
		
	for(i=0; i<b.length; i++){		
			b[i].onmouseover = function() {
				this.childNodes[0].style.background = "url('images/tabs/selected/l.gif') repeat-x";
				this.childNodes[1].style.background = "url('images/tabs/selected/m.gif') repeat-x";
				this.childNodes[2].style.background = "url('images/tabs/selected/r.gif') repeat-x";
			}
		
			b[i].onmouseout = function() {
				this.childNodes[0].style.background = "url('images/tabs/unselected/l.gif') repeat-x";
				this.childNodes[1].style.background = "url('images/tabs/unselected/m.gif') repeat-x";
				this.childNodes[2].style.background = "url('images/tabs/unselected/r.gif') repeat-x";		
			}
		}

	// Login switch
	// -------------------- //
	
	var select_login = get('select_login');
	
	select_login.onchange = function() {
		
		var login_frame_container_personal = get('login_frame_container_personal');
		var login_frame_container_business = get('login_frame_container_business');
		
		if( this.value == 'personal' ){
			login_frame_container_personal.style.display = 'block';
			login_frame_container_business.style.display = 'none';
			setCookie('personal');
		}
		else {
			login_frame_container_business.style.display = 'block';
			login_frame_container_personal.style.display = 'none';
			setCookie('business');
		}
	}

}


/* --------------------
	Set Cookies
----------------------- */

function setCookie(value){
	
	if(value == 'personal'){
		createCookie('login', 'personal', 99);
	}
	else {
		createCookie('login', 'business', 99);	
	}
	
}