// Copyright (c) 2000 Macromedia. All rights reserved.

// Run the webLayer function
webLayer = GetWebLayer();

var alertMessage;
var promptMessage;
var tmp  = (Files.getLanguageDirectory()).split("/");
var lang = ((tmp[tmp.length-1]).substr(0,2)).toLowerCase();

switch (lang)
{
	// German
	case "de":
	case "ge":
		alertMessage = "Es wurden keine leeren ALT-Text gefunden.";
		promptMessage = "Mit diesem Befehl wird bei Hotspots und Segmenten, denen im Bedienfeld Objekt bzw. im Dialogfeld HTML-Einrichtung noch kein ALT-Text zugewiesen wurde, ALT-Text eingefügt. Geben Sie den ALT-Text ein:";
		break;

	// French
	case "fr":
		alertMessage = "Aucune texte ALT vierge n'a été trouvée.";
		promptMessage = "Cette commande permet d'indiquer le texte secondaire (ALT) pour les découpes et les références pour lesquelles aucune balise ALT n'a été indiquée dans le panneau 'Objet' ou dans la boîte de dialogue 'Configuration HTML'. Tapez le texte de la balise ALT :";
		break;

	// Italian
	case "it":
		alertMessage = "Nessun testo ALT vuoto individuato.";
		promptMessage = "Questo comando permette di inserire il testo ALT per i punti attivi e porzioni se non è stato specificato nel pannello Oggetto o nella finestra di dialogo Imposta HTML. Immettere il testo ALT:";
		break;

	// Spanish
	case "es":
	case "sp":
		alertMessage = "No se encontraron testo ALT vacíos.";
		promptMessage = "Este comando introduce texto ALT en las zonas interactivas y divisiones que no tengan códigos ALT especificados en el panel Objeto o el cuadro de diálogo Configuración de HTML. Escriba el texto ALT:";
		break;

	// Japanese
	case "ja":
		alertMessage = "空の ALT テキストが見つかりません。";
		promptMessage = "[オブジェクト] パネルや [HTML の設定] ダイアログボックスで、ALT テキストが指定されていないホットスポットおよびスライスに Alt テキストを入力します。Alt テキストを入力してください。";
		break;

	// Chinese (Simplified)
	case "si":
		alertMessage = "未找到空白 ALT 文字";
		promptMessage = "此命令可为未在“对象”对话框或“HTML 设置”对话框中指定 ALT 文字的热点或切片输入 ALT 文字。输入 ALT 文字:";
		break;

	// Chinese (Traditional)
	case "tr":
		alertMessage = "找不到空白替代文字。";
		promptMessage = "這個命令可為未於「物件」面板或「HTML 設定」對話框中指定替代文字的連結區和分割輸入替代文字。請輸入替代文字：";
		break;

	// Korean
	case "ko":
		alertMessage = "빈 대체 태그를 찾을 수 없습니다.";
		promptMessage = "이 명령은 객체 패널 또는 HTML 설정에서 지정된 대체 태그가 없는 핫스팟과 슬라이스에 대체 텍스트를 입력합니다. 대체 텍스트를 입력하십시오:";
		break;

	// English
	case "en":
	default:
		alertMessage = "No blank ALT Text were found.";
		promptMessage = "This command enters ALT text for hotspots and slices that do not have ALT text specified in the Property inspector or HTML Setup dialog. Enter ALT text:";
		break;
}
// Check to make that the webLayer has objects on it
if(webLayer != null) {
	// Check to make sure that the web layer and the
	// default alt tag are blank
	if(!ContainsBlankWebObjects(webLayer) && !DefaultAltTextIsBlank()) {
		alert(alertMessage);
	}
	else {
		// Prompt for the new alt tag
		altTag = prompt(promptMessage);
		// Check to make sure the user input something
		if (altTag != null){

			// set the default alt tag for the document
			if (DefaultAltTextIsBlank()) {
				fw.getDocumentDOM().defaultAltText = altTag;
			}

			// set the alt tag for the elements
			for (i in theWebLayer.elements) {
				oldAltTag = theWebLayer.elements[i].altText;
				// Firworks sometimes returns NULL, and sometimes
				//  the empty string ""
				if(oldAltTag == null || oldAltTag == "")
					theWebLayer.elements[i].altText = altTag;
			}
		}
	}
}

// -----------------------------------------------------------
function GetWebLayer()
{
	theWebLayer = null;

	// Get the layers list
	layers = fw.getDocumentDOM().layers;
	for (layerIndex in layers) {
		if (layers[layerIndex].layerType == "web"){
			theWebLayer = fw.getDocumentDOM().frames[0].layers[layerIndex];

			break;
		}
	}

	return theWebLayer;
}

// -----------------------------------------------------------
function ContainsBlankWebObjects(aLayer) {

	if(aLayer != null) {

		for (i in aLayer.elements) {
			// Firworks sometimes returns NULL, and sometimes the empty string ""
			if(aLayer.elements[i].altText == null || aLayer.elements[i].altText == "")
				return(true);
		}
	}

	// No blank objects found
	return(false);
}

// -----------------------------------------------------------

function DefaultAltTextIsBlank() {
	return(fw.getDocumentDOM().defaultAltText == null || fw.getDocumentDOM().defaultAltText == "");
}

// -----------------------------------------------------------
