
function IsAnySelected( e, msg )
{
	bSel = false;

	if( e != null )
	{
		if( e.checked )
			bSel = true;

		for( i = 0; i < e.length; i++ )
		{
			if( e[i].checked )
				bSel = true;
		}
		if( !bSel )
			alert( msg );
	}

	return( bSel );
}

function CheckEmpty( e, strCaption )
{
	var temp, re;

	re = /\s/g;
	temp = e.value.replace( re, "" )
	if(temp=="")
	{
		alert("Please enter " + strCaption + "." );
		e.focus();
		return false;
	}
	else
		return true;
}

function IsValidEmail( e, strCaption )
{
	var AtPos = e.value.indexOf("@");
	var StopPos = e.value.lastIndexOf(".");

	if ((e.value == "") ||
		(AtPos == -1 || StopPos == -1) ||
		(StopPos < AtPos) ||
		(StopPos - AtPos == 1))
	{
		alert("Please enter " + strCaption + "." );
		e.focus();
		return false;
	}

	return true;
}

function IsValidNumeric( e, strCaption )
{
	var anum = /(^\d+$)|(^\d+\.\d+$)/
	if (!anum.test(e.value))
	{
		alert("Please enter " + strCaption);
		e.focus();
		return false;
	}
	return true;
}

function IsPositiveInteger( e, strCaption )
{  
	if(IsValidNumeric(e, strCaption) && e.value > 0)
		return true;

	return false;
}

function OnSelectRow( iRow, rowName )
{
	if( document.theform.checkSelect.length == null )
	{
		eRow = document.getElementById( rowName )
			
		if(document.theform.moveToSelect)
		{
			if( document.theform.checkSelect.checked ) {
				if( !document.theform.moveToSelect.checked )
					eRow.bgColor = "#DFEFFF"
			} else {
				if( document.theform.moveToSelect.checked )
					eRow.bgColor = "yellow"
				else
					eRow.bgColor = "white"
			}
		}
		else
		{
			if( document.theform.checkSelect.checked ) {
					eRow.bgColor = "yellow"
			} else {
					eRow.bgColor = "white"
			}
		}
	}
	else
	{
		eRow = document.getElementById( rowName )

		if(document.theform.moveToSelect)
		{
			if( document.theform.checkSelect[iRow].checked ) {
				if( !document.theform.moveToSelect[iRow].checked )
					eRow.bgColor = "#DFEFFF"
			} else {
				if( document.theform.moveToSelect[iRow].checked )
					eRow.bgColor = "#00d999"
				else
					eRow.bgColor = "white"
			}
		}
		else
		{
			if( document.theform.checkSelect[iRow].checked ) {
					eRow.bgColor = "#00d999"
			} else {
					eRow.bgColor = "white"
			}
		}
	}
}

function hideElement(el) {
    document.getElementById(el).style.display = "none";
}

function showElement(el) {
    document.getElementById(el).style.display = "block";
}

function toggleDisplay(el) {
    if (document.getElementById(el).style.display == "block") {
        document.getElementById(el).style.display = "none";
    } else {
        document.getElementById(el).style.display = "block";
    }
}

function copyAddrBillToShip() {

    if (document.theform.BillingShippingSame.checked) {
        document.theform.ShipAddress1.value = document.theform.BusAddress1.value;
        document.theform.ShipAddress2.value = document.theform.BusAddress2.value;
        document.theform.ShipCity.value = document.theform.BusCity.value;
        document.theform.ShipState.value = document.theform.BusState.value;
        document.theform.ShipZip.value = document.theform.BusZip.value;
        document.theform.ShipCountry.value = document.theform.BusCountry.value;
    }
}

function ToggleItems(item, value) {

    if (item == 'PaymentMethod') {
        if (value == 'PONumber') {
            document.getElementById('PaymentMethodPONumberDetail').style.display = 'inline';
            document.getElementById('PaymentMethodCCNumberDetail').style.display = 'none';
        } else {
        document.getElementById('PaymentMethodPONumberDetail').style.display = 'none';
        document.getElementById('PaymentMethodCCNumberDetail').style.display = 'inline';
        }
    }
    
    
}
