
var OPTIONAL_COST_DESCRIPTION = 10;
var OPTIONAL_COST_CATEGORIES = 10;
var OPTIONAL_COST_VISITOR_INFO = 10;
var OPTIONAL_COST_FACILITIES = 10;
var OPTIONAL_COST_RATE_CARD = 5;
var OPTIONAL_COST_IMAGE_BAND_1_MAX = 5;
var OPTIONAL_COST_IMAGE_BAND_2_MAX = 10;
var OPTIONAL_COST_IMAGE_BAND_1 = 20;
var OPTIONAL_COST_IMAGE_BAND_2 = 35;
var OPTIONAL_COST_IMAGE_EXTRA = 2;
var OPTIONAL_COST_VIDEO_EACH = 15;
var OPTIONAL_COST_AUDIO_EACH = 15;
var OPTIONAL_COST_DOCUMENT_EACH = 5;

function ResetForm() {

	document.frmAdAdmin.reset();
	
}

function PreviewText()
	{
		
		if (document.getElementById('OVPreview'))
			{
				if (document.getElementById('OVPreview').style.display == 'none')
					{
						document.getElementById('OVPreview').style.display = 'block';
						document.getElementById('OVPreview').innerHTML = document.frmMain.txtDetails.value;
						
						if (document.getElementById('PreviewLink'))
							{
								document.getElementById('PreviewLink').innerText = 'Hide preview';
							}
					}
				else
					{
						document.getElementById('OVPreview').style.display = 'none';

						if (document.getElementById('PreviewLink'))
							{
								document.getElementById('PreviewLink').innerText = 'Show preview';
							}
					}
			}
			
			
	}	

function WizardMove(iDirection)
	{
		if (parseInt(iDirection) > 0)
			{
				FormSubmit('WizardMoveAdd');
			}
		else
			{
				FormSubmit('WizardMoveBack');
			}
	}	

function WizardComplete()
	{
		FormSubmit('WizardPreview');
	}	
	
function SetListingPeriods(objCombo)
    {
        var iSelectedListingType = parseInt(objCombo[objCombo.selectedIndex].value);
        var objPeriods = document.getElementById('ListingPeriod');
        
        if (objPeriods) 
            { 
                objPeriods.options.length = 0; 
            
                if (iSelectedListingType == 0)
                    {
                        // Mini listing, only 12 months allowed
                        objPeriods.options[0] = new Option('12 months', 12);               
                    }
                else
                    {
                        // Full listing - all options
                        objPeriods.options[0] = new Option('3 months', 3);               
                        objPeriods.options[1] = new Option('6 months', 6);               
                        objPeriods.options[2] = new Option('12 months', 12);               
                        
                        objPeriods.selectedIndex = 2; // Make sure that 12 months is selected
                    }
                    
                // Recalculate the costs //
                SetListingCost();                    
            }
    }

function CheckCategories(objClickedItem)
    {
    
        if (objClickedItem.checked == true)
            {
                var bAllowMultipleCategories = false;
            
                if (document.getElementById('chkAlCat')) 
                    {
                        bAllowMultipleCategories = document.getElementById('chkAlCat').value; 
                    }

                if ((bAllowMultipleCategories == 0) || (bAllowMultipleCategories == false) || (bAllowMultipleCategories == 'false') )
                    {

                        if (document.frmMain.chkCat)
                            {
                                if (document.frmMain.chkCat.length)
                                    {
                                    
                                        var iCatLoop;
                                        
                                        for (iCatLoop = 0; iCatLoop < document.frmMain.chkCat.length; iCatLoop++)
                                            {
                                                if (document.frmMain.chkCat[iCatLoop].id != objClickedItem.id)
                                                    {
                                                        document.frmMain.chkCat[iCatLoop].checked = false;
                                                    }
                                            }
                                    
                                    }                            
                            }
                        
                    }
            }
    
    }
        
	

function HideShowFileSelectionPanel(bShow)
    {
        if (document.getElementById('divFileTypeSelector')) { document.getElementById('divFileTypeSelector').style.display = (bShow == 1 ? 'block' : 'none'); }
        if (document.getElementById('divItemTitle')) { document.getElementById('divItemTitle').style.display = (bShow == 1 ? 'block' : 'none'); }
        if (document.getElementById('divItemDescription')) { document.getElementById('divItemDescription').style.display = (bShow == 1 ? 'block' : 'none'); }
        if (document.getElementById('divFileSelector')) { document.getElementById('divFileSelector').style.display = (bShow == 1 ? 'block' : 'none'); }
        
    }
    
function CheckOVChars(OVText)    
    {
        // Trim if required //
        if (OVText.value.length > 500) { OVText.value = OVText.value.substr(0, 500); }
        
        // Count the number of characters in the overview text box//
        if (document.getElementById('OVCharsLeft')) 
            {
                document.getElementById('OVCharsLeft').innerHTML = (500 - OVText.value.length) + ' character' + ((500 - OVText.value.length) != 1 ? 's' : '') + ' remaining';
            }
    }
