﻿// JScript File
var strImagesPath = "../images/";

function fnValidateName(strFieldName)
{
	var blnError = true;

    blnError = fnIsNameValid(strFieldName);

    if (blnError) 
        fnValidationPassed(strFieldName);
    else
        fnValidationFailed(strFieldName);
    
	return blnError;
}

function fnIsNameValid(strFieldName)
{
    var blnError = true;
    if (blnError) blnError = fnCheckForEmpty(strFieldName, "Please enter your name");    
    
    return blnError;
}

// Validate First Name
function fnValidateFirstName(strFieldName)
{
	var blnError = true;

    blnError = fnIsFirstNameValid(strFieldName);

    if (blnError) 
        fnValidationPassed(strFieldName);
    else
        fnValidationFailed(strFieldName);
    
	return blnError;
}

function fnIsFirstNameValid(strFieldName)
{
    var blnError = true;
    
    if (blnError) blnError = fnCheckForEmpty(strFieldName, "Please enter your first name");    
    
    return blnError;
}


// Validate First Name
function fnValidateLastName(strFieldName)
{
	var blnError = true;

    blnError = fnIsLastNameValid(strFieldName);

    if (blnError) 
        fnValidationPassed(strFieldName);
    else
        fnValidationFailed(strFieldName);
    
	return blnError;
}

function fnIsLastNameValid(strFieldName)
{
    var blnError = true;
    if (blnError) blnError = fnCheckForEmpty(strFieldName, "Please enter your last name");    
    
    return blnError;
}


function fnValidateZipCode(strFieldName)
{
    var blnError = true;

    blnError = fnIsZipCodeValid(strFieldName);

    if (blnError) 
        fnValidationPassed(strFieldName);
    else
        fnValidationFailed(strFieldName);
    
	return blnError;
}

function fnIsZipCodeValid(strFieldName)
{
    var blnError = true;
    
    if (blnError) blnError = fnCheckForEmpty(strFieldName, "Please enter your zip code");    
    
    return blnError;
}


// Validate Email
function fnValidateEmail(strFieldName)
{
	var blnError = true;
	
	blnError = fnIsEmailValid(strFieldName)

    if (blnError) 
        fnValidationPassed(strFieldName);
    else
        fnValidationFailed(strFieldName);

    return blnError;
}

function fnIsEmailValid(strFieldName)
{
	var blnError = true;
	
    if (blnError) blnError = fnCheckForEmpty(strFieldName,"Please enter your email id");
	if (blnError) blnError = fnCheckForEmailChars(strFieldName, "Please check email id for invalid characters");
	if (blnError) blnError = fnCheckForEmailFormat(strFieldName,"Email format to use myname@domain.com");
	
	return blnError;
}

//Validate Country Code, Area Code, Phone Number
function fnValidateContractorCountryAreaPhoneNo()
{
    var blnError = true;
    
    blnError = fnIsContractorISDPhoneNumberValid('txtCountryCode1');
    if(blnError)
        blnError = fnIsContractorISDPhoneNumberValid('txtAreaCode1');
        
    if(blnError)
        blnError = fnIsContractorISDPhoneNumberValid('txtPhoneNo1');        

    if (blnError) 
    {
        //fnValidationPassedForPhNo('txtPhoneNo1');
         fnHideID("hlp_txtPhoneNo1");
         fnHideID("err_txtPhoneNo1");
         fnShowTick("img_txtPhoneNo1"); 
    }
    else
    {
        //fnValidationFailedForPhNo('txtPhoneNo1');
        fnHideID("hlp_txtPhoneNo1");
        fnShowID("err_txtPhoneNo1");
        fnResetTick("img_txtPhoneNo1");   
    }
        
    return blnError;
}

function keyRestrict(e, validchars)
{
    var key='', keychar='';
    key = getKeyCode(e);
    if (key == null) return true;
    keychar = String.fromCharCode(key);
    keychar = keychar.toLowerCase();
    validchars = validchars.toLowerCase();
    if (validchars.indexOf(keychar) != -1)
      return true;
    if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
      return true;
    return false;
}

function getKeyCode(e)
{
    if (window.event)
        return window.event.keyCode;
    else if (e)
        return e.which;
    else
        return null;
}

//Validate Contractor Phone Number
function fnValidateContractorISDPhoneNumber(strFieldName)
{
    var blnError = true;
    
    strValueCountryCode = fnGetFieldValue('txtCountryCode1')
    strValueAreaCode = fnGetFieldValue('txtAreaCode1')
    strValuePhoneNo = fnGetFieldValue('txtPhoneNo1')

    if (strFieldName == 'txtCountryCode1')
    {
        blnError = fnIsContractorISDPhoneNumberValid(strFieldName);
        if(blnError)
        {
            if(strValueAreaCode != "" && strValuePhoneNo != "")
            {
                blnError = fnIsContractorISDPhoneNumberValid('txtAreaCode1');
                blnError = fnIsContractorISDPhoneNumberValid('txtPhoneNo1');
            }            
            else
            {   
                //blnError = false;
            }
        }
    }
    else if(strFieldName == 'txtAreaCode1')
    {
        blnError = fnIsISDPhoneNumberValid(strFieldName);
        if(blnError)
        {
            if(strValueCountryCode != "" && strValuePhoneNo != "")
            {
                blnError = fnIsContractorISDPhoneNumberValid('txtCountryCode1');
                blnError = fnIsContractorISDPhoneNumberValid('txtPhoneNo1');
            }            
            else
            {   
                //blnError = false;
            }
        }
    }
    else if(strFieldName == 'txtPhoneNo1')
    {
        blnError = fnIsISDPhoneNumberValid(strFieldName);
        if(blnError)
        {
            if(strValueCountryCode != "" && strValueAreaCode != "")
            {
                blnError = fnIsContractorISDPhoneNumberValid('txtCountryCode1');
                blnError = fnIsContractorISDPhoneNumberValid('txtAreaCode1');
            }            
            else
            {   
                //blnError = false;
            }
        }
    }    

    if (blnError) 
        fnContractorValidationPassedForPhNo('txtPhoneNo1');
    else
        fnContractorValidationFailedForPhNo('txtPhoneNo1');
        
    return blnError;
}

function fnContractorValidationPassedForPhNo(strFieldID)
{
     fnHideID("hlp_txtPhoneNo1");
     fnHideID("err_txtPhoneNo1");
     fnShowTick("img_txtPhoneNo1"); 
}

function fnContractorValidationFailedForPhNo(strFieldID)
{  
    fnHideID("hlp_txtPhoneNo1");
    fnShowID("err_txtPhoneNo1");
    fnResetTick("img_txtPhoneNo1");    
}

function fnIsContractorISDPhoneNumberValid(strFieldName)
{
   	var blnError = true;

	if (blnError) blnError = fnCheckForEmptyForContractorPhoneNo(strFieldName, "Please enter your phone number");
	if (blnError) blnError = fnCheckForContractorPhoneNoFormat(strFieldName, "Please enter valid phone number.");
    
    return blnError;
}


function fnCheckForEmptyForContractorPhoneNo(strFieldName,strErrorMessage)
{
    strValue = fnGetFieldValue(strFieldName)

    if (strValue == "") 
        return fnDisplayErrMsg('txtPhoneNo1', strErrorMessage);
    else
       return fnHideErrMsg('txtPhoneNo1');  
}

function fnCheckForContractorPhoneNoFormat(strFieldName,strErrorMessage)
{
    obj = document.getElementById(strFieldName);
	var charlist = "0123456789()-+ ";

    if ( fnCheckForContractorPhoneChars(strFieldName, strErrorMessage, charlist ) == false )
	    return fnDisplayErrMsg('txtPhoneNo1', strErrorMessage); 
	else
	    return fnHideErrMsg('txtPhoneNo1');
}

function fnCheckForContractorPhoneChars(strFieldName, strErrorMessage, charlist )
{
    var obj = document.getElementById(strFieldName);

    if ( isChars(obj.value, charlist ) == false )
		    return fnDisplayErrMsg('txtPhoneNo1', strErrorMessage); 
	else
		    return fnHideErrMsg('txtPhoneNo1');
   
}

// Validate Phone Number
function fnValidatePhoneNumber(strFieldName)
{
	var blnError = true;

    blnError = fnIsPhoneNumberValid(strFieldName);

    if (blnError) 
        fnValidationPassed(strFieldName);
    else
        fnValidationFailed(strFieldName);
        
    return blnError;
}

function fnIsPhoneNumberValid(strFieldName)
{
   	var blnError = true;

	if (blnError) blnError = fnCheckForEmpty(strFieldName, "Please enter your phone number");
	if (blnError) blnError = fnCheckForPhoneFormat(strFieldName, "Please enter valid phone number.");
    
    return blnError;
}

//Validate Country Code, Area Code, Phone Number
function fnValidateCountryAreaPhoneNo()
{
    var blnError = true;
    
    blnError = fnIsISDPhoneNumberValid('txtCountryCode');
    if(blnError)
        blnError = fnIsISDPhoneNumberValid('txtAreaCode');
        
    if(blnError)
        blnError = fnIsISDPhoneNumberValid('txtPhoneNo');        

    if (blnError) 
        fnValidationPassedForPhNo('txtPhoneNo');
    else
        fnValidationFailedForPhNo('txtPhoneNo');
        
    return blnError;
}

function fnValidateNotMandatoryCountryAreaPhoneNo()
{
    var blnError = true;
    
    blnError = fnIsNotMandatoryISDPhoneNoValid('txtCountryCode');
    if(blnError)
        blnError = fnIsNotMandatoryISDPhoneNoValid('txtAreaCode');
        
    if(blnError)
        blnError = fnIsNotMandatoryISDPhoneNoValid('txtPhoneNo');        

    if (blnError) 
        fnValidationPassedForPhNo('txtPhoneNo');
    else
        fnValidationFailedForPhNo('txtPhoneNo');
        
    return blnError;
}

function fnHideErrIDForNotMandatoryPhoneNo(strFieldName)
{
    if(fnGetFieldValue('txtCountryCode') == "" && fnGetFieldValue('txtAreaCode') == "" 
         && fnGetFieldValue('txtPhoneNo') == "")
         {
            fnHideID('err_txtPhoneNo');
         }
}


//Validate ISD Phone Number
function fnValidateNotMandatoryISDPhoneNo(strFieldName)
{
    var blnError = true;

    strValueCountryCode = fnGetFieldValue('txtCountryCode')
    strValueAreaCode = fnGetFieldValue('txtAreaCode')
    strValuePhoneNo = fnGetFieldValue('txtPhoneNo')

    if (strFieldName == 'txtCountryCode')
    {
        blnError = fnIsNotMandatoryISDPhoneNoValid(strFieldName);
        if(blnError)
        {
            if(strValueAreaCode != "" && strValuePhoneNo != "")
            {
                blnError = fnIsNotMandatoryISDPhoneNoValid('txtAreaCode');
                blnError = fnIsNotMandatoryISDPhoneNoValid('txtPhoneNo');
            }            
            else
            {   
                //blnError = false;
            }
        }
    }
    else if(strFieldName == 'txtAreaCode')
    {
        blnError = fnIsNotMandatoryISDPhoneNoValid(strFieldName);
        if(blnError)
        {
            if(strValueCountryCode != "" && strValuePhoneNo != "")
            {
                blnError = fnIsNotMandatoryISDPhoneNoValid('txtCountryCode');
                blnError = fnIsNotMandatoryISDPhoneNoValid('txtPhoneNo');
            }            
            else
            {   
                //blnError = false;
            }
        }
    }
    else if(strFieldName == 'txtPhoneNo')
    {
        blnError = fnIsNotMandatoryISDPhoneNoValid(strFieldName);
        if(blnError)
        {
            if(strValueCountryCode != "" && strValueAreaCode != "")
            {
                blnError = fnIsNotMandatoryISDPhoneNoValid('txtCountryCode');
                blnError = fnIsNotMandatoryISDPhoneNoValid('txtAreaCode');
            }            
            else
            {   
                //blnError = false;
            }
        }
    } 
    if (blnError) 
        fnValidationPassedForPhNo(strFieldName);
    else
        fnValidationFailedForPhNo(strFieldName);
        
    return blnError;
}

function fnIsNotMandatoryISDPhoneNoValid(strFieldName)
{
   	var blnError = true;
	
	if (blnError) blnError = fnCheckForPhoneNoFormat(strFieldName, "Please enter valid phone number.");
    
    return blnError;
}


//Validate ISD Phone Number
function fnValidateISDPhoneNumber(strFieldName)
{
    var blnError = true;

    strValueCountryCode = fnGetFieldValue('txtCountryCode')
    strValueAreaCode = fnGetFieldValue('txtAreaCode')
    strValuePhoneNo = fnGetFieldValue('txtPhoneNo')

    if (strFieldName == 'txtCountryCode')
    {
        blnError = fnIsISDPhoneNumberValid(strFieldName);
        if(blnError)
        {
            if(strValueAreaCode != "" && strValuePhoneNo != "")
            {
                blnError = fnIsISDPhoneNumberValid('txtAreaCode');
                blnError = fnIsISDPhoneNumberValid('txtPhoneNo');
            }            
            else
            {   
                //blnError = false;
            }
        }
    }
    else if(strFieldName == 'txtAreaCode')
    {
        blnError = fnIsISDPhoneNumberValid(strFieldName);
        if(blnError)
        {
            if(strValueCountryCode != "" && strValuePhoneNo != "")
            {
                blnError = fnIsISDPhoneNumberValid('txtCountryCode');
                blnError = fnIsISDPhoneNumberValid('txtPhoneNo');
            }            
            else
            {   
                //blnError = false;
            }
        }
    }
    else if(strFieldName == 'txtPhoneNo')
    {
        blnError = fnIsISDPhoneNumberValid(strFieldName);
        if(blnError)
        {
            if(strValueCountryCode != "" && strValueAreaCode != "")
            {
                blnError = fnIsISDPhoneNumberValid('txtCountryCode');
                blnError = fnIsISDPhoneNumberValid('txtAreaCode');
            }            
            else
            {   
                //blnError = false;
            }
        }
    } 
    if (blnError) 
        fnValidationPassedForPhNo(strFieldName);
    else
        fnValidationFailedForPhNo(strFieldName);
        
    return blnError;
}

function fnValidationPassedForPhNo(strFieldID)
{
     fnHideID("hlp_txtPhoneNo");
     fnHideID("err_txtPhoneNo");
     fnShowTick("img_txtPhoneNo"); 
}

function fnValidationFailedForPhNo(strFieldID)
{  
    fnHideID("hlp_txtPhoneNo");
    fnShowID("err_txtPhoneNo");
    fnResetTick("img_txtPhoneNo");    
}

function fnIsISDPhoneNumberValid(strFieldName)
{
   	var blnError = true;

	if (blnError) blnError = fnCheckForEmptyForPhoneNo(strFieldName, "Please enter your phone number");
	if (blnError) blnError = fnCheckForPhoneNoFormat(strFieldName, "Please enter valid phone number.");
    
    return blnError;
}


function fnCheckForEmptyForPhoneNo(strFieldName,strErrorMessage)
{
    strValue = fnGetFieldValue(strFieldName)

    if (strValue == "") 
        return fnDisplayErrMsg('txtPhoneNo', strErrorMessage);
    else
       return fnHideErrMsg('txtPhoneNo');  
}

function fnCheckForPhoneNoFormat(strFieldName,strErrorMessage)
{
    obj = document.getElementById(strFieldName);
	var charlist = "0123456789()-+ ";

    if ( fnCheckForPhoneChars(strFieldName, strErrorMessage, charlist ) == false )
	    return fnDisplayErrMsg('txtPhoneNo', strErrorMessage); 
	else
	    return fnHideErrMsg('txtPhoneNo');
}

function fnCheckForPhoneChars(strFieldName, strErrorMessage, charlist )
{
    var obj = document.getElementById(strFieldName);

    if ( isChars(obj.value, charlist ) == false )
		    return fnDisplayErrMsg('txtPhoneNo', strErrorMessage); 
	else
		    return fnHideErrMsg('txtPhoneNo');
   
}

// Validate Mobile Number
function fnValidateMobileNumber(strFieldName)
{
	var blnError = true;

    blnError = fnIsMobileNumberValid(strFieldName);

    if (blnError) 
        fnValidationPassed(strFieldName);
    else
        fnValidationFailed(strFieldName);
        
    return blnError;
}

function fnIsMobileNumberValid(strFieldName)
{
   	var blnError = true;

	if (blnError) blnError = fnCheckForEmpty(strFieldName, "Please enter your mobile number");
	if (blnError) blnError = fnCheckForPhoneFormat(strFieldName, "Please enter valid mobile number.");
    
    return blnError;
}

// Validate Fax Number
function fnValidateFaxNumber(strFieldName)
{
	var blnError = true;

    blnError = fnIsFaxNumberValid(strFieldName);

    if (blnError) 
        fnValidationPassed(strFieldName);
    else
        fnValidationFailed(strFieldName);
        
    return blnError;
}

function fnIsFaxNumberValid(strFieldName)
{
   	var blnError = true;

	if (blnError) blnError = fnCheckForEmpty(strFieldName, "Please enter your fax number");
	if (blnError) blnError = fnCheckForPhoneFormat(strFieldName, "Please enter valid fax number.");
    
    return blnError;
}



// Validate Job Title
function fnValidateJobTitle(strFieldName)
{
	var blnError = true;
    
    blnError = fnIsJobTitleValid(strFieldName);

    if (blnError) 
        fnValidationPassed(strFieldName);
    else
        fnValidationFailed(strFieldName);   
    
	return blnError;
}

function fnIsJobTitleValid(strFieldName)
{
	var blnError = true;

	if (blnError) blnError = fnCheckForEmpty(strFieldName, "Please enter your designation");
    
    return blnError;
}

// Validate Company Name
function fnValidateCompanyName(strFieldName)
{
    var blnError = true;
    
    blnError = fnIsCompanyNameValid(strFieldName);

    if (blnError) 
        fnValidationPassed(strFieldName);
    else
        fnValidationFailed(strFieldName);

  	return blnError;
}

function fnIsCompanyNameValid(strFieldName)
{
    var blnError = true;

	if (blnError) blnError = fnCheckForEmpty(strFieldName, "Please enter your company name");

    return blnError;
}

// Validate Firm Name
function fnValidateFirmName(strFieldName)
{
    var blnError = true;
    
    blnError = fnIsFirmNameValid(strFieldName);

    if (blnError) 
        fnValidationPassed(strFieldName);
    else
        fnValidationFailed(strFieldName);

  	return blnError;
}

function fnIsFirmNameValid(strFieldName)
{
    var blnError = true;

	if (blnError) blnError = fnCheckForEmpty(strFieldName, "Please enter your firm name");

    return blnError;
}

// Validate Generic Name
function fnValidateGenericName(strFieldName,strTxt)
{
    var blnError = true;
    
    blnError = fnIsGenericNameValid(strFieldName,strTxt);

    if (blnError) 
        fnValidationPassed(strFieldName);
    else
        fnValidationFailed(strFieldName);

  	return blnError;
}

function fnIsGenericNameValid(strFieldName,strTxt)
{
    var blnError = true;

	if (blnError) blnError = fnCheckForEmpty(strFieldName, strTxt);
	
    return blnError;
}

// Validate File Upload Control
function fnValidateFileUpload(strFieldName,strTxt)
{
    var blnError = true;
    var blnReturn = false;
        
    if (blnError) blnError = fnCheckForEmpty(strFieldName, strTxt);
	if (blnError)
	{
	    fnHideID("hlp_" + strFieldName);
	    fnHideID("err_" + strFieldName);
	    blnReturn = fnCheckFileExtension();
	    if(blnReturn)
        {           
            fnShowTick("img_" + strFieldName);
        }
	}    
    else
    {
        //fnValidationFailed(strFieldName);
        fnHideID("hlp_" + strFieldName);
        fnShowID("err_" + strFieldName);
        fnHideID("err_fileext");
        fnResetTick("img_" + strFieldName);
    }

  	return blnError;
}


// Validate Country
function fnValidateCountryILiveContactUs(strFieldName)
{
    var blnError = true;
    
    blnError = fnIsCountrySelected(strFieldName);

    if (blnError) 
        fnValidationPassed(strFieldName);
    else
        fnValidationFailed(strFieldName);
   
	return blnError;    
}

function fnIsCountrySelected(strFieldName)
{
    var blnError = true;
    
	if (blnError) blnError = fnCheckForCountryList(strFieldName, "Please select the country you live");
    
    return blnError;
}


function fnCheckForCountryList(strFieldName, strErrorMessage)
{
    strValue = fnGetFieldValue(strFieldName)
    
    if (strValue == 0) 
        return fnDisplayErrMsg(strFieldName, strErrorMessage);
    else
        return fnHideErrMsg(strFieldName);  
}

// Validate Salutation
function fnValidateSalutation(strFieldName)
{
    var blnError = true;
    
    blnError = fnIsSalutationSelected(strFieldName);

    if (blnError) 
        fnValidationPassed(strFieldName);
    else
        fnValidationFailed(strFieldName);
   
	return blnError;    
}

function fnIsSalutationSelected(strFieldName)
{
    var blnError = true;
    
	if (blnError) blnError = fnCheckForSalutationList(strFieldName, "Please select your title");
    
    return blnError;
}

function fnCheckForSalutationList(strFieldName, strErrorMessage)
{
    strValue = fnGetFieldValue(strFieldName)
    
    if (strValue == 0) 
        return fnDisplayErrMsg(strFieldName, strErrorMessage);
    else
        return fnHideErrMsg(strFieldName);  
}

// Validate OrganizationType
function fnValidateOrgType(strFieldName)
{
    var blnError = true;
    
    //blnError = fnIsOrgTypeSelected(strFieldName);
    strValue = fnGetFieldValue(strFieldName)
    if (strValue != 0)
    {
        if (blnError) 
            fnValidationPassed(strFieldName);
        else
            fnValidationFailed(strFieldName);
    }
    else
    {
        fnHideID("hlp_" + strFieldName);
    }   
	return blnError;    
}


function fnCheckForEmptyForField(strFieldName)
{
    strValue = fnGetFieldValue(strFieldName)
    if (strValue != "")
    {
        fnValidationPassed(strFieldName);
    }    
    else
    {
        fnHideID("hlp_" + strFieldName);
    }
}

function fnIsOrgTypeSelected(strFieldName)
{
    var blnError = true;
    
	if (blnError) blnError = fnCheckForOrgTypeList(strFieldName, "Please select the organization type ");
    
    return blnError;
}

function fnCheckForOrgTypeList(strFieldName, strErrorMessage)
{
    strValue = fnGetFieldValue(strFieldName)
    
    if (strValue == 0) 
        return fnDisplayErrMsg(strFieldName, strErrorMessage);
    else
        return fnHideErrMsg(strFieldName);  
}

function fnValidateQuestionsAnswered(strFieldName)
{
    var blnError = true;
    
    blnError = fnIsQuestionsAnswered(strFieldName);
    
    if (blnError) 
        fnValidationPassed(strFieldName);
    else
        fnValidationFailed(strFieldName);
   
	return blnError;        
}

function fnIsQuestionsAnswered(strFieldName)
{
    var blnError = true;
    
    if (blnError) blnError = fnRadioButtonList(strFieldName);
    
    return blnError;
}

function fnValidationPassed(strFieldID)
{
    fnHideID("hlp_" + strFieldID);
    fnHideID("err_" + strFieldID);
    fnShowTick("img_" + strFieldID);
}

function fnValidationFailed(strFieldID)
{
    fnHideID("hlp_" + strFieldID);
    fnShowID("err_" + strFieldID);
    fnResetTick("img_" + strFieldID);
}

function fnShowID(ID)
{
    document.getElementById(ID).style.display = "inline";
}

function fnHideID(ID)
{
    document.getElementById(ID).style.display = "none";
}

function fnHideDivID(ID)
{
    if (document.getElementById(ID).style.display == "inline")
    {
        document.getElementById(ID).style.display = "none";    
    }    
}

function fnShowTick(TickImageID)
{
    document.getElementById(TickImageID).src = strImagesPath + 'check-anim2.gif';
    setTimeout(function(){setToBlack(TickImageID)},500);
}

function fnResetTick(TickImageID)
{
    document.getElementById(TickImageID).src = strImagesPath + 'spacer.gif';
}

function setToBlack(imgid)
{
	document.getElementById(imgid).src='../images/spacer.gif';
}

function fnShowHelpText(strTextFieldID, strHelpID, strErrorID, TickImageID)
{
    if ( document.getElementById(strErrorID).style.display == "none" )
    {
        fnShowID(strHelpID);
    }
}

function fnShowHelpTextForFriend(strFieldName,strText)
{
    if(document.getElementById('err_' + strFieldName).style.display == "none")
    {
        document.getElementById('hlp_' + strFieldName).innerHTML = strText;
        document.getElementById('hlp_' + strFieldName).style.display = "inline";
    }
}

function fnShowHelpTextForFileUpload(strFieldName,strText,strErrorFieldName,strErrorFieldName1)
{
    if(document.getElementById(strErrorFieldName).style.display == "none"
        && document.getElementById(strErrorFieldName1).style.display == "none")
    {
        document.getElementById('hlp_' + strFieldName).innerHTML = strText;
        document.getElementById('hlp_' + strFieldName).style.display = "inline";
    }
}

function fnCheckBoxListForQuestions(cbQuestionList,divid)
{
    var chkList1 = document.getElementById(cbQuestionList);
    var arrayOfCheckBoxes = chkList1.getElementsByTagName("input");
    var arrayOfCheckBoxLabels = chkList1.getElementsByTagName("label");
    var j = 0;
            
    for(var i=0;i<arrayOfCheckBoxes.length;i++)
    {
        var chklstid = arrayOfCheckBoxes[i].id;
                    
        if(!document.getElementById(chklstid).checked)
        {            
            j += 1;    
        }
        if(document.getElementById(chklstid).checked)
        {            
            j = 0;
        }              
    }
    if(j == arrayOfCheckBoxes.length)
    {     
       document.getElementById(divid).style.display="none";                                      
    }
}

function fnRadioButtonList(rbQuestionList)
{
    var blnError = true;
    var rblList1 = document.getElementById(rbQuestionList);
    var arrayOfCheckBoxes = rblList1.getElementsByTagName("input");
    var arrayOfCheckBoxLabels = rblList1.getElementsByTagName("label");
    var j = 0;
    
    blnError = getRadioSelectedValue(rblList1);
    
    if (blnError)
        document.getElementById("err_" + rbQuestionList).style.display = "none";
    else
        document.getElementById("err_" + rbQuestionList).style.display = "inline";             
    
    return blnError;
}

function fnRadioButtonVendorType(rbQuestionList)
{
    var rblList1 = document.getElementById(rbQuestionList);
    var arrayOfCheckBoxes = rblList1.getElementsByTagName("input");
    var arrayOfCheckBoxLabels = rblList1.getElementsByTagName("label");
    var j = 0;   
    
    for(var i=0;i<arrayOfCheckBoxes.length;i++)
    {
        var rblList1 = arrayOfCheckBoxes[i].id;   
        if(document.getElementById(rblList1).checked)
        {
            if (arrayOfCheckBoxLabels[i].innerHTML == "Consultant")
            {
                document.getElementById('spnConsultant').style.display = "inline";
                document.getElementById('spnContractor').style.display = "none";                
                document.getElementById('divVendorRegistration').style.display = "inline";
                document.getElementById('divConsultant').style.display = "inline";
                document.getElementById('divContractors').style.display = "none";
                document.getElementById('divThanks').style.display = "none";                  
            }
            else if (arrayOfCheckBoxLabels[i].innerHTML == "Contractor")
            {       
                document.getElementById('spnConsultant').style.display = "none";
                document.getElementById('spnContractor').style.display = "inline";    
                document.getElementById('divVendorRegistration').style.display = "inline";     
                document.getElementById('divConsultant').style.display = "none";
                document.getElementById('divContractors').style.display = "inline";                
                document.getElementById('divThanks').style.display = "none";                
            }
        }
    }
   
}

function fnCheckOthersText(divid,strFieldName)
{
    var blnError = true;
    if (document.getElementById(divid).style.display == "inline")
    {
        blnError = fnCheckForEmpty(strFieldName,"Please fill this");
    }   
    if (blnError) 
    {
        fnHideID("err_" + strFieldName);       
    }        
    else
    {
         fnShowID("err_" + strFieldName);     
    }
        
    return blnError;
}

function fnValidateOtherFields(strFieldName)
{
    var blnError = true;
    
    if (blnError) 
    {
        if (strFieldName == "txtOthers18")
        {
            blnError = fnCheckOthersText('divOthers18','txtOthers18');
        }
        if (strFieldName == "txtOthers19")
        {
            blnError = fnCheckOthersText('divOthers19','txtOthers19');
        }
        if (strFieldName == "txtOthers39")
        {
            blnError = fnCheckOthersText('divOthers39','txtOthers39');
        }
        if (strFieldName == "txtOthers44")
        {
            blnError = fnCheckOthersText('divOthers44','txtOthers44');
        }
    }        
    
    return blnError;
}

function fnValidateIdentificationNo(strFieldName)
{
    var blnError = true;
    
    blnError = fnIsIdentificationNoValid(strFieldName)
    
    if (blnError) 
        fnValidationPassed(strFieldName);
    else
        fnValidationFailed(strFieldName);
    return blnError;
}

function fnIsIdentificationNoValid(strFieldName)
{
    var blnError = true;
    
    if (blnError) blnError = fnCheckForEmpty(strFieldName,"Please enter Identification Number");
    if (blnError) blnError = fnCheckForAlphaNumeric(strFieldName,"Please enter valid Identification Number");
    
    return blnError;
}

function fnChangePersonalInfoImage(divid,imgid)
{
    fnHideID(divid);
    document.getElementById(imgid).src = "images/arrow_per_down.jpg";
    //fnShowID('divSite1');
}

function fnChangeSiteQuestionsImage(divid,imgid)
{
    fnShowID(divid);
    document.getElementById(imgid).src = "images/arrow_site_up.jpg";
}

function fnChangeSuggestionsImage(divid,imgid)
{
    fnShowID(divid);
    document.getElementById(imgid).src = "images/arrow_sug_up.jpg";
}

function fnValidateSuggestionsField(strFieldName)
{
    var blnError = true;
    
    blnError = fnIsSuggestionsValid(strFieldName)
    
    if (blnError) 
    {
        fnHideID("err_" + strFieldName);
    }
    else
    {
        fnShowID("err_" + strFieldName);
    }        
    return blnError;
}

function fnIsSuggestionsValid(strFieldName)
{
    var blnError = true;
    
    if (blnError) blnError = fnCheckForEmpty(strFieldName,"Please provide your answer for this question.");
    
    return blnError;    
}

// Validate Comments
function fnValidateComments(strFieldName)
{
    var blnError = true;
    
	if (blnError) blnError = fnCheckForEmpty(strFieldName, "Please enter your comments");

    if (blnError) 
        fnValidationPassed(strFieldName);
    else
        fnValidationFailed(strFieldName);

	return blnError;        
}

// Validate Address
function fnValidateAddress(strFieldName)
{
    var blnError = true;
    
    if (blnError) blnError = fnCheckForEmpty(strFieldName,"Please enter your address");
    
    if (blnError)
        fnValidationPassed(strFieldName);
    else
        fnValidationFailed(strFieldName);
        
    return blnError;
}

// Validate City
function fnValidateCity(strFieldName)
{
    var blnError = true;    
    
    if (blnError) blnError = fnCheckForEmpty(strFieldName,"Please enter your city"); 
    
    if (blnError)
    {
        fnValidationPassed(strFieldName);        
    }
    else
    {
        fnValidationFailed(strFieldName);       
    }
        
    return blnError;
}

//Validate Nationality
function fnValidateNationality(strFieldName)
{
    var blnError = true;
    
    if (blnError) blnError = fnCheckForEmpty(strFieldName,"Please enter your nationality");
    
    if (blnError)
        fnValidationPassed(strFieldName);
    else
        fnValidationFailed(strFieldName);
        
    return blnError;
}

//Validate URL

function fnValidateUrl(strFieldName)
{
     var blnError = true;
    
    if (blnError) blnError = fnCheckForEmpty(strFieldName,"Please enter your website");
    if (blnError) blnError = isURL(fnGetFieldValue(strFieldName),strFieldName);   
    
    if (blnError)
        fnValidationPassed(strFieldName);
    else
        fnValidationFailed(strFieldName);
        
    return blnError;
}

function learnRegExp(){
  return /^(ftp|https?):\/\/+(www\.)?[a-z0-9\-\.]{3,}\.[a-z]{3}$/.test(learnRegExp.arguments[0]);
}

function isValidURL(url){ 
    var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/; 
    if(RegExp.test(url)){ 
        return true; 
    }else{ 
        return false; 
    } 
} 



function isURL(argvalue,strFieldName) 
{
    var blnError = true;
    
    if(blnError) blnError = isValidURL(argvalue);
    
    if(blnError)
       return fnHideErrMsg(strFieldName);
    else
       return fnDisplayErrMsg(strFieldName, "Please enter valid url");           
        

//  if (argvalue.indexOf(" ") != -1)
//    return fnDisplayErrMsg(strFieldName, "Please enter valid url"); 
//  else if (argvalue.indexOf("www.") == -1)
//    return fnDisplayErrMsg(strFieldName, "Please enter valid url"); 
//  else if (argvalue == "www.")
//    return fnDisplayErrMsg(strFieldName, "Please enter valid url"); 
//  else if (argvalue.indexOf("www.") > 0)
//    return fnDisplayErrMsg(strFieldName, "Please enter valid url"); 

//  argvalue = argvalue.substring(7, argvalue.length);
//  if (argvalue.indexOf(".") == -1)
//   return fnDisplayErrMsg(strFieldName, "Please enter valid url"); 
//  else if (argvalue.indexOf(".") == 0)
//   return fnDisplayErrMsg(strFieldName, "Please enter valid url"); 
//  else if (argvalue.charAt(argvalue.length - 1) == ".")
//    return fnDisplayErrMsg(strFieldName, "Please enter valid url"); 

//  if (argvalue.indexOf("/") != -1) {
//    argvalue = argvalue.substring(0, argvalue.indexOf("/"));
//    if (argvalue.charAt(argvalue.length - 1) == ".")
//      return fnDisplayErrMsg(strFieldName, "Please enter valid url"); 
//  }

//  if (argvalue.indexOf(":") != -1) {
//    if (argvalue.indexOf(":") == (argvalue.length - 1))
//      return fnDisplayErrMsg(strFieldName, "Please enter valid url"); 
//    else if (argvalue.charAt(argvalue.indexOf(":") + 1) == ".")
//      return fnDisplayErrMsg(strFieldName, "Please enter valid url"); 
//    argvalue = argvalue.substring(0, argvalue.indexOf(":"));
//    if (argvalue.charAt(argvalue.length - 1) == ".")
//     return fnDisplayErrMsg(strFieldName, "Please enter valid url"); 
//  }  
//  
//  return fnHideErrMsg(strFieldName);
}


function fnCheckForCheckBoxCount(strFieldName)
{
    var chkList1 = document.getElementById(strFieldName);
    var arrayOfCheckBoxes = chkList1.getElementsByTagName("input");
    var arrayOfCheckBoxLabels = chkList1.getElementsByTagName("label");
    var j = 0;
            
    for(var i=0;i<arrayOfCheckBoxes.length;i++)
    {
        var chklstid = arrayOfCheckBoxes[i].id;
                    
        if(document.getElementById(chklstid).checked)
        {            
            j += 1;
        }              
    }    	
	return j;
}

// -------------------------------------------------------------------
// CHECK Checkbox
// -------------------------------------------------------------------
		
function fnCheckForCheckBox( divid, txt )
{
    var blnError = true;
    var blnCheckForDevelopment = true;
    var blnCheckForVillas = true;
    var blnCheckForApartments = true;
    var blnCheckForOther = true;
	var chkCount = 0;
	var subChkCount = 0;
	
	chkCount = fnCheckForCheckBoxCount('chkSeaPort');
	chkCount += fnCheckForCheckBoxCount('chkIndustrialPlots');	
	chkCount += fnCheckForCheckBoxCount('chkWarehouse');
	chkCount += fnCheckForCheckBoxCount('chkOffices');
	chkCount += fnCheckForCheckBoxCount('chkRetail');
	chkCount += fnCheckForCheckBoxCount('chkHotels');
	chkCount += fnCheckForCheckBoxCount('chkEntertainment');
	chkCount += fnCheckForCheckBoxCount('chkSchool');
	chkCount += fnCheckForCheckBoxCount('chkHospitals');
	subChkCount = fnCheckForCheckBoxCount('chkDevelopment');
	chkCount += subChkCount;	
	if(subChkCount != 0)
	{
	    if(document.getElementById('DevelopmentPlotsSub').style.display == "inline")
	    {
	        blnCheckForDevelopment = fnCheckForSubCheckBoxCount('chkDevelopment')
	        if(!blnCheckForDevelopment)
	        {
	            document.getElementById('err_rdoPropertyType').style.display = "inline";
                document.getElementById('err_rdoPropertyType').innerHTML = "Please select your development plot type"; 
	        }	       
	    }   
	    else
	    {
	        document.getElementById('DevelopmentPlotsSub').style.display = "inline";	
	        document.getElementById('err_rdoPropertyType').innerHTML = "Please select your development plot type";       
	        subChkCount = 0;
	        //blnCheckForDevelopment = true;
	    }
	}	
	else
	{
	    blnCheckForDevelopment = true;
	}
	subChkCount = fnCheckForCheckBoxCount('chkVillas');
	chkCount += subChkCount;	
	if(subChkCount != 0)
	{
	    if(document.getElementById('VillasSub').style.display == "inline")
	    {
	       blnCheckForVillas = fnCheckForSubCheckBoxCount('chkVillas');
	       if(!blnCheckForVillas)
	       {
	            document.getElementById('err_rdoPropertyType').style.display = "inline";
                document.getElementById('err_rdoPropertyType').innerHTML = "Please select your villa type"; 
	       }
	    }
	    else
	    {
	        document.getElementById('VillasSub').style.display = "inline";	   
	        document.getElementById('err_rdoPropertyType').innerHTML = "Please select your villa type";    
	        subChkCount = 0;
	        //blnCheckForVillas = true;
	    }
	}
	else
	{
	    blnCheckForVillas = true;
	}
	subChkCount = fnCheckForCheckBoxCount('chkApartments');	
	chkCount += subChkCount;	
	if(subChkCount != 0)
	{
	    if(document.getElementById('ApartmentsSub').style.display == "inline")
	    {
	       blnCheckForApartments = fnCheckForSubCheckBoxCount('chkApartments');	       
	       if(!blnCheckForApartments)
	       {
	            document.getElementById('err_rdoPropertyType').style.display = "inline";
                document.getElementById('err_rdoPropertyType').innerHTML = "Please select your apartment type"; 
	       }	      
	    }
	    else
	    {
	        document.getElementById('ApartmentsSub').style.display = "inline";
	        document.getElementById('err_rdoPropertyType').innerHTML = "Please select your apartment type"; 
	        subChkCount = 0;
	        //blnCheckForApartments = true;
	    }
	}
	else
	{
	    blnCheckForApartments = true;
	}
	subChkCount = fnCheckForCheckBoxCount('chkOther');
	chkCount += subChkCount;
	if(subChkCount != 0)
	{
	    if(document.getElementById('OtherInfo').style.display == "inline")
	    {
	       blnCheckForOther = fnCheckForSubCheckBoxCount('chkOther');
	       if(!blnCheckForOther)
	       {
	            document.getElementById('err_rdoPropertyType').style.display = "inline";
                document.getElementById('err_rdoPropertyType').innerHTML = "Please enter your investment type"; 
	       }
	    }
	    else
	    {
	        document.getElementById('OtherInfo').style.display = "inline";
	        document.getElementById('err_rdoPropertyType').innerHTML = "Please enter your investment type"; 
	        subChkCount = 0;
	        //blnCheckForOther = true;
	    }
	}	
	else
	{
	    blnCheckForOther = true;
	}
	
	if ( chkCount == 0 )
	{
	    //document.getElementById("err_" + divid).style.display = "inline";
	    document.getElementById("err_rdoPropertyType").style.display = "inline";
	    //document.getElementById("err_" + divid).innerHTML = txt;
	    document.getElementById("err_rdoPropertyType").innerHTML = txt;
		return false; 
    }
    else if(blnCheckForDevelopment == false || blnCheckForVillas == false ||
         blnCheckForApartments == false ||  blnCheckForOther == false)
         {
            return false;
         }
	else
	{
	    document.getElementById("err_rdoPropertyType").style.display = "none";
	    //document.getElementById("err_" + divid).style.display = "none";
		return true;
	}
}		

function fnCheckForSubCheckBoxCount(chkType)
{
    var blnError = true;
    var subChkCount = 0;
    if(chkType == 'chkDevelopment')
    {
        if(document.getElementById('DevelopmentPlotsSub').style.display == "inline")
        {
            subChkCount += fnCheckForCheckBoxCount('chkResidential');
            subChkCount += fnCheckForCheckBoxCount('chkCommercial');
            if(subChkCount == 0)
            {
                //document.getElementById('err_chkDevelopment').style.display = "inline";
                //document.getElementById('err_rdoPropertyType').style.display = "inline";
                //document.getElementById('err_rdoPropertyType').style.display = "inline";
                //document.getElementById('err_rdoPropertyType').innerHTML = "Please select your preferred plot type";
                blnError = false;
            }
            else
            {
                //fnValidationPassed('chkDevelopment');
                fnValidationPassed('rdoPropertyType');
                blnError = true;
            }
        }
        else
        {
            blnError = true;
        }
    }
    if (chkType == 'chkVillas')
    {
        if(document.getElementById('VillasSub').style.display == "inline")
        {
            subChkCount += fnCheckForCheckBoxCount('chkDuplexes');
            subChkCount += fnCheckForCheckBoxCount('chkStandAlone');
            if (subChkCount == 0)
            {
                //document.getElementById('err_chkVillas').style.display = "inline";
                //document.getElementById('err_rdoPropertyType').style.display = "inline";
                //document.getElementById('err_rdoPropertyType').style.display = "inline";
                //document.getElementById('err_rdoPropertyType').innerHTML = "Please select your preferred villa type";
                blnError = false;
            }
            else
            {
                //fnValidationPassed('chkVillas');
                fnValidationPassed('rdoPropertyType');
                blnError = true;
            }
        }
        else
        {
            blnError = true;
        }
    }
    if (chkType == "chkApartments")
    {
        if(document.getElementById('ApartmentsSub').style.display == "inline")
        {
            subChkCount += fnCheckForCheckBoxCount('chkStudio');
            subChkCount += fnCheckForCheckBoxCount('chkOneBedroom');
            subChkCount += fnCheckForCheckBoxCount('chkTwoBedroom');
            subChkCount += fnCheckForCheckBoxCount('chkThreeBedroom');
            if (subChkCount == 0)
            {
                //document.getElementById('err_chkApartments').style.display = "inline";
                //document.getElementById('err_rdoPropertyType').style.display = "inline";
                //document.getElementById('err_rdoPropertyType').innerHTML = "Please select your preferred apartment type";
                blnError = false;
            }
            else
            {
                //fnValidationPassed('chkApartments');
                fnValidationPassed('rdoPropertyType');
                blnError = true;
            }
        }
        else
        {
            blnError = true;
        }
    }
    if (chkType == "chkOther")
    {
        if(document.getElementById('OtherInfo').style.display == "inline")
        {
            strValue = fnGetFieldValue('txtOthers')            
            if (strValue == "") 
            {
                //document.getElementById('err_rdoPropertyType').style.display = "inline";
                //document.getElementById('err_rdoPropertyType').innerHTML = "Please enter your investment type";
                //document.getElementById('err_txtOthers').style.display = "inline";
                //document.getElementById('err_txtOthers').innerHTML = "<br/>Please enter your investment type";
                blnError = false;                   
            }
            else
            {
                blnError = fnHideErrMsg('txtOthers'); 
            }                
            if(blnError)
            {
                 fnValidationPassed('rdoPropertyType');
                //fnValidationPassed('txtOthers');                
            }
        }
        else
        {
            blnError = true;
        }
    }
    return blnError;
}

function fnValidateInvestmentTypes()
{
    var blnError = true;
    var blnCheckForDevelopment = true;
    var blnCheckForVillas = true;
    var blnCheckForApartments = true;
    var blnCheckForOther = true;
    
    if(blnError) blnError = fnCheckForCheckBox('rdoPropertyType','Please select atleast one of the options');    
//    if(blnError)
//    {
//        if(document.getElementById('DevelopmentPlotsSub').style.display == "inline")
//	    {
//	        blnCheckForDevelopment = fnCheckForSubCheckBoxCount('chkDevelopment')	            
//	    } 	   
//	    if(document.getElementById('VillasSub').style.display == "inline")
//	    {
//	       blnCheckForVillas = fnCheckForSubCheckBoxCount('chkVillas');	      
//	    } 	    
//	    if(document.getElementById('ApartmentsSub').style.display == "inline")
//	    {
//	       blnCheckForApartments = fnCheckForSubCheckBoxCount('chkApartments');	      
//	    } 	  
//	    if(document.getElementById('OtherInfo').style.display == "inline")
//	    {
//	       blnCheckForOther = fnCheckForSubCheckBoxCount('chkOther');	       
//	    }	   
//    }
    
//    if(blnError == true && blnCheckForDevelopment == false)                
//        fnHideID('err_rdoPropertyType');    
//    else if(blnError == true && blnCheckForVillas == false)
//        fnHideID('err_rdoPropertyType'); 
//    else if(blnError == true && blnCheckForApartments == false)
//        fnHideID('err_rdoPropertyType');
//    else if(blnError == true && blnCheckForOther == false)
//        fnHideID('err_rdoPropertyType');                
//    else
    if (blnError)
        fnValidationPassed('rdoPropertyType');    
    else
        fnValidationFailed('rdoPropertyType');
        
    return blnError;
}

// Validate Contact Person
function fnValidateContactPerson(strFieldName)
{
	var blnError = true;

    blnError = fnIsContactPersonValid(strFieldName);

    if (blnError) 
        fnValidationPassed(strFieldName);
    else
        fnValidationFailed(strFieldName);
    
	return blnError;
}

function fnIsContactPersonValid(strFieldName)
{
    var blnError = true;
    
    if (blnError) blnError = fnCheckForEmpty(strFieldName);    
    
    return blnError;
}

// Validate Required Field
function fnValidateRequiredField(strFieldName)
{
	var blnError = true;

    blnError = fnIsFieldValueValid(strFieldName);

    if (blnError) 
        fnValidationPassed(strFieldName);
    else
        fnValidationFailed(strFieldName);
    
	return blnError;
}

function fnIsFieldValueValid(strFieldName)
{
    var blnError = true;
    
    if (blnError) blnError = fnCheckForEmptyField(strFieldName);    
    
    return blnError;
}

function fnCheckForEmptyField(strFieldName)
{
    strValue = fnGetFieldValue(strFieldName)
    if (strValue == "") 
        return fnDisplayErrMsgField(strFieldName);
    else
        return fnHideErrMsg(strFieldName);
}

function fnDisplayErrMsgField(strFieldName, errObj)
{	    
    fnShowID("err_" + strFieldName);   
	return false;
}


function fnValidateUrlNonMandatory(strFieldName)
{
     var blnError = true;
    
    if(fnGetFieldValue(strFieldName) != "")
    {
        if (blnError) blnError = isURL(fnGetFieldValue(strFieldName),strFieldName);  
    } 
    
    if (blnError)
        fnValidationPassed(strFieldName);
    else
        fnValidationFailed(strFieldName);
        
    return blnError;
}


// Validate Drop Down List
function fnValidateDropDownList(strFieldName)
{
    var blnError = true;
    
    blnError = fnIsDDLSelected(strFieldName);

    if (blnError) 
        fnValidationPassed(strFieldName);
    else
        fnValidationFailed(strFieldName);
   
	return blnError;    
}

function fnIsDDLSelected(strFieldName)
{
    var blnError = true;
    
	if (blnError) blnError = fnCheckForDDList(strFieldName);
    
    return blnError;
}


function fnCheckForDDList(strFieldName)
{
    strValue = fnGetFieldValue(strFieldName)
    
    if (strValue == 0) 
    {
        return fnDisplayErrMsgField(strFieldName);
    }
    else
        return fnHideErrMsg(strFieldName);  
}

function fnValidateInvestmentTypesBuyer()
{
    var blnError = true;
    var blnCheckForDevelopment = true;
    var blnCheckForVillas = true;
    var blnCheckForApartments = true;
    var blnCheckForOther = true;
    
    if(blnError) blnError = fnCheckForCheckBoxBuyer('rdoPropertyType','Please select atleast one of the options');    
    if (blnError)
        fnValidationPassed('rdoPropertyType');    
    else
        fnValidationFailed('rdoPropertyType');
        
    return blnError;
}


function fnCheckForCheckBoxBuyer( divid, txt )
{
    var blnError = true;
    var blnCheckForDevelopment = true;
    var blnCheckForVillas = true;
    var blnCheckForApartments = true;
    var blnCheckForOther = true;
	var chkCount = 0;
	var subChkCount = 0;
	
//	chkCount = fnCheckForCheckBoxCount('chkSeaPort');
//	chkCount += fnCheckForCheckBoxCount('chkIndustrialPlots');	
//	chkCount += fnCheckForCheckBoxCount('chkWarehouse');
//	chkCount += fnCheckForCheckBoxCount('chkOffices');
//	chkCount += fnCheckForCheckBoxCount('chkRetail');
//	chkCount += fnCheckForCheckBoxCount('chkHotels');
//	chkCount += fnCheckForCheckBoxCount('chkEntertainment');
//	chkCount += fnCheckForCheckBoxCount('chkSchool');
//	chkCount += fnCheckForCheckBoxCount('chkHospitals');
	subChkCount = fnCheckForCheckBoxCount('chkDevelopment');
	chkCount += subChkCount;	
	if(subChkCount != 0)
	{
	    if(document.getElementById('DevelopmentPlotsSub').style.display == "inline")
	    {
	        blnCheckForDevelopment = fnCheckForSubCheckBoxCount('chkDevelopment')
	        if(!blnCheckForDevelopment)
	        {
	            document.getElementById('err_rdoPropertyType').style.display = "inline";
                document.getElementById('err_rdoPropertyType').innerHTML = "Please select your development plot type"; 
	        }	       
	    }   
	    else
	    {
	        document.getElementById('DevelopmentPlotsSub').style.display = "inline";	
	        document.getElementById('err_rdoPropertyType').innerHTML = "Please select your development plot type";       
	        subChkCount = 0;
	        //blnCheckForDevelopment = true;
	    }
	}	
	else
	{
	    blnCheckForDevelopment = true;
	}
	subChkCount = fnCheckForCheckBoxCount('chkMainResidential');
	chkCount += subChkCount;	
	if(subChkCount != 0)
	{
//	    if(document.getElementById('VillasSub').style.display == "inline")
//	    {
//	       blnCheckForVillas = fnCheckForSubCheckBoxCount('chkVillas');
//	       if(!blnCheckForVillas)
//	       {
//	            document.getElementById('err_rdoPropertyType').style.display = "inline";
//                document.getElementById('err_rdoPropertyType').innerHTML = "Please select your villa type"; 
//	       }
//	    }
//	    else
//	    {
//	        document.getElementById('VillasSub').style.display = "inline";	   
//	        document.getElementById('err_rdoPropertyType').innerHTML = "Please select your villa type";    
//	        subChkCount = 0;
//	        //blnCheckForVillas = true;
//	    }
	}
	else
	{
	    blnCheckForVillas = true;
	}
	subChkCount = fnCheckForCheckBoxCount('chkIndustrialPlots');	
	chkCount += subChkCount;	
	if(subChkCount != 0)
	{
//	    if(document.getElementById('ApartmentsSub').style.display == "inline")
//	    {
//	       blnCheckForApartments = fnCheckForSubCheckBoxCount('chkApartments');	       
//	       if(!blnCheckForApartments)
//	       {
//	            document.getElementById('err_rdoPropertyType').style.display = "inline";
//                document.getElementById('err_rdoPropertyType').innerHTML = "Please select your apartment type"; 
//	       }	      
//	    }
//	    else
//	    {
//	        document.getElementById('ApartmentsSub').style.display = "inline";
//	        document.getElementById('err_rdoPropertyType').innerHTML = "Please select your apartment type"; 
//	        subChkCount = 0;
//	        //blnCheckForApartments = true;
//	    }
	}
	else
	{
	    blnCheckForApartments = true;
	}
	subChkCount = fnCheckForCheckBoxCount('chkOther');
	chkCount += subChkCount;
	if(subChkCount != 0)
	{
	    if(document.getElementById('OtherInfo').style.display == "inline")
	    {
	       blnCheckForOther = fnCheckForSubCheckBoxCount('chkOther');
	       if(!blnCheckForOther)
	       {
	            document.getElementById('err_rdoPropertyType').style.display = "inline";
                document.getElementById('err_rdoPropertyType').innerHTML = "Please enter your investment type"; 
	       }
	    }
	    else
	    {
	        document.getElementById('OtherInfo').style.display = "inline";
	        document.getElementById('err_rdoPropertyType').innerHTML = "Please enter your investment type"; 
	        subChkCount = 0;
	        //blnCheckForOther = true;
	    }
	}	
	else
	{
	    blnCheckForOther = true;
	}
	
	if ( chkCount == 0 )
	{
	    //document.getElementById("err_" + divid).style.display = "inline";
	    document.getElementById("err_rdoPropertyType").style.display = "inline";
	    //document.getElementById("err_" + divid).innerHTML = txt;
	    document.getElementById("err_rdoPropertyType").innerHTML = txt;
		return false; 
    }
    else if(blnCheckForDevelopment == false || blnCheckForVillas == false ||
         blnCheckForApartments == false ||  blnCheckForOther == false)
         {
            return false;
         }
	else
	{
	    document.getElementById("err_rdoPropertyType").style.display = "none";
	    //document.getElementById("err_" + divid).style.display = "none";
		return true;
	}
}		


