function countInvites(formId, source) {
	var count	= 0;

	var emailId, gaAction, iStart;
	if ($defined(source)) {
		emailId		= 'address_';
		gaAction	= 'Invite - ' + source;
		iStart		= 1;
	} else {
		emailId		= 'friendsEmail';
		gaAction	= 'Invite';
		iStart		= 0;
	}

	var friendsEmail, i;
	for (i = iStart; $(emailId + i); i ++) {
		friendsEmail	= $(emailId + i).value;
		if (friendsEmail != '' && friendsEmail != 'Email Address') {
			if ($defined(source)) {
				if ($(emailId + i).checked) {
					count ++;
				}
			} else {
				count ++;
			}
		}
	}

	pageTracker._trackEvent('Contest', gaAction, '30 Handbags in 30 Days', count);
	$(formId).submit();
}

function fieldClear(id) {
	$(id).value	= '';
	return true;
}
function fieldFill(id) {
	var value	= $(id).value;
	if (value == '') {
		if (id.contains('Name')) {
			$(id).value	= 'First Name';
		} else if (id.contains('Email')) {
			$(id).value	= 'Email Address';
		}
	}
	return true;
}

function validateform(formobj) {
	if (formobj.firstname.value == "") {
		alert("Please enter your first name!");
		return (false);
	}
	if (formobj.email.value == "") {
		alert("Please enter your e-mail address!");
		return (false);
	}
	return (true);
}

/*
Author: Robert Hashemian
http://www.hashemian.com/
*/
function calcage(secs, num1, num2) {
	var returnstring = "";
	s = ((Math.floor(secs/num1))%num2).toString();
	if (LeadingZero && s.length < 2) {
    	s = "0" + s;
	}
//	if (LeadingZero && s.length < 2) {
 //   	s = "0" + s;
//	}
	for (i=0;i<=s.length-1;i++) {
		returnstring = returnstring + '<img src="/images/'+s.charAt(i)+'.gif" width="17" height="22" />';
	}
	return returnstring;
}

var tdays;
var thours;
var tminutes;
var tseconds;
function CountBack(secs) {
	if (tdays != calcage(secs,86400,100000)) {
		tdays = calcage(secs,86400,100000)	;
		document.getElementById("tdays").innerHTML = tdays + "<br>Days";
	}
	if (thours != calcage(secs,3600,24)) {
		thours = calcage(secs,3600,24);
		document.getElementById("thours").innerHTML = thours + "<br>Hours";
	}
	if (tminutes != calcage(secs,60,60)) {
		tminutes = calcage(secs,60,60);
		document.getElementById("tminutes").innerHTML = tminutes + "<br>Minutes";
	}
	if (tseconds != calcage(secs,1,60)) {
		tseconds = calcage(secs,1,60);
		document.getElementById("tseconds").innerHTML = tseconds + "<br>Seconds";
	}
	if (CountActive)
		setTimeout("CountBack(" + (secs+CountStepper) + ")", SetTimeOutPeriod);
}

TargetDate		= "10/15/2009 12:00 PM";
CountActive		= true;
CountStepper	= -1;
LeadingZero		= false;

CountStepper = Math.ceil(CountStepper);
if (CountStepper == 0) {
	CountActive = false;
}
var SetTimeOutPeriod = 1000 // (Math.abs(CountStepper)-1)*1000 + 990;
var dthen = new Date(TargetDate);
var dnow = new Date();
if (CountStepper>0) {
	ddiff = new Date(dnow-dthen);
} else {
	ddiff = new Date(dthen-dnow);
	gsecs = Math.floor(ddiff.valueOf()/1000);
}
