/* $Id: parship_home.js 20834 2009-02-06 13:11:37Z parship.lein $ */
var visibleElem;
var curOpacity;
var fadeFuncInterval;
var numBeingShown;

function ps_homeTeaserOver(num) {
	// if (typeof btnElem == 'string') btnElem = document.getElementById(btnElem);
	// if (btnElem) btnElem.src = btnElem.src.substr(0, btnElem.src.length - 4) + '_active.jpg';
	
	if (numBeingShown == num) return;
	numBeingShown = num;
	
	if (fadeFuncInterval) window.clearInterval(fadeFuncInterval);

	var contentElem;
	var counter = 1;
	while (contentElem = document.getElementById('ps_homeTeaserContent'+counter)) {
		contentElem.style.display = counter == num ? '' : 'none';
		if (counter == num) {
			curOpacity = 0.25;
			if (visibleElem == contentElem) return;
			visibleElem = contentElem;
			visibleElem.style['opacity'] = 0.25;
			visibleElem.style['filter'] = "alpha(opacity=25)";
			fadeFuncInterval = window.setInterval(fadeIn, 50);
		}
		++counter;
	}
}

function switchTeaser(num, attr) {
  document.getElementById('teaserMenu').style.backgroundImage = "url(/static/img/homepage/pic_homepageContent" + num + attr + ".jpg)";
}

function fadeIn() {
	curOpacity += 0.25;
	visibleElem.style['opacity'] = curOpacity;
	visibleElem.style['filter'] = 'alpha(opacity=' + (curOpacity*100) + ')';
	if (curOpacity >= 1) window.clearInterval(fadeFuncInterval);
}

function ps_homeTeaserOut(btnElem) {
	// if (typeof btnElem == 'string') btnElem = document.getElementById(btnElem);
	// btnElem.src = btnElem.src.replace('_active', '');
	ps_homeTeaserOver(null, 1);
}

function defaultUsername(e, defaultValue) {
  if(e.value == defaultValue.replace(/\s*:\s*/,"")) e.value='';
}

function fakePasswordField(e, realField) {
  e.style.display = 'none';
  var realField = document.getElementById(realField);
  realField.style.display='inline';
  realField.focus();
}

window.onload = function() {
	if (!document.getElementById('ps_fakepassword') && document.getElementById('ps_loginEmail')) {
		document.getElementById('ps_loginEmail').focus();
	}
	visibleElem = document.getElementById('ps_homeTeaserContent1');

};
