var popups_id = 'popups';

window.onload = function() {

	popups();
	
	if (document.getElementById('copyContainer')) {

	    //reset elements since js is enabled
	    document.getElementById('copyContainer').style.overflow = 'hidden';
	    if (document.getElementById("copy").offsetHeight > parseInt('454')) document.getElementById('scrollArea').style.display = 'block';

	    //collect the variables
	    docH = document.getElementById("copy").offsetHeight;
	    contH = document.getElementById("copyContainer").offsetHeight;
	    scrollAreaH = document.getElementById("scrollArea").offsetHeight;
	      
	    //calculate height of scroller and resize the scroller div
	    //(however, we make sure that it isn't to small for long pages)
	    scrollH = (contH * scrollAreaH) / docH;
	    //if(scrollH < 15) scrollH = 15;	
	    document.getElementById("scroller").style.height = Math.round(scrollH) + "px";
	    
	    //what is the effective scroll distance once the scoller's height has been taken into account
	    scrollDist = Math.round(scrollAreaH-scrollH);
	    
	    //make the scroller div draggable
	    Drag.init(document.getElementById("scroller"),null,0,0,-1,scrollDist);
	    
	    //add ondrag function
	    document.getElementById("scroller").onDrag = function (x,y) {
	      var scrollY = parseInt(document.getElementById("scroller").style.top);
	      var docY = 0 - (scrollY * (docH - contH) / scrollDist);
	      document.getElementById("copy").style.top = docY + "px";
	      
	    }	
	    
	}

}

function popups() {

	if (document.getElementById(popups_id)) {

		var elements = document.getElementById(popups_id).getElementsByTagName('a');
		
		for (var i = 0; i < elements.length; i++) {
		
			elements[i].onclick = function() { 
				
				window.open (this.href,this.title,'width=450,height=600,status=false,toolbar=false,location=false,menubar=false,resizeable=false,scrollbars=false');
			
				return false;
				
			};
			
		}
	
	}
	
}

function popup(url) {
	
	window.open (url,'popup','width=450,height=600,status=false,toolbar=false,location=false,menubar=false,resizeable=false,scrollbars=false');
			
	return false;
	
}

function addEventHandler(element, type, func) { 

	if(element.addEventListener) {
		
		element.addEventListener(type,func,false);
		
	}else if (element.attachEvent) {
		
		element.attachEvent('on'+type,func);
		
	}
	
}



//onload = init;