function MIVA_appendGetVars()
{
	var theroot = document.getElementById("columnData");
	var theLinks = _getElementsByTagName(theroot,"a");
	
	var theHREF;
	
	for ( var i = 0; i < theLinks.length; i++ )
	{
		theHREF = theLinks[i].getAttribute("href");
		theHREF += "&gTheSite="+this.gTheSite;
		theLinks[i].setAttribute("href",theHREF);
	}
	
	var theForms = _getElementsByTagName(theroot,"form");
	
	var theActionAttribute;
	
	for ( var i = 0; i < theForms.length; i++ )
	{
		theActionAttribute = theForms[i].getAttribute("action");
		theActionAttribute += "gTheSite="+this.gTheSite;
		theForms[i].setAttribute("action",theActionAttribute);
		//document.write("action: "+theForms[i].getAttribute("action")+"<br />");
	}
}

function MIVA_addCategoryToAllBodyLinks()
{	
	var theroot = document.getElementById("columnData");
	var theLinks = _getElementsByTagName(theroot,"a");
	
	var theHREF;
	
	for ( var i = 0; i < theLinks.length; i++ )
	{
		theHREF = theLinks[i].getAttribute("href");
		theHREF += "&Category_Code="+this.gMIVACat;
		theLinks[i].setAttribute("href",theHREF);
	}
}

function MIVA_writeDocumentTitle()
{
	var theSection = document.getElementById("itemnameData").firstChild.nodeValue;
	if (gTheSite == "FH")
		document.title = "Fountain House :: "+ theSection;
	else if (gTheSite == "HPF")
		document.title = "High Point Farm :: "+ theSection;
	else
		document.title = "No Site Defined :: "+ theSection;
}

/*function getAppendVars (inSecureSessionURL,inLoggedin)
{
	
	SecureSessionURL = validateSecureSessionURL (inSecureSessionURL);
	Loggedin = validateLoggedInvar (inLoggedin);
	
	var appendVariables = "?loggedin="+Loggedin+"&secureSessionURL="+escape(SecureSessionURL);
		
	return appendVariables	
}

function validateLoggedInvar (inLoggedin)
{
	
	if (inLoggedin == undefined)
		inLoggedin = getQueryVariable('loggedin');
		
	return inLoggedin;
}

function validateSecureSessionURL (inSecureSessionURL)
{
	var SecureSessionURL = inSecureSessionURL
	
	if (inSecureSessionURL == undefined)
		SecureSessionURL = getQueryVariable('secureSessionURL')
	
	if (SecureSessionURL == '')
		SecureSessionURL= 'https://secure40.securewebsession.com/fountainhouse.site.aplus.net/mm5/merchant.mvc?';
	
	if (SecureSessionURL.indexOf(":") == -1)
		SecureSessionURL = unescape(SecureSessionURL);
		
	return SecureSessionURL;
}

function getQueryVariable(variable)
{
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  }
  return '';
  //alert('Query Variable ' + variable + ' not found');
}

function MIVAINT_doURLFixing (inSecureSessionURL,inLoggedin)
{
	//var appendVariables = getAppendVars (inSecureSessionURL,inLoggedin);
	
	//for (i=0;i<document.links.length;i++)
	//{
	//	if (document.links[i].href.indexOf('?') == -1 )
	//		document.links[i].href += appendVariables;
		
		//document.write(document.links[i].href+'  '+typeof(document.links[i].href)+'<br />');
	//}
}*/
