var ref = false;
	if (document.referrer != ''){
		if(document.referrer.indexOf('www.soundreading') >-1)
			eraseCookie('mathDesign');
		ref = document.referrer;
	}
	if((ref && ref.indexOf('mathmakessense') >-1) || readCookie('mathDesign') || location.hash == "#math"){
		mathDesign();
		createCookie('mathDesign','true',.01);
		//location.hash = '#math';
	}
  
function loadCSS(filename){
	var fileref=document.createElement("link")
	fileref.setAttribute("rel", "stylesheet")
	fileref.setAttribute("type", "text/css")
	fileref.setAttribute("href", filename)
	if(typeof fileref!="undefined")
		document.getElementsByTagName("head")[0].appendChild(fileref)
}
function removeCSS(filename){
	var allsuspects=document.getElementsByTagName('link');
	for (var i=allsuspects.length; i>=0; i--){ //search backwards within nodelist for matching elements to remove
		if (allsuspects[i] && allsuspects[i].getAttribute('href')!=null && allsuspects[i].getAttribute('href').indexOf(filename)!=-1)
			allsuspects[i].parentNode.removeChild(allsuspects[i]) //remove element by calling parentNode.removeChild()
	}
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
function mathDesign(){
	removeCSS('menu.php');
	removeCSS('main.php');
	//removeCSS('Template.css');
	
	loadCSS('http://www.mathmakessense.com/css/mathstore.css');
	loadCSS('http://www.mathmakessense.com/css/menu.css');
	try{
	document.body.style.backgroundImage="url('http://www.mathmakessense.com/images/headerbackground.png')";
	}catch(e){};
}
document.write('                                                                           ');
document.write('                                                                           ');
document.write('                                                                           ');
document.write('                                                                           ');