//Author: Pratik.Gohil
BarTab = function()
{		
	// User details
	BarTab.IsSignIn = 0;
	BarTab.UserID = 0;
	BarTab.ViewerUserID = 0;
	
	// Site and Web service urls
	BarTab.SiteUrl = "";
	BarTab.ServiceUrl = "";
	BarTab.PageUrl = "";	
	BarTab.InValidCharacters = " `~!@#$%^&*()+=-[]\\\';,./{}|\":<>? ";
	
	// Flag for WidgetManager.Browser.Opera web browser
	BarTab.Browser = new Object();
	BarTab.Browser.IE = navigator.userAgent.toLowerCase().indexOf('msie') >= 0 ? true : false;
	BarTab.Browser.Opera = navigator.userAgent.toLowerCase().indexOf('opera') >= 0 ? true : false;	
	BarTab.Browser.Mozilla = navigator.userAgent.toLowerCase().indexOf('firefox') >= 0 ? true : false;
	BarTab.Browser.Netscape = navigator.userAgent.toLowerCase().indexOf('netscape') >= 0 ? true : false;
	
	// Value for scroll height & width of the page
	BarTab.ScrollWidth = document.body? document.body.scrollWidth : 0;
	BarTab.ScrollHeight = document.body? document.body.scrollHeight: 0;
			
	BarTab.ScrollLeft = typeof( window.pageXOffset ) == "number"? window.pageXOffset: (document.body?(document.body.scrollLeft? document.body.scrollLeft : document.documentElement.scrollLeft): 0);	
	BarTab.ScrollTop = typeof( window.pageYOffset ) == "number"? window.pageYOffset: (document.body? (document.body.scrollTop? document.body.scrollTop : document.documentElement.scrollTop): 0);
				
	// Value for browser height & width of the page
	BarTab.ClientWidth = self.innerWidth || (document.documentElement.clientWidth || (document.body? document.body.clientWidth: 0));
	BarTab.ClientHeight = self.innerHeight || (document.documentElement.clientHeight || (document.body? document.body.clientHeight: 0));
			
	BarTab.Browser.Client = function()
	{
		// Value for scroll height & width of the page
		BarTab.ScrollWidth = document.body? document.body.scrollWidth: 0;
		BarTab.ScrollHeight = document.body? document.body.scrollHeight: 0;
				
		BarTab.ScrollLeft = typeof( window.pageXOffset ) == "number"? window.pageXOffset : (document.body? (document.body.scrollLeft? document.body.scrollLeft : document.documentElement.scrollLeft): 0);	
		BarTab.ScrollTop = typeof( window.pageYOffset ) == "number"? window.pageYOffset : (document.body? (document.body.scrollTop? document.body.scrollTop : document.documentElement.scrollTop): 0);
					
		// Value for browser height & width of the page
		BarTab.ClientWidth = self.innerWidth || (document.documentElement.clientWidth || (document.body? document.body.clientWidth: 0));
		BarTab.ClientHeight = self.innerHeight || (document.documentElement.clientHeight || (document.body? document.body.clientHeight: 0));		
	};
	
	/**********************************************************************************************************
	 * Function		: Sets a Cookie with the given name and value.
	 * [name]		: Name of the cookie
	 * [value]		: Value of the cookie
	 * [expires]	: Expiration date of the cookie (default: end of current session)
	 * [path]		: Path where the cookie is valid (default: path of calling document)
	 * [domain]		: Domain where the cookie is valid (default: domain of calling document)
	 * [secure]		: Boolean value indicating if the cookie transmission requires a secure transmission
	 **********************************************************************************************************/
	BarTab.SetCookie = function(name, value, expires, path, domain, secure)
	{
		document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");	
	};
	
	
	/**********************************************************************************************************
	 * Function		: Gets a Cookie with the given name.
	 * [name]		: Name of the cookie
	 **********************************************************************************************************/
	BarTab.GetCookie = function(name)
	{
		var prefix = name + "=";
		var begin = document.cookie.indexOf("; " + prefix);
		if (begin == -1)
		{
			begin = document.cookie.indexOf(prefix);
			if (begin != 0) return null;
		}
		else
		{
			begin += 2;
		}
		var end = document.cookie.indexOf(";", begin);
		if (end == -1)
		{
			end = document.cookie.length;
		}
		return unescape(document.cookie.substring(begin + prefix.length, end));	
	};
	
	/**********************************************************************************************************
	 * Function		: Deletes the specified cookie.
	 * [name]		: Name of the cookie
	 * [path]		: Path of the cookie (must be same as path used to create cookie)
	 * [domain]		: Domain of the cookie (must be same as domain used to create cookie)
	 **********************************************************************************************************/
	BarTab.DeleteCookie = function(name, path, domain)
	{
		if (BarTab.GetCookie(name))
		{
			document.cookie = name + "=" + 
				((path) ? "; path=" + path : "") +
				((domain) ? "; domain=" + domain : "") +
				"; expires=Thu, 01-Jan-70 00:00:01 GMT";
		}
	};
	
	BarTab.IsUserLogin = function()
	{	
		if(BarTab.GetCookie("BarTab.UserInfo"))
			{return true;}
		else
			{return false;}
	};	
	
	// Widgets class
	BarTab.Widgets = function()
	{
		// Set type object
		BarTab.Widgets.Type = new Object();
		BarTab.Widgets.Type.Generic = 0;
		BarTab.Widgets.Type.RSS = 1;
		BarTab.Widgets.Type.Video = 2;
		BarTab.Widgets.Type.Audio = 3;
		BarTab.Widgets.Type.Photo = 4;
		BarTab.Widgets.Type.Profile = 5;
		BarTab.Widgets.Type.Blog =  6;        
		BarTab.Widgets.Type.Group = 8;
		BarTab.Widgets.Type.Bookmark = 9;
		BarTab.Widgets.Type.WebUrl = 10;
		BarTab.Widgets.Type.HtmlWidget = 11;
		BarTab.Widgets.Type.MailCenter = 12;
		BarTab.Widgets.Type.Contact = 13;
		BarTab.Widgets.Type.Calender = 14;
		BarTab.Widgets.Type.Network = 15;
		BarTab.Widgets.Type.Ads = 16;
		BarTab.Widgets.Type.Search = 17;
		BarTab.Widgets.Type.Friend = 18;
		BarTab.Widgets.Type.ProfileComment = 19;
		BarTab.Widgets.Type.WebUrlTracker = 20;
		BarTab.Widgets.Type.HistoryLog = 25;
		BarTab.Widgets.Type.SiteTracker_TrackDetail = 34;
		BarTab.Widgets.Type.SiteTracker_KeywordTracks = 24;

		// Get widget icon url
		BarTab.Widgets.GetIcon = function(type)
		{
			var imageUrl = "";
			switch(type)
			{
				case BarTab.Widgets.Type.Generic :
					{
						imageUrl = "App_Themes/UserThemeNew/Img/Icons/Generic-Widget.gif";
						break;
					}
				case BarTab.Widgets.Type.RSS :
					{
						imageUrl = "App_Themes/UserThemeNew/Img/Icons/My-Feed.gif";
						break;
					}
				case BarTab.Widgets.Type.Video :
					{
						imageUrl = "App_Themes/UserThemeNew/Img/Icons/My-Video.gif";
						break;
					}
				case BarTab.Widgets.Type.Audio :
					{
						imageUrl = "App_Themes/UserThemeNew/Img/Icons/My-Audio.gif";
						break;
					}
				case BarTab.Widgets.Type.Photo :
					{
					imageUrl = "App_Themes/UserThemeNew/Img/Icons/MY-Photos.gif";
					break;
					}
				case BarTab.Widgets.Type.Profile :
					{
						imageUrl = "App_Themes/UserThemeNew/Img/Icons/My-Profile.gif";
						break;
					}
				case BarTab.Widgets.Type.Blog :
					{
						imageUrl = "App_Themes/UserThemeNew/Img/Icons/My-Blogs.gif";
						break;
					}
				case BarTab.Widgets.Type.Group :
					{
						imageUrl = "App_Themes/UserThemeNew/Img/Icons/My-groups.gif";
						break;
					}
				case BarTab.Widgets.Type.Bookmark :
					{
						imageUrl = "App_Themes/UserThemeNew/Img/Icons/My-Bookmarks.gif";
						break;
					}
				case BarTab.Widgets.Type.WebUrl :
					{
						imageUrl = "App_Themes/UserThemeNew/Img/Icons/Web-Url.gif";
						break;
					}
				case BarTab.Widgets.Type.WebUrlTracker :
					{
						imageUrl = "App_Themes/UserThemeNew/Img/Icons/Web-Url.gif";
						break;
					}
				case BarTab.Widgets.Type.HtmlWidget :
					{
						imageUrl = "App_Themes/UserThemeNew/Img/Icons/HTML-Widgets.gif";
						break;
					}
				case BarTab.Widgets.Type.MailCenter :
					{
						imageUrl = "App_Themes/UserThemeNew/Img/Icons/Email-Center.gif";
						break;
					}
				case BarTab.Widgets.Type.Contact :
					{
						imageUrl = "App_Themes/UserThemeNew/Img/Icons/My-Contacts.gif";
						break;
					}
				case BarTab.Widgets.Type.Network :
					{
						imageUrl = "App_Themes/UserThemeNew/Img/Icons/My-Network.gif";
						break;
					}
				case BarTab.Widgets.Type.Ads :
					{
						imageUrl = "App_Themes/UserThemeNew/Img/Icons/Ads.gif";
						break;
					}
				case BarTab.Widgets.Type.Friend :
					{
						imageUrl = "App_Themes/UserThemeNew/Img/Icons/My-friends.gif";
						break;
					}
				case BarTab.Widgets.Type.ProfileComment :
					{
						imageUrl = "App_Themes/UserThemeNew/Img/Icons/Profile-Comments.gif";
						break;
					}
				case BarTab.Widgets.Type.Calender :
					{
						imageUrl = "App_Themes/UserThemeNew/Img/Icons/My-Calendar.gif";
						break;
					}
				case BarTab.Widgets.Type.HistoryLog :
					{
						imageUrl = "App_Themes/UserThemeNew/Img/Icons/My-History.gif";
						break;
					}
				case BarTab.Widgets.Type.Search :
					{
						imageUrl = "App_Themes/UserThemeNew/Img/Icons/Search.gif";
						break;
					}
				case BarTab.Widgets.Type.SiteTracker_TrackDetail :
					{
						imageUrl = "App_Themes/UserThemeNew/Img/Icons/Track-Details.gif";
						break;
					}
				case BarTab.Widgets.Type.SiteTracker_KeywordTracks :
					{
						imageUrl = "App_Themes/UserThemeNew/Img/Icons/Keyword-tracks.gif";
						break;
					}
				default :
					{
						imageUrl = null;
						break;
					}
			}

			return imageUrl;
		};
	};
};

new BarTab();