                function change(event)
                {
                        var evt = (window.event) ? window.event : event;
                        var elem = (evt.srcElement) ? evt.srcElement : evt.target;
                        var inputID = $(elem).attr('id');
                        var inputValue = $(elem).attr('value');
                        if(inputValue == 'password')
                        {
                                var passwordInput = document.createElement('input');
                                passwordInput.id = inputID;
                                passwordInput.name = 'pass';
                                passwordInput.type = 'password';
                                passwordInput.value = '';
                                passwordInput.style.textAlign = 'left';
                                passwordInput.style.color = 'black';
                                passwordInput.onblur = changeBack;
                                document.getElementById(inputID).parentNode.replaceChild(passwordInput, document.getElementById(inputID));
                                window.setTimeout(function(){passwordInput.focus();}, 0);
                        }
                }

                function changeBack(event)
                {
                        var evt = (window.event) ? window.event : event;
                        var elem = (evt.srcElement) ? evt.srcElement : evt.target;
                        var inputID = $(elem).attr('id');
                        var inputValue = $(elem).attr('value');
                        if(inputValue == '')
                        {
                                var textInput = document.createElement('input');
                                textInput.type = 'text';
                                textInput.name = 'pass';
                                textInput.id = inputID;
                                textInput.value = 'password';
                                textInput.style.textAlign = 'left';
                                textInput.style.color = 'black';                                 
                                textInput.onfocus = change;
                                document.getElementById(inputID).parentNode.replaceChild(textInput, document.getElementById(inputID));
                        }
                }

(function($){

/* FUNCTION FOR CENTERING POPUP */

$.fn.centerInClient = function(options) {
    /// <summary>Centers the selected items in the browser window. Takes into account scroll position.
    /// Ideally the selected set should only match a single element.
    /// </summary>    
    /// <param name="fn" type="Function">Optional function called when centering is complete. Passed DOM element as parameter</param>    
    /// <param name="forceAbsolute" type="Boolean">if true forces the element to be removed from the document flow 
    ///  and attached to the body element to ensure proper absolute positioning. 
    /// Be aware that this may cause ID hierachy for CSS styles to be affected.
    /// </param>
    /// <returns type="jQuery" />
    var opt = { forceAbsolute: false,
                container: window,    // selector of element to center in
                completeHandler: null
              };
    $.extend(opt, options);
   
    return this.each(function(i) {
        var el = $(this);
        var jWin = $(opt.container);
        var isWin = opt.container == window;

        // force to the top of document to ENSURE that 
        // document absolute positioning is available
        if (opt.forceAbsolute) {
            if (isWin)
                el.remove().appendTo("body");
            else
                el.remove().appendTo(jWin.get(0));
        }

        // have to make absolute
        el.css("position", "absolute");

        // height is off a bit so fudge it
        var heightFudge = isWin ? 2.0 : 1.8;

        var x = (isWin ? jWin.width() : jWin.outerWidth()) / 2 - el.outerWidth() / 2;
        var y = (isWin ? jWin.height() : jWin.outerHeight()) / heightFudge - el.outerHeight() / 2;

        el.css("left", x + jWin.scrollLeft());
        el.css("top", y + jWin.scrollTop());

        // if specified make callback and pass element
        if (opt.completeHandler)
            opt.completeHandler(this);
    });
}

/* POPUP PACKAGE LIGHTBOXES */

$('a.viewvideo').click(function(e){
e.preventDefault();

var url = $(this).attr('href');
var tbheight = $(this).attr('tbheight');
var maskHeight = $(document).height();
var maskWidth = $(window).width();

var tbcss = '';
var tbwidth=480;
var tbheight=390;

$('body').append('<div id="fjp_overlay"></div>');
$('#fjp_overlay').css({'width':maskWidth,'height':maskHeight});
$('#fjp_overlay').fadeTo(500, .75);

	
	$('body').append('<div id="fjp_lightbox"><div id="popup" class="'+tbcss+'"><div class="top"><a href="#" class="close"><img src="images_11/close.png" alt="Close" class="pngfix" border="0" /></a></div><div class="mid"><iframe src="'+url+'?sid='+Math.random()+'" width="'+tbwidth+'" height="'+tbheight+'" frameborder="0" style="width:'+tbwidth+'px;height:'+tbheight+'px;border:0px;margin:0px;" scrolling="no" id="lghtbox'+Math.random()+'"></iframe></div><div class="bot"><!-- spacer --></div></div></div>');

var posTop = ( $(window).height() - $("#fjp_lightbox").height() ) / 2 + $(window).scrollTop();
$("#fjp_lightbox").centerInClient();

$('#fjp_overlay').fadeTo(500, 0.75, function(){
	$('#fjp_lightbox').css('display', 'block');

});

$('#fjp_lightbox a.close').click(function(e){
	e.preventDefault();
	$('#fjp_lightbox').fadeTo(100, 0, function(){
		$('#fjp_overlay').fadeTo(250, 0, function(){
			$(this).remove();
		});
		$(this).remove();

	});
});

});

})(window.jQuery);

