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

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

function receiveArguments(newcategory)
{
    // Check if the document already contains a value for the 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;
            break;
        }
    }
    if (!foundEnclosure)
    {
        // Could not find the enclosure meta-tag or the tag was empty
        
        //Open up the remote browse for file dialog
		while(1)
		{
			var enclosureFile = dw.popUpEnclosureFileBrowser();
			
			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 value for 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()
{
	if((dw.isCCOnline()) && dw.hasAnyWebsites() && 
	   (CCWorkspaceManager.getManager(dw.getDocumentDOM()) != null) && 
	   (CCWorkspaceManager.getManager(dw.getDocumentDOM()).isBlogSite()) &&
	   (CCWorkspaceManager.getManager(dw.getDocumentDOM()).getState() == 'edit') &&
	   (CCWorkspaceManager.getManager(dw.getDocumentDOM()).shouldUseDefaultEditor()) )
		return true;
	else
		return false;
}


</script>
</head>

<body>
</body>
</html>

