function ShowNextMedia(e) {
    if (e.preventDefault)
	    e.preventDefault();

	if (!manager) {
		return false;
	}

    if (manager.medias.length <= 0) {
        return false;
    }

    if (manager.currentMediaIndex < (manager.medias.length - 1)) {
        manager.currentMediaIndex++;
        manager.UpdateView();
    }

    return false;
};

function ShowPrevMedia(e) {
    if (e.preventDefault) {
	    e.preventDefault();
	}

	if (!manager) {
		return false;
	}

    if (manager.medias.length <= 0) {
        return false;
    }

    if (manager.currentMediaIndex > 0)
    {
        manager.currentMediaIndex--;
        manager.UpdateView();
    }

    return false;
};

function ChangeMediaSelection(index, isPhoto) {
	if (!manager) {
		return false;
	}

    if (manager.medias.length <= 0) {
        return false;
    }

    if (index < manager.medias.length) {
        manager.currentMediaIndex = manager.SearchIndex(index, isPhoto);
        manager.UpdateView();
    }

    return false;
};

function MediaManager(catId, albumId, mainHost, password, domain, theme, isPublishing)
{
    this._length = 0;
    this.CategoryId = catId;
    this.AlbumId = albumId;
    this.MainHost = mainHost;
    this.medias = new Array();
    this.currentTooltipMediaIndex = 0;
    this.currentMediaIndex = 0;
    this.Password = password;
    this.Domain = domain;
    this.Theme = theme;
    this.IsPublishing = isPublishing;
    
    this.PhotoCount = function() {
        var result = 0;
        
        for (var k = 0; k < this._length; k++) {
            var p = this.medias[k];
            
            if (p.IsPhoto) {
                result = result + 1;
            }
        }

        return result;
    }
    
    this.AddMedia = function (thumbnailUrl, url, alternateText, elementId, body, index, id, cleanedAlternateText, isPhoto) {
	    this.medias[this._length] = new Media();
	    this.medias[this._length].Index = index;
	    this.medias[this._length].ElementId = elementId;
	    this.medias[this._length].ThumbnailUrl = thumbnailUrl;
	    this.medias[this._length].Url = url;
	    this.medias[this._length].AlternateText = alternateText;
	    this.medias[this._length].Body = body;
	    this.medias[this._length].MediaId = id;
	    this.medias[this._length].CleanedAlternateText = cleanedAlternateText;
	    this.medias[this._length].IsPhoto = isPhoto;
	    this._length++;
    };
    
    this.SearchIndex = function(index, isPhoto) {
        for (var k = 0; k < this._length; k++) {
            var p = this.medias[k];
            
            if ((p.Index == index) && (p.IsPhoto == isPhoto)) {
                return k;
            }
        }

        return -1;
    };
    
    this.GetCurrentTooltipedMedia = function() {
        return this.medias[this.currentTooltipMediaIndex];
    };
    
    this.GetCurrentMedia = function() {
        return this.medias[this.currentMediaIndex];
    };
    
    this.UpdateView = function() {
        var el = $("container");

        for (var i = 0; i < el.childNodes.length; i++) {
            el.removeChild(el.childNodes[i]);
        }
            
        var m = this.GetCurrentMedia();
        var elToAdd;
        
        if (m.IsPhoto) {
            if (!bh.IsIe()) {
                elToAdd1 = document.createElement("a");
                
                if (manager.Password == "") {
                    elToAdd1.setAttribute("href", "http://" + manager.MainHost + "/ShowMedia.aspx?id=" + m.MediaId + "&albumId=" + manager.AlbumId + "&p=" + manager.IsPublishing + "&lng=" + localizer.ISOLanguage());
                }
                else {
                    elToAdd1.setAttribute("href", "http://" + manager.MainHost + "/ShowMedia.aspx?id=" + m.MediaId + "&albumId=" + manager.AlbumId + "&p=" + manager.IsPublishing + "&cp=" + manager.Password + "&lng=" + localizer.ISOLanguage());
                }
                
                elToAdd = document.createElement("img");
                elToAdd.setAttribute("src", m.Url);
                
                elToAdd.setAttribute("alt", m.CleanedAlternateText.replace('"', '\\"'));
                elToAdd.setAttribute("title", m.CleanedAlternateText.replace('"', '\\"'));
                elToAdd.setAttribute("style", "max-width : 520px; border : none;");
                
                elToAdd1.appendChild(elToAdd);
                el.appendChild(elToAdd1);
            }
            else
            {
                if (manager.Password == "") {
                    el.innerHTML = "<a href=\"http://" + manager.MainHost + "/ShowMedia.aspx?id=" + m.MediaId + "&albumId=" + manager.AlbumId + "&p=" + manager.IsPublishing + "&lng=" + localizer.ISOLanguage() + "\"><img src=\"" + m.Url + "\" alt=\"" + m.AlternateText.replace('"', '\\"') + "\" style=\"max-width : 520px; border : none;\" /></a>";
                }
                else {
                    el.innerHTML = "<a href=\"http://" + manager.MainHost + "/ShowMedia.aspx?id=" + m.MediaId + "&albumId=" + manager.AlbumId + "&p=" + manager.IsPublishing + "&cp=" + manager.Password + "&lng=" + localizer.ISOLanguage() + "\"><img src=\"" + m.Url + "\" alt=\"" + m.AlternateText.replace('"', '\\"') + "\" style=\"max-width : 520px; border : none;\" /></a>";
                }
            }
        }
        else {
            if (!bh.IsIe()) {
                elToAdd = document.createElement("embed");
                elToAdd.setAttribute("wmode", "transparent");
                elToAdd.setAttribute("src", "http://" + manager.MainHost + "/ThirdParty/FlvPlayer/FlvPlayer.swf");
                elToAdd.setAttribute("quality", "high");
                elToAdd.setAttribute("width", "450");
                elToAdd.setAttribute("height", "253");
                elToAdd.setAttribute("name", "FlvPlayer");
                elToAdd.setAttribute("align", "middle");
                elToAdd.setAttribute("flashvars", "file=" + m.Url + "&#038;shownavigation=true");
                elToAdd.setAttribute("type", "application/x-shockwave-flash");
                elToAdd.setAttribute("pluginspage", "http://www.adobe.com/go/getflashplayer");
                el.appendChild(elToAdd);
            }
            else {
                el.innerHTML = "<embed pluginspage=\"http://www.adobe.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" flashvars=\"file=" + m.Url + "&#038;shownavigation=true\" align=\"middle\" name=\"FlvPlayer\" width=\"450\" height=\"253\" quality=\"high\" wmode=\"transparent\" src=\"http://" + manager.MainHost + "/ThirdParty/FlvPlayer/FlvPlayer.swf\" />";
            }
        }
        
        if ($("labelCurrentMedia")) {
			$("labelCurrentMedia").innerHTML = (this.currentMediaIndex + 1);
		}
        
        if ($("lbSubmitFriend")) {
			if (manager.Password == "") {
				$("lbSubmitFriend").href = "http://" + manager.MainHost + "/SubmitFriend.aspx?id=" + m.MediaId + "&albumId=" + manager.AlbumId + "&p=" + manager.IsPublishing + "&lng=" + localizer.ISOLanguage();
			}
			else {
				$("lbSubmitFriend").href = "http://" + manager.MainHost + "/SubmitFriend.aspx?id=" + m.MediaId + "&albumId=" + manager.AlbumId + "&p=" + manager.IsPublishing + "&cp=" + manager.Password + "&lng=" + localizer.ISOLanguage();
			}
        }
        
        if ($("ButtonPrev")) {
			if (manager.currentMediaIndex <= 0) {
				$("ButtonPrev").src = "http://" + manager.MainHost + "/App_Themes/" + manager.Theme + "/images/pulsante_prev_off.gif";
			}
			else {
				$("ButtonPrev").src = "http://" + manager.MainHost + "/App_Themes/" + manager.Theme + "/images/pulsante_prev.gif";
			}
        }
        
        if ($("ButtonNext")) {
			if (manager.currentMediaIndex >= manager.medias.length - 1) {
				$("ButtonNext").src = "http://" + manager.MainHost + "/App_Themes/" + manager.Theme + "/images/pulsante_next_off.gif";
			}
			else {
				$("ButtonNext").src = "http://" + manager.MainHost + "/App_Themes/" + manager.Theme + "/images/pulsante_next.gif";
			}
		}
    }
};

function CheckPassword(e) {
    if (e.preventDefault) {
	    e.preventDefault();
	}
	
    var targ = $("txtPassword");
    
    if (SHA1(targ.value) == manager.Password) {
	    var cookieName = manager.AlbumId + "_cat_" + manager.CategoryId;
	    var cookieValue = SHA1(targ.value);
	    var today = new Date();
  	    var expires = new Date();
  	    expires.setTime(today.getTime() + 24 * 365 * 3600000);
  	    document.cookie = cookieName + "=" + escape(cookieValue) + "; expires=" + expires.toGMTString() + "; path=/";
  	    
  	    if ($("rightContent-password")) {
  			$("rightContent-password").style.display = "none";
  		}
  		
  		if ($("rightContent")) {
  			$("rightContent").style.display = "block";
  		}
    }
	else {
		alert(localizer.GetValue("WrongPassword"));
	}

    return false;
}

function IsElementContained(node, count)
{
    if (!node) {
        return;
    }
    
    while (node = node.parentNode) {
        if (node == count) {
            return true;
        }
    }
    
    return false;
};

//function ShowHideToolTip(e, el) {

//}

function DoTooltip(e) {
    e = EventHelper.GetEvent(e);
    var el = e.relatedTarget ? e.relatedTarget : e.toElement;
    
    if (typeof el == "undefined" || el == null) {
        return;
    }
    
    //setTimeout("ShowHideToolTip(e, el)", 2000)
    
    var isPhoto =  false;
    
    if (!bh.IsIe()) {
        isPhoto = (el.id.indexOf("photo_") >= 0) ? true : false;
    }
    else {
        isPhoto = (el.parentNode.id.indexOf("photo_") >= 0) ? true : false;
    }
    
    var index = !bh.IsIe() ? parseInt(el.id.substring(6)) : parseInt(el.parentNode.id.substring(6));
    
    if (el.nodeName == "TD") {
		var divElements = el.getElementsByTagName("div");
		
		if (divElements.length > 0) {
			var divElement = divElements[0];
			
			if (divElement) {
				index = parseInt(divElement.id.substring(6));
			}
		}
    }
    
    if (el.nodeName == "DIV") {
        if (el.getAttribute('id') == null) {
            index = parseInt(el.parentNode.getElementsByTagName("div")[0].id.substring(6))
        }
        else {
            index = parseInt(el.id.substring(6));
        }
    }
    
    manager.currentTooltipMediaIndex = manager.SearchIndex(index, isPhoto);
    var m = manager.GetCurrentTooltipedMedia();

    if (typeof m == "undefined" || !m.ready) {
        return;
    }
        
    m.ClearTooltipTimer();
    
    if (m.tip && m.tip.onmouseout == null) {
        m.tip.onmouseout = TipOutCheck;
        m.tip.onmouseover = m.ClearTooltipTimer;
    }

    m.ShowTooltip(e);
};

function TipOutCheck(e) {
    var p = manager.GetCurrentTooltipedMedia();
    
    if (typeof p == "undefined" || !p.ready) {
        return;
    }
        
    e = EventHelper.GetEvent(e);
    var el = e.relatedTarget ? e.relatedTarget : e.toElement;

    if (this != el && !IsElementContained(el, this)) {
        p.HideTooltip();
    }
};

function HideTip(e) {
    var p = manager.GetCurrentTooltipedMedia();
    
    if (typeof p == "undefined" || !p.ready) {
        return;
    }
        
    e = EventHelper.GetEvent(e);
    var el = e.relatedTarget ? e.relatedTarget : e.toElement;

    if ($(p.TipId) != el) {
        p.timerId = window.setTimeout(function() { p.HideTooltip(); }, 300);
    }
};

function ToggleTooltipVisibility(id, vis)
{
    var el = $(id);
    
    if (el) {
        el.style.visibility = vis;
    }
};

function Media() {
    this.ElementId = "";
    this.ThumbnailUrl = "";
    this.Url = "";
    this.AlternateText = "";
    this.CleanedAlternateText = "";
    this.Body = "";
    this.MediaId = "";
    this.IsPhoto = false;
    this.Index = 0;
    
    this.offX = 0;
    this.offY = 0;
    this.showDelay = 1000;
    this.hideDelay = 200;
    this.ready = false; 
    this.timer = null; 
    this.tip = null;
    this.TipId = "";
    this.timerId = 0;
    
    this.GetInnerText = function() {
        var result = "<strong>" + this.AlternateText + "</strong>";
        result += "<br />";
        result += this.Body;
        result += "<br />";
        
        if (manager.Password == "") {
            result += "<a href=\"http://" + manager.MainHost + "/ShowMedia.aspx?id=" + this.MediaId + "&albumId=" + manager.AlbumId + "&p=" + manager.IsPublishing + "&lng=" + localizer.ISOLanguage() + "\">" + localizer.GetValue("Details") + "</a>";
        }
        else {
            result += "<a href=\"http://" + manager.MainHost + "/ShowMedia.aspx?id=" + this.MediaId + "&albumId=" + manager.AlbumId + "&p=" + manager.IsPublishing + "&cp=" + manager.Password + "&lng=" + localizer.ISOLanguage() + "\">" + localizer.GetValue("comments") + "</a>";
        }
            
        return result;
    };
    
    this.InitTooltip = function() {
        if (document.createElement &&
			document.body &&
			typeof document.body.appendChild != "undefined") {
            this.TipId = "div_" + this.ElementId;
            
            if (!$(this.TipId)) {
                var el = document.createElement("DIV");
                el.id = this.TipId;
                el.className = "Tooltip";
                document.body.insertBefore(el, document.body.firstChild);
                
                this.tip = $(this.TipId);
                
                EventHelper.Add($(this.ElementId), "mouseover", DoTooltip, true);
                EventHelper.Add($(this.ElementId), "mouseout", HideTip, true);
            }
            
            this.ready = true;
        }
    };
    
    this.ShowTooltip = function(e) {            
        if (this.timer) {
            clearTimeout(this.timer);
            this.timer = 0;
        }

        if ((this.AlternateText != "") || (this.Body != ""))
        {
            this.WriteTip(this.GetInnerText());
            WindowHelper.GetAll();
            this.PositionTip(e);
            this.timer = setTimeout("ToggleTooltipVisibility('" + this.TipId + "', 'visible')", this.showDelay);
        }
    };
    
    this.WriteTip = function(msg) {
        if (this.tip && typeof this.tip.innerHTML != "undefined") {
            this.tip.innerHTML = "<div class=\"TooltipInner\">" + msg + "</div>";
        }
    };
    
    this.PositionTip = function(e) {        
        if (this.tip && this.tip.style) {        
	        var el = $(this.ElementId);
	        var xPos = el.offsetLeft;
	        var yPos = el.offsetLeft;
		    var parent = el.offsetParent;
  		    
  		    while (parent != null) {
  			    xPos += parent.offsetLeft;
  			    yPos += parent.offsetTop;
	  		    parent = parent.offsetParent;
  		    }

	        this.tip.style.left = (xPos - 130) + "px";
	        this.tip.style.top = (yPos - this.tip.offsetHeight) + "px";
        }
    };
    
    this.HideTooltip = function() {
        if (this.timer) {
            clearTimeout(this.timer);
            this.timer = 0;
        }
        
        this.timer = setTimeout("ToggleTooltipVisibility('" + this.TipId + "', 'hidden')", this.hideDelay);
    };
    
    this.ClearTooltipTimer = function() {
        if (this.timerId) {
            clearTimeout(this.timerId);
            this.timerId = 0;
        }
    };
};
 
window.onload = function() {
    localizer.Init();
};

function page_load() {
	InitializePage();
}

function InitializePage() {
	// REFACTORING
	TreeView_RebuildExpandState();
	
	if (!manager) {
		return;
	}
	
	if ($("form1")) {
		EventHelper.Add($("form1"), "submit", form1_callback, true);
	}
	
	if ($("ButtonNext")) {
		EventHelper.Add($("ButtonNext"), "click", ShowNextMedia, true);
    }
    
    if ($("ButtonPrev")) {
		EventHelper.Add($("ButtonPrev"), "click", ShowPrevMedia, true);
	}
	
	if ($("btnPasswordSubmit")) {
		EventHelper.Add($("btnPasswordSubmit"), "click", CheckPassword, true);
    }
    
    if ($("txtPassword")) {
		EventHelper.Add($("txtPassword"), "keyup", txtPassword_KeyPress, true);
    }
    
    if ((manager.CategoryId != "") || (manager.Password == ""))
    {
		if ($("hlPlugin")) {
			$("hlPlugin").style.visibility = "visible";
		}
		
		if ($("hlRss")) {
			$("hlRss").style.visibility = "visible";
        }
        
        if (manager.IsPublishing && $("hlRss")) {
            $("hlRss").href = "Feeds/" + manager.CategoryId + ".xml";
        }
        else {
            $("hlRss").href = "http://" + manager.MainHost + "/rss.axd?id=" + manager.CategoryId;
        }
    }
    
    if ($("hlAlbumAdmin")) {
		$("hlAlbumAdmin").innerHTML = localizer.GetValue("hlAlbumAdmin");
		$("hlAlbumAdmin").href = "http://" + manager.MainHost + "/Admin/Default.aspx?id=" + manager.AlbumId;
		$("hlAlbumAdmin").target = "_top";
    }
    
    if (manager.Password == "") {
		if ($("rightContent")) {
			$("rightContent").style.display = "block";
		}
    }
    else
    {
        var cookieName = manager.AlbumId + "_cat_" + manager.CategoryId;

        if (GetCookie(cookieName) == manager.Password) {
			if ($("rightContent")) {
				$("rightContent").style.display = "block";
			}
        }
        else {
			if ($("rightContent-password")) {
				$("rightContent-password").style.display = "block";
			}
        }
    }
    
    if (manager.medias.length > 0) {
        manager.UpdateView();
		
		if ($("lbSubmitFriend")) {
			if (manager.Password == "") {
				$("lbSubmitFriend").href = "http://" + manager.MainHost + "/SubmitFriend.aspx?id=" + manager.medias[0].MediaId + "&albumId=" + manager.AlbumId + "&p=" + manager.IsPublishing + "&lng=" + localizer.ISOLanguage();
			}
			else {
				$("lbSubmitFriend").href = "http://" + manager.MainHost + "/SubmitFriend.aspx?id=" + manager.medias[0].MediaId + "&albumId=" + manager.AlbumId + "&p=" + manager.IsPublishing + "&cp=" + manager.Password + "&lng=" + localizer.ISOLanguage();
			}
        }
        
        if ($("lbSubmitFriend")) {
			$("lbSubmitFriend").innerHTML = localizer.GetValue("lbSubmitFriend");
        }
        
        if ($("pluginText")) {
			$("pluginText").innerHTML = localizer.GetValue("pluginText");
		}
        
        if ($("lbSlideShow")) {
			if (!manager.IsPublishing)
				$("lbSlideShow").href = "http://" + manager.MainHost + "/Admin/SlideShow.aspx?id=" + manager.CategoryId + "&p=false";
			else
				$("lbSlideShow").href = "SlideShows/" + manager.CategoryId + ".html";
			
			$("lbSlideShow").innerHTML = localizer.GetValue("lbSlideShow");
        }
		
		if ($("labelTotalMedias")) {
			$("labelTotalMedias").innerHTML = manager.medias.length;
        }
        
        if ($("ButtonPrev")) {
			EventHelper.Add($("ButtonPrev"), "mouseover", ButtonPrev_MouseOver, true);
			EventHelper.Add($("ButtonPrev"), "mouseout", ButtonPrev_MouseOut, true);
        }
        
        if ($("ButtonNext")) {
			EventHelper.Add($("ButtonNext"), "mouseover", ButtonNext_MouseOver, true);
			EventHelper.Add($("ButtonNext"), "mouseout", ButtonNext_MouseOut, true);
        }
        
        var photosCount = 0;
        
        for (var z = 0; z < manager.medias.length; z++) {
            if (manager.medias[z].IsPhoto) {
                photosCount++;
            }
        }
		
		if ($("hlPlugin")) {
			$("hlPlugin").style.display = (photosCount > 0) ? "inline" : "none";
		}
		
		if ($("hlRss")) {
			$("hlRss").style.display = (photosCount > 0) ? "inline" : "none";
        }
    }
    else
    {
		if ($("shadow-container")) {
			$("shadow-container").style.visibility = "hidden";
        }
        
        if ($("ButtonNext")) {
			$("ButtonNext").style.visibility = "hidden";
        }
        
        if ($("ButtonPrev")) {
			$("ButtonPrev").style.visibility = "hidden";
		}
		
		if ($("PageIndexer")) {
			$("PageIndexer").style.visibility = "hidden";
        }

		if ($("tableSubmitFriend")) {
			$("tableSubmitFriend").style.visibility = "hidden";
        }
        
        if ($("tableSlideShow")) {
			$("tableSlideShow").style.visibility = "hidden";
		}
		
		if ($("hlPlugin")) {
			$("hlPlugin").style.display = "none";
        }
        
        if ($("hlRss")) {
			$("hlRss").style.display = "none";
        }
        
        if ($("tableSlideShow")) {
			$("tableSlideShow").style.display = "none";
        }
    }
	
	if ($("hlRss")) {
		$("hlRss").style.visibility = (manager.Password == "") ? 'visible' : 'hidden';
	}
	
	if ($("hlPlugin")) {
		$("hlPlugin").style.visibility = (manager.Password == "") ? 'visible' : 'hidden';
	}
    
    if ($("h2PasswordRequired")) {
		$("h2PasswordRequired").innerHTML = localizer.GetValue("PasswordRequired");
	}
	
	if ($("spTypePassword")) {
		$("spTypePassword").innerHTML = localizer.GetValue("TypePassword");
	}
    
    if ($("tableSlideShow")) {
		$("tableSlideShow").style.visibility = (manager.PhotoCount() > 1) ? "visible" : "hidden";
	}
	
	if ($("tableNavigatePhotos")) {
		$("tableNavigatePhotos").style.visibility = (manager.medias.length > 1) ? "visible" : "hidden";
	}
}

function form1_callback(e) {
    if (e.preventDefault) {
        e.preventDefault();
    }
        
    return false;
};

function ButtonPrev_MouseOver(e) {
	if (manager && $("ButtonPrev")) {
		if (manager.currentMediaIndex > 0)
			$("ButtonPrev").src = "http://" + manager.MainHost + "/App_Themes/" + manager.Theme + "/images/pulsante_prev_over.gif";
    }
};

function ButtonPrev_MouseOut(e) {
	if (manager && $("ButtonPrev")) {
		if (manager.currentMediaIndex > 0) {
			$("ButtonPrev").src = "http://" + manager.MainHost + "/App_Themes/" + manager.Theme + "/images/pulsante_prev.gif";
		}
    }
};

function ButtonNext_MouseOver(e) {
	if (manager && $("ButtonNext")) {
		if (manager.currentMediaIndex < manager.medias.length - 1) {
			$("ButtonNext").src = "http://" + manager.MainHost + "/App_Themes/" + manager.Theme + "/images/pulsante_next_over.gif";
		}
	}
};

function ButtonNext_MouseOut(e) {
	if (manager && $("ButtonNext")) {
		if (manager.currentMediaIndex < manager.medias.length - 1) {
			$("ButtonNext").src = "http://" + manager.MainHost + "/App_Themes/" + manager.Theme + "/images/pulsante_next.gif";
		}
    }
};

function ShowPluginCode() {
    $("pluginDiv").style.display = "block";
    return false;
};

function HidePluginCode() {
	if ($("pluginDiv")) {
		$("pluginDiv").style.display = "none";
    }
    
    return false;
};

function LocalizeInterface(lng) {
    localizer.Language = lng;
    
    var cookieName = "InterfaceLanguage";
    var cookieValue = lng;
    var today = new Date();
    var expires = new Date();
    expires.setTime(today.getTime() + 24 * 365 * 3600000);
    document.cookie = cookieName + "=" + escape(cookieValue) + "; expires=" + expires.toGMTString() + "; path=/";
	
	if ($("hlAlbumAdmin")) {
		$("hlAlbumAdmin").innerHTML = localizer.GetValue("hlAlbumAdmin");
    }
    
    if ($("lbSubmitFriend")) {
		$("lbSubmitFriend").innerHTML = localizer.GetValue("lbSubmitFriend");
    }
    
    if ($("pluginText")) {
		$("pluginText").innerHTML = localizer.GetValue("pluginText");
    }
    
    if ($("lbSlideShow")) {
		$("lbSlideShow").innerHTML = localizer.GetValue("lbSlideShow");
    }
    
    if ($("h2PasswordRequired")) {
		$("h2PasswordRequired").innerHTML = localizer.GetValue("PasswordRequired");
    }
    
    if ($("spTypePassword")) {
		$("spTypePassword").innerHTML = localizer.GetValue("TypePassword");
    }
    
    manager.UpdateView();
    
    return false;
};

function txtPassword_KeyPress(e) {
    e = e || window.event;
    var code = e.keyCode || e.which;
    
    if (code == 13) {
        e.returnValue = false;

        if (!bh.IsIe()) {
            e.preventDefault();
            e.stopPropagation();
        }

        CheckPassword(e);
    }

    return false;
}