﻿// JScript File
var fltrEmail = /^([\w-]+)([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,9}|[0-9]{1,3})(\]?)$/i;


function trim(str)
{
	var s = str;
	while ( ( s.length > 0 ) && ( s.charAt(0)==' ') )
		s = s.substring(1);
	while ( ( s.length > 0) && ( s.charAt(s.length - 1)==' ') )
		s = s.substring(0, s.length - 1);
	return s;
}

function CheckEmptyField() 
{
	//var eMailTxt = document.get ("txtEmail");		
	var eMailTxt =window.document.getElementById("txtEmail")
	
	if ( trim( eMailTxt.value ) == "" )
	{
		alert("Please input an Email Address.");
		eMailTxt.focus();
		return false;
	} 		
	else if( !fltrEmail.test( trim(eMailTxt.value ) ))
	{
		alert("Invalid Email Address.");
		eMailTxt.focus();
		return false;
	}		
	else {
		return true;
	}
}	
function ClickSubmit()
{
    document.getElementById("Submit2").click();
}
function Redirect()
{
    if(CheckEmptyField())
    {
        window.location = "RD.aspx?email=" + document.getElementById("txtEmail").value;
        return true;
    }
    else
        return false;
}

function RedirectCustom()
{
    if(CheckEmptyField())
    {
        window.location = "RDN.aspx?email=" + document.getElementById("txtEmail").value;
        return true;
    }
    else
        return false;
}



function CheckMail(eMailTxt)
{
//var eMailTxt =window.document.getElementById("txtEmail")
	//var fltrEmail = /emailPattern/;///^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i;
	
	if ( trim( eMailTxt.value ) == "" )
	{
		alert("Please input an Email Address.");
		eMailTxt.focus();
		return false;
	} 		
	else if( !fltrEmail.test( trim(eMailTxt.value ) ))
	{
		alert("Invalid Email Address.");
		eMailTxt.focus();
		return false;
	}		
	else {
		return true;
	}
}

function checkCheckBoxes(dgLists)
{
    var arr = dgLists.all;
    for (var i = 0; i < arr.length; i++)
    {
        if (arr[i].type == 'checkbox')
        {
            if (arr[i].checked)
                return true; 
        }
    }
    alert('Please select at least one list');
    return false;
}