// Made for Morrisons by Mark Mulrooney/Candi

function changecss(theClass,element,value) {
// documentation for this script at http://www.shawnolson.net/a/503/
// credit for this code to Shawn Olson at www.shawnolson.net
	 var cssRules;
	 if (document.all) {
	  cssRules = 'rules';
	 }
	 else if (document.getElementById) {
	  cssRules = 'cssRules';
	 }

	 for (var S = 0; S < document.styleSheets.length; S++){
	  for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
	   if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
	    document.styleSheets[S][cssRules][R].style[element] = value;
	   }
	  }
	 }	
}


// JavaScript routine to keep two id boxes the same height. 
// Used in 2.5-fresh-foods-whatsinseason.htm and fresh-foods-what-is-free-range.htm.
function id_height_corrector(id1,id2) {
	var test_ID_existence=document.getElementById(id2)
	if (test_ID_existence) {
	
		var h1=getOffsetHeight(id1);
		var h2=getOffsetHeight(id2);
		
		//alert("h1=" + h1 + "  h2=" + h2);
			
		if (h1>h2) {
			var obj=document.getElementById(id2).style;
			h1=h1-18;	// to cope with the vertical padding that has been added by the CSS
			obj.height=h1 + "px"
		}
		else {
			h2=h2-18;
			var obj=document.getElementById(id1).style;
			obj.height=h2 + "px"
		}
	}
	
}




// function getOffsetHeight(id) obtained off Internet
function getOffsetHeight(id)
{
	h = Number.NaN;
	if (document.getElementById) {
		var ele = document.getElementById(id);
		if (ele && typeof ele.offsetHeight != 'undefined') {
		h = ele.offsetHeight;
		}
	}
	return h;
}


// function getOffsetWidth(id) derived from function getOffsetHeight(id)
function getOffsetWidth(id)
{
	w = Number.NaN;
	if (document.getElementById) {
		var ele = document.getElementById(id);
		if (ele && typeof ele.offsetWidth != 'undefined') {
		w = ele.offsetWidth;
		}
	}
	return w;
}




