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

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

function receiveArguments(newcategory)
{
    // Check if the document 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)
    {
        //Couldnt find the enclosure meta-tag
        
        //Open up the browse for internet file dialog    
        while(1)
		{
			var enclosureFile = dw.blogBrowseToInternetFile();
			
			if(enclosureFile.length == 0)
	            return; // No selection made

			var retVal = dw.validateEnclosureFile(enclosureFile);
			if(!retVal)
				return;
			else
				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()
{
	if((dw.isCCOnline()) && 
	   (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 onLoad="canAcceptCommand()">
</body>
</html>

