var currentTab = 'frontpage', tips = new Array();

// Get date
var monthNames = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
var now = new Date();
var date = monthNames[now.getMonth()] + ' ' + now.getDate() + ', ' + now.getFullYear();

ondocumentready = initializeHomepage;

function initializeHomepage() {
	loginMessage();
	tips[0] = {element:document.getElementById('tip_search'), end:243, relative:'right', timer:0,interval:null};
	tips[1] = {element:document.getElementById('tip_tabs'), end:100, relative:'top', timer:0,interval:null};
	tips[2] = {element:document.getElementById('tip_quickaccess'), end:100, relative:'top', timer:0,interval:null};
	tip = Math.floor(Math.random()*tips.length);
	setTimeout('showTip('+tip+')',1500);
	setTimeout('hideTip('+tip+')',6500);
	
}

function showTab(newTab) {
	document.getElementById('tab_'+currentTab).className='tab';
	document.getElementById('feature_'+currentTab).className='feature';
	document.getElementById('tab_'+newTab).className='tab active';
	document.getElementById('feature_'+newTab).className='feature visible';
	currentTab=newTab;
}

function showTip(tip) {
	tips[tip].element.style.display='block';
	tips[tip].interval = setInterval('doPopup('+tip+')',15);
}

function hideTip(tip) {
	tips[tip].interval = setInterval('doPopout('+tip+')',15);
}

function doPopup(tip) {
	tips[tip].element.style[tips[tip].relative]=sineIn(tips[tip].timer, (tips[tip].end-10), 10, 15) + 'px';
	tips[tip].element.style.opacity=sineIn(tips[tip].timer, 0, 0.9, 15);
	tips[tip].timer++;
	if(tips[tip].timer==15) {
		tips[tip].timer = 0;
		tips[tip].element.style[tips[tip].relative]=tips[tip].end+'px';
		tips[tip].element.style.opacity=0.9;
		clearInterval(tips[tip].interval);
	}
	return;
}

function doPopout(tip) {
	tips[tip].element.style[tips[tip].relative]=sineIn(tips[tip].timer, tips[tip].end, -10, 15) + 'px';
	tips[tip].element.style.opacity=sineIn(tips[tip].timer, 0.9, -0.9, 15);
	tips[tip].timer++;
	if(tips[tip].timer==15) {
		tips[tip].timer = 0;
		tips[tip].element.style[tips[tip].relative]=(tips[tip].end-10)+'px';
		tips[tip].element.style.opacity=0;
		tips[tip].element.style.display='none';
		clearInterval(tips[tip].interval);
	}
	return;
}

function sineIn(t, b, c, d) {
	return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
}
