﻿
function SetControlsReadOnlyAndClear(tableId, readOnly)
{
	var table = document.getElementById(tableId);
	var controls = table.getElementsByTagName("input");
	var controls2 = table.getElementsByTagName("select");

	for(var i = 0; i < controls.length; i++)
	{
		controls[i].readOnly = readOnly;
		controls[i].value = "";
	}
	
	for(var j = 0; j < controls2.length; j++)
	{
		controls2[j].disabled = readOnly;
		controls2[j].selectedIndex = 0;
	}
}

function ValidateShippingAddress1(source, clientside_arguments) 
{
    var regExp = new RegExp("(^(p[\s|\.|,]*| ^post[\s|\.]*)(o[\s|\.|,]*| office[\s|\.]*))| (^box[.|\s]*\d+)");
    var result = regExp.test(clientside_arguments.Value);
    clientside_arguments.IsValid = !result;
}

function ShowPopUp()
{
	var pop = document.getElementById('popup');

	if(pop.className == "popup")
	{
		pop.className += ' popupShow';
	}
	else
	{
		pop.className = 'popup';
	}
}

function ValidatePasswordLength(source, arguments) 
{
	if (arguments.Value.length < 5)
		arguments.IsValid = false;
	else
		arguments.IsValid = true;
}

function DisablePaymentButton(paymentButton, validationGroup)
{
    if(Page_ClientValidate(validationGroup))
    {
    	paymentButton.value = "Processing...";
    	paymentButton.disabled = true;
    	__doPostBack();
    }
}

function gup(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null)
        return "";
    else
        return results[1];
}


