function toggle(btnName, state) {
	var newImg = "images/m_" + btnName + "_" + state+ ".jpg";
	document[btnName].src = newImg;	
}

function toggleMain(btnName, state) {
	var newImg = "images/m_h_" + btnName + "_" + state+ ".jpg";
	document[btnName].src = newImg;	
}


// Min and Max font sizes

//p
var min=8;
var max=16;

//news list
var newsMin = 11;
var newsMax = 16;

//pull quote
var pullMin = 11;
var pullMax = 16;

function increaseFont() {
	changeContentText(1);
	changePullQuote(1);
	changeNews(1);
	changeFeature(1);
	changeFooter(1);
}

function decreaseFont() {
	changeContentText(-1);
	changePullQuote(-1);
	changeNews(-1);
	changeFeature(-1);
	changeFooter(-1);
}

function increaseFontHome() {
	changeHomePull(1);
	changeNewsHome(1);
	changeFeatureHome(1);
	changeFooter(1);
}

function decreaseFontHome() {
	changeHomePull(-1);
	changeNewsHome(-1);
	changeFeatureHome(-1);
	changeFooter(-1);
}

/* Changes for Homepage */
function changeHomePull(direction) {
	var p = document.getElementById('pullContentHome');
	var l = p.getElementsByTagName('p');
	for(var j = 0; j < l.length; j++) {
		if(l[j].style.fontSize) {
			var s = parseInt(l[j].style.fontSize.replace("pt",""));
		} else {
			var s = 11;
		}
		if((direction == 1 && s != pullMax) || (direction == -1 && s!=pullMin)) {
			s += direction;
		}
		l[j].style.fontSize = s+"pt"
	}
}

function changeNewsHome(direction) {
	var p = document.getElementById('newsSideListHome');
	if(p.style.fontSize) {
		var s = parseInt(p.style.fontSize.replace("px",""));
	} else {
		var s = 11;
	}
	if((direction == 1 && s != newsMax) || (direction == -1 && s!=newsMin)) {
		s += direction;
	}
	p.style.fontSize = s+"px"
}

function changeFeatureHome(direction){
	var p = document.getElementById('homeFeatureContent');
	var l = p.getElementsByTagName('p');
	for(i = 0; i < l.length; i++) {
		if(l[i].style.fontSize) {
			var s = parseInt(l[i].style.fontSize.replace("pt",""));
		} else {
			var s = 9;
		}
		if((direction == 1 && s != max) || (direction == -1 && s!=min)) {
			s += direction;
		}
		l[i].style.fontSize = s+"pt"
	}
}

/* subpages */
function changeContentText(direction) {
	var b = document.getElementById('mainColumn');
	var p = b.getElementsByTagName('p');
	for(i=0;i<p.length;i++) {
		if(p[i].style.fontSize) {
			var s = parseInt(p[i].style.fontSize.replace("pt",""));
		} else {
			var s = 9;
		}
		if((direction == 1 && s != max) || (direction == -1 && s!=min)) {
			s += direction;
		}
		p[i].style.fontSize = s+"pt"
	}
}

function changePullQuote(direction) {
	var p = getElementsByStyleClass('pullContent');
	for(i = 0; i < p.length; i++) {
		var l = p[i].getElementsByTagName('li');
		for(var j = 0; j < l.length; j++) {
			if(l[j].style.fontSize) {
				var s = parseInt(l[j].style.fontSize.replace("px",""));
			} else {
				var s = 11;
			}
			if((direction == 1 && s != pullMax) || (direction == -1 && s!=pullMin)) {
				s += direction;
			}
			l[j].style.fontSize = s+"px"
		}
	}
}

/* news list */
function changeNews(direction) {
	var p = document.getElementById('newsSideList');
	if(p.style.fontSize) {
		var s = parseInt(p.style.fontSize.replace("px",""));
	} else {
		var s = 11;
	}
	if((direction == 1 && s != newsMax) || (direction == -1 && s!=newsMin)) {
		s += direction;
	}
	p.style.fontSize = s+"px"
}

/* feature story in right column */
function changeFeature(direction){
	var p = document.getElementById('featureContent');
	var l = p.getElementsByTagName('p');
	for(i = 0; i < l.length; i++) {
		if(l[i].style.fontSize) {
			var s = parseInt(l[i].style.fontSize.replace("pt",""));
		} else {
			var s = 8;
		}
		if((direction == 1 && s != max) || (direction == -1 && s!=min)) {
			s += direction;
		}
		l[i].style.fontSize = s+"pt"
	}
}

/* footer */
function changeFooter(direction) {
	var p = document.getElementById('copyright');
	if(p.style.fontSize) {
		var s = parseInt(p.style.fontSize.replace("px",""));
	} else {
		var s = 11;
	}
	
	if((direction == 1 && s != newsMax) || (direction == -1 && s!=newsMin)) {
		s += direction;
	}
	p.style.fontSize = s+"px"
	
	var p = document.getElementById('footerLinks');
	if(p.style.fontSize) {
		var s = parseInt(p.style.fontSize.replace("px",""));
	} else {
		var s = 11;
	}
	if((direction == 1 && s != newsMax) || (direction == -1 && s!=newsMin)) {
		s += direction;
	}
	p.style.fontSize = s+"px"
}

function getElementsByStyleClass (className) {
	var all = document.getElementsByTagName('div');
	var elements = new Array();
	for (e = 0; e < all.length; e++){
		if (all[e].className == className) {
			elements[elements.length] = all[e];
		}
	}
	return elements;
}