<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<html xmlns:MMString="http://www.macromedia.com/schemes/data/string/">
<head>
<title><MMString:loadString id="Menus/MM/ccBlogEnclosureLocal/title" /></title>

<script language="javascript" src="../../Shared/MM/Scripts/CMN/ccBlogMetaDataStrings.js">

function receiveArguments(newcategory)
{
    // Check if the document contains a value enclosure meta-tag
    theDom = dw.getDocumentDOM();
    metatags = theDom.getElementsByTagName("meta");
    count = metatags.length;
    var enclosureVal;
    var foundEnclosure = 0;
    for (i = 0; i < count; i++)
    { 
        if (metatags[i].name == TEMPLATE_ENCLOSURE)
        {
            enclosureVal = metatags[i].content;
            if(enclosureVal.length > 0)
                foundEnclosure = 1; // Meta-tag contains content
            break;
        }
    }
    if (!foundEnclosure)
    {
        // Could not find the enclosure meta-tag or the tag was empty
        
        //Open the local file browser
        // Set the filter as none.. so that any file can be selected
        var filter = new Array("");
    
	 	while(1)
		{
                        // Open the browse for file dialog
			var enclosureFile = dw.browseForFileURL("open", dw.loadString("blog enclosure/enclosure title"), false, true, filter, "", "", "desktop");
			
			if(enclosureFile.length == 0)
	            return; // No selection made

			var retVal = dw.validateEnclosureFile(enclosureFile);
			if(retVal)
				break;
		}
        
        // TODO: Not sure if we need to check the file size. This needs to be confirmed
        if (dw.appName == "Contribute" && dw.isGreaterThanMaxDependentFileSize(enclosureFile))
            return '';
          
        //Insert the enclosure meta-tag  
        dw.getDocumentDOM().insertBlogMetaTag(TEMPLATE_ENCLOSURE, enclosureFile);
    }
    else
    {
		// Enclosure exists... Show an alert
		var errMsg = dw.loadString("blog enclosure/enclosure exists");
		alert(errMsg);
	}
    //Update the workspace manager UI
    CCWorkspaceManager.getManager(dw.getDocumentDOM()).updateUI();
    return;
}

function canAcceptCommand()
{
    var dwDOM = dw.getDocumentDOM();
    var wm = CCWorkspaceManager.getManager(dwDOM);
	if( (wm != null) && wm.isBlogSite() && (wm.getState() == 'edit') && wm.shouldUseDefaultEditor() &&
	    (wm.isAudioSupported() || wm.isVideoSupported()) )
		return true;
	else
		return false;
		
}
</script>
</head>

<body>
</body>
</html>


