function onYearGraduationChange()
{
    var minYrs = document.getElementById('minYearsExp').value;
    if (minYrs != '-1')
    {
        if (document.getElementById('drpYearOfGraduate').value != 'Please Select')
        {
            if (document.getElementById('currentYear').value - document.getElementById('drpYearOfGraduate').value < minYrs)
            {
                document.getElementById('validationMessage').innerHTML = 'Sorry this listing requires ' + minYrs + '+ yrs post graduate experience';
            }
            else
            {
                document.getElementById('validationMessage').innerHTML = '';
            }
        }
        else
        {
            document.getElementById('validationMessage').innerHTML = '';
        }
    }    
}

//////////////////////////////////////////

function trim(stringToTrim)
{
    return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function validateFCKEditor(FCKeditor1)
{    
    retVal = true;
    if (getEditorValue(FCKeditor1)=='')
    {
        alert("Please define an Email Template..");        
        retVal = false;
    }
    else if (trim(document.getElementById('txtEmailSubject').value) == '')
    {
        alert("Please enter the Email Subject..");
        document.getElementById('txtEmailSubject').focus();
        retVal = false;
    }
    else if (trim(document.getElementById('txtFromEmail').value) == '')
    {
        alert("Please enter the From Email..");
        document.getElementById('txtFromEmail').focus();
        retVal = false;
    }
        
    return retVal;
}

function getEditorValue( instanceName )
{
    // Get the editor instance that we want to interact with.
    var oEditor = FCKeditorAPI.GetInstance( instanceName ) ;

    // Get the editor contents as XHTML.
    return oEditor.GetXHTML( true ) ; // "true" means you want it formatted.
}

function getCheckedValue(radioObj) {
    // return the value of the radio button that is checked
    // return an empty string if none are checked, or
    // there are no radio buttons
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}	
	return "";
}

function disableOption(chkBoxId)
{
     document.getElementById(chkBoxId).checked = false;
}

function checkDurations(chkHomeId, chkCountryId, chkeJobsId, rdoDuration)
{
    if (document.getElementById(chkHomeId).checked == false && document.getElementById(chkCountryId).checked == false && document.getElementById(chkeJobsId).checked == false )
    {
        var radioLength = rdoDuration.length;
        
        for (var i = 0; i < radioLength; i++) 
        {
		    rdoDuration[i].checked = false;
		}
    }
}

function validateFeaturedListingOptions(chkHomeId, chkCountryId, chkeJobsId, selectedDuration)
{
    if (
        (
            document.getElementById(chkHomeId).checked ||
            document.getElementById(chkCountryId).checked ||
            document.getElementById(chkeJobsId).checked
        )
        &&
        (
            selectedDuration == ""
        )
    )
    {
        alert('Please select the duration for which you would like to feature your listing.');
        return false;
    }
    else if (
        (
            selectedDuration != ""
        )
        &&
        (
            document.getElementById(chkHomeId).checked == false &&
            document.getElementById(chkCountryId).checked == false &&
            document.getElementById(chkeJobsId).checked == false 
        )
    )
    {
        alert('Please select one or more placement options for your featured listing.');
        return false;
    }
    else
    {
        return true;
    }
}

function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}
