function validateFreeDataConsultForm(obj)
{
	var valid = true;
	var errorMsg = "Please enter the following fields in their correct format: \n\n";
	var frmName =		document.getElementById('Name');
	var frmCompany =	document.getElementById('Company');
	var frmAddress =	document.getElementById('Address');
	var frmCity =		document.getElementById('City');
	var frmState =		document.getElementById('State');
	var frmZip =		document.getElementById('Zip');
	var frmPhone =		document.getElementById('Phone');
	var frmEmail =		document.getElementById('Email');	
	var frmWhichApplies = document.getElementById('EndUser');
	var frmWhichApplies2 = document.getElementById('Reseller');
	var frmMarketsServed = document.getElementById('MarketsServed');
	var frmAnnualData = document.getElementById('RecordsPerYear');
	
	if (frmName.value.length === 0)
	{
		errorMsg += "* Name \n";
		valid = false;
	}	
	
	if (frmCompany.value.length === 0)
	{
		frmCompany.value = frmName.value;
	}	
	
	if (frmAddress.value.length === 0)
	{
		errorMsg += "* Address \n";
		valid = false;
	}	
	
	if (frmCity.value.length === 0)
	{
		errorMsg += "* City \n";
		valid = false;
	}	
	
	if (frmState.value.length === 0)
	{
		errorMsg += "* State \n";
		valid = false;
	}	
	
	var re = new RegExp(/\d\d\d\d\d/);	
	if (frmZip.value.length === 0 || !re.test(frmZip.value))
	{
		errorMsg += "* Zip Code \n";
		valid = false;
	}	
	
	if (frmPhone.value.length === 0 || !check_usphone(frmPhone.value))
	{
		errorMsg += "* Phone \n";
		valid = false;
	}
	
	var re2 = new RegExp(/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i);	
	if (frmEmail.value.length === 0 || !re2.test(frmEmail.value))
	{
		errorMsg += "* Email \n";
		valid = false;
	}
	
	if (!frmWhichApplies.checked && !frmWhichApplies2.checked)
	{
		errorMsg += "* Data Reseller / End User \n";
		valid = false;
	}
	if (frmMarketsServed.selectedIndex === 0)
	{
		errorMsg += "* Markets Served \n";
		valid = false;
	}
	if (frmAnnualData.selectedIndex === 0)
	{
		errorMsg += "* Annual Data Purchase \n";
		valid = false;
	}
	
	if (valid)
	{
		_doPostBack(obj);
	}
	else
	{
		alert(errorMsg);
		return false;
	}
}


function Init()
{
	if ( location.protocol.toLowerCase() == 'http:' )
		location.href = location.href.replace( /http:/i, 'https:' );

	var profile = _readCookie("_.profile");

	//if (profile && profile.indexOf("ANONYMOUS") < 0)
	// ------------------------------------------------------------
	// 08/15/07 - jwh 04
	// ---
	// added back in the check to see if "profile" had valid
	// content before it checked if the name was "anonymous" as
	// the lack of this code broke when no cookie was present on
	// the user's system. in this case the ui showed "logout",
	// but the user couldn't actually access anything that
	// requires them to be logged in.
	// ---
	//if (profile != "ANONYMOUS")
	// ------------------------------------------------------------
	if ( profile && profile != "ANONYMOUS" )
	{
		if ( document.getElementById( 'MyPagesLinkBox' ) !== null )
			document.getElementById( 'MyPagesLinkBox' ).style.display = '';

		// 10/03/07 - jwh - #4115
		//document.getElementById( 'trHyginelink' ).style.display = 'none';
		//document.getElementById( 'trHyginelinkDisabled' ).style.display = 'none';
		document.getElementById( 'loginHeader' ).firstChild.nodeValue = 'Welcome';
		// ------------------------------------------------------------
		// 08/15/07 - jwh 05
		// ---
		// cleaning up username not showing and logout button not being
		// aligned properly in the login section of the page.
		// ---
		//document.getElementById("profile").firstChild.nodeValue = profile;
		// ------------------------------------------------------------
		document.getElementById( 'profile' ).appendChild( document.createTextNode( profile ) );
		document.getElementById( 'trUsername' ).style.display = 'none';
		document.getElementById( 'trPassword' ).style.display = 'none';
		//document.getElementById( 'trRememberme' ).style.display = 'none';
		document.getElementById( 'trLogin' ).style.display = 'none';
		document.getElementById( 'trLogout' ).style.display = '';
		document.getElementById( 'trHygieneDisabled' ).style.display = 'none';
		document.getElementById( 'trHygiene' ).style.display = '';
	}
	else
	{
		if ( document.getElementById( 'MyPagesLinkBox' ) !== null )
			document.getElementById( 'MyPagesLinkBox' ).style.display = 'none';
	
		document.getElementById( 'trLogout' ).style.display = 'none';
		document.getElementById( 'max:AccuData_CTL_Logon:0:username' ).focus();
		document.getElementById( 'trHygiene' ).style.display = 'none';
		document.getElementById( 'trHygieneDisabled' ).style.display = '';
	}
	getAffiliateID('ID');
}

function liveChat() 
{
	var e = window.open('http://help.acculeads.com/SightMaxAgentInterface/PreChatSurvey.aspx?accountID=1&siteID=1&queueID=2','chatWindow','width=420,height=306,resizable=0,scrollbars=no,menubar=no,status=no');
}

function termsOfUse() 
{
	URL = "Terms_of_Use.html";
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=600,height=500,left = 276,top = 182');");
}

function OpenAnchor()
{
	window.open('CowAnchorInterface.max',new Date().getTime(),'titlebar=no,menubar=no,location=no,resizable=yes,scrollbars=yes');
}

function AdvoAlert()
{
	alert('Important Note Regarding New Postal Regulations:  On May 14, 2007, there will be a significant change to USPS postal regulations and rates.  The mail date used in your count determines whether your data will be processed using the new or old rates and regulations. If your count mail date is Friday 5/11/07 or before, your AccuLeads order will come with reporting that reflects current rates and regulations must be mailed PRIOR to May 14th.  If your count mail date if Saturday 5/12/07 or greater, your AccuLeads order will come with reporting that reflects the new rates and regulations and can not be mailed until AFTER May 14th.');
}

// 10/08/07 - jwh - #4164
function loginOnEnter(evt)
{
	try
	{
		// make sure enter was pressed
		var keyCode = ( window.event ) ? event.keyCode : evt.keyCode;
		if ( keyCode != 13 )
			return;

		// find the login link
		var loginLink = document.getElementById( 'loginLink' );
		if ( ! loginLink )
			return;

		// submit the form
		_doPostBack( loginLink );
	}
	catch ( exc ) {}
}

// 10/11/07 - jwh - #3943
function populateDistrictId(sel, arr)
{
	var idx;
	var opt;

	try
	{
		sel.options.length = 0;

		for ( idx = 0; idx < arr.length; idx++ )
		{
			opt = arr[idx].split( '|', 2 );
			sel.options[idx] = new Option( opt[0], opt[1] );
		}
	}
	catch ( exc ) {}
}

// 10/11/07 - jwh - #3943
function populateDistrictId_Ca(sel)
{
	try
	{
		var arr = new Array(
			'Alberta|61', 'British Columbia|62', 'Manitoba|63', 'New Brunswick|64',
			'Newfoundland and Labrador|65', 'Northwest Territories|66', 'Nova Scotia|67',
			'Nunavut|68', 'Ontario|69', 'Prince Edward Island|70', 'Quebec|71',
			'Saskatchewan|72', 'Yukon|73'
		);

		populateDistrictId( sel, arr );
	}
	catch ( exc ) {}
}

// 10/11/07 - jwh - #3943
function populateDistrictId_Us(sel)
{
	try
	{
		var arr = new Array(
			'Alabama|1', 'Alaska|2', 'Arizona|3', 'Arkansas|4', 'California|5', 'Colorado|6',
			'Connecticut|7', 'Delaware|8', 'District of Columbia|9', 'Florida|10', 'Georgia|11',
			'Hawaii|12', 'Idaho|13', 'Illinois|14', 'Indiana|15', 'Iowa|16', 'Kansas|17',
			'Kentucky|18', 'Louisiana|19', 'Maine|20', 'Maryland|21', 'Massachusetts|22',
			'Michigan|23', 'Minnesota|24', 'Mississippi|25', 'Missouri|26', 'Montana|27',
			'Nebraska|28', 'Nevada|29', 'New Hampshire|30', 'New Jersey|31', 'New Mexico|32',
			'New York|33', 'North Carolina|34', 'North Dakota|35', 'Ohio|36', 'Oklahoma|37',
			'Oregon|38', 'Pennsylvania|39', 'Rhode Island|40', 'South Carolina|41',
			'South Dakota|42', 'Tennessee|43', 'Texas|44', 'Utah|45', 'Vermont|46',
			'Virginia|47', 'Washington|48', 'West Virginia|49', 'Wisconsin|50', 'Wyoming|51',
			'American Samoa|52', 'FS of Micronesia|53', 'Guam|54', 'Marshall Islands|55',
			'Northern Mariana Islands|56', 'Palau|57', 'Puerto Rico|58',
			'U.S. Minor Outlying Islands|59', 'Virgin Islands of the U.S.|60'
		);

		populateDistrictId( sel, arr );
	}
	catch ( exc ) {}
}

// 10/11/07 - jwh - #3943
function updateDistrictIdLayout()
{
	var cnt;
	var sel;
	var txt;
	var use_sel = true;

	try
	{
		sel = document.getElementById( 'max:AccuData_CTL_CowSignUp:0:districtid' );
		cnt = document.getElementById( 'max:AccuData_CTL_CowSignUp:0:country' ).value;

		switch ( cnt )
		{
			case  "37": populateDistrictId_Ca( sel ); break; // canada
			case "226": populateDistrictId_Us( sel ); break; // usa
			   default:              use_sel = false; break;
		}

		txt = document.getElementById( 'max:AccuData_CTL_CowSignUp:0:Province' );

		if ( use_sel )
		{
			txt.disabled = true;
			txt.style.display = 'none';
			sel.disabled = false;
			sel.style.display = '';
		}
		else
		{
			sel.disabled = true;
			sel.style.display = 'none';
			txt.disabled = false;
			txt.style.display = '';
		}
	}
	catch ( exc ) {}
}
/* CTV 10/22/07 Code to get Affiliate ID if passed and save it in a cookie */
function getAffiliateID(paramName) {
	var currentUrl = window.location.search;
	var strBegin = currentUrl.indexOf(paramName) + (paramName.length+1);
	var strEnd = currentUrl.indexOf("&",strBegin);
	
	if (strEnd==-1)
	{
		strEnd = currentUrl.length;
	}
	
	var _strParam = currentUrl.substring(strBegin,strEnd);
	if((_strParam==null) || (_strParam.length == 0))
	{
		return 'Empty';
	}
	_createCookie('aldbAffiliate',currentUrl.substring(strBegin,strEnd),365)
	return _strParam;
}