Hand = new Class({
	//implements
	Implements: [Options],

	//options
	options: {
		userId:			null,
		isCribbage:		false,
		team: 			null,
		trackPoints: 	false,
		settings:		new Hash(),
		pegPoints:		new Hash(),
		idPrefix: 		'card'
	},
		
	Cards: new Array(),
	CardCombIdx: null,
	CardComb: null,
	counterPoints: new Array(),

	meldPoints: 	0,
	handPoints: 	0,
	cribPoints: 	0,
	gamePoints: 	0,
	gamesWon:		0,
	noCutPoints: 	0,
	
	suit: 		'CDHS',
	rank:		'A23456789TJQK',
	

	initialize: function(options) {
		this.setOptions(options);
		this.initArrays();
	},


	cardString: function(played) {
		var str = '';
		
		var arr = new Array();
		
		for (var c=0; c<this.Cards.length; c++) {
			if ((played && this.Cards[c].getPlayed()) || !this.Cards[c].getPlayed()) {
				str += this.Cards[c].getCardCode() + ' ';			
			}
		}
		
		return str;
	},
	
	
	containsCard: function(nc) {
		var ret = false;
		
		for (var curCard=0; curCard<this.Cards.length; curCard++) {
			if (this.Cards[curCard].getId() == nc) {
				ret = true;
				break;
			}
		}
		
		return ret;
	},
	
	
	add: function(card) {
		this.Cards.push(card);
	},
	
	
	clearCards: function(card) {
		this.Cards.each(function(card) {
			var cDom = $(this.options.idPrefix+'_'+card.getId());

			if (cDom && cDom.get('id').contains('card_')) {
				var cd = cDom.retrieve('cardDrag');
				if (cd) {
					cd.detach();
				}
			}
			
			toolTips.detach(cDom);
		}.bind(this));
		
		this.Cards.empty();
	},
	
	
	getCard: function(pos) {
		if (!this.Cards || pos < 0 || pos > this.Cards.length) {
			return null;
		}
				
		return this.Cards[pos];
	},
	
	
	getCutCard: function() {
		var cut = null;
		
		for (var curCard=0; curCard<this.Cards.length; curCard++) {
			if (this.Cards[curCard].getCut()) {
				cut = this.Cards[curCard];
				break;
			}
		}
		
		return cut;
	},
	
	
	getCardRanks: function(played) {
		var arr = new Array();
		
		for (var c=this.Cards.length; c--;) {
			if ((played && this.Cards[c].getPlayed()) || !this.Cards[c].getPlayed()) {
				arr.push(this.Cards[c].getRank());				
			}
		}
		
		return arr;
	},
	
	
	getCardValues: function(played) {
		var arr = new Array();
		
		for (var c=this.Cards.length; c--;) {
			if ((played && this.Cards[c].getPlayed()) || !this.Cards[c].getPlayed()) {
				arr.push(this.Cards[c].getValue());
			}
		}
				
		return arr;
	},
	
	/*	
	getCardValues: function(played) {
		var arr = new Array();
		
		for (var c=this.Cards.length; c--;) {
			if ((played && this.Cards[c].getPlayed()) || !this.Cards[c].getPlayed()) {
				arr.push(this.Cards[c].getValue());
			}
		}
				
		return arr;
	},
	*/
	
    hasPair: function() {
		var ret = null;
		
        this.CardComb[0].each(function(comb) {
        	if (comb[0] < this.Cards.length && comb[1] < this.Cards.length) {
	        	if ((this.Cards[comb[0]].getRank() && !this.Cards[comb[0]].getPlayed()) == (this.Cards[comb[1]].getRank() && !this.Cards[comb[1]].getPlayed())) {
	        		ret = comb[0];
	        	}
        	}
        }.bind(this));

        return ret;
    },

    
    getCardByValue: function(val, played) {
		var ret = null;
		
		for (var c=this.Cards.length; c--;) {
			if (((played && this.Cards[c].getPlayed()) || !this.Cards[c].getPlayed()) && this.Cards[c].getValue() == val) {
				ret = this.Cards[c];
				break;
			}
		}
				
		return ret;
    },
    
 
    hasTwoMakesFive: function(num) {
    	var vals = this.getCardValues(false);
    	var ret = null;
    	
    	if (vals.contains(2) && vals.contains(3)) {
    		ret = this.getCardByValue(Number.random(2, 3), false);
    		
    	} else if (vals.contains(1) && vals.contains(4)) {
    		ret = this.getCardByValue(4, false);
    	}
    	
    	return ret;
    },
    
    
    getLessThanFive: function() {
    	var ret = null;
    	var vals = new Array(1,2,3,4);
    	vals.shuffle();

    	for (var c=vals.length; c--;) {
    		ret = this.getCardByValue(vals[c]);
    		if (ret != null) {
    			//return ret;
    			break;
    		}
    	}

    	return ret;
    },
    
    
    getNonFive: function() {
		var nonFives = this.Cards.filter(function(card, index) {
			return card.getValue() != 5;
		});
		
		if (nonFives.length) {
			return this.getCardByValue(nonFives[0].getValue(), false);
		}

    	return null;
    },
	
	
	getCardThatDoesNotMake: function(dontmake, total) {
		var ret = null;
		
		//try {
	    	for (var c=this.Cards.length; c--;) {
				if (!this.Cards[c].getPlayed()) {
					var canPlay = true;
					
			    	for (var dm = dontmake.length; dm--;) {
						if (this.Cards[c].getValue() + total == dontmake[dm]) {
							canPlay = false;
						}
						
						if (this.Cards[c].getValue() + total > 31) {
							canPlay = false;
						}
					}
					
					if (canPlay) {
						ret = this.Cards[c];
					}
				}
	    	}
	    	/*
		}
		
		catch (e) {
		    console.log('Hand.getCardThanDoesNotMake Error');
			console.log(e);
		}
		*/
		
		return ret;
	},
	
	
	getFirstPlayableCard: function() {
		var ret = null;
		
    	for (var c=this.Cards.length; c--;) {
    		if (!this.Cards[c].getPlayed()) {
    			ret = this.Cards[c];
    			break;
    		}
    	}
		
		return ret;
	},

    
    makeHand: function(cards, cut) {
		var newHand = new Array();
		
		cards.each(function(card) {
			var cv1 = this.rank.indexOf(card[0]);
			var cv2 = ((this.suit.indexOf(card[1])) * 13);
			var cv = cv1+cv2;
			
			newHand.push(new Card({'value': cv, 'idPrefix': this.options.idPrefix}));
		}.bind(this));
			
		/*
		if ($defined(cut)) {
			var cv = this.rank.indexOf(cut[0]) + (this.suit.indexOf(cut[1]) * 13);
			newHand.push(new Card({'value': cv, 'cut': true, 'idPrefix': this.options.idPrefix}));
		}
		*/
		
		this.Cards = newHand;
	},


	buildHand: function(cards, sort) {
		var tmpHand = new Array();
		var tmpCard = null;
		
		cards.each(function(card) {
			tmpCard = new Card({'value': card, 'idPrefix': this.options.idPrefix});
			tmpHand.push(tmpCard);
		});
		
		if (sort) {
			tmpHand = this.sortCards(tmpHand);
		}
		
		return tmpHand;
	},
	
	
	countPlayableCards: function() {
		var ret = 0;
		
		for (var curCard=0; curCard<this.Cards.length; curCard++) {
			if (!this.Cards[curCard].getPlayed()) {
				ret++;
			}
		}
		
		return ret;
	},
	
	
	getPlayableCards: function(total) {
		var cards = new Array();
		
		for (var curCard=0; curCard<this.Cards.length; curCard++) {
			if (!this.Cards[curCard].getPlayed() && this.Cards[curCard].getValue() + total <= 31) {
				cards.push(this.Cards[curCard]);
			}
		}
        
		return cards;
	},
	
	
	canPlayCard: function(val) {
		var ret = false;
		
		for (var curCard=0; curCard<this.Cards.length; curCard++) {
			if (!this.Cards[curCard].getPlayed() && this.Cards[curCard].getValue() <= val) {
				ret = true;
				break;
			}
		}
		
		return ret;
	},
    
    
    getFirstNonCutCard: function() {
        var ret = null;
        
		for (var curCard=0; curCard<this.Cards.length; curCard++) {
			if (!this.Cards[curCard].getCut() && !ret) {
				ret = this.Cards[curCard];
			}
		}
        
        return ret;
    },
    
    
    getNonCutCards: function() {
        var ret = new Array();
        
		for (var curCard=0; curCard<this.Cards.length; curCard++) {
			if (!this.Cards[curCard].getCut()) {
				ret.push(this.Cards[curCard]);
			}
		}
        
        return ret;
    },
    
    
    getLastCards: function(num) {
        var ret = new Array();
        var start = this.Cards.length-num;
        
        for (var curCard=start; curCard<this.Cards.length; curCard++) {
            ret.push(this.Cards[curCard]);
        }
        
        return ret;
    },
	
	
	getHandPlayed: function() {
        var ret = new Array();
        
        for (var curCard=0; curCard<this.Cards.length; curCard++) {
            ret.push(this.Cards[curCard].getPlayed());
        }
        
        return ret;
	},
	
	
	getHandIds: function() {
		var ret = new Array();
		
		for (var curCard=0; curCard<this.Cards.length; curCard++) {
			ret.push(this.Cards[curCard].getId());
		}
		
		return ret;
	},

	
	getHandValues: function() {
        var ret = new Array();
        
        for (var curCard=0; curCard<this.Cards.length; curCard++) {
            ret.push(this.Cards[curCard].getValue());
        }
        
        return ret;
	},

	
	getHandCodes: function() {
        var ret = new Array();
        
        for (var curCard=0; curCard<this.Cards.length; curCard++) {
            ret.push(this.Cards[curCard].getCardCode());
        }
        
        return ret;
	},

	
	getHandStatuses: function() {
        var ret = new Array();
        
        for (var curCard=0; curCard<this.Cards.length; curCard++) {
            ret.push(this.Cards[curCard].getStatus());
        }
        
        return ret;
	},

	
	hasJoker: function() {
        var ret = false;
        
        for (var curCard=0; curCard<this.Cards.length; curCard++) {
            if (this.Cards[curCard].getId() < 0) {
            	ret = true;
            	break;
            }
        }
        
        return ret;
	},

	
	getJokerIndex: function() {
        var ret = null;
        
        for (var curCard=0; curCard<this.Cards.length; curCard++) {
            if (this.Cards[curCard].getId() < 0) {
            	ret = curCard;
            	break;
            }
        }
        
        return ret;
	},

	
	getJokerCard: function() {
        var ret = null;
        
        /*
		if (this.hasJoker()) {
			ret = this.Cards[curCard];
		}
        */
        
        for (var curCard=0; curCard<this.Cards.length; curCard++) {
            if (this.Cards[curCard].getId() < 0) {
            	ret = curCard;
            }
        }
        
        return ret;
	},

	
	compareCards: function(c1, c2) {
		return c1.getRank() - c2.getRank();
	},
	
	
	sortHand: function() {
		this.Cards.sort(this.compareCards);
	},
	
	
	sortCards: function(cards) {
		var tmpCards = cards;

		tmpCards.sort(this.compareCards);
		return tmpCards;
    },
	

    sortASC: function (a, b) { return (a-b); },
    sortDESC: function (a, b) { return (b-a); },

    
    isSortRun: function(cards, roundTheWorld) {
    	var ret = cards.length;
    	
    	var tmp = [];
    	for (var cc=0; cc<cards.length; cc++) {
    		if (roundTheWorld == undefined || !roundTheWorld) {
    			tmp.push(cards[cc].getRank());
    		} else {
    			if (cards[cc].getRank() >= 0 && cards[cc].getRank() <= 6) {
    				tmp.push(cards[cc].getRank() + 13);
    			} else { 
    				tmp.push(cards[cc].getRank());
    			}
    		}
    	}
    	cards = tmp;
    	
    	cards.sort(this.sortASC);

		if (cards.length >= 3) {
			for (var curCard=0; curCard<cards.length-1; curCard++) {
				try {
					if (cards[curCard]+1 != cards[curCard+1]) {
						ret = 0;
						break;
					}
				}
				catch(e) {
					console.log('Hand.isSortRun error');
					console.log(e);
					ret = 0;
					break;
				}
			}
		} else {
			ret = 0;
		}
    
    	if (!this.options.isCribbage && this.options.trackPoints) {
    		if (ret) {
    			this.addCounterPoint(cards, 'Runs');
    		}
    	}
    	
		return ret;
    },
    
    
	isFullRun: function() {
    	return this.isSortRun(this.Cards);
    },


    countBigRuns: function(num) {
    	var self = this;
	    var	score=0, cnt=0;
	    var tmp = new Array();

        if (num < 3 || num > 7 || num > this.Cards.length) {
            return 0;
        }
               
		group = this.CardComb[num-2];
        for (var cg=0; cg<group.length; cg++) {
        	tmp = new Array();
			var tooBig = group[cg].filter(function(card, index) {
				return card >= self.Cards.length;
			});

			if (!tooBig.length) {
	        	for (var cc=0; cc<group[cg].length; cc++) {
        			tmp.push(new Card({'value': this.Cards[group[cg][cc]].getId(), 'idPrefix': this.options.idPrefix}));
	        	}
			}
			
            if (this.isSortRun(tmp, false)) {
                score += num;
            } else {
                if (this.options.settings.get('runaroundworld') && this.isSortRun(tmp, true)) {
                    score += num;
                }
            }
        }

        return score;
    },
    
    
	countRuns: function() {
    	var score = 0;
    	var cards=new Array();

        if (this.isFullRun() == this.Cards.length) {
        	if (!this.options.isCribbage && this.options.trackPoints) {
        		this.addCounterPoint(this.Cards, 'Runs');
        	}
            return this.Cards.length;
        }

        for (var x=7; x>3; x--) {
        	if (x <= this.Cards.length-1) {
	            score = this.countBigRuns(x);
	            if (score > 4 || (score==4 && this.Cards.length==5)) {
	                return score;
	            }
	        }
        }

        if (score == 0) {
			return this.countBigRuns(3);
		}

        if (this.Cards.length == 7 && score == 4) {
            score += this.countBigRuns(3);
        }

        return score;
    },
    

    countFifteens: function(num) {
    	var fifteens=0;
		var cg=0;
		var cards=new Array();
		var total=0;
		var curCard=0;
		var self=this;
		
		for (var cardGroup=0; cardGroup<this.CardComb.length-1; cardGroup++) {
			for (var cardSet=0; cardSet<this.CardComb[cardGroup].length; cardSet++) {
				var tooBig = self.CardComb[cardGroup][cardSet].filter(function(card, index) {
					return card >= self.Cards.length;
				});

				if (!tooBig.length) {
					total=0;
					for (curCard=0; curCard<this.CardComb[cardGroup][cardSet].length; curCard++) {
						try {
							total += parseInt(this.Cards[this.CardComb[cardGroup][cardSet][curCard]].getValue());
						}
						catch(e) {
                            console.log('Hand.countFifteens Error');
							total = 0;
							break;
						}
					}
					if (total == 15) {
						fifteens++;
						if (!this.options.isCribbage && this.options.trackPoints) {
							cards=new Array();
							for (curCard=0; curCard<this.CardComb[cardGroup][cardSet].length; curCard++) {
								cards.push(this.Cards[this.CardComb[cardGroup][cardSet][curCard]]);
							}
						
							this.addCounterPoint(cards, 'Fifteens');
						}
					}
				}
			}
		}

        return fifteens;
    },
    

    countThirtyOnes: function(num) {
    	var thirtyones=0;
		var cg=0;
		var cards=new Array();
		var total=0;
		var curCard=0;
		var self=this;
		
		for (var cardGroup=0; cardGroup<this.CardComb.length-1; cardGroup++) {
			for (var cardSet=0; cardSet<this.CardComb[cardGroup].length; cardSet++) {
				var tooBig = self.CardComb[cardGroup][cardSet].filter(function(card, index) {
					return card >= self.Cards.length;
				});

				if (!tooBig.length) {
					total=0;
					for (curCard=0; curCard<this.CardComb[cardGroup][cardSet].length; curCard++) {
						try {
							total += parseInt(this.Cards[this.CardComb[cardGroup][cardSet][curCard]].getValue());
						}
						catch(e) {
                            console.log('Hand.countThirtyOnes Error');
							total = 0;
							break;
						}
					}
					if (total == 31) {
						thirtyones++;
						if (!this.options.isCribbage && this.options.trackPoints) {
							cards=new Array();
							for (curCard=0; curCard<this.CardComb[cardGroup][cardSet].length; curCard++) {
								cards.push(this.Cards[this.CardComb[cardGroup][cardSet][curCard]]);
							}
						
							this.addCounterPoint(cards, 'ThirtyOnes');
						}
					}
				}
			}
		}

        return thirtyones;
    },

	
    countPairs: function() {
    	var cnt=0, x=0, pairs=0;
    	var cards=new Array();

        this.CardComb[0].each(function(comb) {
        	if (comb[0] < this.Cards.length && comb[1] < this.Cards.length) {
	        	if (this.Cards[comb[0]].getRank() == this.Cards[comb[1]].getRank()) {
	        		pairs++;

	        		if (!this.options.isCribbage && this.options.trackPoints) {
						cards=new Array();
						cards.push(this.Cards[comb[0]]);
						cards.push(this.Cards[comb[1]]);
					
						this.addCounterPoint(cards, 'Pairs');
					}
	        	}
        	}
        }.bind(this));

        return pairs;
    },
	
    
    countFlushPairs: function() {
        return 0;
    },
    

    countFlush: function() {
        var f = 0;

    	if (this.Cards.length) {
	        //var s = this.Cards[0].getSuit();
	        var s = this.getFirstNonCutCard().getSuit();
	        var cards=new Array();
	
	        for (var x=0; x<this.Cards.length; x++) {
	            if (!this.Cards[x].getCut() && this.Cards[x].getSuit() == s) {
	                f++;
	                if (!this.options.isCribbage && this.options.trackPoints) {
	                	cards.push(this.Cards[x]);
	                }
	            }
	        }
	        
	        if (f != this.Cards.length-1) {
	        	f=0;
	        }
	
			if (f) {
		        for (var x=0; x<this.Cards.length; x++) {
		            if (this.Cards[x].getCut() && this.Cards[x].getSuit() == s) {
		                f++;
		                if (!this.options.isCribbage && this.options.trackPoints) {
		                	cards.push(this.Cards[x]);
		                }
		            }
		        }
			}
			
			if (this.options.isCribbage && f != this.Cards.length) {
				f=0;
			}
			
			if (f < 4) {
				f=0;
			}
			
			if (f) {
				if (!this.options.isCribbage && this.options.trackPoints) {
					this.addCounterPoint(cards, 'Flush');
				}
			}
	    }

        return f;
    },


    countHisNobs: function() {
    	var cutCard = this.getCutCard();
		var cards=new Array();

    	if (cutCard != null) {		  	
	        for (var x=0; x<this.Cards.length; x++) {
	            if (this.Cards[x].getRank()+1 == 11 				&& 
	            	!this.Cards[x].getCut() 						&& 
	            	this.Cards[x].getSuit() == cutCard.getSuit()) {
	            	
	            	if (!this.options.isCribbage && this.options.trackPoints) {
	            		cards.push(this.Cards[x]);
	            		this.addCounterPoint(cards, 'HisNobs');
	            	}
	            	
					return 1;
	            }
	        }
    	}
    	
        return 0;
    },


    countThirtyOne: function() {
        return 0;
    },


    countDifferentSuits: function() {
        var handCards = this.getNonCutCards();
        var suits = new Hash({
            Clubs:      false,
            Diamonds:   false,
            Hearts:     false,
            Spades:     false
        });
        var ret = 4;
        
        if (handCards.length==4) {
            for (var x=0; x<handCards.length; x++) {
                suits.set(handCards[x].getSuitName(), true);
            }
        }
        
        if (suits.hasValue(false)) {
            ret = 0;
        }
        
        return ret;
    },


    countPoints: function() {
    	var Pairs		    = 0;
        var Fifteens	    = 0;
        var ThirtyOnes	    = 0;
        var Runs		    = 0;
        var Flush		    = 0;
        var HisNobs         = 0;
        var ThirtyOne       = 0;
        var FlushPairs      = 0;
        var DifferentSuits  = 0;
        var Total		    = 0;
        
		this.counterPoints	= new Array();
         
        Pairs		    	= this.countPairs()			    * this.getPegPoints('pair');
        Fifteens	    	= this.countFifteens()		    * this.getPegPoints('fifteen');
	    if (this.options.settings.get('thirtyoneinhand')) {
			ThirtyOnes	    = this.countThirtyOnes()	    * this.getPegPoints('thirtyone');
		}
        Runs		    	= this.countRuns()			    * this.getPegPoints('run');
	    Flush		    	= this.countFlush()			    * this.getPegPoints('flush');
	    HisNobs		    	= this.countHisNobs()		    * this.getPegPoints('hisnobs');
	    ThirtyOne	    	= this.countThirtyOne()		    * this.getPegPoints('thirtyone');
	    FlushPairs	    	= this.countFlushPairs()	    * this.getPegPoints('flushpairs');
	    if (this.options.settings.get('differentsuits')) {
	    	DifferentSuits	= this.countDifferentSuits()	* this.getPegPoints('differentsuits');
	    }
	    
	    Total		    	= Pairs + Fifteens + ThirtyOnes + Runs + Flush + HisNobs + ThirtyOne + FlushPairs + DifferentSuits;
	    
		var details = 
		{
	        'Pairs'		    : Pairs,
	        'Fifteens'	    : Fifteens,
		    'ThirtyOnes'    : ThirtyOnes,
	        'Runs'		    : Runs,
		    'Flush'		    : Flush,
		    'HisNobs'	    : HisNobs,
		    'Total'		    : Total,
		    'ThirtyOne'     : ThirtyOne,
		    'FlushPairs'    : FlushPairs,
		    'DifferentSuits': DifferentSuits,
		    'Go' 		    : 0,
		    'LastCard' 	    : 0,
		    'HisHeels' 	    : 0,
		    'Details'	    : this.counterPoints
		};
	    
	    return details;
    },

    
	getPegPoints: function (key) {
		return this.options.pegPoints.get(key);
	},
	
	
	addCounterPoint: function(cards, whatType) {
		var point = {'cards': cards, 'whatType': whatType};
		this.counterPoints.push(point);
	},


	discard: function(discard) {
		var retCard = null;
		
		for (var c=0; c<this.Cards.length; c++) {
			if (this.Cards[c].getId() == discard) {
				retCard = this.Cards[c];
				this.Cards.splice(c, 1);
			}
		}
		
		return retCard;
	},
	
	
	getPlayedCard: function(playedCard) {
		var retCard = null;
		
        for (var curCard=0; curCard<this.Cards.length; curCard++) {
        	if (this.Cards[curCard].getId() == playedCard) {
        		retCard = this.Cards[curCard];
        	}
        }
        
		return retCard;
	},
	
	
	setCardPlayed: function(playedCard) {
		try {
    		this.Cards.each(function(card, idx) {
    			if (card.getId() == playedCard) {
    				this.Cards[idx].setPlayed(true);
    			}
    		}.bind(this));
		}
        catch(e) {
            console.log('Hand.setCardPlayed');
            console.log(e);
        }
	},
	
	
	// Game Points
	addGamePoints: function(points) {
		if (!isNaN(points)) {
			this.gamePoints += parseInt(points);			
		}
	},


	setGamePoints: function(points) {
		if (!isNaN(points)) {
			this.gamePoints = parseInt(points);
		}
	},


	getGamePoints: function() {
		return this.gamePoints;
	},
	
	
	// Hand Points
	addHandPoints: function(points) {
		if (!isNaN(points)) {
			this.handPoints += parseInt(points);
			//this.addGamePoints(parseInt(points));
		}
	},


	setHandPoints: function(points) {
		if (!isNaN(points)) {
			this.handPoints = parseInt(points);
		}
	},


	getHandPoints: function() {
		return this.handPoints;
	},

	
	// No Cut Points (Points in hand before cut card)
	setNoCutPoints: function(points) {
		if (!isNaN(points)) {
			this.noCutPoints = parseInt(points);
		}
	},


	getNoCutPoints: function() {
		return this.noCutPoints;
	},

	
	// Meld Points
	addMeldPoints: function(points) {
		if (!isNaN(points)) {
			this.meldPoints += parseInt(points);
			//this.addGamePoints(parseInt(points));
		}
	},


	setMeldPoints: function(points) {
		if (!isNaN(points)) {
			this.meldPoints = parseInt(points);
		}
	},


	getMeldPoints: function() {
		return this.meldPoints;
	},

	
	// Crib Points
	addCribPoints: function(points) {
		if (!isNaN(points)) {
			this.cribPoints += parseInt(points);
			//this.addGamePoints(parseInt(points));
		}
	},


	setCribPoints: function(points) {
		if (!isNaN(points)) {
			this.cribPoints = parseInt(points);
		}
	},


	getCribPoints: function() {
		return this.cribPoints;
	},
	
	
	setUserId: function(userId) {
		this.options.userId = userId;
	},
	
	
	getUserId: function() {
		return this.options.userId;
	},
	
	
	setTeam: function(team) {
		this.options.team = team;
	},
	
	
	getTeam: function() {
		return this.options.team;
	},


	setGamesWon: function(games) {
		this.gamesWon = games;
	},


	getGamesWon: function() {
		return this.gamesWon;
	},

	
    initArrays: function() {
		this.CardCombIdx = 	new Array(							// 4, 5, 6, 7 - Number of Cards To Check
								new Array(6, 10, 15, 21),       // 2 \                                  
								new Array(4, 10, 20, 35),       // 3  \                                 
								new Array(1,  5, 15, 35),       // 4   \ Card                           
								new Array(0,  0,  6, 21),       // 5   / Combinations                   
								new Array(0,  0,  1,  7),       // 6  /                                 
								new Array(0,  0,  0,  1)        // 7 /                                  
							);
	
	
		this.CardComb =		new Array(
								new Array(
									new Array(0,1),
									new Array(0,2),
									new Array(0,3),
									new Array(0,4),
									new Array(0,5),
									new Array(0,6),
									new Array(1,2),
									new Array(1,3),
									new Array(1,4),
									new Array(1,5),
									new Array(1,6),
									new Array(2,3),
									new Array(2,4),
									new Array(2,5),
									new Array(2,6),
									new Array(3,4),
									new Array(3,5),
									new Array(3,6),
									new Array(4,5),
									new Array(4,6),
									new Array(5,6)
								),

								new Array(
									new Array(0,1,2),
									new Array(0,1,3),
									new Array(0,1,4),
									new Array(0,1,5),
									new Array(0,1,6),
									new Array(0,2,3),
									new Array(0,2,4),
									new Array(0,2,5),
									new Array(0,2,6),
									new Array(0,3,4),
									new Array(0,3,5),
									new Array(0,3,6),
									new Array(0,4,5),
									new Array(0,4,6),
									new Array(0,5,6),
									new Array(1,2,3),
									new Array(1,2,4),
									new Array(1,2,5),
									new Array(1,2,6),
									new Array(1,3,4),
									new Array(1,3,5),
									new Array(1,3,6),
									new Array(1,4,5),
									new Array(1,4,6),
									new Array(1,5,6),
									new Array(2,3,4),
									new Array(2,3,5),
									new Array(2,3,6),
									new Array(2,4,5),
									new Array(2,4,6),
									new Array(2,4,6),
									new Array(3,4,5),
									new Array(3,4,6),
									new Array(3,5,6),
									new Array(4,5,6)
								),
								
								new Array(
									new Array(0,1,2,3),
									new Array(0,1,2,4),
									new Array(0,1,2,5),
									new Array(0,1,2,6),
									new Array(0,1,3,4),
									new Array(0,1,3,5),
									new Array(0,1,3,6),
									new Array(0,1,4,5),
									new Array(0,1,4,6),
									new Array(0,1,5,6),
									new Array(0,2,3,4),
									new Array(0,2,3,5),
									new Array(0,2,3,6),
									new Array(0,2,4,5),
									new Array(0,2,4,6),
									new Array(0,2,5,6),
									new Array(0,3,4,5),
									new Array(0,3,4,6),
									new Array(0,3,5,6),
									new Array(0,4,5,6),
									new Array(1,2,3,4),
									new Array(1,2,3,5),
									new Array(1,2,3,6),
									new Array(1,2,4,5),
									new Array(1,2,4,6),
									new Array(1,2,5,6),
									new Array(1,3,4,5),
									new Array(1,3,4,6),
									new Array(1,3,5,6),
									new Array(1,4,5,6),
									new Array(2,3,4,5),
									new Array(2,3,4,6),
									new Array(2,3,5,6),
									new Array(2,4,5,6),
									new Array(3,4,5,6)
								),
		
								new Array(
									new Array(0,1,2,3,4),
									new Array(0,1,2,3,5),
									new Array(0,1,2,3,5),
									new Array(0,1,2,4,5),
									new Array(0,1,2,4,6),
									new Array(0,1,2,5,6),
									new Array(0,1,3,4,5),
									new Array(0,1,3,4,6),
									new Array(0,1,3,4,6),
									new Array(0,1,3,5,6),
									new Array(0,1,4,5,6),
									new Array(0,2,3,4,5),
									new Array(0,2,3,4,6),
									new Array(0,2,3,5,6),
									new Array(0,2,4,5,6),
									new Array(1,2,3,4,5),
									new Array(1,2,3,4,6),
									new Array(1,2,3,5,6),
									new Array(1,2,4,5,6),
									new Array(1,3,4,5,6),
									new Array(2,3,4,5,6)
								),
		
								new Array(
									new Array(0,1,2,3,4,5),
									new Array(0,1,2,3,4,6),
									new Array(0,1,2,3,5,6),
									new Array(0,1,2,4,5,6),
									new Array(0,1,3,4,5,6),
									new Array(0,2,3,4,5,6),
									new Array(1,2,3,4,5,6)
								),
		
								new Array(
									new Array(0,1,2,3,4,5,6)
								)
							);
    }


});


