var InviteLinkValid = true;
var EmailAddressValid = true;

var tErrors = new Array();
var tErrors1 = new Array();
var tErrors2 = new Array();
var tErrors3 = new Array();

function validateRequestBarFormCon()
{
	tErrors = new Array();
	
	var v_ConfirmCustomization = gEl('ConfirmCustomization');
	if (!v_ConfirmCustomization.checked)
		tErrors[tErrors.length] = "Please Confirm Customization";
	if (tErrors.length > 0)
	{
		showValidationAlert();
		return false;
	}
	return true;
}

function validateCreateBar()
{
	//gEl("errorDivContainer").style.visibility = "hidden";

    tErrors = new Array();
    tErrors1 = new Array();
    tErrors2 = new Array();
    tErrors3 = new Array();

	var v_Agree = gEl('Agree');
	var v_AddToDeals = gEl('AddToDeals');
	var v_isReadyForCreate = gEl('isReadyForCreate');
	
	if (v_isReadyForCreate.value != '1')
    {
		tErrors[tErrors.length] = "Please Upload Logo";
        tErrors1[tErrors1.length] = 'Please Upload Logo';
    }
	else if (v_Agree.value != '1')
    {
		tErrors[tErrors.length] = "You must agree to the TERMS";
        tErrors1[tErrors1.length] = 'You must agree to the TERMS';
	}

	if (tErrors1.length > 0 || tErrors2.length > 0 || tErrors3.length > 0)
    {
		      showValidationAlertEx();
    		  return false;
    }
    else
    {
    		  return true;
    }
}

function validateUploadLogo()
{

	tErrors = new Array();
    tErrors1 = new Array();
    tErrors2 = new Array();
    tErrors3 = new Array();

	var v_logoMessage = gEl('SiteCaption');
	var v_clickedURL = gEl('SiteUrl');
	var v_logoImage = gEl('LogoImage');
	
	if (js_trim(v_logoMessage.value) == '')
    {
		tErrors[tErrors.length] = "Enter Logo mouse over message";
        tErrors1[tErrors1.length] = 'Enter Logo mouse over message';
    }

    if (js_trim(v_clickedURL.value) == '')
    {
		tErrors[tErrors.length] = "Enter Logo clicked website URL";
        tErrors1[tErrors1.length] = 'Enter Logo clicked website URL';
	}

	if (js_trim(v_logoImage.value) == '')
    {
		tErrors[tErrors.length] = "Select Logo Image for Toolbar";
        tErrors1[tErrors1.length] = 'Select Logo Image for Toolbar';
    }
    else
	{
		var parts = new Array();
		parts = js_trim(v_logoImage.value).split('.');
		if (parts.length == 1)
        {
			tErrors[tErrors.length] = "Wrong filename: " + v_logoImage.value + "<br>" + "You can only upload image files that are JPG, GIF or PNG";
            tErrors1[tErrors1.length] = 'Wrong filename (can only JPG, GIF or PNG)';
        }
        else
		{
			var ext = parts[(parts.length-1)].toLowerCase();
			if (ext != 'gif' && ext != 'png' && ext != 'jpg' && ext != 'jpeg')
            {
				tErrors[tErrors.length] = "Wrong file type: "  + v_logoImage.value + "<br>" + "You can only upload image files that are JPG, GIF or PNG";
                tErrors1[tErrors1.length] = 'Wrong file type (can only JPG, GIF or PNG)';
            }
		}
	}

	if (tErrors1.length > 0 || tErrors2.length > 0 || tErrors3.length > 0)
    {
		      showValidationAlertEx();
    		  return false;
    }
    else
    {
    		  return true;
    }
}

function validateUploadDealsLogo()
{
	//gEl("errorDivContainer").style.visibility = "hidden";
	
	tErrors = new Array();
    tErrors1 = new Array();
    tErrors2 = new Array();
    tErrors3 = new Array();

	var v_logoMessage = gEl('copy_SiteCaption');
	var v_clickedURL = gEl('copy_SiteUrl');
	var v_logoImage = gEl('LogoDealsImage');
	var v_HasCustomBarFl = gEl('HasCustomBarFl');

	if (v_HasCustomBarFl.value != '1')
    {
		tErrors[tErrors.length] = "Please create a Bar to add Deals Logo";
        tErrors1[tErrors1.length] = 'Please create a Bar to add Deals Logo';
    }
    else
	{
		if (js_trim(v_logoMessage.value) == '')
        {
			tErrors[tErrors.length] = "Enter Logo mouse over message";
            tErrors1[tErrors1.length] = 'Enter Logo mouse over message';
        }

        if (js_trim(v_clickedURL.value) == '')
        {
			tErrors[tErrors.length] = "Enter Logo clicked website URL";
            tErrors1[tErrors1.length] = 'Enter Logo clicked website URL';
	    }

		if (js_trim(v_logoImage.value) == '')
        {
			tErrors[tErrors.length] = "Select Logo Image for Deals Page";
            tErrors1[tErrors1.length] = 'Select Logo Image for Deals Page';
        }
        else
		{
			var parts = new Array();
			parts = js_trim(v_logoImage.value).split('.');
			if (parts.length == 1)
            {
				tErrors[tErrors.length] = "Wrong filename: " + v_logoImage.value + "<br>" + "You can only upload image files that are JPG, GIF or PNG";
                tErrors1[tErrors1.length] = 'Wrong filename (only JPG, GIF or PNG)';
            }
            else
			{
				var ext = parts[(parts.length-1)].toLowerCase();
				if (ext != 'gif' && ext != 'png' && ext != 'jpg' && ext != 'jpeg')
                {
					tErrors[tErrors.length] = "Wrong file type: "  + v_logoImage.value + "<br>" + "You can only upload image files that are JPG, GIF or PNG";
                    tErrors1[tErrors1.length] = 'Wrong file type (only JPG, GIF or PNG)';
                }
			}
		}
	}


    if (tErrors1.length > 0 || tErrors2.length > 0 || tErrors3.length > 0)
    {
		      showValidationAlertEx();
    		  return false;
    }
    else
    {
    		  return true;
    }
}

function validateUploadReceipt()
{
	tErrors = new Array();
	var v_RecOwner = gEl('rec-owner');
	var v_ReceiptImage = gEl('receipt-image');
	
	if (!v_RecOwner.checked)
		tErrors[tErrors.length] = "Owner of the domain identified is Required";
	
	if (js_trim(v_ReceiptImage.value) == '')
		tErrors[tErrors.length] = "Receipt Image is Required";
	else
	{
		var parts = new Array();
		parts = js_trim(v_ReceiptImage.value).split('.');
		if (parts.length == 1)
			tErrors[tErrors.length] = "Wrong filename: " + v_ReceiptImage.value + "<br>" + "You can only upload image files that are JPG, GIF or PNG";
		else
		{
			var ext = parts[(parts.length-1)].toLowerCase();
			if (ext != 'gif' && ext != 'png' && ext != 'jpg' && ext != 'jpeg')
				tErrors[tErrors.length] = "Wrong file type: "  + v_ReceiptImage.value + "<br>" + "You can only upload image files that are JPG, GIF or PNG";
		}
	}
	
	if (tErrors.length > 0)
	{
		showValidationAlert();
		return false;
	}
	return true;
}

function validateRequestBarForm()
{
	tErrors = new Array();
	
	var v_SiteCaption = gEl('SiteCaption');
	var v_SiteUrl = gEl('SiteUrl');
	var v_PrivacyCaption = gEl('PrivacyCaption');
	var v_PrivacyUrl = gEl('PrivacyUrl');
	var v_RegisterCaption = gEl('RegisterCaption');
	var v_Logo = gEl('LogoFile');

	
	if (js_trim(v_SiteCaption.value) != '')
	{
		if (js_trim(v_SiteUrl.value) == '')
			tErrors[tErrors.length] = "Privacy Url is Required";
		else if (!validateUrl(v_SiteUrl.value))
			tErrors[tErrors.length] = "Privacy Url Format is Not a Valid";
	}
	if (js_trim(v_PrivacyCaption.value) != '')
	{
		if (js_trim(v_PrivacyUrl.value) == '')
			tErrors[tErrors.length] = "Privacy Url is Required";
		else if (!validateUrl(v_PrivacyUrl.value))
			tErrors[tErrors.length] = "Privacy Url Format is Not a Valid";
	}
	if (js_trim(v_Logo.value) == '')
		tErrors[tErrors.length] = "Please Upload Logo";
	if (tErrors.length > 0)
	{
		showValidationAlert();
		return false;
	}
	return true;
}
	
		
/* --------------- registr form ------------------------------------------------*/

var regInviteCheckedInDB_History = new Array();
/*
regInviteCheckedInDB_History[(str)invateLink] = (bool)result;
*/

var regLastInvLinkCheckedInDB_History = ''; // last state of invite link

/*
* @param (obj) o_invOBJ - is object of invite link field
* @return (bool)
*/
function CheckInviteLinkInDB(o_invOBJ)
{
  InviteLinkValid = false;
  gEl('InviteEr').style.visibility = 'hidden';
  gEl('InviteErM').innerHTML = '';
  var errorStr = '';

  if (typeof(o_invOBJ) == 'object')
  {
     var o_vl = o_invOBJ.value;
     regLastInvLinkCheckedInDB_History = o_vl;

     if (o_vl.length > 0)
     {
        if (validateInvite(o_vl))
        {
           var RegEx1 = /^\d{5,6}\w{2,3}$/;
           var RegEx2 = /^\w{3}\d{1}$/;

           if(!o_vl.match(RegEx1) && !o_vl.match(RegEx2))
           {
              if (typeof(regInviteCheckedInDB_History) != 'undefined')
              {
                 if (typeof(regInviteCheckedInDB_History[ o_vl ]) != 'undefined')
                 {
                        if (!regInviteCheckedInDB_History[ o_vl ])
                        {
                            InviteLinkValid = true;
                        }
                        else
                        {
                            errorStr = 'That one is taken. Try again';
                        }
                 }
                 else
                 {
                    //alert("Active AJAX!");
                    AjaxAfterLoadCall = 'CheckInvLinkAfterPost';
                   	AjaxRequestPost('/ajax/', 'get=v_invite&s=' + o_vl, 'null');
                 }
              }
           }
           else errorStr = 'Invalid Invite Link';
        }
        else errorStr = 'Invalid Invite Link';
     }
  }

  if (errorStr.length > 0 )
  {
    gEl('InviteEr').style.visibility = 'visible';
    gEl('InviteErM').innerHTML = errorStr;
  }

  return false;
}

function CheckInvLinkAfterPost()
{
  if (AjaxRequestResult != '')
 	{
    		if (typeof(regInviteCheckedInDB_History) != 'undefined' && typeof(regLastInvLinkCheckedInDB_History) != 'undefined')
      {
         if (regLastInvLinkCheckedInDB_History.length > 0)
            regInviteCheckedInDB_History[ regLastInvLinkCheckedInDB_History ] = (AjaxRequestResult == 'ok' ? false : true);
      }

      InviteLinkValid = (AjaxRequestResult == 'ok' ? false : true);

      if (AjaxRequestResult != 'ok')
      {
         gEl('InviteEr').style.visibility = 'visible';
         gEl('InviteErM').innerHTML = AjaxRequestResult;
      }
 	}
  else InviteLinkValid = false;
}


function validateRegisterForm()
{
	tErrors = new Array();
	tErrors1 = new Array();
	tErrors2 = new Array();
	tErrors3 = new Array();
	
	var v_Email = gEl('regEmail');
	var v_EmailRetype = gEl('EmailRetype');
	
	var v_Password = gEl('regPassword');
	var v_PasswordRetype = gEl('PasswordRetype');
	var v_Question = gEl('Question');
	var v_Answer = gEl('Answer');
	var v_AnswerRetype = gEl('AnswerRetype');
	
	var v_InviteLink = gEl('InviteLink');
	var v_CompanyName = gEl('CompanyName');
	var v_FirstName = gEl('FirstName');
	var v_LastName = gEl('LastName');
	var v_Phone = gEl('Phone');
	var v_Address1 = gEl('Address1');
	var v_Address2 = gEl('Address2');
	
	var v_City = gEl('City');
	var v_State = gEl('State');
	var v_Zip = gEl('Zip');
	var v_Country = gEl('Country');
	var v_TaxIdNumber = gEl('TaxIdNumber');
	var v_CertifiedNonProfit = gEl('CertifiedNonProfit');

	var v_IntroducerEmail = gEl('IntroducerEmail');
	var v_IntroducerEmailConfirm = gEl('IntroducerEmailRetype');
	
	var v_InvitePass = gEl('InvitePass');
	var v_InvitePassRetype = gEl('InvitePassRetype');
	
	var v_SecureCode = gEl('SecureCode');
	var v_Agree = gEl('Agree');
	
	
	
	if (js_trim(v_Email.value) == '')
		tErrors1[tErrors1.length] = "Email Address";
	else if (!validateEmail(js_trim(v_Email.value)))
		tErrors1[tErrors1.length] = "Email Address";
	else if (v_Email.value != v_EmailRetype.value)
		tErrors1[tErrors1.length] = "Email Address";
	else if (!EmailAddressValid)
		tErrors1[tErrors1.length] = "Email Address";
	
	if (!InviteLinkValid)
		tErrors2[tErrors2.length] = "Invite Link";
	else if (js_trim(v_InviteLink.value) == '')
		tErrors2[tErrors2.length] = "Invite Link";
	
	if (js_trim(v_Password.value) == '')
		tErrors1[tErrors1.length] = "Password";
	else if (v_Password.value != v_PasswordRetype.value)
		tErrors1[tErrors1.length] = "Password";
	
	if (js_trim(v_Question.value) == '')
		tErrors1[tErrors1.length] = "Question";
	if (js_trim(v_Answer.value) == '')
		tErrors1[tErrors1.length] = "Answer";
	else if (js_trim(v_Answer.value) != js_trim(v_AnswerRetype.value))
		tErrors1[tErrors1.length] = "Answer";
	
	if (js_trim(v_InvitePass.value) != '')
	{
		if ( js_trim(v_InvitePass.value) != js_trim(v_InvitePassRetype.value))
			tErrors1[tErrors1.length] = "Invite Tag";
		else if ( !validateInvite( js_trim(v_InvitePass.value) ) )
			tErrors1[tErrors1.length] = "Invite Tag";
	}
	
	if (js_trim(v_CompanyName.value) == '')
		tErrors3[tErrors3.length] = "Company Name";
	if (js_trim(v_FirstName.value) == '')
		tErrors3[tErrors3.length] = "First Name";
	if (js_trim(v_LastName.value) == '')
		tErrors3[tErrors3.length] = "Last Name";
	if (js_trim(v_Phone.value) == '')
		tErrors3[tErrors3.length] = "Phone";
	if (js_trim(v_Address1.value) == '' && js_trim(v_Address2.value) == '')
		tErrors3[tErrors3.length] = "Address";
	if (js_trim(v_City.value) == '')
		tErrors3[tErrors3.length] = "City";
	if ((v_Country.value == 230 && gEl('USStateId').value == '') || (v_Country.value == 39 && gEl('CanadaStateId').value == '') || (v_Country.value != 230 && v_Country.value != 39 && gEl('State').value == ''))
		tErrors3[tErrors3.length] = "State / Province";
	if (js_trim(v_Zip.value) == '')
		tErrors3[tErrors3.length] = "Zip / Postal Code";
	if (js_trim(v_Country.value) == '')
		tErrors3[tErrors3.length] = "Country";
	
		
	if (js_trim(v_TaxIdNumber.value) == '')
    {
		tErrors3[tErrors3.length] = "Tax ID Number";
	}

	if (js_trim(v_CertifiedNonProfit.value) == '')
		tErrors3[tErrors3.length] = "Certified Non Profit";
	
	
	/*
	if (v_IntroducerEmail && v_IntroducerEmailConfirm && js_trim(v_IntroducerEmail.value) != 'Email' && js_trim(v_IntroducerEmail.value) != '')
	{
	    if (js_trim(v_IntroducerEmail.value) == '')
		    tErrors1[tErrors1.length] = "Introducer Email";
	    else if (!validateEmail(js_trim(v_IntroducerEmail.value)))
		    tErrors1[tErrors1.length] = "Introducer Email";
	    else if (v_IntroducerEmail.value != v_IntroducerEmailConfirm.value)
		    tErrors1[tErrors1.length] = "Introducer Email";
	}
	*/
	
	if (tErrors1.length > 0 || tErrors2.length > 0 || tErrors3.length > 0)
		showValidationAlertEx();
	else
		gEl('registerForm').submit();
	
	return false;

}
function validateAccount()
{
	tErrors = new Array();
	
	var v_Email = gEl('email-input');
	
	var v_Password = gEl('password-input');
	var v_Question = gEl('Question');
	var v_Answer = gEl('answer-input');
	
	
	var v_CompanyName = gEl('company-input');
	var v_FirstName = gEl('fname-input');
	var v_LastName = gEl('lname-input');
	var v_Phone = gEl('phone-input');
	var v_Address1 = gEl('address1-input');
	var v_Address2 = gEl('address2-input');
	
	var v_City = gEl('city-input');
	var v_Zip = gEl('zip-input');
	var v_Country = gEl('CountryId');
	var v_TaxIdNumber = gEl('taxid-input');


	
	if (js_trim(v_Email.value) == '')
		tErrors[tErrors.length] = "Enter Email Address";
	else if (!validateEmail(js_trim(v_Email.value)))
		tErrors[tErrors.length] = "Enter valid Email";
	
	if (js_trim(v_Password.value) == '')
		tErrors[tErrors.length] = "Enter Password";
	
	if (js_trim(v_Question.value) == '')
		tErrors[tErrors.length] = "Select Security Question";
	if (js_trim(v_Answer.value) == '')
		tErrors[tErrors.length] = "Enter Answer";
	
	if (js_trim(v_CompanyName.value) == '')
		tErrors[tErrors.length] = "Enter Company Name";
	if (js_trim(v_FirstName.value) == '')
		tErrors[tErrors.length] = "Enter First Name";
	if (js_trim(v_LastName.value) == '')
		tErrors[tErrors.length] = "Enter Last Name";
	if (js_trim(v_Phone.value) == '')
		tErrors[tErrors.length] = "Enter Phone";
	if (js_trim(v_Address1.value) == '' && js_trim(v_Address2.value) == '')
		tErrors[tErrors.length] = "Enter Address";
	if (js_trim(v_City.value) == '')
		tErrors[tErrors.length] = "Enter City";
	if ((v_Country.value == 230 && gEl('USStateId').value == '') || (v_Country.value == 39 && gEl('CanadaStateId').value == '') || (v_Country.value != 230 && v_Country.value != 39 && gEl('State').value == ''))
		tErrors[tErrors.length] = "Select State";
	if (js_trim(v_Zip.value) == '')
		tErrors[tErrors.length] = "Enter Zip/Postal Code";
	if (js_trim(v_Country.value) == '')
		tErrors[tErrors.length] = "Select Country";
		
	if (js_trim(v_TaxIdNumber.value) == '')
		tErrors[tErrors.length] = "Enter Tax ID Number";
	
	if (!InviteLinkValid)
		tErrors[tErrors.length] = "Invalid Invite Link";
	
	if (tErrors.length > 0)
	{
		showValidationAlert();
		return false;
	}
	return true;
	
}

function validateRequestFunds()
{
	tErrors = new Array();
	
	var v_FirstName = gEl('FirstName');
	var v_LastName = gEl('LastName');
	var v_Phone = gEl('Phone');
	var v_Address = gEl('Address');
	var v_City = gEl('City');
	var v_State = gEl('State');
	
	var v_Money = gEl('currentEarnings');
	var has_request = document.getElementById('has_request');
	
	var v_SecureCode = gEl('SecureCode');
	var v_Agree = gEl('Agree');
	
	if (has_request.value == '1')
		tErrors[tErrors.length] = "Your request has already been submitted";
	else if ( parseInt(v_Money.innerHTML.replace('$', '')) < 10 )
		tErrors[tErrors.length] = "Minimum account balance to request funds is $10.";
	else
	{
		if (js_trim(v_FirstName.value) == '')
			tErrors[tErrors.length] = "Enter First Name";
		if (js_trim(v_LastName.value) == '')
			tErrors[tErrors.length] = "Enter Last Name";
		if (js_trim(v_Phone.value) == '')
			tErrors[tErrors.length] = "Enter Phone";
		if (js_trim(v_Address.value) == '')
			tErrors[tErrors.length] = "Enter Address";
		if (js_trim(v_City.value) == '')
			tErrors[tErrors.length] = "Enter City";
		if (js_trim(v_State.value) == '')
			tErrors[tErrors.length] = "Enter State/Province";
	
	
		if (js_trim(v_SecureCode.value).length != 5)
			tErrors[tErrors.length] = "Enter correct security text";

		if (!v_Agree.checked)
			tErrors[tErrors.length] = "You must agree to the Terms &amp; Conditions";
	}
	
	if (tErrors.length > 0)
	{
		showValidationAlert();
		return false;
	}
	return true;
	
}

function showValidationAlertEx()
{
	try { wsScrollTo(0); } catch(e) { window.scroll(0,0); }
	e = '';
	if (tErrors1.length > 0)
	{
		for (var i = 0; i < tErrors1.length; i++)
			e =  e + "<span>" + tErrors1[i] + "</span>";
	}
	gEl('erError1').innerHTML = e;
	e = '';
	if (tErrors2.length > 0)
	{
		for (var i = 0; i < tErrors2.length; i++)
			e =  e + "<span>" + tErrors2[i] + "</span>";
	}
	gEl('erError2').innerHTML = e;
	e = '';
	if (tErrors3.length > 0)
	{
		for (var i = 0; i < tErrors3.length; i++)
			e =  e + "<span>" + tErrors3[i] + "</span>";
	}
	gEl('erError3').innerHTML = e;
	
	show('errorEx');
}
function showValidationAlert(errorText) 
{
	var error = "";
	window.scroll(0,0);
	
	if (errorText)
		error = errorText;
	else if (tErrors.length < 1)
		return;
		
	for (var i = 0; i < tErrors.length; i++)
		error =  error + "<li>" + tErrors[i] + "</li>";
		
	error = "Please correct the following:<ul>" + error + "</ul>";
	
	gEl("errorDiv").innerHTML = error;
	gEl("errorDivContainer").style.visibility = "visible";
}

function js_trim(_v) 
{
	_v = _v.replace(/^\s+/, '');
	return _v.replace(/\s+$/, '');
}


function validateString(str, minlength)
{
	if(!str)
		return false;

	str = new String(str);
	if(str.replace(/ /g, '').length<minlength)
		return false;

	return true;
}

function validateEmail(str)
{
	var emailRegEx = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
	if(str.match(emailRegEx))
		return true;
	return false;
}
function validateUrl(str)
{
	var UrlRegEx = /^http(s)?\:\/\//;
	str = js_trim(str);
	if(str.match(UrlRegEx))
		return true;
	return false;
}
function validateInvite(str)
{
	var inviteRegEx = /[a-zA-Z0-9\-\_]{3,50}/;
	if(str.match(inviteRegEx))
		return true;
	return false;
}

function validateFundRequest()
{
	var fname = document.getElementById('fname').value;
	var lname = document.getElementById('lname').value;
	var phone = document.getElementById('phone').value;
	var address = document.getElementById('address').value;
	var city = document.getElementById('city').value;
	var state = document.getElementById('state').value;
	var captcha = document.getElementById('captcha').value;
	var agree = document.getElementById('agree').checked;
	
	var errors = new Array();
	var i=0;

	if(!validateString(fname, 2))
	{
		errors[i]="Enter First Name";
		i++;
	}
	
	if(!validateString(lname, 2))
	{
		errors[i]="Enter Last Name";
		i++;
	}
	
	if(!validateString(phone, 3))
	{
		errors[i]="Enter Phone";
		i++;
	}
	
	if(!validateString(address, 2))
	{
		errors[i]="Enter Address";
		i++;
	}
	
	if(!validateString(city, 2))
	{
		errors[i]="Enter City";
		i++;
	}
	
	if(!validateString(state, 1))
	{
		errors[i]="Select State/Province";
		i++;
	}
	
	if(!validateString(captcha, 3))
	{
		errors[i]='Enter security text';
		i++;
	}
	
	if(!agree)
	{
		errors[i]='You must agree to the Terms & Conditions';
		i++;
	}

	var div = document.getElementById('errorDiv');
	var errorContent = 'Please correct the following:<ul>';
	for(i=0;i<errors.length;i++)
	{
		errorContent += ('<li>'+errors[i]+'</li>');
	}
	errorContent += '</ul>';
	div.innerHTML = errorContent;

	var moneyAmount = parseInt(document.getElementById("currentEarnings").innerHTML.replace('$', ''));
	if(moneyAmount < 10)
	{
		div.innerHTML = '<br />Minimum account balance to request funds is $10.<br /><br />';
		document.getElementById("errorDivContainer").style.visibility = "visible";
		return false;
	}
	else if(errors.length>0)
	{
		document.getElementById("errorDivContainer").style.visibility = "visible";
		return false;
	}
	else
	{
		return true;
	}
}

function setSelectedValue(dropDownId, value) 
{
	var dropDown = document.getElementById(dropDownId);
	if(dropDown)
	{
		for(var i=0;i<dropDown.length; i++)
		{
			if(dropDown.options[i].value == value)
			{
				dropDown.selectedIndex = i;
				return;
			}
		}
		
	}
}

function stateSet(countryId)
{
	if (gEl('state-edit'))
		setField('state');
		
	gEl('State').style.display = (countryId != 230 && countryId != 39) ? 'block' : 'none';
	gEl('USStateId').style.display = (countryId == 230) ? 'block' : 'none';
	gEl('CanadaStateId').style.display = (countryId == 39) ? 'block' : 'none';
}