package com.guru.conn
{
	import com.guru.facebook.FacebookIFrameCenter;
	import flash.display.LoaderInfo;
	/**
	 * ...
	 * @author Eddy Lee
	 */
	public class ConnPath
	{
		private static var sLocalMode_bol:Boolean = false;
		
		private static var sAppPrefix_str:String = "http://apps.facebook.com/firstclassexperience/";
		
		private static var sServerPrefix_str:String = "http://www.whisperguru.com/";
		private static var sServerApiFolder_str:String = "api/";
		private static var sServerSwfFolder_str:String = "swf/";
		private static var sServerImageFolder_str:String = "image/";
		private static var sServerVideoFolder_str:String = "video/";
		
		//private static var sServerPrefix_str:String = "http://www.whisperguru.com/phase3_testing/";
		//private static var sServerApiFolder_str:String = "../api/";
		//private static var sServerSwfFolder_str:String = "";
		//private static var sServerImageFolder_str:String = "../image/";
		//private static var sServerVideoFolder_str:String = "../video/";
		
		private static var sLocalPrefix_str:String = "";
		private static var sLocalApiFolder_str:String = "api/";
		private static var sLocalSwfFolder_str:String = "";
		private static var sLocalImageFolder_str:String = "image/";
		private static var sLocalVideoFolder_str:String = "video/";
		
		
		public function ConnPath()
		{
			
		}
		
		public static function init(pLoaderInfo:LoaderInfo):void
		{
			sLocalMode_bol = new RegExp("file://").test(pLoaderInfo.url);
			Logger.eddy("Local Mode: " + sLocalMode_bol);
			
			Logger.eddy("ConnPath info:");
			Logger.eddy("getServerPrefix: " + getServerPrefix());
			Logger.eddy("getAPIPrefix: " + getAPIPrefix());
			Logger.eddy("getAppPrefix: " + getAppPrefix());
			Logger.eddy("getSwfPrefix: " + getSwfPrefix());
			Logger.eddy("getImagePrefix: " + getImagePrefix());
			Logger.eddy("getVideoPrefix: " + getVideoPrefix());
		}
		
		public static function forceLocal(pForce_bol:Boolean):void
		{
			if (pForce_bol)
			{
				sLocalMode_bol = pForce_bol;
				Logger.eddy("force local: " + sLocalMode_bol);
			}
		}
		
		public static function isLocalMode():Boolean
		{
			return sLocalMode_bol;
		}
		
		public static function getAppPrefix():String
		{
			var prefix_str:String;
			
			if (sLocalMode_bol)
				prefix_str = sLocalPrefix_str;
			else
				prefix_str = sAppPrefix_str;
			
			return prefix_str;
		}
		
		public static function getSwfPrefix():String
		{
			var prefix_str:String;
			
			if (sLocalMode_bol)
				prefix_str = sLocalPrefix_str + sLocalSwfFolder_str;
			else
				prefix_str = sServerPrefix_str + sServerSwfFolder_str;
			
			return prefix_str;
		}
		
		public static function getServerPrefix():String
		{
			var prefix_str:String;
			
			if (sLocalMode_bol)
				prefix_str = sLocalPrefix_str;
			else
				prefix_str = sServerPrefix_str;
			
			return prefix_str;
		}
		
		public static function getImagePrefix():String
		{
			var prefix_str:String;
			
			if (sLocalMode_bol)
				prefix_str = sLocalPrefix_str + sLocalImageFolder_str;
			else
				prefix_str = sServerPrefix_str + sServerImageFolder_str;
			
			return prefix_str;
		}
		
		public static function getVideoPrefix():String
		{
			var prefix_str:String;
			
			if (sLocalMode_bol)
				prefix_str = sLocalPrefix_str + sLocalVideoFolder_str;
			else
				prefix_str = sServerPrefix_str + sServerVideoFolder_str;
			
			return prefix_str;
		}
		
		public static function getAPIPrefix():String
		{
			var prefix_str:String;
			
			if (sLocalMode_bol)
				prefix_str = sLocalPrefix_str + sLocalApiFolder_str;
			else
				prefix_str = sServerPrefix_str + sServerApiFolder_str;
			
			return prefix_str;
		}
		
		//**************** PHP CENTER ****************//
		public static function getProfilePath():String
		{
			return getAPIPrefix() + "getProfile.php" + getSessionParam();
		}
		public static function getFriendsPath():String
		{
			return getAPIPrefix() + "getFriends.php" + getSessionParam();
		}
		
		private static function getSessionParam():String
		{
			var param_str:String = "";
			if (FacebookIFrameCenter.getSessionForBrowserBug().length > 0)
				param_str = "?session=" + FacebookIFrameCenter.getSessionForBrowserBug();
			
			return param_str;
		}
		
		//**************** END ****************//
		
		public static function getFormPath():String
		{
			return getAPIPrefix() + "submitForm.php";
		}
		
		public static function getHasRegPath():String
		{
			return getAPIPrefix() + "hasReg.php";
		}
		
		public static function getTracking():String
		{
			return getAPIPrefix() + "tracking.php";
		}
		
		public static function getGlobalRankPath():String
		{
			return getAPIPrefix() + "getGlobalRank.php";
		}
		
		public static function getFriendRankPath():String
		{
			return getAPIPrefix() + "getFriendRank.php";
		}
		
		public static function getWeekRankPath():String
		{
			return getAPIPrefix() + "getWeekRank.php";
		}
		
		public static function getWholeRankingUIDPath():String
		{
			return getAPIPrefix() + "GetWholeRankingUID.php";
		}
		
		public static function getPublishPath():String
		{
			return getAPIPrefix() + "publish.php" + getSessionParam();
		}
		
		//API
		public static function getSaveProfilePath():String
		{
			return getAPIPrefix() + "profile/saveProfile.php";
		}
		
		public static function getGetProfilePath():String
		{
			return getAPIPrefix() + "profile/getProfile.php";
		}
		
		public static function getSubmitGameResultPath():String
		{
			return getAPIPrefix() + "profile/submitGameResult.php";
		}
		
		public static function getGetDatePath():String
		{
			return getAPIPrefix() + "profile/getDate.php";
		}
		
		//escape game
		public static function getSubmitEscapeGameCodePath():String
		{
			return getAPIPrefix() + "escapeGame/submitEscapeGameCode.php";
		}
		
		//phase4
		public static function getSubmitPhase4FormPath():String
		{
			return getAPIPrefix() + "phase4/submitPhase4Form.php";
		}
	}

}