String.prototype.ellipse = function(maxLength){
    if(this.length > maxLength){
        return this.substr(0, maxLength-3) + '...';
    }
    return this;
};

String.prototype.unescapeHtml = function () {
    var temp = document.createElement("div");
    temp.innerHTML = this;
    var result = temp.childNodes[0].nodeValue;
    temp.removeChild(temp.firstChild)
    return result;
}

Array.prototype.remove = function(from, to) {
	  var rest = this.slice((to || from) + 1 || this.length);
	  this.length = from < 0 ? this.length + from : from;
	  return this.push.apply(this, rest);
	};

var PARENT_PAGE = '';

var ArktanUtils = function(){
	var commentsWindow;
	var allCommentsWindow;	
	var siteContext;
	var loggedIn = false;
    return {
		
	jumpToPage: function(page){
		var loc = location.href;
		if(loc.indexOf("?") > -1){
			if(loc.indexOf("&pageRequested") > -1){
				loc = loc.split("&pageRequested")[0];
			}else if(loc.indexOf("pageRequested") > -1){
				loc = loc.split("pageRequested")[0];
			}
			loc += '&pageRequested='+ page;
		}else{
			loc += '?pageRequested='+ page;
		}
		location.href = loc;
	},
	
	arktanAlert: function(msg){
		var $genericAlert = $('#genericAlert');
		if($genericAlert.length){
			$genericAlert.html(msg);
			
			var alerttimer = window.setTimeout(function () {
				$genericAlert.trigger('click');
			}, 3000);
			$genericAlert.animate({height: $genericAlert.css('line-height') || '50px'}, 200)
			.click(function () {
				window.clearTimeout(alerttimer);
				$genericAlert.animate({height: '0'}, 200);
			});
		}
	},
	
    loginUser: function(e){
	  	e.preventDefault();
	  	location.href = ArktanUtils.getSiteContext() + "login?furl="+location.href;
	  	return false;
	  },
	  
	loginUserPop: function(e){
	  	e.preventDefault();
	  	location.href = ArktanUtils.getSiteContext() + "login?popup=true&furl="+location.href;
	  	return false;
	  },
	  
    twitterLoginUser: function(e){
	  	e.preventDefault();
	  	location.href = ArktanUtils.getSiteContext() + "m?furl="+location.href;
	  	return false;
	  },
	  
	addAsFriend: function(acName){
		pageTracker._trackEvent('FollowUser', 'FeaturedUserMessage', 'Request');
		var siteC = this.siteContext;
	 	$.ajax({
		   type: "POST",
		   url: this.siteContext + "ajax/AddFriend.action",
		   dataType: 'json',
		   data:{
				accountName: acName
			},
		   success: function(resp){
		    if (resp.success == true) {
				pageTracker._trackEvent('FollowUser', 'FeaturedUserMessage', 'Success');
				alert('You are now following ' + acName +'\'s updates');
				var loc = location.href;
				location.href = loc;
			}else{
				pageTracker._trackEvent('FollowUser', 'FeaturedUserMessage', 'Failure');
				alert(resp.message);
				return true;
			}
		   }
		 });
	  },
	  
	  deleteItem:function(contentId){
	  	var answer = confirm("Are you sure you want to delete this item forever?")
		if (answer){
			$.ajax({
			   type: "POST",
			   url: this.siteContext + "ajax/ManageContentItem.action",
			   dataType: 'json',
			   data:{
					action: 'delete',
		   			cfeId: contentId
				},
			   success: function(resp){
			    if (resp.success == false) {
					alert(resp.error);
					return;
				}else{
					var loc = location.href;
					location.href = loc;
				}
			   }
			 });
		}
	  },
		
	deleteComment: function(url, commentId){
		var answer = confirm("Are you sure ?")
		if (answer){
			$.ajax({
			   type: "POST",
			   url: url,
			   dataType: 'json',
			   data:{
					action: 'delete',
		   			commentId: commentId
				},
			   success: function(resp){
			    if (resp.success == false) {
					alert(resp.error);
					return;
				}else{
					$("#comment_"+commentId).remove();
				}
			   }
			 });
		}
	},
	
	deleteMessage: function(url, commentId){
		var answer = confirm("Are you sure ?")
		if (answer){
			$.ajax({
			   type: "POST",
			   url: url,
			   dataType: 'json',
			   data:{
					action: 'delete',
		   			commentId: commentId,
					type: 'message'
				},
			   success: function(resp){
			    if (resp.success == false) {
					alert(resp.error);
					return;
				}else{
					$("#comment_"+commentId).remove();
				}
			   }
			 });
		}
	},
	
	setSiteContext: function(sContext){
		this.siteContext = sContext;
	},
	
	getSiteContext: function(){
		return this.siteContext;
	},
	
	setLoggedIn: function(lIn){
		this.loggedIn = lIn;
	},
	
	getLoggedIn: function(){
		return this.loggedIn;
	},
		
	saveUrl: function(redirect){
		var contentURL = Ext.get('contentURL').getValue();
		var contentName = Ext.get('contentName').getValue();
		var comment = Ext.get('comment').getValue();
		
		var params = {
			contentURL: contentURL,
			contentName: contentName,
			redirect: redirect,
			comment: comment
		}
		
		if(IS_LOGGED_IN == true){
			ArktanUtils.submitUrl(params);
		}else{
			LoginWindow.show('submitUrl',params);
		}
	},
	
	submitUrl: function(params){
		Ext.Ajax.request({
			   url: 'ajax/ManageUrl.action',
			   params: params,
			   	
			   scope: this,
			   success: function(resp){
			   		var c = resp.responseText;
			   		var resp = Ext.decode(c);
			   		if(resp.success == false){
			   			Ext.Msg.alert('Add Url', resp.error);
						return;
			   		}	
					
					if (params.redirect == 'true') {
						window.location.href = params.contentURL;
					}else {
						window.close();
					}	   				   		 			
			   },
			   
			   failure: function(resp){
			   		Ext.Msg.show("Unable to connect to the server");
			   }
			});
	},
		
		
	processProfileForm :  function(f){
	    
	    if(f.firstName.value.trim() == ''){
	    	Ext.Msg.alert('First Name', 'Please enter a URL for the content you are adding.', function(btn, text){
			    if (btn == 'ok'){
			        var tt = Ext.get('contentURL');
	       			tt.focus();
			    }
			});
			return;
	    }
	    
	    if(f.contentName.value.trim() == ''){
	    	Ext.Msg.alert('Content name', 'Please enter a name for the content you are adding.', function(btn, text){
			    if (btn == 'ok'){
			        var tt = Ext.get('contentName');
	       			tt.focus();
			    }
			});
			return;
	    }
	    
	    contentURL = f.contentURL.value;
	    contentName = f.contentName.value;
	    Ext.Ajax.request({
		   url: 'ajax/ManageUrl.action',
		   params: {
		   		userName: f.userName.value,
		   		contentName: f.contentName.value,
		   		contentURL: f.contentURL.value,
		   		actionType: 'add'		   			   		
		   	},
		   	
		   success: processResponse,
		   
		   failure: function(resp){
		   		Ext.Msg.alert('Status', 'There was an error adding content.');
		   }
		});
		
		contentAdded = true;
	},
		
	submitComment: function(params, uiType, fn){
		var comment = params.comment;
		var cfeId = params.cfeId;
		Ext.Ajax.request({
			   url: 'ajax/ManageComment.action',
			   params: {
			   		action: 'add',
			   		cfeID: cfeId,
			   		text: comment.getValue()	   		
			   	},
			   	
			   scope: this,
			   success: function(resp){
			   		var c = resp.responseText;
			   		var resp = Ext.decode(c);
			   		if(resp.success == false){
			   			Ext.Msg.alert('Add Comment', resp.error);
						return;
			   		}		   		
			   		if(uiType && uiType == 'window'){
						comment.reset();
		   				commentsWindow.reloadView();
					}else{
						window.location.href="ShowContentItem.action?cfeId="+cfeId;
			   		}	   				   		 			
			   },
			   
			   failure: function(resp){
			   		Ext.Msg.show("Unable to connect to the server");
			   }
			});
	},
    
    createCookie: function (name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	},
	
	readCookie: function (name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	},
	
	eraseCookie: function (name) {
		ArktanUtils.createCookie(name,"",-1);
	},
    
    toggleCommentEntry: function(title, contentEntry, img, siteContext){
    	var el = document.getElementById(contentEntry);
			el.style.display = (el.style.display != 'none' ? 'none' : 'block' );
			
			var imgEl = document.getElementById(img);
			var titleEl = document.getElementById(title);
			if(imgEl){
				if(el.style.display != 'none'){
					imgEl.src = siteContext + '/img/minus.gif';
					if(titleEl)
						titleEl.style.display = 'none';
				}else{
					imgEl.src = siteContext + '/img/plus.gif';
					if(titleEl)
						titleEl.style.display = 'block';
				}
			}
    },
	
	toggleVideo: function(obj, button){
		var el = document.getElementById(obj);
			el.style.display = (el.style.display != 'none' ? 'none' : '' );
			
			var el2 = document.getElementById(button);
			if(el.style.display == 'none'){
				el2.src = 'img/play-32x32.png';
			}else{
				el2.src = 'img/stop-32x32.png';
			}
	},
	
	toggleVideo: function(obj, button, siteContext){
		var el = document.getElementById(obj);
			el.style.display = (el.style.display != 'none' ? 'none' : '' );
			
			var el2 = document.getElementById(button);
			if(el.style.display == 'none'){
				el2.src = siteContext + 'img/play-32x32.png';
			}else{
				el2.src = siteContext + 'img/stop-32x32.png';
			}
	},
	
	
	addToFavourites: function(cfeId){
		Ext.MessageBox.confirm('Confirm', 'Save this to your <b>Favorites</b> Channel ?', function(reply){
			if (reply == 'yes') {
				Ext.Ajax.request({
					url: 'ajax/SaveCFEInChannel.action',
					params: {
						saveType: 'favourite',
						cfeID: cfeId
					},
					
					scope: this,
					success: function(resp){
						var c = resp.responseText;
						var resp = Ext.decode(c);
						if (resp.success == false) {
							Ext.Msg.alert('Favourites', resp.error);
							return;
						}
					},
					
					failure: function(resp){
						Ext.Msg.show("Unable to connect to the server");
					}
				});
			}
			
		});
	},
    
    showCommentsWindow: function(contentId){
    	commentsWindow = new CommentsWindow({
    					url:'ajax/ShowCFEComments.action?cfeID='+contentId,		    					    					    			
		    			width:700, 		    			
		    			height:450,
		    			contentId: contentId
		    		});	       		  
		commentsWindow.show();
    },
    
    showShareChannel: function(channelName){
    	var shareChannelWindow = null;
    	shareChannelWindow = new ShareChannelWindow({		    					    					    			
		    			width:750, 		    			
		    			height:500,
		    			channelName: CURRENT_CHANNEL_NAME
		    		});	       		  
		shareChannelWindow.show();
    },
	
	showShareCFE: function(cfeId){
    	var shareCFEWindow = null;
    	shareCFEWindow = new ShareCFEWindow({		    					    					    			
		    			width:750, 		    			
		    			height:500,
		    			channelName: CURRENT_CHANNEL_NAME
		    		});	       		  
		shareCFEWindow.show();
    },
    
	addChannelSettings: function(setting){
		Ext.Ajax.request({
					url: 'ajax/AddFacesToChannel.action?'+setting+'_face=true',
					params: {
						channel: CURRENT_CHANNEL_NAME			
					},
					scope: this,
					success: function(resp){
						var c = resp.responseText;
						var resp = Ext.decode(c);
						if (resp.success == false) {
							Ext.Msg.alert('Settings', resp.error);
							return;
						}
					},
					
					failure: function(resp){
						Ext.Msg.show("Unable to connect to the server");
					}
				});
	},
	
    showEditChannel: function(channelName){
    	var editChannelWindow = new EditChannelWindow({	
	      		url:'ajax/FetchContents.action?channelName='+CURRENT_CHANNEL_NAME,	    					    			
	  			width:650, 
	  			height:425,
	  			channelName: CURRENT_CHANNEL_NAME
	  		});	       		  
		editChannelWindow.show();
    },
    
    
    addChannel: function(){
    	var editChannelWindow = new EditChannelWindow({	
       		url:'ajax/FetchContents.action',	    					    			
   			width:650, 
   			height:425,
   			channelName: ''
   		});	       		  
		editChannelWindow.show();
    },
    
    removeContent: function(id, cfeId, page){
    	Ext.Ajax.request({
		   url: 'ajax/ManageComment.action',
		   params: {
		   		action: 'delete',
		   		commentId: id		   		
		   	},		   			   
		   success: function(resp){
		   		var c = resp.responseText;
		   		var resp = Ext.decode(c);
		   		if(resp.success == false){
		   			Ext.Msg.alert('Add Comment', resp.error);
					return;
		   		}
		   		if(page == 'showCFE'){
		   			window.location.href="ShowContentItem.action?cfeId="+cfeId;
		   		}else if(page == 'home'){
		   			allCommentsWindow.getUpdater().refresh();
		   		}else{
		   			//Ext.get('comment_'+id).hide();
		   			commentsWindow.reloadView();
		   		}	   				   		 			
		   },
		   
		   failure: function(resp){
		   		Ext.Msg.show("Unable to connect to the server");
		   }
		});
		return false;
    },
	
	
	removeComment: function(id, uiType){
    	Ext.Ajax.request({
		   url: 'ajax/ManageComment.action',
		   params: {
		   		action: 'delete',
		   		commentId: id		   		
		   	},		   			   
		   success: function(resp, options){
		   		var c = resp.responseText;
		   		var resp = Ext.decode(c);
		   		if(resp.success == false){
		   			Ext.Msg.alert('Remove Comment', resp.error);
					return;
		   		}
		   		Ext.get('comment_'+options.params.commentId+'_'+uiType).remove();   				   		 			
		   },
		   
		   failure: function(resp){
		   		Ext.Msg.show("Unable to connect to the server");
		   }
		});
		return false;
    },
    
    closeShareUpdate: function(){        	 
 		Ext.get('shareByEMail_update').dom.style.display = "none";        	
    	return false;
    },
    
    processShareForm: function(f, channelName, channelUrl){
    	if(f.form.recipients.value.trim() == ''){
	    	Ext.Msg.alert('Share Channel', 'Please enter an email/list of emails separated by commas.', function(btn, text){
			    if (btn == 'ok'){
			        var tt = Ext.get('recipients');
	       			tt.focus();
			    }			   
			});
			return;
	    }
	    
		Ext.Ajax.request({
		   url: 'ajax/ShareUrl.action',
		   params: {
		   		emails: f.form.recipients.value,
		   		message: f.form.message.value,
		   		channelName: channelName,
		   		channelUrl: channelUrl,
		   		shareType: 'channel'		   		
		   	},
		   	
		   success: function(resp){
		   		var c = resp.responseText;
		   		var resp = Ext.decode(c);
		   		if(resp.success == false){
		   			Ext.Msg.alert('Share Channel', resp.error);
					return;
		   		}
		   				   		
		   		var resultHTML = '<div style="color: #555555; font-weight: bold;">E-Mail(s) sent. You have successfully shared your "'+channelName+'" channel.</div>';
		   		//resultHTML = 'Success';
	   			f.form.recipients.value = '';
       			f.form.message.value = '';		   		
		   		Ext.get('shareByEMail_message').update(resultHTML);		   		
		   		Ext.get('shareByEMail_update').slideIn();		   				   		 			
		   },
		   
		   failure: function(resp){
		   		Ext.Msg.show("Unable to connect to the server");
		   }
		});
    },
    
    resetInviteForm: function(f){
    	f.form.recipients.value = '';
    	f.form.message.value = '';
    },
    
    showAddContentMenu: function(el){
    	var e = Ext.get(el);
    	var menu = new Ext.menu.Menu({
                id:'add-content-menu',
                items: [{
                        text : 'by username',						
						handler : function(){
							AddIdentityWindow.show(this);
						},																	
						scope: this
					},{
                        text : 'by website',	                        			
						handler : function(){
							AddPortalWindow.show(this);
						},
						scope: this
					},{						
						text : 'by URL',																	
						handler : function(){
							AddURLWindow.show(this);
						},
						scope: this
					}
                
                ]
            });
            //this.menu.on('hide', this.onContextHide, this);
        
        
        
        menu.showAt(e.getAnchorXY('bl'));
        
    },
	
	showChannelSecurityMenu: function(el){
    	var e = Ext.get(el);
    	/*
		var menu = new Ext.menu.Menu({
                id:'channel-security-menu',
                items: [{
                        text : 'Public',
						checked: false,
						group: 'permissions',				
						checkHandler : function(){
							//AddIdentityWindow.show(this);
						},																	
						scope: this
					},{
                        text : 'Private',	                        			
						checked: false,
						group: 'permissions',				
						checkHandler : function(){
							//AddIdentityWindow.show(this);
						},
						scope: this
					},{						
						text : 'Only Arktan Users',																	
						checked: true,
						group: 'permissions',				
						checkHandler : function(){
							//AddIdentityWindow.show(this);
						},
						scope: this
					}
                
                ]
            });
            */
            //this.menu.on('hide', this.onContextHide, this);
        
        
       PERMISSIONS_MENU.showAt(e.getAnchorXY('bl'));
        
    },
    
    removeFeed: function(node){
    	Ext.MessageBox.confirm('Confirm', 'Are you sure you want to remove this content from all channels?', function(reply){
			if(reply == 'yes'){
				StartStation.removeFeedFromChannels(node);
				Ext.Ajax.request({
						  url:'ajax/ManageContent.action',
						  params:{
						  	'userName':node.attributes.username,
						  	'portalName':node.parentNode.text, // parse the id for delimiters and get the actual id later.
						  	'contentName':node.text,
						  	'contentURL' : node.attributes.url,
						  	'actionType' : 'delete'
						  },
						  method : 'post',
						  success : function(resp, opt){
						  	//alert(resp.responseText);
						  },
						  failure: function(resp, opt){
						  	alert(resp.responseText);
						  }
					});
				node.remove();
			}else{
				node.getUI().toggleCheck();
				
				
			}
			});
    },
    
    approveFriend : function(acName){
		Ext.Ajax.request({
		   url: 'ajax/ApproveFriendRequest.action',
		   params: {
		   		accountName: acName
		   	},
		   	
		   success: function(resp, opt){
		   		var c = resp.responseText;
		   		if(c == 'Success\r\n'){
		   			Ext.Msg.alert('Congratulations!', 'You are now connected to '+opt.params.accountName, function(btn, text){
					    if (btn == 'ok'){
					       if(location.href.indexOf('Friends') > 0){
								location.href = 'InviteFriends.action';
							}else{
								location.href = 'Home.action';
							}
					    }
					});		   			
		   			//Ext.get('friendApprove_'+opt.params.accountName).update('<img src="img/icon_accept.gif" /> Approved');
		   			
		   			//Ext.get('friendAdd_'+opt.params.accountName).update('Added Successfully');
		   			//Ext.get('friend_'+opt.params.accountName).highlight('#afff7f', {block:true});		   			
		   		}else{		   			
		   			Ext.Msg.show("Server error, please try again.");
		   		}	 
		   },
		   
		   failure: function(resp){
		   		Ext.Msg.show("Unable to connect to the server");
		   }
		});
	},
      
        getRequestParameter : function( queryString, parameterName ) {
   // Add "=" to the parameter name (i.e. parameterName=value)
   var parameterName = parameterName + "=";
   if ( queryString.length > 0 ) {
      // Find the beginning of the string
      begin = queryString.indexOf ( parameterName );
      // If the parameter name is not found, skip it, otherwise return the value
      if ( begin != -1 ) {
         // Add the length (integer) to the beginning
         begin += parameterName.length;
         // Multiple parameters are separated by the "&" sign
         end = queryString.indexOf ( "&" , begin );
      if ( end == -1 ) {
         end = queryString.length
      }
      // Return the string
      return unescape ( queryString.substring ( begin, end ) );
	   }
	   // Return "null" if no parameter has been found
	   return "null";
	   }
	},
	/*
	 addAsFriend: function(acName){
	 	
		Ext.Ajax.request({
		   url: 'ajax/AddFriend.action',
		   params: {
		   		accountName: acName
		   	},
		   	
		   success: function(resp, opt){
		   		var c = resp.responseText;
		   		if(c == 'Success\r\n'){
		   			Ext.get('friend-request').update('Friend request submitted.');
		   			Ext.get('friend-request').highlight('#afff7f', {block:true});		   			
		   		}
				
				//handle failure here	 
		   },
		   
		   failure: function(resp){
		   		Ext.Msg.show("Unable to connect to the server");
		   }
		});
	
	 },
	*/
         
     openIframeWindow: function(url, title) 
	{
		if (url.indexOf('nytimes') > 0 || url.indexOf('vimeo') > 0 || url.indexOf('tumblog') > 0) {
		
			var win=null;
			
			w = '700';
			h = '450';
			scroll = 'yes';
			mypage = url;
			myname = 'winNew';
			pos = 'center';
			
			if(pos=="center"){LeftPosition=(screen.availWidth)?(screen.availWidth-w)/2:50;TopPosition=(screen.availHeight)?(screen.availHeight-h)/2:50;}
			settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
			win=window.open(mypage,myname,settings);
			if(win.focus){win.focus();}
		
		
		}
		else {
		
			var ulDialog = new Ext.Window({
				height: 450,
				width: 700,
				minHeight: 50,
				minWidth: 100,
				modal: false,
				maximizable: true,
				shadow: true,
				//collapsible:	true,
				closable: true,
				body: new Ext.ux.ManagedIFrame({
					showLoadIndicator: true,
					autoCreate: {
						id: 'dynamicIframe1_' + url,
						cls: 'x-window-body',
						width: '100%',
						height: '100%',
						src: url
					}
				}),
				animate: true,
				//title:			''+ title + '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[ <a target="_blank" style="color: white;" href="'+url+'">Open in a new window</a> ]',
				title: '<div style="text-align: center;font-size: 18px;">' + title + '</div>',
				resizable: true,
				bodyBorder: true,
				//buttons:		[{text: "Close", handler: function() {ulDialog.hide();ulDialog.destroy();} }],
				keys: [{
					key: 27,
					fn: function(){
						ulDialog.hide();
						ulDialog.destroy();
					},
					scope: this
				}]
			});
			ulDialog.show();
		}
	},
	
	openContentInWindow: function(n,url,params){
	// Panel for the west
        var feedsPanel = new Ext.Panel({            
            region: 'center',            
            width: 200,            
            autoScroll: true,
            margins:'3 0 3 3',
            cmargins:'3 3 3 3',
            autoLoad: {
					    url: url +'?uiType=win',
					    params: params, // or a URL encoded string			   
					    nocache: false,
					    text: "Loading...",
					    timeout: 30,
					    scripts: true
					}
        });
    	
    	var win = new Ext.Window({
            title: n.text,
            closable:true,
            width:700,
            height:450,
            //border:false,
            plain:true,
            layout: 'border',
            items: [feedsPanel]
        });
		
        win.show(n);
        },
        
        openURLInWindow: function(url, title, src, params){
	// Panel for the west
        var feedsPanel = new Ext.Panel({            
            region: 'center',            
            width: 678,            
            autoScroll: true,
            margins:'3 3 3 3',
            cmargins:'3 3 3 3',
            autoLoad: {
					    url: url +'?uiType=win',
					    params: params, // or a URL encoded string			   
					    nocache: false,
					    text: "Loading...",
					    timeout: 30,
					    scripts: true
					}
        });
    	
    	var win = new Ext.Window({
            title: '<span style="font-size: 15px; font-family: Arial;">'+title+'</span>',
            closable:true,
            width:700,
            height:450,
            //border:false,
            plain:true,
            layout: 'border',
            items: [feedsPanel]
        });
		
        win.show(this);
        },
        
     openCommentsWindow: function(){
		var url = 'ajax/FetchUserComments.action';
		var params = {type: 'comment'};
		var title = 'Comments';
        var feedsPanel = new Ext.Panel({            
            region: 'center',            
            width: 678,            
            autoScroll: true,
            margins:'3 3 3 3',
            cmargins:'3 3 3 3',
            autoLoad: {
					    url: url +'?uiType=win',
					    params: params, // or a URL encoded string			   
					    nocache: false,
					    text: "Loading...",
					    timeout: 30,
					    scripts: true
					}
        });
    	
    	var win = new Ext.Window({
            title: '<span style="font-size: 15px; font-family: Arial;">'+title+'</span>',
            closable:true,
            width:700,
            height:450,
            //border:false,
            plain:true,
            layout: 'border',
            items: [feedsPanel]
        });
		
        win.show(this);     
        allCommentsWindow = win;   
        },
        
       openChannelShareWindow: function(node){
		// Panel for the west
        var feedsPanel = new Ext.Panel({            
            region: 'center',            
            width: 678,            
            autoScroll: true,
            margins:'3 3 3 3',
            cmargins:'3 3 3 3',
            items:[{
                    //region: 'north',
                    contentEl: 'shareByEmail',                    					                                       
                    frame: true,
                    width: 520,
                    border: false,
                    title: 'Find Friends on Arktan',
                    collapsible: true,
                    collapsed: false,                    
//                  title:'South',
                    margins:'0 0 0 0'
                },{
                    //region: 'north',
                    contentEl: 'shareByWidget',                    					                                       
                    frame: true,
                    width: 520,
                    border: false,
                    title: 'Invite Friends to Arktan',
                    collapsible: true,
                    collapsed: false,                    
//                  title:'South',
                    margins:'0 0 0 0'
                }]
        });
    	
    	var win = new Ext.Window({
            title: '<span style="font-size: 15px; font-family: Arial;">'+title+'</span>',
            closable:true,
            width:700,
            height:450,
            //border:false,
            plain:true,
            layout: 'border',
            items: [feedsPanel]
        });
		
        win.show(this);
        }
	
    };
    
    
}();