/***********************************************************************
*	MAIN.JS
*  
*	(c) 2005 Walker Art Center - Brent Gustafson 
***********************************************************************/

var pageTotal = 0;

function searchGo(url,val) {
	if ((val > 0) && (val <= pageTotal)) document.location = url + val;
	else return false;
}

function popup(url,width,height) {
	var properties = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height;
	var myPopup = window.open(url, "myPopup", properties);
	myPopup.focus();
}


window.addEvent('domready', function() {
	var blogImages = $ES('img','blogEntry');
		if (blogImages.length >= 1){
			tImg = new Element('img', { 'src': blogImages[0].src}).setProperty('id', 'tImg').setStyles('position:absolute;left:-9000px').injectInside(document.body);
			tImgY = tImg.getSize().size.y;
			tImgX = tImg.getSize().size.x;
			if (tImgX >= 350){  //resize the image on the fly!
				ratio = 350/tImgX;
				newY = Math.round(tImgY*ratio);
				blogImages[0].style.width = '350px';
				blogImages[0].style.height = newY+'px';
			}
				blogImages[0].setStyle('display', 'inline');
			tImg.remove();  //take our size temp Image out of the DOM
		}

	var blogParas = $ES('p','blogEntry');
	if (blogParas.length > 3){
		var pCount = 0;
		var lastPara;
		blogParas.each(function(para) {
			pCount++;
			if (pCount >=3){
				para.setStyle('display','none');
			} else {
				lastPara = para;
			}
		});
		new Element('span').setHTML("&nbsp;&nbsp;").injectInside(lastPara);
		readMore = new Element('a', {  'href': $('blogEntryLink').getProperty('href'), 'class':'more'});
		readMore.setHTML('read more &raquo;');
		readMore.injectInside(lastPara);
	}
});
