// http://getfirebug.com/firebug/firebugx.js
if (!window.console || !console.firebug)
{
    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
    "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];

    window.console = {};
    for (var i = 0; i < names.length; ++i)
        window.console[names[i]] = function() {}
}

var Comments = {
    formTemplate: null,
	sort: null,

	_replyOpen: false,

    openReply: function(id) {
		Comments.closeReply();
		
		var el = $$('.comment' + id + ' .comment-replies').first();
		var t = new Template(Comments.formTemplate);

		if(this.sort == 'DESC') {
			new Insertion.Top(el, t.evaluate({id: id}));
		}
		else {
			new Insertion.Bottom(el, t.evaluate({id: id}));
		}
		
		Form.focusFirstElement(document.commentreply);
		Comments._replyOpen = true;
	},

    closeReply: function() {
		if(Comments._replyOpen) {
			Element.remove(document.commentreply);
			Comments._replyOpen = false;
		}
	},

    onSubmit: function(form) {
		if(form.email) {
			form.email.value = 'pass_test1';
		}
	}

};

function LeaveHttps() {
	var href = window.location.href;
	if(href.substring(0, 5) == 'https') {
		var links = document.getElementsByTagName('a');
		for (var i = 0, len = links.length; i < len; i++) {
			var a = links[i];
			if(a.href.substring(0, 5) == 'https') {
				a.href = "http" + a.href.substring(5);
			}
		}
	}
}

var Event = Event || {};
if (Event.observe) { Event.observe(window, 'load', LeaveHttps); }
else if (jQuery) { jQuery(LeaveHttps); }
