/**
 * @author daco
 * Wire all possible scrollbars and, if necessary, provide additional methods. * 
 * Also, wire non css style things like vertical aligment
 * 
 */


/* --------------- Vertical center bio div on page load --------------- */
ComicHouse.verticalCenterBio = function () {
	var bio = $('bio');
	if (bio) {
		
		if (Prototype.Browser.IE && IEVersion().DocMode !=8) {
			bio.select('.staticportfolio_content, .bio_content').each(function(node){
				var wrapperElement = new Element('div').setStyle({position:'absolute',top:'50%'});  		// outer style
				node.setStyle({position:'relative',top:'-50%'}).wrap(wrapperElement);						// inner style
			});
		}
		
		bio.setStyle({visibility:'visible'});
		
		//var h = $('bio').getHeight();
		//var mt = Math.round(-(h / 2) + 35);
		//var editmode = $('main').hasClassName('editmode');
		//if (editmode) {
		//	mt -= 60;
		//}
		//$('bio').setStyle({marginTop:mt+'px'})
	}

};

/* --------------- /end Vertical center bio div on page load --------------- */



ComicHouse.setTextInputHeight = function () {
	return;
	if (!$('edittextinput')) {return;}

	var viewportHeight = document.viewport.getHeight();
	var availHeight = Math.round((viewportHeight - 500) / 2);
	if ($('artwork_description')) {
		availHeight -= $('artwork_description').getHeight(); 
	}
	availHeight = (availHeight<80)? 80:availHeight;
	availHeight = (availHeight>=100)? 100:availHeight;
	$('edittextinput').setStyle({height:availHeight+'px'});

}



ComicHouse.wireScrollBars = Class.create(LazzoBaseClass, {

	_initDomLoaded: function(){
	
		ComicHouse.verticalCenterBio();
	
		ComicHouse.setTextInputHeight();
		
		ComicHouse.scrollBars = new Hash();
		
		if ($('imageCol')) {
		
			ComicHouse.scrollBars.set('imageCol', new ComicHouse.Scrollblock($('imageCol'), {customClassName:'trits', offsetBy:{left:2,top:-28},leftAlign:false}));
			
		};
		

		
		if ($('webtour')) {
		
			ComicHouse.scrollBars.set('webtour', new ComicHouse.Scrollblock($('webtour'), {
				customClassName: 'trits',
				offsetBy: {
					left: -33,
					top: -28
				},
				leftAlign: false
			}));
			
		};
		
		this._fireEvent('wirescrollbars');
		
	}
});
new ComicHouse.wireScrollBars();

 

ComicHouse.resetScrollBars = function () {
	ComicHouse.setTextInputHeight();
	
	ComicHouse.scrollBars.each(function(sb){
		// prevent from resetting in the sort editor
		if (!ComicHouse.portfolioEditor || (ComicHouse.portfolioEditor && ComicHouse.portfolioEditor.getMode() != 7)) {
			sb.value.reset();
		}
	});
};

Event.observe(document.onresize ? document : window, "resize", ComicHouse.resetScrollBars);  



