/***********************************************************************
*
* File: gameModelObjects.js
*
* This contains all the Model objects that can be streamed from XML into JavaScript objects.
*
* Data accessed from the back end comes in as XML and is then transformed into JavaScript
* "model" objects.
*
************************************************************************/


//alert ( "BEGIN LOAD MODEL OBJECTS" );

function GenericResponse () {
  	 
     this.parseXML = function ( xml ) {
	    this.code = xml.getAttribute ( "code" );
		this.msg = xml.getAttribute ( "msg" );
	 }
	 
	 this.toString = function () {
	    var str = GenericResponse.TAG_NAME + "{";
		str += "code=\"" + this.code + "\", ";
		str += "msg=\"" + this.msg + "\"";
		str += "}";
		return str;
	 }
}

GenericResponse.TAG_NAME = "vbresponse";





// Email Contact List
function WebEmailContactListResponse () {
   
     this.contacts = new WebEmailContactList ();
	 
     this.parseXML = function ( xml ) {
	    this.code = xml.getAttribute ( "code" );
		this.errorMessage = xml.getAttribute ( "errorMessage" );
	  //  alert ( "PARSE XML CALLED, code: " + this.code );
	    if ( xml.getElementsByTagName (WebEmailContactList.TAG_NAME).length > 0 ) {
		   this.contacts.parseXML ( xml.getElementsByTagName (WebEmailContactList.TAG_NAME).item(0) );
		}
	 }
	 
	 this.toString = function () {
	    var str = WebEmailContactListResponse.TAG_NAME + "{";
		str += "code=\"" + this.code + "\"";
		str += "errorMessage=\"" + this.errorMessage + "\"";
		str += this.contacts;
		str += "}";
		return str;
	 }
}
WebEmailContactListResponse.TAG_NAME = "vbresponse";


function WebEmailContactList () {

     this.contacts = new Array ();
	 
     this.parseXML = function ( xml ) {
	 	 
	     var childElements = xml.getElementsByTagName ( WebEmailContact.TAG_NAME );
		 
		 for ( var idx = 0; idx < childElements.length; idx++ ) {
			 var contact = new WebEmailContact ();
			 contact.parseXML (childElements.item(idx));
			 this.contacts.push(contact);
		 }
		 
	     
	 };
	 
	 this.toString = function () {
	    var str = WebEmailContactList.TAG_NAME + "{";
		for ( var idx = 0; idx < this.contacts.length; idx++ ) {
			str += this.contacts[idx];
		}
		str += "}";
		return str;
	 }
	 
}
WebEmailContactList.TAG_NAME = "contacts";


function WebEmailContact () {

     this.parseXML = function ( xml ) {	 
	     var _contactName = unescape(xml.getAttribute ( "contactName" )); 
		 // str.replace(/Microsoft/, "W3Schools")
	     this.contactName = _contactName.replace(/\+/g, " ");
	 
	    // this.contactName = xml.getAttribute ( "contactName" );
		 this.emailAddress = xml.getAttribute ( "emailAddress" );
	 };
	 
	 this.toString = function () {
	    var str = WebEmailContact.TAG_NAME + "{";
		str += "contactName:\"" + this.contactName + "\", ";
		str += "emailAddress:\"" + this.emailAddress + "\", ";
		str += "}";
		return str;
	 }
	 
}
WebEmailContact.TAG_NAME = "contact";




function EndGameResponse () {
     this.parseXML = function ( xml ) {
	    this.code = xml.getAttribute ( "code" );
		this.gameId = xml.getAttribute ( "gameId" );
	 }
	 
	 this.toString = function () {
	    var str = EndGameResponse.TAG_NAME + "{";
		str += "code=\"" + this.code + "\", ";
		str += "gameId=\"" + this.gameId + "\"";
		str += "}";
		return str;
	 }
}
EndGameResponse.TAG_NAME = "vbresponse";



/****************************************************************
*
* "GET USER INFO" Data
*
*****************************************************************/

/*
function GetUserInfoResponse () {

  
     this.isLoggedIn = function () {
		 if ( this.code == "GET_USER_OK" ) {
			 return true;
		 } else {
			 return false; 
		 }
	 }
	 
     this.parseXML = function ( xml ) {
	    this.code = xml.getAttribute ( "code" );
		this.name = xml.getAttribute ( "name" );
		this.email = xml.getAttribute ( "email" );
		this.dailyScore = xml.getAttribute ( "dailyScore" );
		this.weeklyScore = xml.getAttribute ( "weeklyScore" );
		this.monthlyScore = xml.getAttribute ( "monthlyScore" );
		this.yearlyScore = xml.getAttribute ( "yearlyScore" );
		this.lifetimeScore = xml.getAttribute ( "lifetimeScore" );
		this.totalNumberOfGamesPlayed = xml.getAttribute ( "totalNumberOfGamesPlayed" );

	  //  alert ( "PARSE XML CALLED, code: " + this.code );
		
	 }
	 
	 this.toString = function () {
		 
	    var str = GetUserInfoResponse.TAG_NAME + "{";
		str += "code=\"" + this.code + "\",";
		str += "name=\"" + this.name + "\",";
		str += "email=\"" + this.email + "\",";
		str += "dailyScore=\"" + this.dailyScore + "\",";
		str += "weeklyScore=\"" + this.weeklyScore + "\",";
		str += "monthlyScore=\"" + this.monthlyScore + "\",";
		str += "yearlyScore=\"" + this.yearlyScore + "\",";
		str += "lifetimeScore=\"" + this.lifetimeScore + "\",";
		str += "totalNumberOfGamesPlayed=\"" + this.totalNumberOfGamesPlayed + "\",";
		
		str += "}";
		return str;
	 }
}
GetUserInfoResponse.TAG_NAME = "vbresponse";
*/



/****************************************************************
*
* "QUESTION" RESPONSE Data
*
*****************************************************************/

function QuestionResponse () {

     this.parseXML = function ( xml ) {
	 
//alert ( "CALLED PARSE" );

	     this.code = xml.getAttribute ( "code" );
	     this.questions = new Array ();
		 
	     var childElements = xml.getElementsByTagName ( Question.TAG_NAME );
		 
//alert ( " childElements: " + childElements + " LEN: " + childElements.length );

		 
		 for ( var idx = 0; idx < childElements.length; idx++ ) {
			 var question = new Question ();
			 question.parseXML (childElements.item(idx));
			 this.questions.push(question);
		 }
		 
	     
	 };
	 
	 this.hasBonusQuestion = function () {
		 return this.questions.length > 1;
	 }
	 
	 this.toString = function () {
	    var str = QuestionResponse.TAG_NAME + "{";
		
		str += "code=\"" + this.code + "\"";
		
		for ( var idx = 0; idx < this.questions.length; idx++ ) {
			str += this.questions[idx];
		}
		
		str += "}";
		return str;
	 }
	 
}
QuestionResponse.TAG_NAME = "vbresponse";



function Question () {
	
     this.parseXML = function ( xml ) {
		 
//alert ( " PARSE CALLED: " + xml );

//alert ( " PARSE Q CALLED " );

	    this.code = xml.getAttribute ( "code" );
		this.id = xml.getAttribute ( "id" );
		this.text = xml.getAttribute ( "text" );
		this.url = xml.getAttribute ( "url" );
		this.embedTag = xml.getAttribute ( "embedTag" );
		this.type = xml.getAttribute ( "type" );
		this.clockDuration = xml.getAttribute ( "clockDuration" );
		this.countdownStartTime = xml.getAttribute ( "countdownStartTime" );
		this.revealStart = xml.getAttribute ( "revealStart" );
		this.revealEnd = xml.getAttribute ( "revealEnd" );
		this.blockTitle = xml.getAttribute ( "blockTitle" );
		this.choice0 = xml.getAttribute ( "choice0" );
		this.choice1 = xml.getAttribute ( "choice1" );
		this.choice2 = xml.getAttribute ( "choice2" );
		this.choice3 = xml.getAttribute ( "choice3" );
		this.isRecall = xml.getAttribute ( "isRecall" );
		

		this.correct_answer = xml.getAttribute ( "correct_answer" );
		this.startVideo = xml.getAttribute ( "startVideo" );
		this.endVideo = xml.getAttribute ( "endVideo" );
		this.muteVideo = xml.getAttribute ( "muteVideo" );
		this.unmuteVideo = xml.getAttribute ( "unmuteVideo" );		
		
		this.recallTitle = xml.getAttribute ( "recallTitle" );
		if ( this.recallTitle == null || this.recallTitle == "null" || this.recallTitle == "undefined" ) {
			this.recallTitle = "Watch Closely";
		}
		this.recallMessage = xml.getAttribute ( "recallMessage" );
		if ( this.recallMessage == null || this.recallMessage == "null" || this.recallMessage == "undefined" ) {
			this.recallMessage = "Watch Closely";
		}
		
//alert ( "DONE: " );
//alert ( " TO STRING: " + this );

	 }
	 
	 this.toString = function () {
	    var str = Question.TAG_NAME + "{";
		str += "code=\"" + this.code + "\"";
		str += "id=\"" + this.id + "\"";
		str += "text=\"" + this.text + "\"";
		str += "revealStart=\"" + this.revealStart + "\"";
		str += "}";
		return str;
	 };
	 
}
Question.TAG_NAME = "question";
Question.TYPE_MULTIPLE_CHOICE = "SINGLE_CHOICE"; //Number = 0;
Question.TYPE_BINARY = "BINARY"; //"" 		   = 1;
Question.TYPE_FREETEXT = "FREETEXT"; // ""Number 	   = 2;
Question.TYPE_MULTIPLE_ANSWER = "MULTIPLE_CHOICE"; //Number = 3;




/****************************************************************
*
* "ANSWER" RESPONSE Data
*
*****************************************************************/

function AnswerResponse () {

     this.parseXML = function ( xml ) {
	 
	     this.code            = xml.getAttribute ( "code" );
		 this.correct_answer  = xml.getAttribute ( "correct_answer" );
		 this.score           = xml.getAttribute ( "score" );
		 this.gameId          = xml.getAttribute ( "gameId" );
		 this.isAnswerCorrect = xml.getAttribute ( "isAnswerCorrect" );
		 this.average         = xml.getAttribute ( "average" );
		 this.percentile      = xml.getAttribute ( "percentile" );
		 this.playedgameId    = xml.getAttribute ( "playedgameId" );
		 
	 };
	 
	 this.toString = function () {
	    var str = AnswerResponse.TAG_NAME + "{";
		
		str += "code=\"" + this.code + "\", ";
		str += "correct_answer=\"" + this.correct_answer + "\", ";
		str += "score=\"" + this.score + "\", ";
		str += "gameId=\"" + this.gameId + "\" ";
		str += "isAnswerCorrect=\"" + this.isAnswerCorrect + "\" ";
		str += "average=\"" + this.average + "\" ";
		str += "percentile=\"" + this.percentile + "\" ";
		
		str += "}";
		return str;
	 }
	 
}
AnswerResponse.TAG_NAME = "vbresponse";
AnswerResponse.CODE_ANSWER_INCORRECT = "ANSWER_INCORRECT";
AnswerResponse.CODE_ANSWER_CORRECT   = "ANSWER_CORRECT";
AnswerResponse.CODE_GAME_WON         = "GAME_WON";
AnswerResponse.CODE_GAME_LOST        = "GAME_LOST";
AnswerResponse.CODE_BLACKOUT_FINISH  = "BLACKOUT_FINISH";




/**
---------------------- "START GAME" MESSAGE
**/

/*
<vbresponse code="GAME_ALREADY_PLAYED" gameId="140" gameType="hit" pjuid="54" score="500" result="score" playedDate="2008-03-27"/>

*/

function GameAlreadyPlayedResponse () {
  	 
     this.parseXML = function ( xml ) {
	    this.code = xml.getAttribute ( "code" );
		this.gameId = xml.getAttribute ( "gameId" );
		this.gameType = xml.getAttribute ( "gameType" );
		this.pjuid = xml.getAttribute ( "pjuid" );
		this.score = xml.getAttribute ( "score" );
		this.result = xml.getAttribute ( "result" );
		this.playedDate = xml.getAttribute ( "playedDate" );
	 }
	 
	 this.toString = function () {
	    var str = GenericResponse.TAG_NAME + "{";
		str += "code=\"" + this.code + "\", ";
		str += "gameId=\"" + this.gameId + "\", ";
		str += "gameType=\"" + this.gameType + "\", ";
		str += "pjuid=\"" + this.pjuid + "\", ";
		str += "score=\"" + this.score + "\", ";
		str += "result=\"" + this.result + "\", ";
		str += "playedDate=\"" + this.playedDate + "\", ";
		str += "}";
		return str;
	 }
}
GameAlreadyPlayedResponse.TAG_NAME = "vbresponse";


function StartGameResponse () {

     this.parseXML = function ( xml ) {
	 
	     this.code = xml.getAttribute ( "code" );
	     this.averageScore       = xml.getAttribute ( "averageScore" );
	     this.topTenPercentScore = xml.getAttribute ( "topTenPercentScore" );
		 
	     this.gameDefinition = new GameDefinition ();
		 this.gameDetails    = new GameDetails ();
		 this.gridCells      = new GridCells ();
		 this.gameCategories = new GameCategories ();
		 this.adServer       = new AdServer ();
		 
		 //throw "PARSE ERROR";
         var gameDefinitionXml = xml.getElementsByTagName ( GameDefinition.TAG_NAME ).item(0);
		 var gameDetailsXml = null;
		 if ( xml.getElementsByTagName ( GameDetails.TAG_NAME ).length > 0 ) {
		    gameDetailsXml = xml.getElementsByTagName ( GameDetails.TAG_NAME ).item(0);
		 }
		 var gridCellsXml = xml.getElementsByTagName ( GridCells.TAG_NAME ).item(0);
		 var gameCategoriesXml = null;
		 if ( xml.getElementsByTagName ( GameCategories.TAG_NAME ).length > 0 ) {
			 gameCategoriesXml = xml.getElementsByTagName ( GameCategories.TAG_NAME ).item(0);
		 }
         this.gameDefinition.parseXML (gameDefinitionXml);
		 if ( gameDetailsXml ) {
		    this.gameDetails.parseXML (gameDetailsXml);
		 }
		 this.gridCells.parseXML (gridCellsXml);
	     if ( gameCategoriesXml ) {
			 this.gameCategories.parseXML (gameCategoriesXml);
		 }
		 
		 var adServerXml = null;
		 if ( xml.getElementsByTagName ( AdServer.TAG_NAME ).length > 0 ) {
		    adServerXml = xml.getElementsByTagName ( AdServer.TAG_NAME ).item(0);
			 if ( adServerXml ) {
				 this.adServer.parseXML ( adServerXml );
			 } else {
				 this.adServer = null;
			 }
		 }	else {
			 this.adServer = null;
		 }
	     
	 };
	 
	 this.toString = function () {
	    var str = StartGameResponse.TAG_NAME + "{";
		str += "code=\"" + this.gameDefinition + "\", ";
		str += "name=\"" + this.gameDetails + "\", ";
		str += "email=\"" + this.gridCells + "\" ";
		//str += "categories=\"" + this.gameCategories + "\" ";
		str += "}";
		return str;

	 }
	 
}
StartGameResponse.TAG_NAME = "vbresponse";

function GameDefinition () {
	
     this.parseXML = function ( xml ) {

	    this.id = xml.getAttribute ( "id" );
		this.name = xml.getAttribute ( "name" );
		this.numFreeSpinsAllowed = xml.getAttribute ( "numFreeSpinsAllowed" );
		this.numShufflesAllowed = xml.getAttribute ( "numShufflesAllowed" );
		this.numStrikBusterAllowed = xml.getAttribute ( "numStrikBusterAllowed" );
		this.countdownStyle = xml.getAttribute ( "countdownStyle" );
		this.countDownIncr = xml.getAttribute ( "countDownIncr" );
		this.gameGridWidth = xml.getAttribute ( "gameGridWidth" );
		this.gameGridHeight = xml.getAttribute ( "gameGridHeight" );
		this.resultType = xml.getAttribute ( "resultType" );
        this.origin = xml.getAttribute ( "origin" );
	 }
	 
	 this.toString = function () {
	    var str = GameDefinition.TAG_NAME + "{";
		str += "id=\"" + this.id + "\",";
		str += "name=\"" + this.name + "\",";
		str += "numFreeSpinsAllowed=\"" + this.numFreeSpinsAllowed + "\",";
		str += "numShufflesAllowed=\"" + this.numShufflesAllowed + "\",";
		str += "numStrikBusterAllowed=\"" + this.numStrikBusterAllowed + "\",";
		str += "countdownStyle=\"" + this.countdownStyle + "\",";
		str += "countDownIncr=\"" + this.countDownIncr + "\",";
		str += "gameGridWidth=\"" + this.gameGridWidth + "\",";
		str += "gameGridHeight=\"" + this.gameGridHeight + "\",";
		str += "resultType=\"" + this.resultType + "\",";
		str += "origin=\"" + this.origin + "\"";
		str += "}";
		return str;
	 }	 
}
GameDefinition.TAG_NAME = "gameDefinition";

function AdServer () {
	
     this.parseXML = function ( xml ) {

	    this.adServerLocation = xml.getAttribute ( "adServerLocation" );
		this.adDisplayDuration = xml.getAttribute ( "adDisplayDuration" );
		this.allowAdSkip = xml.getAttribute ( "allowAdSkip" );

	 }
	 
	 this.toString = function () {
	    var str = AdServer.TAG_NAME + "{";
		str += "adServerLocation=\"" + this.adServerLocation + "\",";
		str += "adDisplayDuration=\"" + this.adDisplayDuration + "\",";
		str += "allowAdSkip=\"" + this.allowAdSkip + "\",";
		str += "}";
		return str;
	 }	 
}
AdServer.TAG_NAME = "adServer";



function GameDetails () {
	
     this.parseXML = function ( xml ) {

	    this.id = xml.getAttribute ( "id" );
		this.gameName = xml.getAttribute ( "gameName" );
		this.smallVideoPath = xml.getAttribute ( "smallVideoPath" );
		this.largeVideoPath = xml.getAttribute ( "largeVideoPath" );
		this.smallImagePath = xml.getAttribute ( "smallImagePath" );
		this.largeImagePath = xml.getAttribute ( "largeImagePath" );
		this.flashPath = xml.getAttribute ( "flashPath" );
		this.thumbnailPath = xml.getAttribute ( "thumbnailPath" );
		this.playedGame = xml.getAttribute ( "playedGame" );

	 }
	 
	 this.toString = function () {
	    var str = GameDetails.TAG_NAME + "{";
		str += "id=\"" + this.id + "\",";
		str += "gameName=\"" + this.gameName + "\",";
		str += "smallVideoPath=\"" + this.smallVideoPath + "\",";
		str += "largeVideoPath=\"" + this.largeVideoPath + "\",";
		str += "smallImagePath=\"" + this.smallImagePath + "\",";
		str += "largeImagePath=\"" + this.largeImagePath + "\",";
		str += "flashPath=\"" + this.flashPath + "\",";
		str += "thumbnailPath=\"" + this.thumbnailPath + "\"";
		str += "playedGame=\"" + this.playedGame + "\"";
		str += "}";
		return str;
	 }	 
}
GameDetails.TAG_NAME = "gameDetails";


function GridCells () {

     this.parseXML = function ( xml ) {
	 
	     this.gridCells = new Array ();
		 
	     var childElements = xml.getElementsByTagName ( GridCell.TAG_NAME );
		 
		 for ( var idx = 0; idx < childElements.length; idx++ ) {
			 var gridCell = new GridCell ();
			 gridCell.parseXML (childElements.item(idx));
			 this.gridCells.push(gridCell);
		 }
		 
	     
	 };
	 
	 this.toXml = function () {
	    var str = "<" + GridCells.TAG_NAME + ">";
		
		for ( var idx = 0; idx < this.gridCells.length; idx++ ) {
			str += this.gridCells[idx].toXml();
		}
		
		str += "</" + GridCells.TAG_NAME + ">";
		return str;		 
	 }
	 
	 this.toString = function () {
	    var str = GridCells.TAG_NAME + "{";
		
		for ( var idx = 0; idx < this.gridCells.length; idx++ ) {
			str += this.gridCells[idx];
		}
		
		str += "}";
		return str;
	 }
	 
}
GridCells.TAG_NAME = "gridCells";



function GridCell () {
	
	 this.videoPath = null;
	 this.largeImagePath = null;
	 this.caption = null;
	 
     this.parseXML = function ( xml ) {
		 
//alert ( " PARSE CALLED: " + xml ); categoryId="0" points="100"

	    this.categoryId = xml.getAttribute ( "categoryId" );
		this.points = xml.getAttribute ( "points" );
	 }
	 
	 this.setVideoPath = function ( _videoPath ) {
		 this.videoPath = _videoPath;
	 }
	 
	 this.setLargeImagePath = function ( _largeImagePath ) {
		 this.largeImagePath = _largeImagePath;
	 }
	 
	 this.setCaption = function ( _caption ) {
		 this.caption = _caption;
	 }
	 
	 this.toXml = function () {
	    var str = "<" + GridCell.TAG_NAME + " ";
		
		str += " categoryId" + "=\"" + this.categoryId + "\"";
		str += " points" + "=\"" + this.points + "\"";
		if ( this.videoPath ) {
		   str += " videoPath" + "=\"" + this.videoPath + "\"";
		}
		if ( this.largeImagePath ) {
		   str += " largeImagePath" + "=\"" + this.largeImagePath + "\"";
		}		
		if ( this.caption ) {
		   str += " caption" + "=\"" + this.caption + "\"";
		}
		
		str += " />";
		return str;		 
	 }
	 
	 this.toString = function () {
	    var str = GridCell.TAG_NAME + "{";
		str += "categoryId=\"" + this.categoryId + "\",";
		str += "points=\"" + this.points + "\"";
		str += "}";
		return str;
	 }	 
}
GridCell.TAG_NAME = "gridCell";


// 

function GameCategories () {

     this.parseXML = function ( xml ) {
	 
	     this.categories = new Array ();
		 
	     var childElements = xml.getElementsByTagName ( Category.TAG_NAME );
		 
		 for ( var idx = 0; idx < childElements.length; idx++ ) {
			 var category = new Category ();
			 category.parseXML (childElements.item(idx));
			 this.categories.push(category);
		 }
		 
	     
	 };
	 
	 this.getCatgoryById = function ( id ) {
        var category = null;
		for ( var idx = 0; idx < this.categories.length; idx++ ) {
			var _category = this.categories[idx];
			if ( _category.id == id ) {
				category = _category;
				break;
			}
		}
        return category;
	 }
	 
	 this.toString = function () {
	    var str = GameCategories.TAG_NAME + "{";
		
		for ( var idx = 0; idx < this.categories.length; idx++ ) {
			str += this.categories[idx];
		}
		
		str += "}";
		return str;
	 }
	 
}
GameCategories.TAG_NAME = "categories";



function Category () {
	
     this.parseXML = function ( xml ) {
		 
	    this.id = xml.getAttribute ( "id" );
		this.name = xml.getAttribute ( "name" );
		this.smallVideoPath = xml.getAttribute ( "smallVideoPath" );
		this.largeVideoPath = xml.getAttribute ( "largeVideoPath" );
		this.smallImagePath = xml.getAttribute ( "smallImagePath" );
		this.largeImagePath = xml.getAttribute ( "largeImagePath" );
		this.flashPath = xml.getAttribute ( "flashPath" );
		this.thumbnailPath = xml.getAttribute ( "thumbnailPath" );
		this.listOrder = xml.getAttribute ( "listOrder" );
	 }
	 
	 this.toString = function () {
	    var str = Category.TAG_NAME + "{";
		str += "id=\"" + this.id + "\",";
		str += "name=\"" + this.name + "\"";
		str += "}";
		return str;
	 }	 
}
Category.TAG_NAME = "category";



/**
---------------------- "GET USER INFO" MESSAGE
**/

function GetUserResponse () {
  	 
     this.parseXML = function ( xml ) {
	    this.code = xml.getAttribute ( "code" );
		this.name = xml.getAttribute ( "name" );
		this.id = xml.getAttribute ( "id" );
		this.email = xml.getAttribute ( "email" );
		this.dailyScore = xml.getAttribute ( "dailyScore" );
		this.weeklyScore = xml.getAttribute ( "weeklyScore" );
		this.monthlyScore = xml.getAttribute ( "monthlyScore" );
		this.yearlyScore = xml.getAttribute ( "yearlyScore" );
		this.lifetimeScore = xml.getAttribute ( "lifetimeScore" );
		this.totalNumberOfGamesPlayed = xml.getAttribute ( "totalNumberOfGamesPlayed" );
	 }
	 
	 this.toString = function () {
	    var str = GetUserResponse.TAG_NAME + "{";
		str += "code=\"" + this.code + "\", ";
		str += "name=\"" + this.name + "\", ";
		str += "id=\"" + this.id + "\", ";
		str += "email=\"" + this.email + "\", ";
		str += "dailyScore=\"" + this.dailyScore + "\", ";
		str += "weeklyScore=\"" + this.weeklyScore + "\", ";
		str += "monthlyScore=\"" + this.monthlyScore + "\", ";
		str += "yearlyScore=\"" + this.yearlyScore + "\", ";
		str += "lifetimeScore=\"" + this.lifetimeScore + "\", ";
		str += "totalNumberOfGamesPlayed=\"" + this.totalNumberOfGamesPlayed + "\", ";
		str += "}";
		return str;
	 }
}
GetUserResponse.TAG_NAME = "vbresponse";






/****************************************************************
*
* "Hit Games" Data
*
*****************************************************************/

function HitGameInfoResponse () {
   
     this.hitGameGroups = new HitGameGroups ();
	 this.hitGames = new HitGames ();
	 
     this.parseXML = function ( xml ) {
	    this.code = xml.getAttribute ( "code" );
	  //  alert ( "PARSE XML CALLED, code: " + this.code );
		this.hitGameGroups.parseXML ( xml.getElementsByTagName (HitGameGroups.TAG_NAME).item(0) );
		
		this.hitGames.parseXML ( xml.getElementsByTagName (HitGames.TAG_NAME).item(0) );
		
		this.hitGameGroups.fillAllGroupsWithTheirHitGames (this.hitGames);
		
	 }
	 
	 this.toString = function () {
	    var str = HitGameInfoResponse.TAG_NAME + "{";
		str += "code=\"" + this.code + "\"";
		str += this.hitGameGroups;
		str += ", " + this.hitGames;
		str += "}";
		return str;
	 }
}
HitGameInfoResponse.TAG_NAME = "vbresponse";

function HitGameGroups () {

     this.parseXML = function ( xml ) {
	 
	     this.hitGameGroups = new Array ();
		 
	     var childElements = xml.getElementsByTagName ( HitGameGroup.TAG_NAME );
		 
		 for ( var idx = 0; idx < childElements.length; idx++ ) {
			 var hitGameGroup = new HitGameGroup ();
			 hitGameGroup.parseXML (childElements.item(idx));
			 this.hitGameGroups.push(hitGameGroup);
		 }
		 
	     
	 };
	 
	 this.fillAllGroupsWithTheirHitGames = function ( hitGames ) {
		 
		for ( var idx = 0; idx < this.hitGameGroups.length; idx++ ) {
			var hitGameGroup = this.hitGameGroups[idx];
			hitGameGroup.fillWithChildHitGames (hitGames);
		}
		
	 };
	 
	 this.toString = function () {
	    var str = HitGameGroups.TAG_NAME + "{";
		
		for ( var idx = 0; idx < this.hitGameGroups.length; idx++ ) {
			str += this.hitGameGroups[idx];
		}
		
		str += "}";
		return str;
	 }
	 
}
HitGameGroups.TAG_NAME = "hitGameGroups";

function HitGameGroup () {
	
	 this.hitGames = new Array ();
	 
     this.parseXML = function ( xml ) {
	     this.id = xml.getAttribute ( "id" );
		 this.title = xml.getAttribute ( "title" );
		 this.smallVideoPath = xml.getAttribute ( "smallVideoPath" );
		 this.largeVideoPath = xml.getAttribute ( "largeVideoPath" );
		 this.smallImagePath = xml.getAttribute ( "smallImagePath" );
		 this.largeImagePath = xml.getAttribute ( "largeImagePath" );
		 this.flashPath = xml.getAttribute ( "flashPath" );
		 this.thumbnailPath = xml.getAttribute ( "thumbnailPath" );
		 this.childCategoryIds = xml.getAttribute ( "childCategoryIds" );
		 
		 this.gameIdsArray = this.childCategoryIds.split( " " );
	 };
	 
	 this.fillWithChildHitGames = function ( _hitGames ) {
		
		
		 for ( var idx = 0; idx < this.gameIdsArray.length; idx++ ) {
			 var id = this.gameIdsArray[idx];
			 if ( id != "" && id != " " ) {
				 var hitGame = _hitGames.getGameById (id);
				 if ( hitGame != null ) {
					 this.hitGames.push(hitGame);
				 }
			 }
		 }
		 
	 };
	 
	
	 
	 this.toString = function () {
	    var str = HitGameGroup.TAG_NAME + "{";
		str += "id:\"" + this.id + "\", ";
		str += "title:\"" + this.title + "\", ";
		str += "smallVideoPath:\"" + this.smallVideoPath + "\", ";
		str += "largeVideoPath:\"" + this.largeVideoPath + "\", ";
		str += "smallImagePath:\"" + this.smallImagePath + "\", ";
		str += "largeImagePath:\"" + this.largeImagePath + "\", ";
		str += "flashPath:\"" + this.flashPath + "\", ";
		str += "thumbnailPath:\"" + this.thumbnailPath + "\", ";
		str += "childCategoryIds:\"" + this.childCategoryIds + "\"";
		str += "}";
		return str;
	 }
	 
}
HitGameGroup.TAG_NAME = "hitGameGroup";


///

function HitGames () {

     this.parseXML = function ( xml ) {
	 
	     this.hitGames = new Array ();
		 this.hitGamesHashtable = new Object;
		 
	     var childElements = xml.getElementsByTagName ( HitGame.TAG_NAME );
		 
		 for ( var idx = 0; idx < childElements.length; idx++ ) {
			 var hitGame = new HitGame ();
			 hitGame.parseXML (childElements.item(idx));
			 this.hitGames.push(hitGame);
			 
			 this.hitGamesHashtable[hitGame.id] = hitGame;
		 }
		 
	     
	 };
	 
	 this.getGameById = function ( id ) {
		 return this.hitGamesHashtable[id];
	 };
	 
	 this.toString = function () {
	    var str = HitGames.TAG_NAME + "{";
		
		for ( var idx = 0; idx < this.hitGames.length; idx++ ) {
			str += this.hitGames[idx];
		}
		
		str += "}";
		return str;
	 }
	 
}
HitGames.TAG_NAME = "hitGames";

function HitGame () {
	
     this.parseXML = function ( xml ) {
	     this.id = xml.getAttribute ( "id" );
		 this.name = xml.getAttribute ( "name" );
		 this.smallVideoPath = xml.getAttribute ( "smallVideoPath" );
		 this.largeVideoPath = xml.getAttribute ( "largeVideoPath" );
		 this.smallImagePath = xml.getAttribute ( "smallImagePath" );
		 this.largeImagePath = xml.getAttribute ( "largeImagePath" );
		 this.flashPath = xml.getAttribute ( "flashPath" );
		 this.thumbnailPath = xml.getAttribute ( "thumbnailPath" );
		 this.childCategoryIds = xml.getAttribute ( "childCategoryIds" );
	 };
	 
	 this.toString = function () {
	    var str = HitGame.TAG_NAME + "{";
		str += "id:\"" + this.id + "\", ";
		str += "name:\"" + this.name + "\", ";
		str += "smallVideoPath:\"" + this.smallVideoPath + "\", ";
		str += "largeVideoPath:\"" + this.largeVideoPath + "\", ";
		str += "smallImagePath:\"" + this.smallImagePath + "\", ";
		str += "largeImagePath:\"" + this.largeImagePath + "\", ";
		str += "flashPath:\"" + this.flashPath + "\", ";
		str += "thumbnailPath:\"" + this.thumbnailPath + "\", ";
		str += "childCategoryIds:\"" + this.childCategoryIds + "\"";
		str += "}";
		return str;
	 }
	 
}
HitGame.TAG_NAME = "hitGame";



/****************************************************************
*
* "Game Info" (Categories) Data
*
*****************************************************************/

function GameInfoResponse () {
   
     this.categoryGroups = new CategoryGroups ();
	 this.categories = new Categories ();
	 
     this.parseXML = function ( xml ) {
		 
//alert ( "XML: " + xml );

	    this.code = xml.getAttribute ( "code" );
	   //alert ( "PARSE XML CALLED, code: " + this.code );
		this.categoryGroups.parseXML ( xml.getElementsByTagName (CategoryGroups.TAG_NAME).item(0) );
		
		this.categories.parseXML ( xml.getElementsByTagName (Categories.TAG_NAME).item(0) );
		
		this.categoryGroups.fillAllGroupsWithTheirCategories (this.categories);
		
	 }
	 
	 this.toString = function () {
	    var str = GameInfoResponse.TAG_NAME + "{";
		str += "code=\"" + this.code + "\"";
		str += this.categoryGroups;
		str += ", " + this.categories;
		str += "}";
		return str;
	 }
}
GameInfoResponse.TAG_NAME = "vbresponse";

function CategoryGroups () {

     this.parseXML = function ( xml ) {
	 
	     this.categoryGroups = new Array ();
		 
	     var childElements = xml.getElementsByTagName ( CategoryGroup.TAG_NAME );
		 
		 for ( var idx = 0; idx < childElements.length; idx++ ) {
			 var categoryGroup = new CategoryGroup ();
			 categoryGroup.parseXML (childElements.item(idx));
			 this.categoryGroups.push(categoryGroup);
		 }
		 
	     
	 };
	 
	 this.fillAllGroupsWithTheirCategories = function ( categories ) {
		 
		for ( var idx = 0; idx < this.categoryGroups.length; idx++ ) {
			var categoryGroup = this.categoryGroups[idx];
			categoryGroup.fillWithChildCategories (categories);
		}
		
	 };
	 
	 this.toString = function () {
	    var str = CategoryGroups.TAG_NAME + "{";
		
		for ( var idx = 0; idx < this.categoryGroups.length; idx++ ) {
			str += this.categoryGroups[idx];
		}
		
		str += "}";
		return str;
	 }
	 
}
CategoryGroups.TAG_NAME = "categoryGroups";

function CategoryGroup () {
	
	 this.categories = new Array ();
	 
     this.parseXML = function ( xml ) {
	     this.id = xml.getAttribute ( "id" );
		 this.name = xml.getAttribute ( "name" );
		 this.smallVideoPath = xml.getAttribute ( "smallVideoPath" );
		 this.largeVideoPath = xml.getAttribute ( "largeVideoPath" );
		 this.smallImagePath = xml.getAttribute ( "smallImagePath" );
		 this.largeImagePath = xml.getAttribute ( "largeImagePath" );
		 this.flashPath = xml.getAttribute ( "flashPath" );
		 this.thumbnailPath = xml.getAttribute ( "thumbnailPath" );
		 this.listOrder = xml.getAttribute ( "listOrder" );
		 this.childCategoryIds = xml.getAttribute ( "childCategoryIds" );
		 
		 this.categoryIdsArray = this.childCategoryIds.split( " " );
	 };
	 
	 this.fillWithChildCategories = function ( _categories ) {
		
		
		 for ( var idx = 0; idx < this.categoryIdsArray.length; idx++ ) {
			 var id = this.categoryIdsArray[idx];
			 if ( id != "" && id != " " ) {
				 var category = _categories.getCategoryById (id);
				 if ( category != null ) {
					 category.addParentCategoryGroupId ( this.id );
					 this.categories.push(category);
				 }
			 }
		 }
		 
	 };
	 
	
	 
	 this.toString = function () {
	    var str = CategoryGroup.TAG_NAME + "{";
		str += "id:\"" + this.id + "\", ";
		str += "name:\"" + this.name + "\", ";
		str += "smallVideoPath:\"" + this.smallVideoPath + "\", ";
		str += "largeVideoPath:\"" + this.largeVideoPath + "\", ";
		str += "smallImagePath:\"" + this.smallImagePath + "\", ";
		str += "largeImagePath:\"" + this.largeImagePath + "\", ";
		str += "flashPath:\"" + this.flashPath + "\", ";
		str += "thumbnailPath:\"" + this.thumbnailPath + "\", ";
		str += "childCategoryIds:\"" + this.childCategoryIds + "\"";
		str += "}";
		return str;
	 }
	 
}
CategoryGroup.TAG_NAME = "categoryGroup";


///

function Categories () {

     this.parseXML = function ( xml ) {
	 
	     this.categories = new Array ();
		 this.categoriesHashtable = new Object;
		 
	     var childElements = xml.getElementsByTagName ( Category.TAG_NAME );
		 
		 for ( var idx = 0; idx < childElements.length; idx++ ) {
			 var category = new Category ();
			 category.parseXML (childElements.item(idx));
			 this.categories.push(category);
			 
			 this.categoriesHashtable[category.id] = category;
		 }
		 
	     
	 };
	 
	 this.getCategoryById = function ( id ) {
		 return this.categoriesHashtable[id];
	 };
	 
	 this.toString = function () {
	    var str = Categories.TAG_NAME + "{";
		
		for ( var idx = 0; idx < this.categories.length; idx++ ) {
			str += this.categories[idx];
		}
		
		str += "}";
		return str;
	 }
	 
}
Categories.TAG_NAME = "categories";

function Category () {
	
	 this.parentCategoryGroupIds = new Array ();
	 
     this.parseXML = function ( xml ) {
	     this.id = xml.getAttribute ( "id" );
		 this.name = xml.getAttribute ( "name" );
		 this.smallVideoPath = xml.getAttribute ( "smallVideoPath" );
		 this.largeVideoPath = xml.getAttribute ( "largeVideoPath" );
		 this.smallImagePath = xml.getAttribute ( "smallImagePath" );
		 this.largeImagePath = xml.getAttribute ( "largeImagePath" );
		 this.flashPath = xml.getAttribute ( "flashPath" );
		 this.thumbnailPath = xml.getAttribute ( "thumbnailPath" );
		 this.listOrder = xml.getAttribute ( "listOrder" );
		 this.numberOfQuestionsLeft = xml.getAttribute ( "numberOfQuestionsLeft" );
	 };
	 
	 this.addParentCategoryGroupId = function ( categoryGroupId ) {
		 this.parentCategoryGroupIds.push(categoryGroupId);
	 };
	 
	 this.toString = function () {
	    var str = Category.TAG_NAME + "{";
		str += "id:\"" + this.id + "\", ";
        str += "categoryGroupIds:\"" + this.parentCategoryGroupIds + "\", ";		
		str += "name:\"" + this.name + "\", ";
		str += "smallVideoPath:\"" + this.smallVideoPath + "\", ";
		str += "largeVideoPath:\"" + this.largeVideoPath + "\", ";
		str += "smallImagePath:\"" + this.smallImagePath + "\", ";
		str += "largeImagePath:\"" + this.largeImagePath + "\", ";
		str += "flashPath:\"" + this.flashPath + "\", ";
		str += "thumbnailPath:\"" + this.thumbnailPath + "\", ";
		str += "listOrder:\"" + this.listOrder + "\"";
		str += "numberOfQuestionsLeft:\"" + this.numberOfQuestionsLeft + "\"";
		str += "}";
		return str;
	 }
	 
}
Category.TAG_NAME = "category";



/****************************************************************
*
* "SuggestedNextGame" RESPONSE Data
*
*****************************************************************/

function SuggestedNextGamesResponse () {

     this.parseXML = function ( xml ) {
	 
	     this.code           = xml.getAttribute ( "code" );
		 this.endGameMessage = xml.getAttribute ( "endGameMessage" );   // Trac #631
	     this.suggestedNextGames = new Array ();
		 
	     var childElements = xml.getElementsByTagName ( SuggestedNextGame.TAG_NAME );
		 
		 for ( var idx = 0; idx < childElements.length; idx++ ) {
			 var suggestedGame = new SuggestedNextGame ();
			 suggestedGame.parseXML (childElements.item(idx));
			 this.suggestedNextGames.push(suggestedGame);
		 }  
	 };
	 
	 this.toString = function () {
	    var str = SuggestedNextGamesResponse.TAG_NAME + "{";
		
		str += "code=\"" + this.code + "\"";
		
		for ( var idx = 0; idx < this.suggestedNextGames.length; idx++ ) {
			str += this.suggestedNextGames[idx];
		}
		
		str += "}";
		return str;
	 }
	 
}
SuggestedNextGamesResponse.TAG_NAME = "vbresponse";



function SuggestedNextGame () {
	
     this.parseXML = function ( xml ) {
		 
//alert ( " PARSE CALLED: " + xml );

	    this.gameId = xml.getAttribute ( "gameId" );
		this.gameName = xml.getAttribute ( "gameName" );
		this.thumbnailUrl = xml.getAttribute ( "thumbnailUrl" );
	 }
	 
	 this.toString = function () {
	    var str = SuggestedNextGame.TAG_NAME + "{";
		str += "gameId=\"" + this.gameId + "\"";
		str += "gameName=\"" + this.gameName + "\"";
		str += "thumbnailUrl=\"" + this.thumbnailUrl + "\"";
		str += "}";
		return str;
	 };
	 
}
SuggestedNextGame.TAG_NAME = "gameMin";





//alert ( "END LOAD MODEL OBJECTS" );



