function initPage(){
	var t_btn = document.getElementsByTagName('a');
	for( var i = 0; i < t_btn.length; i++) {
		if(t_btn[i].className.indexOf('btn-print') != -1) {
			t_btn[i].onclick = function(){
				var _text = _getParent(this, 'excercises-list');
				if(_text){
					_text.innerHTML = '<div class="excercises-list">' + _text.innerHTML + '</div>';
					var _window = window.open('print-page.html', 'w_box', 'location = 1, toolbar = 1, menubar = 1, scrollbars = 1, resizable = 1');
					_paste(_window, _text);
				}
				return false;
			}
		}
	}
}
function _paste(_parent, _el) {
	function initPrint() {
		var _hold = _parent.document.getElementById('page');
		if(_hold) {
			_hold.innerHTML = _el.innerHTML;
		}
	}

	if (_parent.addEventListener) {
	_parent.addEventListener("load", initPrint, false);
	}
	else if (_parent.attachEvent) {
		_parent.attachEvent("onload", initPrint);
	}
}

function _getParent(_el, _class) {
	var _parent = _el.parentNode;
	while((_parent) && (_parent.className.indexOf(_class) == -1)) {
		_parent = _parent.parentNode;
	}
	return _parent;
}
if (window.addEventListener) {
	window.addEventListener("load", initPage, false);
}
else if (window.attachEvent) {
	window.attachEvent("onload", initPage);
}
// JavaScript Document
// gives up and down scroll buttons to images, spans, ... named up_name, down_name, respectively.
// will keep the default scroll_box's style overflow if it encounters errors (so make overflow: auto;)

// usage: put this after the scrollbox div:  var div_scroll1 = new TextScroll('div_scroll1', 'scroll_box');
function TextScroll(scrollname, div_name, up_name, down_name)
{
    this.div_name = div_name;
    this.name = scrollname;
    this.scrollCursor = 0;
    this.speed = 5;
    this.timeoutID = 0;
    this.div_obj = null;
    this.up_name = up_name;
    this.dn_name = down_name;

{
        if (document.getElementById) {
            div_obj = document.getElementById(this.div_name);
            if (div_obj) {
                this.div_obj = div_obj;
                this.div_obj.style.overflow = 'hidden';
            }
            div_up_obj = document.getElementById(this.up_name);
            div_dn_obj = document.getElementById(this.dn_name);
            if (div_up_obj && div_dn_obj) {
                                div_up_obj.onmouseover = function() { eval(scrollname + ".scrollUp();") };
div_up_obj.onmouseout = function() { eval(scrollname + ".stopScroll();") };

div_dn_obj.onmouseover = function() { eval(scrollname + ".scrollDown();") };
div_dn_obj.onmouseout = function() { eval(scrollname + ".stopScroll();") };
            }
        }
    }

this.stopScroll = function() {
        clearTimeout(this.timeoutID);
    }

this.scrollUp = function() {
        if (this.div_obj) {
            this.scrollCursor = (this.scrollCursor - this.speed) < 0 ? 0 : this.scrollCursor - this.speed;
            this.div_obj.scrollTop = this.scrollCursor;
            this.timeoutID = setTimeout(this.name + ".scrollUp()", 60);
        }
    }

this.scrollDown = function() {
if (this.div_obj) {
this.scrollCursor += this.speed;
this.div_obj.scrollTop = this.scrollCursor;
if (this.div_obj.scrollTop == this.scrollCursor) {
this.timeoutID = setTimeout(this.name + ".scrollDown()", 60);
} else {
this.scrollCursor = this.div_obj.scrollTop;
}
}
}

this.resetScroll = function() {
        if (this.div_obj) {
            this.div_obj.scrollTop = 0;
            this.scrollCursor = 0;
        }
    }
}
