function QueryStringManager(numberOfDays,rowCount){
this._numberOfDays = numberOfDays;
this._rowCount = rowCount;
this._query = window.location.search.substring(1);
this._pair = new Array();
this._queryStringArray = new Array();
}
QueryStringManager.prototype.loadString = function(obj){
if(this._query!=''){
	this.vars = this._query.split("&");
	for(var i=0;i<this.vars.length;i++){
		this._pair[i] = new Array();
		this._pair[i] = this.vars[i].split("=");
		}
this._queryStringRowCount	= 	this._pair[(this._pair.length-1)][1];
this._pair[(this._pair.length-1)] = null;
// There are problems if someone's query string contains data from previous days 
// (so the rows of fixtures from the query string will not tally with the present number of rows of fixtures)
// fix this by making an offset.
alert(this._pair[0][1]+' '+this._pair[1][1]+' '+this._pair[2][1]+' '+this._pair[3][1]+' '+this._pair[4][1]+' '+this._pair[5][1]+' '+this._pair[6][1]+' '+this._pair[7][1])	
if(this._queryStringRowCount!=this._rowCount){
	this._offset = this._queryStringRowCount - this._rowCount;
	this._offset = this._offset*2;
	for(var d=0;d<this._pair.length;d++){
		if(this._pair[(d+this._offset)]){
			this._pair[d][1] = this._pair[(d+this._offset)][1];
			}
		}
	}
	else{
	this._offset = 0;
	}	
alert(this._pair[0][1]+' '+this._pair[1][1]+' '+this._pair[2][1]+' '+this._pair[3][1]+' '+this._pair[4][1]+' '+this._pair[5][1]+' '+this._pair[6][1]+' '+this._pair[7][1])	
var j = 0;
for(var d=0;d<this._numberOfDays;d++){
	var e = 0;
	while(document.inputForm["i_itemNameLeft"+d+"_"+e] != null){
		if(document.inputForm["i_itemLeft"+d+"_"+e].name == this._pair[j][0]){
			if(this._pair[j][1]=='null'){this._pair[j][1]='';}
				document.inputForm["i_itemLeft"+d+"_"+e].value = this._pair[j][1];
				j++;
				}
		if(document.inputForm["i_itemRight"+d+"_"+e].name == this._pair[j][0]){
			if(this._pair[j][1]=='null'){this._pair[j][1]='';}
				document.inputForm["i_itemRight"+d+"_"+e].value = this._pair[j][1];
				j++;
				}	
			e++;		
			}
		}	
	obj.send();	
	}		
} 
QueryStringManager.prototype.saveString = function(){
this.encodeString();
this._QueryString = "?";
for(var i=0;i<this._queryStringArray.length;i++){
this._QueryString = this._QueryString+this._queryStringArray[i][0]+"="+this._queryStringArray[i][1]+"&";
}
alert(this._QueryString);
if(this._QueryString != "?"){
	var numrows = "rc=" + this._rowCount;
	this._QueryString = this._QueryString+numrows;
	// trim off the "&" off the end of the string
	//this._QueryString = this._QueryString.substring(0,(this._QueryString.length-1))
	document.sendtoafriend.success.value = basicURL + this._QueryString;
	}	
//document.sendtoafriend.submit();
}
QueryStringManager.prototype.encodeString = function(){
var j = 0;
for(var d=0;d<this._numberOfDays;d++){
		var e = 0;
		while(document.inputForm["i_itemNameLeft"+d+"_"+e] != null){
		this._queryStringArray[j] = new Array();
		this._queryStringArray[j][0] = document.inputForm["i_itemLeft"+d+"_"+e].value;
		if(this._queryStringArray[j][0]==''){this._queryStringArray[j][0]='x'}
		this._queryStringArray[j][1] = document.inputForm["i_itemRight"+d+"_"+e].value;
		if(this._queryStringArray[j][1]==''){this._queryStringArray[j][1]='x'}
		e++;
		j++;
		}
	}	
}