﻿// JScript File

//0:'Registration'
//1:'Challenges List'
//2:'Email'
//3:'Product'
//4:'Wish List'
//5:'Notifications'
//6:'Blogs'
//7:'Registration'
//8:'My Network'
//9:'Challenge Details'
//10:'Whats Hot'
//11:'Measuring Up'
//12:'Privacy Policy'
//13:'Search Item'
//14:'Eye On You'
//15:'Games'
//16:'Product'
//17:'Reading'
//18:'Videos'
//19:'Purchase'

var KDZUserTracking = new function(){
	
	var Modules = new Array('Registration','Challenges List','Email','Product','Wish List','Notifications','Blogs','Registration','My Network','Challenge Details','Whats Hot','Measuring Up','Privacy Policy','Search Item','Eye On You','Games','Product','Reading','Videos','Purchase');
	var KDZUserTrackingID=0, UserID=0, ModuleName="", PageID=0, PageURL="", AccessInDateTime="", AccessOutDateTime="", IPAddress="", BrowserType="", BrowserVersion="";
	
	this.save = function(mid,modName,url){
//		try{
			try{
				UserID = getUserID(true);
			}catch(ex){
				//do nothing
			}
			if(!isExist(UserID)){
				UserID = 0;
			}
			PageURL = escape(encodeURI(url));
			ModuleName = escape(encodeURI(modName));
			if(isExist(PageURL)){
				var strUniqueCode = "";
				var strDate = new Date();
				strUniqueCode = "&sesid=" + strDate.getSeconds() + strDate.getMilliseconds() + Math.random();
				var l = ""; //window.location.pathname;
				l = this.getRootByModuleID(mid);
				l = l + "Tracker.aspx?uid=" + UserID + "&ModuleName=" + ModuleName + "&PageID=" + PageID + "&PageURL=" + PageURL + "&AccessOutDateTime=" + AccessOutDateTime + strUniqueCode;
				$.ajax({url:l,cache:false,
					success: function(returnStr){
//						var returnObj = eval('('+returnStr+')');
//						if(returnObj.result){
//							
//						}else{
//							alertModal("Problem executing Request.","");
//						}
					}
				});
			}
//		}catch(ex){
//			alert(ex.toString());
//		}
	};
	
	this.makeLogInKDZUserTracking = function(mid,url){
		var modName = "";
		modName = Modules[mid];
		this.save(mid,modName,url);
	};
	
	this.getRootByModuleID=function(mid){
		var returnString = "../";
		try{
			switch(mid){
				case 0:
						returnString="../";
					break;
				case 1:
						returnString="../";
					break;
				case 2:
						returnString="../";
					break;
				case 3:
						returnString="../";
					break;
				case 4:
						returnString="";
					break;
				case 5:
						returnString="";
					break;
				case 6:
						returnString="../";
					break;
				case 7:
						returnString="../";
					break;
				case 8:
						returnString="";
					break;
				case 9:
						returnString="../";
					break;
				case 10:
						returnString="";
					break;
				case 11:
						returnString="";
					break;
				case 12:
						returnString="";
					break;
				case 13:
						returnString="";
					break;
				case 14:
						returnString="../";
					break;
				case 15:
						returnString="../";
					break;
				case 16:
						returnString="../";
					break;
				case 17:
						returnString="";
					break;
				case 18:
						returnString="../";
					break;
				case 19:
						returnString="../";
					break;
				default:
					returnString="../";
			}
		}catch(ex){
			return "../";
		}
		return returnString;
	};
}

