// JavaScript Document

/*
	This parses GET values passed to an HTML page - it was developed for use
	with moogle inorder to strip the left and right columns as well as the
	page header and footer. Other uses might be to configure a web page for 
	mobile device use.
	
	To implement this code on a page use the following:
	<script language="javascript" src="/javascript/parseGET.js" type="text/javascript"></script>
*/


	var fullURL=window.location.href;	//	<- get the currect URL
	var passedInlineVariable=false;
	
//Check String URL for ? - if not present then no variables were passed.
	for (i=0; i<=fullURL.length;i++){
		if(fullURL.charAt(i)=="?"){
			passedInlineVariable=true;
		}
	}
	
	
if(passedInlineVariable==true){	
	var GetVals=fullURL.split("?");		//	<- seperate the URL from any attached variables
	var GetVars=GetVals[1].split(";");	//	<- split the variables into individual VarName=Values
	
	
	// This function takes the VarName=Values and returns the value of a requested VarName
	// For example if your used: var x=checkVal("name") and there was a name=Jim Almeida in the
	// url, x would equal Jim Almeida
	
	function checkVal(checkVar){
		for(i=0;i<=GetVars.length-1;i++){
			returnValues=GetVars[i].split("=");
			if(checkVar==returnValues[0]){
				return(returnValues[1]);
				break;
			}
		}
	}
	
	
	// This is the actual call to the checkVal function that tests to see if a page is being
	// pulled into Moogle. If the page is to be displayed in Moogle you would submit your url
	// with a displayMode variable like so: http://devwww01/about_whoWeAre.aspx?displayMode=moogle
	// the document.write(s) simply add a small CSS definition to the document that hides the
	// left and right columns, and the header and footer. Additional scriplets could be used to add
	// other information to the page as needed using  a similar technique.
	
	if(checkVal("displayMode")=="moogle"){
		document.write("<style type='text/css' media='all'>");
		document.write("#pageHeader, #LCol, #RCol, #pageFooter{display:none;}");
		document.write("#pageWrapper{width:100%; border:none; margin:0;}");
		document.write("#pageContentD #CCol{width:100%;}");
		document.write("</style>");
	}
}

function replaceWithSpace(rs,rw){
	splitMe=rs.split("%20");
	outString="";

	for(i=0;i<=splitMe.length-1;i++){
		outString+=splitMe[i]+" ";
	}
	
	return(outString);
}
