function mpLoadFile(filename, filetype){

	//if filename is a external JavaScript file
	if (filetype=="js"){
		var fileref=document.createElement('script')
		fileref.setAttribute("type","text/javascript")
		fileref.setAttribute("src", filename)
	
	//if filename is an external CSS file
	}else if (filetype=="css"){
		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 mpUnloadFile(filename, filetype){

	//determine element type to create nodelist from
	var targetelement=(filetype=="js")? "script" : (filetype=="css")? "link" : "none"
	
	//determine corresponding attribute to test for
	var targetattr=(filetype=="js")? "src" : (filetype=="css")? "href" : "none"
	var allsuspects=document.getElementsByTagName(targetelement)
 
	//search backwards within nodelist for matching elements to remove
	for (var i=allsuspects.length; i>=0; i--){
		if (allsuspects[i] && allsuspects[i].getAttribute(targetattr)!=null && allsuspects[i].getAttribute(targetattr).indexOf(filename)!=-1)
		
		//remove element by calling parentNode.removeChild()
		allsuspects[i].parentNode.removeChild(allsuspects[i]) 
	}
}

//removejscssfile("somescript.js", "js") //remove all occurences of "somescript.js" on page
//removejscssfile("somestyle.css", "css") //remove all occurences "somestyle.css" on page
