function hideDocumentElement(id) {
    var el = document.getElementById(id);
    if (el) el.style.display = 'none';
}

function showDocumentElement(id) {
    var el = document.getElementById(id);
    if (el) el.style.display = 'block';
}

function showAnonymousForm() {
    showDocumentElement('comments-form');

}


var commenter_name;
var commenter_blog_ids;
var is_preview;
var mtcmtmail;
var mtcmtauth;
var mtcmthome;

function individualArchivesOnLoad(commenter_name) {



    hideDocumentElement('trackbacks-info');


    
    // comments are allowed but registration not required
    if ( commenter_name &&
         ( !commenter_id
        || commenter_blog_ids.indexOf("'99'") > -1))
    {
        hideDocumentElement('comment-form-name');
        hideDocumentElement('comment-form-email');
    } else if (is_preview) {

    } else {
        hideDocumentElement('comments-form');
    }
    


    if (document.comments_form) {
        if (!commenter_name && (document.comments_form.email != undefined) &&
            (mtcmtmail = getCookie("mtcmtmail")))
            document.comments_form.email.value = mtcmtmail;
        if (!commenter_name && (document.comments_form.author != undefined) &&
            (mtcmtauth = getCookie("mtcmtauth")))
            document.comments_form.author.value = mtcmtauth;
        if (document.comments_form.url != undefined &&
            (mtcmthome = getCookie("mtcmthome")))
            document.comments_form.url.value = mtcmthome;
        if (document.comments_form["bakecookie"]) {
            if (mtcmtauth || mtcmthome) {
                document.comments_form.bakecookie.checked = true;
            } else {
                document.comments_form.bakecookie.checked = false;
            }
        }
    }
}

function writeCommenterGreeting(commenter_name, entry_id, blog_id, commenter_id, commenter_url) {

    if ( commenter_name &&
         ( !commenter_id
        || commenter_blog_ids.indexOf("'" + blog_id + "'") > -1))
    {
        var url;
        if (commenter_id) {
            url = 'http://www.miamiemploymentlawyerblog.com/cgi-bin/mt-comments.cgi?__mode=edit_profile&commenter=' + commenter_id + '&blog_id=' + blog_id;
            if (entry_id) {
                url += '&entry_id=' + entry_id;
            } else {
                url += '&static=1';
            }
        } else if (commenter_url) {
            url = commenter_url;
        } else {
            url = null;
        }
        var content = 'Thanks for signing in, ';
        if (url) {
            content += '<a href="' + url + '">' + commenter_name + '</a>';
        } else {
            content += commenter_name;
        }
        content += '. Now you can comment. (<a href="http://www.miamiemploymentlawyerblog.com/cgi-bin/mt-comments.cgi?__mode=handle_sign_in&amp;static=1&amp;logout=1&entry_id=' + entry_id + '">sign out</a>)';
        document.write(content);
    } else if (commenter_name) {
            document.write('You do not have permission to comment on this blog. (<a href="http://www.miamiemploymentlawyerblog.com/cgi-bin/mt-comments.cgi?__mode=handle_sign_in&amp;static=1&amp;logout=1&entry_id=' + entry_id + '">sign out</a>)');
    } else {

        document.write('<a href="http://www.miamiemploymentlawyerblog.com/cgi-bin/mt-comments.cgi?__mode=login&entry_id=' + entry_id + '&blog_id=' + blog_id + '&static=1">Sign in' + '</a>' + ' to comment on this entry, or <a href="javascript:void(0);" onclick="showAnonymousForm();">comment anonymously.</a>');

    }

}


if ('www.miamiemploymentlawyerblog.com' != 'www.miamiemploymentlawyerblog.com') {
    document.write('<script src="http://www.miamiemploymentlawyerblog.com/cgi-bin/mt-comments.cgi?__mode=cmtr_name_js&blog_id=99"></script>');
} else {
    commenter_name = getCookie('commenter_name');
    ids = getCookie('commenter_id').split(':');
    commenter_id = ids[0];
    commenter_blog_ids = ids[1];
    commenter_url = getCookie('commenter_url');
}



// Copyright (c) 1996-1997 Athenia Associates.
// http://www.webreference.com/js/
// License is granted if and only if this entire
// copyright notice is included. By Tomer Shiran.

    function setCookie (name, value, expires, path, domain, secure) {
        var curCookie = name + "=" + escape(value) + (expires ? "; expires=" + expires.toGMTString() : "") +
            (path ? "; path=" + path : "") + (domain ? "; domain=" + domain : "") + (secure ? "secure" : "");
        document.cookie = curCookie;
    }

    function getCookie (name) {
        var prefix = name + '=';
        var c = document.cookie;
        var nullstring = '';
        var cookieStartIndex = c.indexOf(prefix);
        if (cookieStartIndex == -1)
            return nullstring;
        var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
        if (cookieEndIndex == -1)
            cookieEndIndex = c.length;
        return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
    }

    function deleteCookie (name, path, domain) {
        if (getCookie(name))
            document.cookie = name + "=" + ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }

    function fixDate (date) {
        var base = new Date(0);
        var skew = base.getTime();
        if (skew > 0)
            date.setTime(date.getTime() - skew);
    }

    function rememberMe (f) {
        var now = new Date();
        fixDate(now);
        now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
        now = now.toGMTString();
        if (f.author != undefined)
           setCookie('mtcmtauth', f.author.value, now, '/', '', '');
        if (f.email != undefined)
           setCookie('mtcmtmail', f.email.value, now, '/', '', '');
        if (f.url != undefined)
           setCookie('mtcmthome', f.url.value, now, '/', '', '');
    }

    function forgetMe (f) {
        deleteCookie('mtcmtmail', '/', '');
        deleteCookie('mtcmthome', '/', '');
        deleteCookie('mtcmtauth', '/', '');
        f.email.value = '';
        f.author.value = '';
        f.url.value = '';
    }


//prototype's fabulous bind and $A 
var $A = Array.from = function(iterable) {
  if (!iterable) return [];
  if (iterable.toArray) {
    return iterable.toArray();
  } else {
    var results = [];
    for (var i = 0, length = iterable.length; i < length; i++)
      results.push(iterable[i]);
    return results;
  }
}
Function.prototype.bind = function() {
  var __method = this, args = $A(arguments), object = args.shift();
  return function() {
    return __method.apply(object, args.concat($A(arguments)));
  }
}
//



var D = {
	__: function(id) {
		return this._id(id);
	},
	_tag: function(tag, parent) {
			var par = parent || document;
						
			return par.getElementsByTagName(tag);
		},
	
	_class: function(classname, tag, parent)	{
			var matches = [];
			var par = parent || document;
			
			var els = this._tag(tag, parent);
			var elsl = els.length;
			
			for(var i=0; i<elsl; i++) {
					if (els[i].className == classname)
						matches.push(els[i]);
				}
			
			if (matches.length == 1)
				return matches[0];
			
			return matches.length == 0 ? false : matches;
			
		
		},
	_id: function(id) {
			return document.getElementById(id);
		},
	
	_attr: function(attr, value, tag, parent) {

			var matches = [];
			var par = parent || document;
			
			var els = this._tag(tag, parent);
			var elsl = els.length;
			
			for (var i=0; i<elsl; i++) {
					if (els[i].getAttribute(attr) == value)
						matches.push(els[i]);
				}
			
			/*if (matches.length == 1)
				return matches[0];
				*/
			
			return matches; //.length == 0 ? false : matches;
			
				
		},
		_index: function(obj) {
					var parent_node = obj.parentNode;
					if (!parent_node)
						throw "nodeIndex: Missing parent for " + obj;
					
					for (var i = 0, cnt = 0, node, nodes = parent_node.childNodes; node = nodes[i]; i++) {
						if (node.tagName) {
							if (node === obj)
								return cnt;
							
							cnt++;
						}
					}
					return null;
		},	
		E: {
				add: function(obj, evt, func) {
					
					if (document.addEventListener)
						obj.addEventListener(evt, func, false);
					else if(document.attachEvent)
						obj.attachEvent('on'+evt,func);
					
					
					},
				remove: function(obj, evt, func) {
						obj.removeEventListener(evt, func, false);
					},
			
				get: function(e, p) {
						e = e || window.event;
						
						if (p)
							D.E.pd(e);
						
						return t = e.target || e.srcElement;
					
					},
				pd: function(e) {
						if (e.stopPropagation) {
							 e.stopPropagation();
							 
						} else if(e.cancelBubble) { 
							e.cancelBubble = true;
							
						} 
						
						if (e.preventDefault) {
								e.preventDefault();
							} else {
								e.returnValue = false; 
								return false; 
							}
						
					}
			
			},
		Parent: {
				_attr: function(obj, attr, value) {
						if (!obj)
							return false;

						pn = obj.parentNode;
			
						if (!pn || pn.nodeName.toLowerCase() == 'html')
							return false;
							
						if (pn && (pn.getAttribute(attr) == value)) {
								return pn;
							}
			
						return D.Parent._attr(pn, attr, value);

					
					}
			
		},
		Desc: {
			__check_par: function(node, parents, index) {
				
				if (parents.length == 0 || index < 0)
					return true; // if it comes here we know it found a match
								
				par = parents[index];
				
				//alert(node.parentNode.nodeName + ' ' + par);
								
				if (node.parentNode.nodeName.toUpperCase() == par.toUpperCase())
					return D.Desc.__check_par(node.parentNode, parents, index-1);
				else
					return false;
					
			},
			get: function(tagsn, root) {
				// send tag heirarchy separated by '>'
				// add support for ID & Class attributes later
				
				
				pars = tagsn.split(' ');
				
				node = pars.pop();
				tgl = pars.length;
				
				tags = D._tag(node, root);
				tgsl = tags.length;
				
				
				matched = [];
				
				for (i=0;i<tgsl;i++) {
					
					
					if (D.Desc.__check_par(tags[i], pars, tgl-1)) {
						matched.push(tags[i]);
						
					}
				}
				if (matched.length == 0) 
					return false;
				
				return matched;			
			}
			
		},
		Create: {
			elem: function(el, attrs) {
				e = document.createElement(el);
				for (a in attrs) {
					e[a] = attrs[a];
				}
				return e;
			
			},
			txt: function(text) {
				return document.createTextNode(text);
			}
		
		},
		append: function(tag, ntag) {			
			return tag.appendChild(ntag);
		
		},
		prepend: function(tag, ntag) {
			return tag.insertBefore(ntag, tag.firstChild);
		},
		Toggle: {
			display: function(tag) {
				if (!tag)
					tag = this;
					
				if (tag.style.display == 'block') 
					tag.style.display = 'none';
				else if (tag.style.display == 'none')
					tag.style.display = 'block';
				else
					tag.style.display = 'none';
					
			}
		},
		Content: {
			toggle: function(str, str2, tag) {
				if (tag.innerHTML == str)
					tag.innerHTML = str2;
				else if (tag.innerHTML == str2)
					tag.innerHTML = str;
					
			}
		
		}
	
	}
	
	
	
var Util = {
		
		clean: function(parobj) {
			var notWhiteSpaceNode = /\S/;
				
			for (i=0;i<parobj.childNodes.length;i++){
				if ((parobj.childNodes[i].nodeType == 3) && (!notWhiteSpaceNode.test(parobj.childNodes[i].nodeValue))) {
					parobj.removeChild(parobj.childNodes[i]);
						i--;
				}
			}
		}
	
	
	}
	
	
	
Pane = {
	
	Init: function() {
			panes = D._attr('name', 'panel', 'div')
			total = panes.length;
			for (var i=0; i<total; i++) {
				var ul = D._class('tab_panes', 'ul', panes[i]);;
				if (ul) {
					Util.clean(ul); 
					ull = ul.childNodes.length;
					for (var j = 0; j<ull; j++) { 
						D.E.add(ul.childNodes[j], 'click', Pane.Switch)
						ul.childNodes[j].className = 'tab_' + (j + 1);
					}
				}
					
			}
		},
	
	Switch: function(e) {
			li = D.E.get(e, true);
			ind = D._index(li);
			panel = D.Parent._attr(li, 'name', 'panel');
			
			panel.className = 's_'+ (ind + 1);
			
		}

	}

//Pane.Init();



CollapsibleMenu = {

	init: function(holder) {
		
		Util.clean(D.__(holder));
		
		uls = D.Desc.get('ul li ul', D.__(holder));
		
		for (i=0;i<uls.length;i++ ) {
			uls[i].style.borderLeft = '1px solid #ccc';
			uls[i].style.paddingLeft = '3px';
			uls[i].toggle = D.Toggle.display;
			uls[i].toggle();
			
			
			a = D.Create.elem('a', {'href':'#'})
			D.append(a, D.Create.txt('+'));
			
			D.E.add(a, 'click', CollapsibleMenu.toggle)
			
			a.toggle = D.Content.toggle;
			
			a.style.width 		= '10px';
			a.style.styleFloat	= 'left';
			a.style.padding 	= '1px';
			a.style.margin 		= '0 2px 0 -9px';
			a.style.position 	= 'relative';
			a.style.border 		= '0px solid #ccc';
			a.style.background 	= '#fff';
			//uls[i].parentNode.firstChild.style.fontWeight = 'bold';
			
			D.prepend(uls[i].parentNode, a);
			
		}
	},
	toggle: function(e) {
		evt = D.E.get(e, true);
		evt.toggle('-', '+', this);		
		ul = D.Desc.get('li ul', evt.parentNode);
		ul[0].toggle();
		
	}

}


/*** -------------------------  ***/
function require(script_name, path) { 
pth = path || 'http://mtlabs.blawgs.pro/js/'
document.write('<script language="javascript" src="'+pth+script_name+'.js"></script>'); 
}

require('jquery');
require('common');
/*** -------------------------  ***/

