function JScripts()
{
	this._countryList = new Array();
	this._stateList = new Array();
	this._formCheckout = null;
}
JScripts.prototype.setForm = function()
{
	$('#formContainer').html(this._formCheckout);
}
JScripts.prototype.statesDDLOptions = function(country, state)
{
	var ddl = '';
	for (var i in this._stateList[country])
	{
		ddl += '<option value="' + this._stateList[country][i].id + '">' + this._stateList[country][i].name + '</option>';
	}
	return ddl;
}
JScripts.prototype.statesDDL = function(country, state)
{
	var ddl;
	if (country == '' || country == 39 || country == 227)
	{
		ddl = '<select name="state" id="state" class="input1" style="width: 127px;">';
		ddl += '<option value="">- Select ' + ((country.length == 0 || country == 39) ? 'Province' : 'State') + ' -</option>';
		ddl += this.statesDDLOptions(country, state);
		ddl += '</select>';
	}
	else if(country == 226)
	{
		ddl = '<input name="state" type="hidden" id="state" maxlength="100" />';
	}
	else
	{
		
		ddl = '<input name="state" type="text" class="input2" id="state" maxlength="100" />';
	}
	return ddl;
}
JScripts.prototype.stateHTML = function(country, state)
{
	var ddl;
	if(country == 226)
	{
		ddl = this.statesDDL(country, state);
	}
	else
	{
		ddl = '<label for="state"><span style="vertical-align: top; color: red; font-size: 10px;">*</span>' + ((country == '' || country == 39) ? 'Province' : 'State') + ':</label>';
		ddl += this.statesDDL(country, state) + '<br />';
	}
	
	$('#stateContainer').html(ddl);
	$('#state').val(state);
}
JScripts.prototype.endSession = function()
{
	VirtualAgentSuspend = 'LocationRedirect';
	window.location.href = './';
}
JScripts.prototype.continueShopping = function()
{
	$.unblockUI();
}
JScripts.prototype.setEvents = function(country, state)
{
	var obj = this;
	$('#countdown').countdown({
		until: '+5M +0S',
		format: 'MS',
		compact: true,
		layout: '%M%n%M:%S%nn%S',
		onExpiry: function(){
			var top = (($(window).height() / 2) - 70) + 'px';
			var left = (($(window).width() / 2) - 200) + 'px';
			$.blockUI({
				message: '<div style="padding-top:11px; text-align:center; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:15px; color:#ffffff; font-weight:bold;">Your 5:00 Session has expired </div>	<div style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; color:#ffffff; padding-top:11px; line-height:16px; text-align:center;">Shimmering White is Americas hottest teeth whitening product! Our specially formulated pens are disappearing at a rate of 1 per minute! Claim your RISK FREE trial now before its too late!</div><div style="padding-top:11px;">	<div style=" width:223px; float:left"><a style="cursor:pointer; margin:5px;" onclick="JavaScript: js.continueShopping();"><img src="images/end.gif" width="223" height="69" border="0" /></a></div>	<div style="float:right; width:227px"><a style="cursor:pointer;" onclick="JavaScript: js.continueShopping();" href="#top"><img src="images/continue.gif" alt="" border="0" /></a></div>    <div style="margin:0; padding:0; clear:both;"></div></div>',
				css: {
					width: '470px',
					border: '1px #000 solid',
					cursor: 'default',
					top: top,
					left: left,
					background: '#2B5B90'
				}
			});
		}
	});
	$('.animScroll').click(function(){
		$.scrollTo($(this).attr('hash'), {duration: 500});
		return false;
	});
	$('#btnOrderNow').click(function(){
		var errors = new Array();
		$('.msgBox:eq(0)')
			.html('')
			.fadeOut(500);
		$('.errorBox').removeClass('errorBox');
		
		if ($('#first_name').isEmpty())
		{
			errors.push('Please enter First Name.');
			$('#first_name').addClass('errorBox');
		}
		if ($('#last_name').isEmpty())
		{
			errors.push('Please enter Last Name.');
			$('#last_name').addClass('errorBox');
		}
		if ($('#address_1').isEmpty())
		{
			errors.push('Please enter Address.');
			$('#address_1').addClass('errorBox');
		}
		if ($('#city').isEmpty())
		{
			errors.push('Please enter City.');
			$('#city').addClass('errorBox');
		}
		if ($('#state').isEmpty() && $('#country').val() != 226)
		{
			if ($('#country').isEmpty() || $('#country').val() == 227)
			{
				errors.push('Please select State.');
			}
			else if ($('#country').val() == 39)
			{
				errors.push('Please select Province.');
			}
			else
			{
				errors.push('Please enter State.');
			}
			
			$('#state').addClass('errorBox');
		}
		if ($('#zip').isEmpty())
		{
			errors.push('Please enter Zip.');
			$('#zip').addClass('errorBox');
		}
		if ($('#country').isEmpty())
		{
			errors.push('Please select Country.');
			$('#country').addClass('errorBox');
		}
		else if (!$('#email').isEmpty() && !$('#email').emailCheck())
		{
			errors.push('Please enter valid Email.');
			$('#email').addClass('errorBox');
		}
		if (errors.length == 0)
		{
			return true;
		}
		else
		{
			/*$('.msgBox:eq(0)')
				.html('<ul>\n<li>Please enter ' + errors.join(' ,') + '</li>\n</ul>')
				.fadeIn(500);*/
				alert('Please Fill In The Following Fields: \r\n\r\n\r\n'+errors.join(' \r\n'))
			return false;
		}
	});
	$('#country').change(function(){
		if (!$(this).isEmpty())
		{
			js.stateHTML($(this).val(), '');
		}
	});
}