/* Copyright 2004 - 2009 (c) Tosh Meston. All rights reserved. */

window.onload = onLoad;
String.prototype.reverse = reverse;

function onLoad()
{
	if (isIE())
	{
		wsto("switchPic(1,7);", 1000);
		wsto("switchPic(2,1);", 3000);
		wsto("switchPic(3,2);", 5000);
		wsto("switchPic(4,3);", 7000);
		wsto("switchPic(5,4);", 9000);
		wsto("switchPic(6,5);", 11000);
		wsto("switchPic(7,6);", 13000);
	}
}

function isIE()
{
	return navigator.userAgent.indexOf("MSIE") > -1;
}

function innerText(sId, sT)
{
	if (isIE())
		gebi(sId).innerText = sT;
	else
		gebi(sId).textContent = sT;		
}

function reverse()
{
	var s1 = "";
	for (var i = this.length - 1; i >= 0; i--)
		s1 += this.charAt(i);
	
	return s1;
}

function gebi(s)
{
	return document.getElementById(s);
}

function signUp()
{
	if (gebi("txtFirstName").value.length == 0)
	{
		window.alert("Please leave your first name.");
		gebi("txtFirstName").focus();
		return false;
	}

	if (gebi("txtLastName").value.length == 0)
	{
		window.alert("Please leave your last name.");
		gebi("txtLastName").focus();
		return false;
	}

	if (gebi("txtEmail").value.length == 0)
	{
		window.alert("Please leave your email.");
		gebi("txtEmail").focus();
		return false;
	}

	if (gebi("txtBabyName").value.length == 0)
	{
		window.alert("Please leave your baby's name.");
		gebi("txtBabyName").focus();
		return false;
	}

	if (gebi("txtSubDomain").value.length == 0)
	{
		window.alert("Please leave your url.");
		gebi("txtSubDomain").focus();
		return false;
	}

	gebi("frmSignUp").submit();
}

function switchPic(iFrom, iTo)
{
	var o = gebi("img" + iFrom);
	o.filters[0].Apply();
	o.src = "/images/baby" + iTo + ".png";
	o.filters[0].Play(duration=2);
}

function wsto(s, i)
{
	window.setTimeout(s, i);
}

function askQuestion()
{
	if (gebi("txtName").value.length == 0)
	{
		window.alert("Please leave your name.");
		gebi("txtName").focus();
		return false;
	}
		
	if (gebi("txtEmail").value.length == 0)
	{
		window.alert("Please leave your email so we can get back to you.");
		gebi("txtEmail").focus();
		return false;
	}
	
	if (gebi("txtQuestion").innerText.length == 0)
	{
		window.alert("Please leave a question.");
		gebi("txtQuestion").focus();
		return false;
	}
	
	gebi("frmQuestion").submit();
}
