function Trim(TRIM_VALUE){
if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){
return "";
}
else{
return TRIM_VALUE;
}
} 

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} 
return strTemp;

} 

function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} 
return strTemp;
} 



var digits = "0123456789";
var lowercaseLetters = "abcdefghijklmnopqrstuvwxyz"
var uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var whitespace = " \t\n\r";

var decimalPointDelimiter = "."

var phoneNumberDelimiters = "()- ";

var validUSPhoneChars = digits + phoneNumberDelimiters;

var validWorldPhoneChars = digits + phoneNumberDelimiters + "+";

var SSNDelimiters = "- ";

var validSSNChars = digits + SSNDelimiters;

var digitsInSocialSecurityNumber = 9;

var digitsInUSPhoneNumber = 10;

var ZIPCodeDelimiters = "-";

var ZIPCodeDelimeter = "-"

var validZIPCodeChars = digits + ZIPCodeDelimiters

var digitsInZIPCode1 = 5
var digitsInZIPCode2 = 9

var creditCardDelimiters = " "

function isOkBag (s, bag)

{   var i;
    var returnString = "";

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) return false;
    }
    return true;
}

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function isWhiteSpace (s)
{   var i;

    if (isEmpty(s)) return true;

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    return true;
}

function stripCharsInBag (s, bag)

{   var i;
    var returnString = "";

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }

    return returnString;
}

function stripCharsNotInBag (s, bag)

{   var i;
    var returnString = "";

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (bag.indexOf(c) != -1) returnString += c;
    }

    return returnString;
}

function stripWhitespace (s)

{   return stripCharsInBag (s, whitespace)
}

function charInString (c, s)
{   for (i = 0; i < s.length; i++)
    {   if (s.charAt(i) == c) return true;
    }
    return false
}

function stripInitialWhitespace (s)

{   var i = 0;

    while ((i < s.length) && charInString (s.charAt(i), whitespace))
       i++;
    
    return s.substring (i, s.length);
}

function isLetter (c)
{   return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
}

function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

function isLetterOrDigit (c)
{   return (isLetter(c) || isDigit(c))
}



function isInteger (s)

{   var i;

    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);


    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    return true;
}

function isSignedInteger (s)

{   if (isEmpty(s)) 
       if (isSignedInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedInteger.arguments[1] == true);

    else {
        var startPos = 0;
        var secondArg = defaultEmptyOK;

        if (isSignedInteger.arguments.length > 1)
            secondArg = isSignedInteger.arguments[1];

        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;    
        return (isInteger(s.substring(startPos, s.length), secondArg))
    }
}

function isPositiveInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isPositiveInteger.arguments.length > 1)
        secondArg = isPositiveInteger.arguments[1];

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) > 0) ) );
}

function isNonnegativeInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isNonnegativeInteger.arguments.length > 1)
        secondArg = isNonnegativeInteger.arguments[1];

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) >= 0) ) );
}


function isNegativeInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isNegativeInteger.arguments.length > 1)
        secondArg = isNegativeInteger.arguments[1];

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) < 0) ) );
}


function isNonpositiveInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isNonpositiveInteger.arguments.length > 1)
        secondArg = isNonpositiveInteger.arguments[1];

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) <= 0) ) );
}


function isFloat (s)

{   var i;
    var seenDecimalPoint = false;

    if (isEmpty(s)) 
       if (isFloat.arguments.length == 1) return defaultEmptyOK;
       else return (isFloat.arguments[1] == true);

    if (s == decimalPointDelimiter) return false;


    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if ((c == decimalPointDelimiter) && !seenDecimalPoint) seenDecimalPoint = true;
        else if (!isDigit(c)) return false;
    }

    return true;
}


function isSignedFloat (s)

{   if (isEmpty(s)) 
       if (isSignedFloat.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedFloat.arguments[1] == true);

    else {
        var startPos = 0;
        var secondArg = defaultEmptyOK;

        if (isSignedFloat.arguments.length > 1)
            secondArg = isSignedFloat.arguments[1];

        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;    
        return (isFloat(s.substring(startPos, s.length), secondArg))
    }
}


function isAlphabetic (s)

{   var i;

    if (isEmpty(s)) 
       if (isAlphabetic.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphabetic.arguments[1] == true);

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if (!isLetter(c))
        return false;
    }

    return true;
}

function isAlphanumeric (s)

{   var i;

    if (isEmpty(s)) 
       if (isAlphanumeric.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphanumeric.arguments[1] == true);

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if (! (isLetter(c) || isDigit(c) ) )
        return false;
    }

    return true;
}

function reformat (s)

{   var arg;
    var sPos = 0;
    var resultString = "";

    for (var i = 1; i < reformat.arguments.length; i++) {
       arg = reformat.arguments[i];
       if (i % 2 == 1) resultString += arg;
       else {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }
    return resultString;
}

function reformatZIPCode (ZIPString)
{   if (ZIPString.length == 5) return ZIPString;
    else return (reformat (ZIPString, "", 5, "-", 4));
}

function reformatUSPhone (USPhone)
{   return (reformat (USPhone, "(", 3, ") ", 3, "-", 4))
}

function reformatSSN (SSN)
{   return (reformat (SSN, "", 3, "-", 2, "-", 4))
}

function isLeapYear(argYear) {
	return ((argYear % 4 == 0) && (argYear % 100 != 0)) || (argYear % 400 == 0) 
}

function daysInMonth(argMonth, argYear) {
	switch (Number(argMonth)) {
		case 1:		// Jan
		case 3:		// Mar
		case 5:		// May
		case 7:		// Jul
		case 8:		// Aug
		case 10:		// Oct
		case 12:		// Dec
			return 31;
			break;
		
		case 4:		// Apr
		case 6:		// Jun
		case 9:		// Sep
		case 11:		// Nov
			return 30;
			break;
		
		case 2:		// Feb
			if (isLeapYear(argYear))
				return 29
			else
				return 28
			break;
		
		default:
			return 0;
	}
}

function getDateSeparator(argDate) {
	if ((argDate.indexOf('-') > 0) && (argDate.indexOf('/') > 0))
		return ' '

	if (argDate.indexOf('-') > 0)
		return '-'
	else
		if (argDate.indexOf('/') > 0)
			return '/'
		else
			return ' '
}

function getYear(argDate) {
	var dateSep = getDateSeparator(argDate)
	
	if (dateSep == ' ')
		return 0

	if(argDate.split(dateSep).length == 3)
		return argDate.split(dateSep)[2]
	else
		return 0
}

function getMonth(argDate) {
	var dateSep = getDateSeparator(argDate)
	
	if (dateSep == ' ')
		return 0

	if(argDate.split(dateSep).length == 3)
		return argDate.split(dateSep)[0]
	else
		return 0
}

function getDay(argDate) {
	var dateSep = getDateSeparator(argDate)
	
	if (dateSep == ' ')
		return 0

	if(argDate.split(dateSep).length == 3)
		return argDate.split(dateSep)[1]
	else
		return 0
}

function isProperDay(argDay, argMonth, argYear) {
	if ((isWhiteSpace(argDay)) || (argDay == 0))
		return false

	if ((argDay > 0) && (argDay < daysInMonth(argMonth, argYear) + 1))
		return true
	else 
		return false
}

function isProperMonth(argMonth) {
	if ((isWhiteSpace(argMonth)) || (argMonth == 0))
		return false
	
	if ((argMonth > 0) && (argMonth < 13))
		return true
	else
		return false
}

function isProperYear(argYear) {
	if ((isWhiteSpace(argYear)) || (argYear.toString().length > 4) || (argYear.toString().length == 3))
		return false
	
	switch (argYear.toString().length) {
		case 1:
			if (argYear >=0 && argYear < 10)
				return true
			else
				return false
			
		case 2:
			if (argYear >=0 && argYear < 100)
				return true
			else
				return false
			
		case 4:
			if (((argYear >=1900) || (argYear >=2000)) && ((argYear < 3000) || (argYear < 2000)))
				return true
			else
				return false
		
		default:
			return false
	}
}

function isProperDate(argDate) {
	var tmpDay = getDay(argDate)
	var tmpMon = getMonth(argDate)
	var tmpYear = getYear(argDate)

	return isProperDay(tmpDay, tmpMon, tmpYear) && isProperMonth(tmpMon) && isProperYear(tmpYear)
}

function charOccurences(argString, argChar) {
	var intCt = 0

	for(var intI=0; intI < argString.length; intI++)
		if (argString.charAt(intI) == argChar)
			intCt++
	
	return intCt
}

function isProperEmail(argEmail) {
	if (charOccurences(argEmail, '@') + charOccurences(argEmail, '.') < 2)
		return false

	var atPos = argEmail.indexOf('@')
	var dotPos = argEmail.indexOf('.')

	if((atPos == 0) || (atPos == (argEmail.length - 1)))
		return false

	if((dotPos == 0) || (dotPos == (argEmail.length - 1)))
		return false
	
	var checkTLD=1;
 
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
 
	var emailPat=/^(.+)@(.+)$/;
 
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
 
 
	var validChars="\[^\\s" + specialChars + "\]";
 
 
	var quotedUser="(\"[^\"]*\")";
 
 
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
 
 
	var atom=validChars + '+';
 
	var word="(" + atom + "|" + quotedUser + ")";
 
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
 
 
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
 
 
 
	var matchArray=argEmail.match(emailPat);
 
	if (matchArray==null)
		{
		return false;
		}
	var user=matchArray[1];
	var domain=matchArray[2];
 
	for (i=0; i<user.length; i++)
		{
		if (user.charCodeAt(i)>127)
			{
			return false;
			}
		}
	for (i=0; i<domain.length; i++)
		{
		if (domain.charCodeAt(i)>127)
			{
			return false;
			}
		}
 
	if (user.match(userPat)==null)
		{
		return false;
	}
 
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null)
		{
		for (var i=1;i<=4;i++)
			{
			if (IPArray[i]>255)
				{
				return false;
				}
			}
		return true;
		}
 
 
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++)
		{
		if (domArr[i].search(atomPat)==-1)
			{
			return false;
			}
		}
 
	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1)
		{
		return false;
		}
 
	if (len<2)
		{
		return false;
		}
 
	return true;
}

function isProperNumber(argNumber) {
	var numberValue = Number(argNumber)
	
	if (isNaN(numberValue)) 
		return false
	else
		return !isWhiteSpace(argNumber)
}

function isProperAlphabetic(argString) {
	var alphabets = "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ"

	for(var intI=0; intI<argString.length; intI++)
		if (alphabets.indexOf(argString.charAt(intI)) == -1)
			return false
	
	return true
}

function objectValue(argFrm, argElem) {
	var intI
	var objElem = null

	for (intI=0; intI<argFrm.length; intI++)
		if (argFrm[intI].name == argElem) 
			objElem = argFrm[intI]

	switch (objElem.type) {
		case 'text':
		case 'hidden':
		case 'password':
			return objElem.value
			break;
		
		case 'select-one':
			if (objElem.length == 0)
				return ''
			else 
				return objElem.options[objElem.selectedIndex].value
			break;
		
		case 'radio':
			for (intI=0; intI<argFrm.length; intI++)
				if (argFrm[intI].name == argElem) 
					if (argFrm[intI].checked)
						return argFrm[intI].value

			return ''
			break;
	}
}

function objectFocus(argFrm, argElem) {
	var intI
	var objElem = null
	for (intI=0; intI<argFrm.length; intI++)
		if (argFrm[intI].name == argElem) 
			objElem = argFrm[intI]
	objElem.focus();
}

function isProperZip(argZip) {
	if ((argZip.length == 5) || (argZip.length == 9))
		return isProperNumber(argZip)
	
	if (argZip.length == 10)
		return (isProperNumber(argZip.substr(0, 5)) && isProperNumber(argZip.substr(6, 4)) & (argZip.charAt(5) == '-'))
}

function isProperUSPhone (argPhone)
{
	var argPhone2 = stripCharsNotInBag(argPhone,"0123456789")
    return (isOkBag(argPhone,"01234567890 -().") && isInteger(argPhone2) && argPhone2.length==digitsInUSPhoneNumber)
}

function isProperUSSSN(argSSN) {
	var argSSN2 = stripCharsNotInBag(argSSN,"0123456789")
    return (isOkBag(argSSN,"01234567890-") && isInteger(argSSN2) && argSSN2.length==11)
}

function actionFields(argActions) {
	this.email			= (argActions.indexOf('[email]') > -1)
	this.required		= (argActions.indexOf('[req]') > -1)
	this.checkDate		= (argActions.indexOf('[date]') > -1)
	this.checkZip		= (argActions.indexOf('[zip]') > -1)
	this.checkNumber	= (argActions.indexOf('[number]') > -1)
	this.checkAlphabetic= (argActions.indexOf('[alpha]') > -1)
	this.checkUSPhone	= (argActions.indexOf('[usphone]') > -1)
	this.checkUSSSN		= (argActions.indexOf('[usssn]') > -1)

	if (argActions.indexOf('[len=') > -1) {
		this.checkLength = true

		var lenToCheck = ''
		var bolCont = true

		for (var intI=(argActions.indexOf('[len=') +  5);((intI < argActions.length) && bolCont); intI++)
			if (argActions.charAt(intI) != ']')
				lenToCheck += argActions.charAt(intI)
			else
				bolCont = false
		this.lengthToCheck = lenToCheck
	}
	else
		this.checkLength = false

	if (argActions.indexOf('[blankalert=') > -1) {
		this.blankAlert = true

		var alertString = ''
		var bolCont = true

		for (var intI=(argActions.indexOf('[blankalert=') +  12);((intI < argActions.length) && bolCont); intI++)
			if (argActions.charAt(intI) != ']')
				alertString += argActions.charAt(intI)
			else
				bolCont = false
		this.blankAlertMessage = alertString
	}
	else
		this.blankAlert = false
	
	if (argActions.indexOf('[invalidalert=') > -1) {
		this.invalidAlert = true

		var alertString = ''
		var bolCont = true

		for (var intI=(argActions.indexOf('[invalidalert=') +  14);((intI < argActions.length) && bolCont); intI++)
			if (argActions.charAt(intI) != ']')
				alertString += argActions.charAt(intI)
			else
				bolCont = false
		this.invalidAlertMessage = alertString
	}
	else
		this.invalidAlert = false

	if (argActions.indexOf('[equals=') > -1) {
		this.shouldEqual = true

		var equalsString = ''
		var bolCont = true

		for (var intI=(argActions.indexOf('[equals=') +  8);((intI < argActions.length) && bolCont); intI++)
			if (argActions.charAt(intI) != ']')
				equalsString += argActions.charAt(intI)
			else
				bolCont = false
		this.shouldEqualString = equalsString
	}
	else
		this.shouldEqual = false

}


function validateForm(argForm)
	{
	// Added By RDPL on 26th June 2009 for validating the Billing Address section -- start	
	//debugger;trCardName
	
	//To Validate and Change Color Credit Card Section 24  Sept 2009
	CheckForEmpty('CardNumber','trCardNumber');
	CheckForEmpty('CardName','trCardName');
	CheckForEmpty('CardExtraCode','trCardExtraCode');
	CheckForEmpty('CardIssueNumber','trIssueNo');
	//CheckForEmpty('CardNumber','trCardNumber'); duplicate
	CheckForEmptyDDL('CardType','trCardType');
	CheckForEmpty2DDL('CardExpirationMonth','CardExpirationYear','trExpirationDate');
	CheckForEmpty2DDL('CardExpirationYear','CardExpirationMonth','trExpirationDate');
	CheckForEmpty2DDL('CardStartDateMonth','CardStartDateYear','trStartDate');
	CheckForEmpty2DDL('CardStartDateYear','CardStartDateMonth','trStartDate');
	//End -- To Validate and Change Color Credit Card Section
	
	//Code is added to validate Over18 -- Start
	if(document.getElementById('Over13_00')!=null && document.getElementById('Over13Row')!=null)
    {
        //Added by Lokesh to get Error and background color -- Start
        var ErrorColor = 'Orange';
        var BackgroundColor = '#e3e3e3';
        if(document.getElementById('hErrorColor') != null)
            ErrorColor = document.getElementById('hErrorColor').value;
        if(document.getElementById('hBackgroundColor') != null)
            BackgroundColor = document.getElementById('hBackgroundColor').value;
        //Added by Lokesh to get Error and background color -- End
    
        if(document.getElementById("Over13_00").checked == false)
            document.getElementById('Over13Row').style.backgroundColor  = ErrorColor;
        else
            document.getElementById('Over13Row').style.backgroundColor  = BackgroundColor;//Lokesh UK
    }
    //Code is added to validate Over18 -- End
    
	//Billing Address Section 24  Sept 2009
	CheckForEmpty('AddressFirstName_00','trAddressLine1_00');
	CheckForEmpty('AddressLastName_00','trAddressLine2_00');
	CheckForEmpty('AddressPhone_00','trAddressPhone_00');
	CheckForEmpty('AddressAddress1_00','trAddress1_00');
	CheckForEmpty('AddressCity_00','trCity_00');
	CheckForEmpty('AddressZip_00','trPostCode_00');
	CheckForEmpty('EMail_00','EmailRow');
	CheckForEmpty('txtpassword_00','PasswordRow');
	CheckForEmpty('RePassword_00','RePasswordRow');
	//End -- Billing Address Section
	
////	//Code is added by Lokesh UK -- Start
////	if(document.getElementById('txtBillingEmail')!=null && document.getElementById('trBillingEmail')!=null)
////    {
////        if(document.getElementById('txtBillingEmail').value == '')
////        {
////            document.getElementById('trBillingEmail').style.backgroundColor  = 'Orange';
////            return false;
////        }
////        else
////            document.getElementById('trBillingEmail').style.backgroundColor  = 'White';
////    }
////	//Code is added by Lokesh UK -- end
	
	//Start validation 24  Sept 2009 
	if(document.getElementById("PasswordRow")!=null && document.getElementById("PasswordRow").style.display!='none')
	{
        if(document.getElementById("txtpassword_00")!=null ) //Password
        {
            if(document.getElementById("txtpassword_00").value == '')
              {
                //alert("Please enter Password.");
                document.getElementById("txtpassword_00").focus();
                callshowHideControls();
	            return false;
              }
        }
     }
     if(document.getElementById("RePasswordRow")!=null && document.getElementById("RePasswordRow").style.display!='none')
	{
        if(document.getElementById("RePassword_00")!=null ) //RePassword
        {
            if(document.getElementById("RePassword_00").value == '')
              {
                //alert("Please re enter Password.");
                document.getElementById("RePassword_00").focus();
                callshowHideControls();
	            return false;
              }
//              if(document.getElementById("RePassword_00").value != document.getElementById("txtpassword_00").value)
//              {
//                //alert("Password Mismatch.");
//                document.getElementById("RePassword_00").focus();
//	            return false;
//              }
        }
     }
	
	
        
	//End-------------- 24  Sept 2009
	
	if(document.getElementById("AddressFirstName_00")!= null)//For First Name
	{
	    if(document.getElementById("AddressFirstName_00").value == "")
	    {
	        //alert("Please enter First Name");//Commented on 24 Sept 2009
	         document.getElementById("AddressFirstName_00").focus();
	         callshowHideControls();
	        return false;
	    }
	}
	if(document.getElementById("AddressLastName_00")!= null)//For Last Name
	{
	    if(document.getElementById("AddressLastName_00").value == "")
	    {
	        //alert("Please enter Last Name"); //Commented on 24 Sept 2009
	        document.getElementById("AddressLastName_00").focus();
	        callshowHideControls();
	        return false;
	    }
	}
	
	if(document.getElementById("trAddress1_00")!=null && document.getElementById("trAddress1_00").style.display!='none')
	{
	    if(document.getElementById("AddressAddress1_00")!= null)//For Address1
	    {
	        if(document.getElementById("AddressAddress1_00").value == "")
	        {
	            //alert("Please enter Address1"); //Commented on 24 Sept 2009
                
	            document.getElementById("AddressAddress1_00").focus();
	            callshowHideControls();
	            return false;
	        }
	    }
	}
	else
	{
	    if(document.getElementById("trAddress1_00")!=null && document.getElementById("AddressAddress1_00").value == "")
	    {
	        document.getElementById("trAddress1_00").style.display = '';
	        document.getElementById("AddressAddress1_00").focus();
	        callshowHideControls();
	        return false;
	    }
	}
	
	if(document.getElementById("AddressPhone_00")!= null)//For Phone number
	{
	    if(document.getElementById("AddressPhone_00").value == "")
	    {
	        //alert("Please enter Phone Number"); //Commented on 24 Sept 2009
	        document.getElementById("AddressPhone_00").focus();
	        callshowHideControls();
	        return false;
	    }
	}
	
	//Code is added to validate Over18 -- Start
	if(document.getElementById("Over13_00")!= null && document.getElementById("Over13Row")!= null)//For Over 18 
	{  
        if(document.getElementById("Over13_00").checked == false)
        {
	        callshowHideControls();
	        return false;
        }
	}
	//Code is added to validate Over18 -- End
	
	if(document.getElementById("trExpirationDate")!=null && document.getElementById("trExpirationDate").style.display!='none')
	{
	    if(document.getElementById("CardExpirationMonth")!=null && document.getElementById("CardExpirationYear")!=null ) // Expir Date
        {
            if(document.getElementById("CardExpirationMonth").value == '')
              {
                alert("Please select Card Expiration Month.");
                document.getElementById("CardExpirationMonth").focus();
                CheckForEmpty2DDL('CardExpirationMonth','CardExpirationYear','trExpirationDate');
                callshowHideControls();
	            return false;
              }
              if(document.getElementById("CardExpirationYear").value == '')
              {
                alert("Please select Card Expiration Year.");
                document.getElementById("CardExpirationYear").focus();
                CheckForEmpty2DDL('CardExpirationYear','CardExpirationMonth','trExpirationDate');
                callshowHideControls();
	            return false;
              }
        }
      }
      
    if(document.getElementById("trStartDate")!=null && document.getElementById("trStartDate").style.display!='none')
	{
      if(document.getElementById("CardStartDateMonth")!=null && document.getElementById("CardStartDateYear")!=null ) //Start Date
        {
            if(document.getElementById("CardStartDateMonth").value == '')
              {
                alert("Please select Card Start Month.");
                document.getElementById("CardStartDateMonth").focus();
                CheckForEmpty2DDL('CardStartDateMonth','CardStartDateYear','trStartDate');
                callshowHideControls();
	            return false;
              }
              if(document.getElementById("CardStartDateYear").value == '')
              {
                alert("Please select Card Start Date.");
                document.getElementById("CardStartDateYear").focus();
                CheckForEmpty2DDL('CardStartDateYear','CardStartDateMonth','trStartDate');
                callshowHideControls();
	            return false;
              }
        }
      }
    if(document.getElementById("trIssueNo")!=null && document.getElementById("trIssueNo").style.display!='none')
	{
        if(document.getElementById("CardIssueNumber")!=null ) //Issue Number
        {
            //Added by lokesh to not validate Issue number -- Lokesh UK -- Start
            var ddl = document.getElementById('CardType');
            if (ddl != null)
            {
	            var count = ddl.selectedIndex;
	            var value = ddl[count].text;
	            if(value == 'Maestro') {}//Added by lokesh to not validate Issue number -- Lokesh UK -- End
                else
                {
                    if(document.getElementById("CardIssueNumber").value == '')
                    {
                        alert("Please select Card issue number.");
                        document.getElementById("CardIssueNumber").focus();
                        callshowHideControls();
	                    return false;
                    }
                }
            }
        }
     }
     
	// Added By RDPL on 26th June 2009 for validating the Billing Address section -- end
	var frmElements = argForm.elements
	var elemName
	var elemObj

	submitonce(argForm);

	for (var intI=0; intI < frmElements.length; intI++) {// *
		elemObj = frmElements[intI]
		elemName = elemObj.name

		if ((elemObj.type == 'hidden') && (elemName.length > 5))
			if (elemName.substr(elemName.length - 5).toLowerCase() == '_vldt') {// **
				var objAction = new actionFields(objectValue(frmElements, elemName))
				var actElem = elemName.substr(0, elemName.length - 5)
				
				if (objAction.required) {
					if (isWhiteSpace(objectValue(frmElements, actElem))) {// ***
						alert (objAction.blankAlert?objAction.blankAlertMessage:actElem + ' cannot be left blank')
//						if(actElem == 'Quantity')
//						{
//						    //var id = document.getElementsByName('txtUserQuantity');
//						    actElem  = 'UserQuantity';
//						}
						objectFocus(frmElements, actElem);
						submitenabled(argForm);
						return false
					} // ***
				}
				
				if ((objectValue(frmElements, actElem) > '') && (!isWhiteSpace(objectValue(frmElements, actElem)))){// ***
					if (objAction.checkDate)
						if (!isProperDate(objectValue(frmElements, actElem))) {// ****
							alert (objAction.invalidAlert?objAction.invalidAlertMessage:actElem + ' cannot have an invalid date')
							objectFocus(frmElements, actElem);
							submitenabled(argForm);
							return false
						} // ****

					if (objAction.checkNumber)
						if (!isProperNumber(objectValue(frmElements, actElem))) {// ****
							alert (objAction.invalidAlert?objAction.invalidAlertMessage:actElem + ' cannot have an invalid number')
							if(actElem == 'Quantity')
						        actElem = 'UserQuantity ';
							objectFocus(frmElements, actElem);
							submitenabled(argForm);
							return false
						} // ****

					if (objAction.checkZip)
						if (!isProperZip(objectValue(frmElements, actElem))) {// ****
							alert (objAction.invalidAlert?objAction.invalidAlertMessage:actElem + ' cannot have an invalid zipcode')
							objectFocus(frmElements, actElem);
							submitenabled(argForm);
							return false
						} // ****

					if (objAction.checkAlphabetic)
						if (!isProperAlphabetic(objectValue(frmElements, actElem))) {// ****
							alert (objAction.invalidAlert?objAction.invalidAlertMessage:actElem + ' cannot have invalid characters')
							objectFocus(frmElements, actElem);
							submitenabled(argForm);
							return false
						} // ****

					if (objAction.checkUSPhone)
						if (!isProperUSPhone(objectValue(frmElements, actElem))) {// ****
							alert (objAction.invalidAlert?objAction.invalidAlertMessage:actElem + ' cannot have invalid characters')
							objectFocus(frmElements, actElem);
							submitenabled(argForm);
							return false
						} // ****

					if (objAction.checkUSSSN)
						if (!isProperUSSSN(objectValue(frmElements, actElem))) {// ****
							alert (objAction.invalidAlert?objAction.invalidAlertMessage:actElem + ' cannot have invalid characters')
							objectFocus(frmElements, actElem);
							submitenabled(argForm);
							return false
						} // ****

					if (objAction.email)
						if (!isProperEmail(objectValue(frmElements, actElem))) {// ****
							alert (objAction.invalidAlert?objAction.invalidAlertMessage:actElem + ' cannot have invalid characters')
							objectFocus(frmElements, actElem);
							submitenabled(argForm);
							return false
						} // ****

					if (objAction.checkLength)
						if (objectValue(frmElements, actElem).length < objAction.lengthToCheck) {// ****
							alert (objAction.invalidAlert?objAction.invalidAlertMessage:actElem + ' must be at least ' + objAction.lengthToCheck + ' characters long')
							objectFocus(frmElements, actElem);
							submitenabled(argForm);
							return false
						} // ****
				} // ***
			} // **
	} // *
		
	return true
}


function submitenabled(theform)
	{
	if (document.all||document.getElementById)
		{
		for (i=0;i<theform.length;i++)
			{
			var tempobj=theform.elements[i];
			if(tempobj.type.toLowerCase()=="submit" || tempobj.type.toLowerCase()=="reset")
				tempobj.disabled=false;
			}
		}
	}


function submitonce(theform)
	{
	if (document.all||document.getElementById)
		{
		for (i=0;i<theform.length;i++)
			{
			var tempobj=theform.elements[i];
			if(tempobj.type.toLowerCase()=="submit" || tempobj.type.toLowerCase()=="reset")
				tempobj.disabled=true;
			}
		}
    }



function observeWindowLoad(handler) {
    if (window.addEventListener) { 
        window.addEventListener('load',handler,false);
    }
    else if (document.addEventListener) {
        document.addEventListener('load',handler,false);
    }
    else if (window.attachEvent) { 
        window.attachEvent('onload',handler);
    }
    else {
        if (typeof window.onload=='function') {
            var oldload=window.onload;
            window.onload = function(){
                oldload();
                handler();
            }
        } 
        else { window.onload=init; }
    }
}

// * Function is Added by RDPL*//
function UpdateQuantity(Quantity) 
{
    if(document.getElementById('Quantity') != null)
    {
        document.getElementById('Quantity').value = Quantity;
        if(typeof(getShipping) == 'function')
        {
            getShipping();
        }
    }
}
//Added By Mukesh RDPL//
function SetSelecteAttribute(strID)
{
    document.getElementById('Size').value=document.getElementById(strID.id).value;
    AddToBasketImage();//Added By RDPL to validate page - v8.3 - 25 May 2009
}
function SetSelecteColorAttribute(strID)
{
    document.getElementById('Color').value=document.getElementById(strID.id).value;
    AddToBasketImage();//Added By RDPL to validate page - v8.3 - 25 May 2009
}
// Radio Button Validation
//function valRdbutton(thisform)
//{
// myOption = -1;
// for (i=thisform.Size.length-1; i > -1; i--)
// {
//    if (thisform.Size[i].checked)
//     {
//        myOption = i; i = -1;
//     }
// }
//    if (myOption == -1)
//    {
//        alert("You must select a radio button");
//        return false;
//    }
//    return true;
//}
                  
//End
function showReminderText(objChk)
{
    if(objChk.checked)
    {
        document.getElementById('divReminder').style.display = 'block';
        document.getElementById('txtReminderOccasion').value = '';
    }
    else
    {
        document.getElementById('divReminder').style.display = 'none';
    }
    //Added By Mukesh to set Image
    AddToBasketImage();
    //End..
    return true;
}

   
function setShipTo(shipTo)
{
    if (shipTo == 'Someone Else')
    {
        document.getElementById('txtDeliveryTo').style.display = 'block';
        document.getElementById('txtDeliveryTo').value = '';
    }
    else
    {
        document.getElementById('txtDeliveryTo').style.display = 'block';
        document.getElementById('txtDeliveryTo').value = shipTo;
    }
    //Added By Mukesh to set Image
    AddToBasketImage();
    //End...
}
   
function setShippingInfo(ShippingMethodId,Name,ShippingMethodGroupId)
{
    if (document.getElementById('hShippingMethodGroupId') != null)
    {
        document.getElementById('hShippingMethodGroupId').value = ShippingMethodGroupId;
    }
//    if (document.getElementById('txtDeliveryTo') != null)
//    {
//        document.getElementById('txtDeliveryTo').value = '';
//    }
    
}
            
function UpdateDeliveryInfo(theForm)
{

	if(document.getElementById('tester2') != null)
	{
	    theForm.DeliveryDate.value = document.getElementById('tester2').value;
	}
    if(document.getElementById('txtDeliveryTo') != null)
    {
        theForm.DeliveryTo.value = document.getElementById('txtDeliveryTo').value;
    }
    //alert(document.getElementById('hShippingMethodGroupId').value);
    if(document.getElementById('hShippingMethodGroupId') != null)
    {
        theForm.ShippingMethodGroupId.value = document.getElementById('hShippingMethodGroupId').value;
    }
    if(document.getElementById('chkReminder') != null)
    {
        theForm.IsReminder.value = document.getElementById('chkReminder').checked;
    }
    if(document.getElementById('txtReminderOccasion') != null)
    {
        theForm.ReminderOccasion.value = document.getElementById('txtReminderOccasion').value;
    }
    if(document.getElementById('tb') != null)//Added By Mukesh RDPL 20 April 2009
    {
        theForm.DeliveryCountry.value = document.getElementById('tb').value;
    }
    //added by Mohit on 1 July to store value of state--start
    if(document.getElementById('ts') != null)//Added By Mukesh RDPL 20 April 2009
    {
        theForm.DeliveryState.value = document.getElementById('ts').value;
    }
    else if(document.getElementById('txtUniversalState') != null)//Added By Mukesh RDPL 20 April 2009
    {
        theForm.DeliveryState.value = document.getElementById('txtUniversalState').value;
    }
    
    //added by Mohit on 1 July to  value of state--end
    //Gareth
    if(document.getElementById('lstBxFuneralTime') !=null)
    {
        theForm.FuneralTime.value = document.getElementById('lstBxFuneralTime').value;
    }
    if(document.getElementById('txtDeceasedName') !=null)
    {
        theForm.DeceasedName.value = document.getElementById('txtDeceasedName').value;
    }
    //Code is Added by Lokesh in UK -- Start
    if(document.getElementById('OccasionId') !=null)
    {
        theForm.OccasionId.value = document.getElementById('OccasionId').value;
    }
    //Code is Added by Lokesh in UK -- End
    
}

// Founction to Validate change Add to Cart Image 
//Added By Mukesh RDPL
function AddToBasketImage()
{
   var isComplete = 1;//if True
   if(document.getElementById('tb')!=null) //It Will Check for Delivery Country.
   {
        if(document.getElementById('tb').value=="")
            isComplete = 0; //IF False
   }
   
   if(document.getElementById('txtUniversalState')!=null) //It Will Check for Delivery State.
   {
        if(document.getElementById('txtUniversalState').value=="")
        {
            isComplete = 0; //IF False
        }
        else
            document.getElementById('trStateRow').style.background = '';
   }
   
   //Added By On 1st July to store value of state--start
   if(document.getElementById('tb') != null)
   {
    if(document.getElementById('tb').value=="United States" || document.getElementById('tb').value=="Canada")
    {
       if(document.getElementById('ts')!=null) //It Will Check for Delivery Country.
       {
            if(document.getElementById('ts').value=="")
                isComplete = 0; //IF False
       }
    }
   }
   ////Added By On 1st July to store value of state--end
   /*Code is added 2nd June 09 -- Start*/
   if(document.getElementById('tb') != null)
   {
    var sameCountry = 0;
    for(iCounter = 0; iCounter < customarray.length; iCounter++)
    {
        if(customarray[iCounter] != '' && customarray[iCounter] == document.getElementById('tb').value)
        {
            sameCountry = 1;
        }
    }
    if(customarray != null && customarray.length >0 && sameCountry == 0)
    {
         isComplete = 0; //IF False
    }
    /*Code is added 2nd June 09 -- End*/
   }
//   //added by RDPL 0n 2nd July--start

   if(document.getElementById('tb') != null)
   {
        //if(document.getElementById('tb').value=="United States")
        if(document.getElementById('tb').value=="United States" || document.getElementById('tb').value=="Canada")
        {
            
           if(document.getElementById('ts') != null && customStateArray[0]!="No State Found")
           {
                var sameState = 0;
                for(iCounter = 0; iCounter < customStateArray.length; iCounter++)
                {
                    if(customStateArray[iCounter] != '' && customStateArray[iCounter] == document.getElementById('ts').value)
                    {
                        sameState = 1;
                    }
                }
                if(customStateArray != null && customStateArray.length >0 && sameState == 0)
                {
                     isComplete = 0; //IF False
                }
            }
           if(document.getElementById('ts') != null && customStateArray[0]=="No State Found")
           {
               
           }
        }
    }
    
    //added by RDPL 0n 2nd July--end
   if(document.getElementById('txtDeliveryTo')!=null) //It Will Check for ship to text Box.
    {
        if(document.getElementById('txtDeliveryTo').value=="")
        {
            isComplete = 0; //IF False
        }
        else
            document.getElementById('trShipToRow').style.background = '';
    }
    
    if(document.getElementById('divReminder')!=null) //It will check for Reminder TextBox
    {
      if(document.getElementById('divReminder').style.display != 'none')
      {
        if(document.getElementById('txtReminderOccasion').value=="")
            isComplete = 0; //IF False
      }
    }
    
    if(document.getElementById('tester2')!=null) //It Will check delivery date text Box. 
    {
        if(document.getElementById('tester2').value=="")
        {
            isComplete = 0; //IF False
        }
        else
        {
            if(document.getElementById('trCalendarRow') != null)
                document.getElementById('trCalendarRow').style.background = '';
        }
    }
    if(document.getElementById('UserQuantity')!=null) //It Will check Quantity text Box. 
    {
        if(document.getElementById('UserQuantity').value=="")
        {
            isComplete = 0; //IF False
        }
        else
        {
            if(document.getElementById('trQuantityRow') != null)
                document.getElementById('trQuantityRow').style.background = '';
            if(isNaN(document.getElementById('UserQuantity').value))
            {
                isComplete = 0; //IF False
                alert("Please enter correct quantity.");
            }
        }
    }
//    if(document.getElementsByName('rdb')!=null) //It Will check delivery date text Box. 
//    {
//        if(document.getElementById('rdb').value=="")
//            isComplete = 0; //IF False
//    }
    
//    //Code is added by RDPL to handle Occasion -- Start
//    if(document.getElementById('txtDeceasedName')==null && document.getElementById('OccasionId')!=null)
//    {
//          var id = document.getElementById('OccasionId').value;
//          if(id == '0' ||id == "")
//          {
//            //alert('Please select Occasion');
//            isComplete = 0;
//          }
//    }
//    //Code is added by RDPL to handle Occasion -- End
    
   // alert(isComplete);
    if(isComplete == 0)
    {
        document.getElementById('imgBtnAddtocart').src='images/add-to-basket1.jpg';
        //document.getElementById('imgBtnAddtocart').disabled = 'disabled';
        document.getElementById('imgBtnAddtocart').style.cursor = 'default';
        //document.getElementById('trCalender').style.bgcolor = 'red';
        
//        //Code is added to un-hide display note -- Lokesh
//        if(document.getElementById('divDisplayNote') != null)
//            document.getElementById('divDisplayNote').style.display = 'block';
//        //Code is added to un-hide display note -- Lokesh
    }    
    else
    {
        if(document.getElementById('imgBtnAddtocart')!=null)
        {
            document.getElementById('imgBtnAddtocart').src='images/add-to-basket.gif';
            //document.getElementById('imgBtnAddtocart').disabled = false;
            document.getElementById('imgBtnAddtocart').style.cursor = 'pointer'; 
        }
        
//        //Code is added to hide display note -- Lokesh
//        if(document.getElementById('divDisplayNote') != null)
//            document.getElementById('divDisplayNote').style.display = 'none';
//        //Code is added to hide display note -- Lokesh
    }    
}
//Added By Mukesh to validate html tag 15 May 2009
function IsInvalideKeyPress(e,id)
 {
     if(CheckSplChr(e))
     {
        alert('Special characters <,>,^,% and / are not allowed.');
        document.getElementById(id).value = RemoveSelectedChr(e);
     }
}  
//Added By Mukesh 12th Aug 2009, to set selected cardid to hidden field

function SetCardDetail( ctrlID, cardID)
{
    
    document.getElementById(ctrlID).value = cardID;
   // alert( document.getElementById(ctrlID).value);
}
function SetAdditinalItemDetail(chkid,ctrlID, PID, Price)
{
    if(document.getElementById(chkid).checked== true)
    {
        document.getElementById(ctrlID).value = PID;
    }
    else
    {
        document.getElementById(ctrlID).value = "";
    }
    //alert( document.getElementById(ctrlID).value);
   // alert(Price);
}
//New Function to set selected Addational Item ID
function SetAllAdditionalItems(form,CartCtrlID)
 {
    //alert(form);
    var cbResults ='';// 'Checkboxes: ';
    for (var i = 0; i < form.elements.length; i++ )
     {
        if (form.elements[i].type == 'checkbox')
         {
            if (form.elements[i].checked == true)
             {
                //alert(form.elements[i].id);
               var str = form.elements[i].id;
               var subStr = str.substring(11,0);
              if(subStr=='chkbAdditem'){
                cbResults += form.elements[i].value + ' ';}
             }
        }
    }
    
    document.getElementById(CartCtrlID).value = cbResults;
    //alert(document.getElementById(CartCtrlID).value);
    cbResults ='';
}
//Function to check include Wish or not
function SetIswishInclude(ctrlID, messageoxID , CardTable, hiCrd)
{
    if(document.getElementById(ctrlID).checked==true)
    {
        //document.getElementById(messageoxID).value ="";
        document.getElementById(hiCrd).value ="";
        //document.getElementById(messageoxID).disabled = true;
        document.getElementById(CardTable).disabled = true;
    }
    if(document.getElementById(ctrlID).checked==false)
    {
        //document.getElementById(messageoxID).disabled = false;
        document.getElementById(CardTable).disabled = false;
    }
}

//End 



function RemoveSelectedChr(str)//It will remove all special characters
{ 
     var str1 =''; 
     var i = 0; 
     while(i != str.length)
     { 
        //Commented and Added To allow %  on Message Text , RDPL 28th Sept 2009 
        //if(str.charAt(i) == '<' ||str.charAt(i) == '>' || str.charAt(i) == '/'|| str.charAt(i) == '%' || str.charAt(i) == '^') 
        if(str.charAt(i) == '<' ||str.charAt(i) == '>' || str.charAt(i) == '/'|| str.charAt(i) == '^') 
             str1 = str1
        else
            str1 = str1 + str.charAt(i);
        i ++;
     }
    return str1;
}

function ReplaceSplChrWithWhiteSpace(str)//It will remove all special characters
{ 
     var str1 =''; 
     var i = 0; 
     while(i != str.length)
     { 
        if(str.charAt(i) == '<' ||str.charAt(i) == '>' || str.charAt(i) == '/'|| str.charAt(i) == '%' || str.charAt(i) == '^') 
             str1 = str1 + ' ';
        else
            str1 = str1 + str.charAt(i);
        i ++;
     }
    return str1;
}

function CheckSplChr(str) //It will check all special characters
{ 
     var str1 =false; 
     var i = 0; 
     while(i != str.length)
     { 
        //Commented and Added to allow % on Message Text , RDPL 28th Sept 2009
        //if(str.charAt(i) == '<' ||str.charAt(i) == '>' || str.charAt(i) == '/' || str.charAt(i) == '%' || str.charAt(i) == '^') 
        if(str.charAt(i) == '<' ||str.charAt(i) == '>' || str.charAt(i) == '/' || str.charAt(i) == '^') 
             str1 = true;
        i ++;
     }
    return str1;
}

function trimAllSpace(str)
{ 
     var str1 = '';
     var i = 0;
     while(i != str.length)
     { 
       if(str.charAt(i) != ' ') 
          str1 = str1 + str.charAt(i);
       i ++; 
     }
       return str1;
}
//End 15 May 2009

//Added By RDPL on 10th June 2009 changed at v8.3d to show the 
//Allowed and remaining characters in Message and setting the maxlength -- Start
function ValidateMaxLength(evnt, str, ctr, id, msg, AllowedCharachters,remaining)
{ 

    //added by mohit on 9th Oct --start
    if(CheckSplChr(str))
    {
        document.getElementById(id).value = RemoveSelectedChr(str);
        return false;
    }
    else
    {
        //added by mohit on 9th Oct --start
        keyPress(ctr,id,msg,AllowedCharachters,remaining);
        var evntKeyCode = evnt.keyCode;
        // Ignore keys such as Delete, Backspace, Shift, Ctrl, Alt, Insert, Delete, Home, End, Page Up, Page Down and arrow keys
        var escChars = ",8,17,18,19,33,34,35,36,37,38,39,40,45,46,";
        if (escChars.indexOf(',' + evntKeyCode + ',') == -1) 
        {
            if (str.length > AllowedCharachters) 
             { 
                return false;
             }
        }
     }
    return true;
}
 
function keyPress(ctr,id,msg,AllowedCharachters,remaining)
{
    var ctr1 = ctr.value;       
    if (ctr1.length > AllowedCharachters)
    { 
        ctr.value=ctr1.substr(0, AllowedCharachters); 
    }
    var ctr2 = ctr.value;
    var RemainingCharachters = AllowedCharachters - ctr2.length;    
    //Code is updated to change the display format
    //document.getElementById("DIV" + id).innerText = msg + '( ' + remaining + ' ' + RemainingCharachters + ')' ;
    document.getElementById("DIV" + id).innerHTML = RemainingCharachters + ' ' + remaining + ' ' + msg;
}
//10th June 2009 changed at v8.3d - End

//Functions added by Lokesh in UK -- Start
function showHideControls(id, isWithSuite, isWithState, isWithCity, isWithPostal)
{
    //Change the status of the Mannual Flag -- Start
    if(document.getElementById('hIsMannual'+ id).value == 'N')
        document.getElementById('hIsMannual'+ id).value = 'Y';
    else
        document.getElementById('hIsMannual'+ id).value = 'N';
    //Change the status of the Mannual Flag -- End
    
    if(document.getElementById('trCompany' + id).style.display == 'none')
    {
        document.getElementById('trCompany'+ id).style.display='';
        document.getElementById('trAddressType'+ id).style.display='';
        document.getElementById('trAddress1'+ id).style.display='';
        document.getElementById('trAddress2'+ id).style.display='';
        if(isWithSuite == 'True') {document.getElementById('trSuite' + id).style.display='';}
    
    
        if(isWithState == 'True')
        {
            document.getElementById('trState'+ id).style.display='';
            document.getElementById('trRegion'+ id).style.display='none';
        }
        else
        {
            document.getElementById('trState'+ id).style.display='none';
            document.getElementById('trRegion'+ id).style.display='';
        }

        if(isWithCity== 'True') {document.getElementById('trCity'+ id).style.display='';}
        if(isWithPostal == 'True') {document.getElementById('trPostCode'+ id).style.display='';}
        
        if(document.getElementById('hCountryName'+ id).value == 'United States')    
        {
            document.getElementById('trState'+ id).style.display='';
            document.getElementById('trRegion'+ id).style.display='none';
        }
        else
        {
            document.getElementById('trState'+ id).style.display='none';
            document.getElementById('trRegion'+ id).style.display='';
        }
        
    }
    else
    {
        document.getElementById('trCompany'+ id).style.display='none';
        document.getElementById('trAddressType'+ id).style.display='none';
        document.getElementById('trAddress1'+ id).style.display='none';
        document.getElementById('trAddress2'+ id).style.display='none';
        if(isWithSuite == 'True') {document.getElementById('trSuite' + id).style.display='none';}
        document.getElementById('trState'+ id).style.display='none';
        document.getElementById('trRegion'+ id).style.display='none';
        if(isWithCity== 'True') {document.getElementById('trCity'+ id).style.display='none';}
        if(isWithPostal == 'True') {document.getElementById('trPostCode'+ id).style.display='none';}
     }
     return false;
}



function CheckForEmpty(textBoxId,currRow)//Modified on 24 Sept 2009
{
    //Added by lokesh to not validate Issue number -- Lokesh UK -- Start
    if(textBoxId == 'CardNumber' || textBoxId == 'CardIssueNumber')
    {
        var ddl = document.getElementById('CardType');
        if (ddl != null)
        {
	        var count = ddl.selectedIndex;
	        var value = ddl[count].text;
	        if(value == 'Maestro') {return;}
        }
    }
    //Added by Lokesh to get Error and background color -- Start
    var ErrorColor = 'Orange';
    var BackgroundColor = '#e3e3e3';
    if(document.getElementById('hErrorColor') != null)
        ErrorColor = document.getElementById('hErrorColor').value;
    if(document.getElementById('hBackgroundColor') != null)
        BackgroundColor = document.getElementById('hBackgroundColor').value;
    //Added by Lokesh to get Error and background color -- End
    
    //Added by lokesh to not validate Issue number -- Lokesh UK -- End
    
    if(document.getElementById(textBoxId)!=null && document.getElementById(currRow)!=null)
    {
        if(document.getElementById(textBoxId).value == '')
        {
            document.getElementById(currRow).style.backgroundColor  = ErrorColor;
            //        if(document.getElementById("divCardNumber")!=null)
            //           document.getElementById("divCardNumber").style.display  = 'block';
        }
        else
        {
            document.getElementById(currRow).style.backgroundColor = BackgroundColor;
        }
    }
}
function CheckForEmptyDDL(ddlId,currRow)//Added By Mukesh 24 Sept 2009
{
    //Added by Lokesh to get Error and background color -- Start
    var ErrorColor = 'Orange';
    var BackgroundColor = '#e3e3e3';
    if(document.getElementById('hErrorColor') != null)
        ErrorColor = document.getElementById('hErrorColor').value;
    if(document.getElementById('hBackgroundColor') != null)
        BackgroundColor = document.getElementById('hBackgroundColor').value;
    //Added by Lokesh to get Error and background color -- End
    if(document.getElementById(ddlId)!=null && document.getElementById(currRow)!=null)
    {
        if(document.getElementById(ddlId).value == '')
            document.getElementById(currRow).style.backgroundColor  = ErrorColor;
        else
            document.getElementById(currRow).style.backgroundColor  = BackgroundColor;//Lokesh UK
    }
}
function CheckForEmpty2DDL(ddlId,ddlId2,currRow)//Added By Mukesh 24 Sept 2009
{
    //Added by Lokesh to get Error and background color -- Start
    var ErrorColor = 'Orange';
    var BackgroundColor = '#e3e3e3';
    if(document.getElementById('hErrorColor') != null)
        ErrorColor = document.getElementById('hErrorColor').value;
    if(document.getElementById('hBackgroundColor') != null)
        BackgroundColor = document.getElementById('hBackgroundColor').value;
    //Added by Lokesh to get Error and background color -- End
    
    if(document.getElementById(ddlId)!=null && document.getElementById(ddlId2)!=null && document.getElementById(currRow)!=null)
    {
        if(document.getElementById(ddlId).value == '')
        {
            document.getElementById(currRow).style.backgroundColor  = ErrorColor;
            return false;
        }
        else if(document.getElementById(ddlId2).value == ''){
            document.getElementById(currRow).style.backgroundColor  = ErrorColor;
             return false;}
        else{
            document.getElementById(currRow).style.backgroundColor  = BackgroundColor;//Lokesh UK
            return true;}
    }
}
function fillFirstLastName(RecipientId,currRow,AddressId)
{
    //Added by Lokesh to get Error and background color -- Start
    var ErrorColor = 'Orange';
    var BackgroundColor = '#e3e3e3';
    if(document.getElementById('hErrorColor') != null)
        ErrorColor = document.getElementById('hErrorColor').value;
    if(document.getElementById('hBackgroundColor') != null)
        BackgroundColor = document.getElementById('hBackgroundColor').value;
    //Added by Lokesh to get Error and background color -- End
    
    if(document.getElementById(RecipientId).value == '')
        document.getElementById(currRow).style.backgroundColor  = ErrorColor;
    else
        document.getElementById(currRow).style.backgroundColor  = BackgroundColor;//Lokesh UK
        
   var Recipient = document.getElementById(RecipientId).value;

    if(Recipient != '')
    {
        var FirstName = '';
        var LastName = '';
 
        if(Recipient.indexOf(' ') > 0)
        {
           FirstName = Recipient.substring(0,Recipient.indexOf(' '));
           LastName = Recipient.substring(Recipient.indexOf(' ') +1);
        }
        else
        {
            FirstName =  Trim(Recipient);
            LastName = '..';
        }
        
        //
        if(document.getElementById('AddressFirstName' + AddressId) != null)
            document.getElementById('AddressFirstName' + AddressId).value = FirstName;
        if(document.getElementById('AddressLastName' + AddressId) != null)
            document.getElementById('AddressLastName' + AddressId).value = LastName;
    }
}

////function validateAddControls_UserAccount()
////{
////    //Get the status of the Mannual Flag -- Start
////    var Mannual = document.getElementById('hIsMannual').value;
////    
////    
////    CheckForEmpty('AddressFirstName', 'trAddressLine1');
////    CheckForEmpty('AddressLastName', 'trAddressLine2');
////    CheckForEmpty('AddressRecipient', 'trRecipient');
////    CheckForEmpty('AddressPhone', 'trAddressPhone');
////    
////    if(Mannual == 'Y')
////    {
////        CheckForEmpty('AddressCity', 'trCity');
////        CheckForEmpty('AddressState', 'trState');
////        CheckForEmpty('AddressZip', 'trPostCode');
////    }
////    if(document.getElementById(textBoxId).value == '' )
////    
////    return false;
////}

function showAllControls(id, isWithSuite, isWithState, isWithCity, isWithPostal)
{
   //Set the status of the Mannual Flag
   document.getElementById('hIsMannual'+ id).value = 'Y';
   
   
   document.getElementById('trCompany'+ id).style.display='';
   document.getElementById('trAddressType'+ id).style.display='';
   document.getElementById('trAddress1'+ id).style.display='';
   document.getElementById('trAddress2'+ id).style.display='';
   if(isWithSuite == 'True') {document.getElementById('trSuite' + id).style.display='';}
   
    if(isWithState == 'True')
    {
        document.getElementById('trState'+ id).style.display='';
        document.getElementById('trRegion'+ id).style.display='none';
    }
    else
    {
        document.getElementById('trState'+ id).style.display='none';
        document.getElementById('trRegion'+ id).style.display='';
    }

    if(isWithCity== 'True') {document.getElementById('trCity'+ id).style.display='';}
    if(isWithPostal == 'True') {document.getElementById('trPostCode'+ id).style.display='';}
        
    if(document.getElementById('hCountryName'+ id).value == 'United States')    
    {
        document.getElementById('trState'+ id).style.display='';
        document.getElementById('trRegion'+ id).style.display='none';
    }
    else
    {
        document.getElementById('trState'+ id).style.display='none';
        document.getElementById('trRegion'+ id).style.display='';
    }
    return false;
}
//Functions added by Lokesh in UK -- End


function highLightControls()
{
   var isComplete = 1;//if True
   var ErrorColor = 'Green';
   if(document.getElementById('hErrorColor')!=null)
        ErrorColor = document.getElementById('hErrorColor').value;
        
//   if(document.getElementById('tb')!=null) //It Will Check for Delivery Country.
//   {
//        if(document.getElementById('tb').value=="")
//            isComplete = 0; //IF False
//   }
   //Added By On 1st July to store value of state--start
//   if(document.getElementById('tb') != null)
//   {
//    if(document.getElementById('tb').value=="United States")
//    {
//       if(document.getElementById('ts')!=null) //It Will Check for Delivery Country.
//       {
//            if(document.getElementById('ts').value=="")
//                isComplete = 0; //IF False
//       }
//    }
//   }
   ////Added By On 1st July to store value of state--end



////   //added by RDPL 0n 2nd July--start
//   if(document.getElementById('tb') != null)
//   {
//        if(document.getElementById('tb').value=="United States")
//        {
//           if(document.getElementById('ts') != null)
//           {
//                var sameState = 0;
//                for(iCounter = 0; iCounter < customStateArray.length; iCounter++)
//                {
//                    if(customStateArray[iCounter] != '' && customStateArray[iCounter] == document.getElementById('ts').value)
//                    {
//                        sameState = 1;
//                    }
//                }
//                if(customStateArray != null && customStateArray.length >0 && sameState == 0)
//                {
//                     isComplete = 0; //IF False
//                }
//            }
//        }
//    }
//    //added by RDPL 0n 2nd July--end

   
   if(document.getElementById('txtUniversalState')!=null) //It Will Check for Delivery State.
   {
        if(document.getElementById('txtUniversalState').value=="")
        {
            isComplete = 0;
            document.getElementById('trStateRow').style.background = ErrorColor;
        }
        else
            document.getElementById('trStateRow').style.background = '';
   }
   if(document.getElementById('txtDeliveryTo')!=null) //It Will Check for ship to text Box.
   {
        if(document.getElementById('txtDeliveryTo').value=="")
        {
            isComplete = 0;
            document.getElementById('trShipToRow').style.background = ErrorColor;
        }
        else
            document.getElementById('trShipToRow').style.background = '';
   }
   
    if(document.getElementById('tester2')!=null) //It Will check delivery date text Box. 
    {
        if(document.getElementById('tester2').value=="")
        {
            isComplete = 0;
            if(document.getElementById('trCalendarRow') != null)
                document.getElementById('trCalendarRow').style.background = ErrorColor;
        }
        else
        {
            if(document.getElementById('trCalendarRow') != null)
                document.getElementById('trCalendarRow').style.background = '';
        }
    }
    
    if(document.getElementById('UserQuantity')!=null) //It Will check Quantity text Box. 
    {
        if(document.getElementById('UserQuantity').value=="")
        {
            isComplete = 0;
            document.getElementById('trQuantityRow').style.background = ErrorColor;
        }
        else
        {
         if(document.getElementById('trQuantityRow') != null)
            document.getElementById('trQuantityRow').style.background = '';
        }
    }
    if(isComplete == 0)
     return false;
    else
    {
        AddToBasketImage();
        return true;
    }
}

//Function is added by Lokesh UK -- Start
function getAddressDetailView(addressID,SelectName, label)
{
    if(document.getElementById('hAddressDetail_'+ SelectName +  '_' + addressID) != null)
    {
        var strValue = document.getElementById('hAddressDetail_'+ SelectName +  '_' + addressID).value;
        if(document.getElementById('divAddressDetailView_' + SelectName) != null)
        {
            document.getElementById('divAddressDetailheading_' + SelectName).innerText = label;
            document.getElementById('divAddressDetailView_' + SelectName).innerText = strValue;
        }
    }
    else
    {
        if(document.getElementById('divAddressDetailView_' + SelectName) != null)
        {
            document.getElementById('divAddressDetailheading_' + SelectName).innerText = '';
            document.getElementById('divAddressDetailView_' + SelectName).innerText = '';
        }
    }
}
//Function is added by Lokesh UK -- End