//******************
//TOGGLE DIV DISPLAY
//******************
function toggleBlind(div1, div2) {

	if (div2 === undefined) {

		if ($(div1).hasClassName('open')) {
			Effect.BlindUp(div1, { duration: 0.25 });
			$(div1).removeClassName('open');
		} else {
			Effect.BlindDown(div1, { duration: 0.25 });
			$(div1).addClassName('open');
		}

	} else {

		if (!$(div1).hasClassName('open')) {
			Effect.BlindUp(div2, { duration: 0.25 });
			$(div2).removeClassName('open');
			Effect.BlindDown(div1, { duration: 0.25, delay: 0.35 });
			$(div1).addClassName('open');
		}

	}

}

function toggleBlindAll(direction, divs) {

	var len = divs.length;
	for (var i = 0; i < len; i++) {

		if (direction == "up") {
			Effect.BlindUp(divs[i], { duration: 0.25 });
			$(divs[i]).removeClassName('open');
		} else if (direction == "down") {
			Effect.BlindDown(divs[i], { duration: 1 });
			$(divs[i]).addClassName('open');
		}

	}

}

function deleteItem(team, type, id) {
	var msg = "Are you sure you want to delete this " + type + "?";
	if (confirm(msg)){
		location.replace("?t=" + team + "&action=delete&id=" + id);
	}
}

function flagItem(comment_id, query_string) {
	var msg = "Are you sure you want to report this comment?";
	if (confirm(msg)){
		location.replace(query_string);
	}
}

function clearField(form_name, field_name) {

	if (document.forms[form_name].elements[field_name].value == "Add a comment...") {
		document.forms[form_name].elements[field_name].value = "";
	}

}

function processForgotPassword(email) {
	
	var dataString = ({'email': email});

	$.ajax({
		url: "/objects/ajax/process_forgot_password.php",
		data: dataString,
		type: "GET",
		success: function(response) {
			$("div#forgotPasswordOverlayText").html(response);
		},
		error: function(xhr, err, e) {
			alert("Forgot password error: " + err);
		}
	});
	
}
	

/* OVERLAYS
----------- */
/*
 * jQuery UI fade effect, based on pulsate
 *
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * Depends:
 *      effects.core.js
 */
/*
 * jQuery UI fade effect, based on pulsate
 *
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * Depends:
 *      effects.core.js
 */
(function($) {

    $.effects.fade = function(o) {

        return this.queue(function() {

            // Create element
            var el = $(this);

            // Set options
            var speed = o.options.speed || 500;
            var mode = o.options.mode || 'show'; // Set Mode

            // Animate
            if (mode == 'show') {
                el.fadeIn(speed);
            } else {
                el.fadeOut(speed);
            }
            ;
            el.queue('fx', function() {
                el.dequeue();
            });
            el.dequeue();
        });
    };

})(jQuery);
        
function overlay(divId) {
    $('.dialog').dialog('destroy');
    $('#' + divId).dialog({
        autoOpen: false,
        dialogClass: 'overlay',
        draggable: false,
        hide: 'fade',
        modal: true,
        resizable: false,
        show: 'fade',
        width: 286
    });
    $('#' + divId).dialog('open');
}

function overlayClose(divId) {
    $('#' + divId).dialog('close');
}
