//Load when the page is ready - Using jQuery to run events
$(document).ready(function(){
	$.tabs('container-1');
	$.tabs('container-2');
	$.tabs('container-3');
} );

$.tabs = function(containerId, start) {
    var ON_CLASS = 'on';
    var id = '#' + containerId;
    var i = (typeof start == "number") ? start - 1 : 0;
    $(id + '>div:eq(' + i + ')').css({display:"block"});
    $(id + '>ul>li:nth-child(' + (i+1) + ')').addClass(ON_CLASS);
    $(id + '>ul>li>a').click(function() {
        if (!$(this.parentNode).is('.' + ON_CLASS)) {
            var re = /([_\-\w]+$)/i;
            var target = $('#' + re.exec(this.href)[1]);
            if (target.size() > 0) {
                $(id + '>div:visible').css({display:"none"});
                target.css({display:"block"});
                $(id + '>ul>li').removeClass(ON_CLASS);
                $(this.parentNode).addClass(ON_CLASS);
            } else {
                alert('There is no such container.');
            }
        }
        return false;
    });
};


var mclickY = 0;

function clickY (evt) {
	if (!evt)
		evt = window.event;

	if (evt.pageY) {
		mclickY = evt.pageY;
	} else if (evt.clientY) {
		mclickY = evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
	}

}

document.onmouseup = clickY;

function showInfo(flag,element,evt)  {

    if (document.getElementById) {
      mylayer = document.getElementById(element);
      addpx = 'px';
    } else {
      mylayer = document.all[element];
      addpx = '';
    }

	if (mylayer) {

		if (window.innerWidth) {
			mylayer.style.left=(window.innerWidth/2 - 280) + addpx;
			if (mclickY) {
				mylayer.style.top=mclickY + addpx;
			}
			
		} else if (document.body.offsetWidth) {
 			mylayer.style.left=(document.body.offsetWidth/2 - 280) + addpx;
			if (mclickY) {
				mylayer.style.top=mclickY + addpx;
	 		}
		}
		if (flag == 1) {
			mylayer.visibility = 'visible';
			mylayer.style.display = '';
		} else {
			mylayer.visibility = 'hidden';
			mylayer.style.display = 'none';
		}
	}
}

