init=function(){
	navStartList();	
	quickLinkStart();
	//resizeImages();
	initLightbox();
	
	
	var lbLaunchers = document.getElementsByClassName('lbLogin');
	lbLaunchers.each(function(lbLaunch){Event.observe(lbLaunch,'click',launchLightbox,false);});
		
	//Event.observe(window,'load',ttr_comment.init,false);
	//Event.observe(window,'load',stars.init,false);

	Event.observe($('overlay'),'click',endLightbox,false);


	//BUTTONS
	Event.observe($('printButton'),'click',function(){window.print();},false);
	Event.observe($('favButton'),'click',function(){ addBookmark('Tycoon Report', 'http://tycoonreport.tycoonresearch.com/');},false);
	
	
	if(document.getElementById('signUpBoxButton')){
		Event.observe($('signUpBoxButton'),'click',toggleSignUpBox,false);
		/*
		Event.observe('signup_form','submit',function(e){
												  Event.stop(e);
												   email_signup('tycoonreport.tycoonresearch.com', 1, ' ', 'web');
												   },false);
		*/
	}
	
	/*
	var subscribeButtons = document.getElementsByClassName('subscribeButtons');
	subscribeButtons.each(function(subscribeButton){Event.observe(subscribeButton,'click',function(){
												   email_signup('tycoonreport.tycoonresearch.com', 1, ' ', 'web');
												   	myLightbox = new Lightbox();
													myLightbox.start('email_signup_top');
												   },false);});
	*/
	

}
resizeImages = function(){
		var imgs = document.getElementsByTagName('img');
		
		for(var i=0;i<imgs.length;i++){
			if(imgs[i].width > 449){
				var newH = (449/imgs[i].width)* imgs[i].height
				
				imgs[i].width = 449;
				imgs[i].height = newH;
				if(imgs[i].parentNode.tagName == 'a'){
					new Insertion.After(imgs[i],'<br />click here to enlarge image');
				}
				else{
					new Insertion.After(imgs[i],'<br /><a href="'+imgs[i].src+'" target="_blank">click here to enlarge image</a>');					
				}
			}
		}

}
//sign up box
toggleSignUpBox = function(e){
	var t = window.event ? window.event.srcElement : e ? e.target : null;

	if($('emailSignup').style.display=='' || $('emailSignup').style.display=='none'){
		 $('emailSignup').style.display = 'block';
		 Element.addClassName(t,'off');
	}
	else{
		 $('emailSignup').style.display = 'none';
		Element.removeClassName(t,'off');
	}
}
// horizontal suckerfish
navStartList = function() {
	if (document.all && document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace
					(" over", "");
				}
			}
		}
	}
}

//quicklinks
quickLinkStart = function(){
	var ql = document.getElementsByClassName('ql');
	ql.each(function(qlink){
					 Event.observe(qlink,'click',quickLinkToggle,false);
					 });
}
quickLinkToggle=function(e){
	var t = window.event ? window.event.srcElement : e ? e.target : null;
	if(!t.nextSibling.style.display || t.nextSibling.style.display=='none'){
		t.nextSibling.style.display = 'block';
	}
	else if(t.nextSibling.style.display == 'block'){
		t.nextSibling.style.display = 'none';
	}
}
//lightbox for log in
initLightbox=function(){
	Event.observe($('lbForgotPWLink'),'click',function(){
		launchLightbox();
		closeInsideLightboxes(); 
		$('lbForgotPW').style.display='block'; 
	},false);
	
	Event.observe($('lbForgotPWLink2'),'click',function(){
		launchLightbox();
		closeInsideLightboxes(); 
		$('lbForgotPW').style.display='block'; 
	},false);
}
launchLightbox=function(e){
	if (typeof e != 'undefined') {
		Event.stop(e);		
	}
	
	myLightbox = new Lightbox();
	myLightbox.start('lbLoginBox');
	
	var lbClose = document.getElementsByClassName('lbClose');
	lbClose.each(function(closeLink){Event.observe(closeLink,'click',myLightbox.end,false);});
}


Event.observe(window,'load',init,false);
