var GearCalc = function(wheelCircum, chainringTeeth, cogTeeth, ambiskidder){
	this.wheelCircum = wheelCircum;
	this.crTeeth = chainringTeeth;
	this.cgTeeth = cogTeeth;
	this.wheelDia = this.wheelCircum/Math.PI;
	if(ambiskidder == "true")
		this.ambiSkidder = true;
	else
		this.ambiSkidder = false;
				
	this.setWheelCircum = function(wheelCircum){
		this.wheelCircum = wheelCircum;
		this.wheelDia = this.wheelCircum/Math.PI;
	}


	this.calcRatio = function(){ return this.crTeeth / this.cgTeeth;}
	this.calcInches = function(){return this.calcRatio() * this.wheelDia;}
	
	this.calcSkidPatches = function(){
		var found = false;
		var result = this.cgTeeth;
		var numerator = 0;
		
		//if number of chainring teeth and number of cog teeth are equal return 1
		if(this.crTeeth % this.cgTeeth == 0){
			found = true;
			result = 1;
			numerator = this.crTeeth;
		}
		
		var i = this.cgTeeth;

		while(!found && i>0){
			if((this.crTeeth%i == 0) && (this.cgTeeth%i==0)){
				found=true;
				result = this.cgTeeth/i;
				numerator = this.crTeeth/i;
			}
			i--;
		}
		
		if(this.ambiSkidder == true){
			if(numerator%2 != 0){
				//numerator is odd
				result = result * 2;
			}
		}
					

		return result;
	}
	
};