/* ***********************************************************
 * FeedspaceSlider "constructor" function.
 * *********************************************************** */

function com_ibm_wps_portlets_FeedspaceSlider(ctx,port,box,rate,frames,show,completionCallback)
{
	this.ctx=ctx;
	this.port=port;
	this.box=box;
	this.rate=rate;
	this.frames=frames;
	this.show=show;
	this.completionCallback=completionCallback;
}

com_ibm_wps_portlets_FeedspaceSlider.prototype.animate=
	function()
	{
		if(this.show){
			this.port.style.visibility='visible';
			this.box.style.visibility='hidden';
			this.box.style.display='block';
			this.box.style.width=(this.port.offsetWidth)+'px';	
		}	
		this.ctx.setTimeout(this,'animInit',250);
	};
	
com_ibm_wps_portlets_FeedspaceSlider.prototype.animInit=
	function() 
	{
		var portO=this.ctx.getScreenOrigin(this.port);
		this.maxH=this.box.offsetHeight;
		this.deltaH=Math.round(this.maxH/this.frames);
		if(this.show){
			this.currClip={top:this.maxH,left:0,width:this.box.offsetWidth,height:0};
			this.currTop=(portO.y-this.maxH);
			this.currH=0;
		}else{
			this.currClip={top:0,left:0,width:this.box.offsetWidth,height:this.maxH};
			this.currTop=portO.y;	
			this.currH=this.maxH;	
			this.port.innerHTML='';
		}
		this.box.style.top=this.currTop+'px';
		this.box.style.left=portO.x+'px';
		this.box.style.clip=this.ctx.calcClip(this.currClip.top,this.currClip.left,this.currClip.width,this.currClip.height);
		this.box.style.visibility='visible';
		this.anim();
	};
	
com_ibm_wps_portlets_FeedspaceSlider.prototype.anim=
	function()
	{
		if(this.show){
			var hh=this.currH+this.deltaH;
			var nexth=(hh<this.maxH?hh:this.maxH);
			var dy=nexth-this.currH;
			this.port.style.height=nexth+'px';
			this.box.style.top=(this.currTop+dy)+'px';
			this.box.style.clip=this.ctx.calcClip(this.currClip.top-dy,this.currClip.left,this.currClip.width,this.currClip.height+dy);
			this.currH=nexth;
			this.currTop+=dy;
			this.currClip.top-=dy;
			this.currClip.height+=dy;
			if(nexth<this.maxH){this.ctx.setTimeout(this,'anim',this.rate);}
			else{this.port.innerHTML=this.box.innerHTML;this.box.style.visibility='hidden';this.port.isFull=true;if(this.completionCallback){this.completionCallback(this);}}
		}else{
			var hh=this.currH-this.deltaH;
			var nexth=(hh>0?hh:0);
			var dy=this.currH-nexth;
			this.port.style.height=(nexth==0?1:nexth)+'px';
			this.box.style.top=(this.currTop-dy)+'px';
			this.box.style.clip=this.ctx.calcClip(this.currClip.top+dy,this.currClip.left,this.currClip.width,this.currClip.height-dy);
			this.currH=nexth;
			this.currTop-=dy;
			this.currClip.top+=dy;
			this.currClip.height-=dy;
			if(nexth>0){this.ctx.setTimeout(this,'anim',this.rate);}
			else{this.box.style.visibility='hidden';this.box.style.display='none';this.port.style.visibility='hidden';this.port.isFull=false;if(this.completionCallback){this.completionCallback(this);}}		
		}
	};

/* ***********************************************************
 * FeedspaceScriptingContext "constructor" function.
 * *********************************************************** */

function com_ibm_wps_portlets_FeedspaceScriptingContext(namespace)
{
	this.namespace=namespace;
	this.selectedConfigPageId='synd_subslist';
	this.configSelectionCount=0;
	this.selectedConfigPresentationStyle=1;
	this.selectedTab=new Object();
	this.selectedTab['top']='synd_general';
	this.selectedTab['general']='synd_subslist';
	this.selectedTab['apprnc']='synd_apprnc_general';
	this.selectedTab['secopts']='synd_list_add_auth_0';
	this.selectedTab['ccopts']='synd_list_add_adv_cctype_0';
	this.selectedTab['addtyp']='synd_list_add_typ_feed';
	this.selectedTab['winopts']='synd_prefs_window_title_0';
	this.selectedTab['headlines_winopts']='synd_prefs_window_title_0';
	this.selectedTab['channel_winopts']='synd_prefs_window_title_0';
	this.dropTargets=new Array();
	this.setTimeout(this,'register',250);
	this.isSelectionDirty=false;
}

com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.register =
	function()
	{
		var list=this.getElementNs('synd_list_table');
		if(list)
		{
			var trs=list.getElementsByTagName('tr');
			if(trs&&trs.length>0){
				for(var ii=0;ii<trs.length;ii++){this.dropTargets.push(trs[ii]);}
			}
		}
	};
	
/* ***********************************************************
 * Language Helpers
 * *********************************************************** */
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.curryFunc =
	function( aThis, aFunc, someArgs )
	{
		var	curryFunc = function () { var thisFunc = arguments.callee; return thisFunc.aFunc.apply( thisFunc.aThis, (thisFunc.someArgs?thisFunc.someArgs:arguments) ); };
		
		curryFunc.aThis = aThis;
		curryFunc.aFunc = aFunc;	
		if(someArgs){curryFunc.someArgs=someArgs;}
		
		return curryFunc;
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.strStartsWith =
	function( s,t )
	{
		if(s&&t&&s.length>=t.length){return s.substring(0,t.length)==t;}
		return false;
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.strEndsWith =
	function( s,t )
	{
		if(s&&t&&s.length>=t.length){return s.substring(s.length-t.length)==t;}
		return false;
	};
		
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.stripNamespace =
	function( id )
	{
		if(this.strStartsWith(id,this.namespace)){return id.substring(this.namespace.length);}
		else{return id;}
	};
		
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.stripSuffix =
	function( id, delim )
	{
		var idx=id.lastIndexOf(delim);
		if(idx!=-1){return id.substring(0,idx);}
		else{return id;}
	};				
/* ***********************************************************
 * Browser Compatibility Layer
 * *********************************************************** */
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.setTimeout =
	function( aThis, aFunc, ms )
	{
		setTimeout(this.curryFunc(aThis,aThis[aFunc]),ms);
	};
			
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.getElement =
	function ( id, aDoc )
	{
		var	obj = null;
		var doc = ( aDoc || document );
	  	if (doc.getElementById)
	  	{
	  		obj = doc.getElementById(id);
	  	}
	  	else if (doc.all)
	  	{
			obj = doc.all[id];
		}
	 	else if (doc.layers)
	  	{
	   		obj = doc.layers[id];
	  	}
	  	return obj;
	};

com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.getElementNs =
	function ( id, aDoc )
	{
		return this.getElement(this.namespace+id,aDoc);
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.getAncestorByName =
	function( element, name )
	{
		var	parent = element.parentNode;
		while ( parent != null )
		{
			if ( parent.nodeName.toLowerCase() == name )
			{
				break;
			}
			else
			{
				parent = parent.parentNode;
			}
		}
		return parent;
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.getScreenOrigin =
	function ( element )
	{
		var parent = element.offsetParent;
		var origin;
		if ( parent == null ) {
			origin = {x:element.offsetLeft,y:element.offsetTop};
		} else {
			var cstyle=this.getComputedStyle(element);
			if(cstyle&&cstyle.position.toLowerCase()=='absolute'){
				origin = {x:0,y:0};
			}else{
				origin = this.getScreenOrigin( parent );
				origin.x += element.offsetLeft;
				origin.y += element.offsetTop;
			}
		}
		return origin;
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.getBounds =
	function (e)
	{
		var pt=this.getScreenOrigin(e);
		return {top:pt.y,left:pt.x,width:e.offsetWidth,height:e.offsetHeight};
	};	
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.getDsocOrigin =
	function ()
	{
		if (window.pageYOffset!==undefined) { return {x:window.pageXOffset,y:window.pageYOffset}; }
		else if (document.documentElement&&document.documentElement.scrollTop!==undefined) { return {x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop}; }
		else if (document.body&&document.body.scrollTop!==undefined) { return {x:document.body.scrollLeft,y:document.body.scrollTop}; }
		else { return {x:0,y:0}; }
	};
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.ptIntersectsRect =
	function (x,y,r1)
	{
		return ((y>=r1.top&&y<=(r1.top+r1.height))&&((x>=r1.left&&x<=(r1.left+r1.width))))
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.getComputedStyle =
	function(e)
	{
		if(window.getComputedStyle){return window.getComputedStyle(e,null);}
		else if(e.currentStyle){return e.currentStyle;}
		else{return null;}
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.getEvent =
	function(event)
	{
		if (!event&&window.event)
		{
			event = window.event;
		}
		return event;
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.stopEventPropagation =
	function( event )
	{
		if ( event.stopPropagation )
		{
			event.stopPropagation();
		}
		else
		{
			event.cancelBubble = true;
		}
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.calcClip=
	function(top,left,width,height)
	{
		return 'rect('+top+'px,'+(left+width)+'px,'+(top+height)+'px,'+left+'px)';
	};
		
/* ***********************************************************
 * DHTML Controls Layer
 * *********************************************************** */
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.showCtl =
	function(aId,isMenu,anchor)
	{
		var e=this.getElementNs(aId);
		if(e) {
			if(e.style.visibility&&e.style.visibility.toLowerCase()=='visible'){return false;}
			if(isMenu){
				var fn=this.curryFunc(this,this.hideMenuCtl,[aId]);
				if(anchor){
					var anchorOrigin=this.getScreenOrigin(anchor);
					var menuX=anchorOrigin.x;
					var menuY=anchorOrigin.y+anchor.offsetHeight+2;
					var pos={x:menuX,y:menuY};				
					e.style.left=pos.x+'px';
					e.style.top=pos.y+'px';
					e.aMenuAnchorRef=anchor.id;
				}
				e.aMenuTimeoutId=setTimeout(fn,7000);
			}
			if(e.nodeName.toLowerCase()=='tr'){try{e.style.display='table-row';}catch(ex){e.style.display='block';}}
			else{e.style.display='block';}
			e.style.visibility='visible';
		}
		return false;
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.handleButton =
	function(aId,isCancel,focusable)
	{
		if (isCancel){
			this.hideCtl(aId);
		}
		else {
			this.showCtl(aId);
			if (aId=='synd_list_import_ctl'){
				this.hideCtl('synd_list_add_ctl');
				}
			else if (aId=='synd_list_add_ctl'){
				this.hideCtl('synd_list_import_ctl');
				}
		}
		if(focusable){
			var e=this.getElementNs(focusable);
			if(e&&e.focus){e.focus();}
		}		
		this.hideCtl('MessageTag');
		return false;
	};
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.hideCtl =
	function(aId,isMenu)
	{
		var e=this.getElementNs(aId);		
		if(e) {
			if(e.style.visibility&&e.style.visibility.toLowerCase()=='hidden'){return false;}	
			if(isMenu) {
				if(e.aMenuTimeoutId){clearTimeout(e.aMenuTimeoutId);e.aMenuTimeoutId=null;};
				if(e.aMenuAnchorRef){
					var anchor=this.getElement(e.aMenuAnchorRef);
					if(anchor&&anchor.focus){anchor.focus();}
				}	
			}
			e.style.display='none';
			e.style.visibility='hidden';
		}
		return false;
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.setCtlVisible =
	function(aId)
	{
		var e=this.getElementNs(aId);
		if(e){e.style.visibility='visible';}
		return false;
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.setCtlInvisible =
	function(aId)
	{
		var e=this.getElementNs(aId);
		if(e){e.style.visibility='hidden';}
		return false;
	};
		
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.swapInlineCtl=
	function(aId,bId,textId)
	{
		var e=this.getElementNs(aId);
		var e2=this.getElementNs(bId);
		if(e&&e2){
			e.style.display='none';
			e.style.visibility='hidden';
			e2.style.display='inline';
			e2.style.visibility='visible';
			if(textId) {
				var e3=this.getElementNs(textId);
				if(e3){if(e3.select){e3.select();}if(e3.focus){e3.focus();}}
			}
		}
		return false;
	};
			
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.sexyShowCtl =
	function(aId,focusable)
	{
		var e=this.getElementNs(aId+"_container");
		var e2=this.getElementNs(aId);
		if(e&&e2) {
			if(e.isFull){return false;}
			var completion=this.curryFunc(this,function(slider){
				if(focusable){
					var f=this.getElementNs(focusable);
					if(f&&f.focus){f.focus();}
				}			
			});
			new com_ibm_wps_portlets_FeedspaceSlider(this,e,e2,35,6,true,completion).animate();			
		}		
		return false;
	};
		
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.sexyHideCtl =
	function(aId,focusable)
	{
		var e=this.getElementNs(aId+"_container");
		var e2=this.getElementNs(aId);
		if(e&&e2) {
			if(!e.isFull){return false;}
			var completion=this.curryFunc(this,function(slider){
				if(focusable){
					var f=this.getElementNs(focusable);
					if(f&&f.focus){f.focus();}
				}			
			});			
			new com_ibm_wps_portlets_FeedspaceSlider(this,e,e2,35,6,false,completion).animate();
		}
		return false;
	};
		
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.clickFormCtl =
	function(aId)
	{		
		var e=this.getElementNs(aId);
		if(e&&e.click){e.click();}
		return false;
	};
			
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.showMenuCtl =
	function(anchorId,menuId)
	{
		var anchor=this.getElementNs(anchorId);
		if(anchor) {
			return this.showCtl(menuId,true,anchor);
		}else{
			return this.showCtl(menuId,true,null);
		}
	};
		
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.hideMenuCtl =
	function(menuId)
	{
		return this.hideCtl(menuId,true);
	};
		
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.menuItemClicked =
	function(e,menuId)
	{
		var ev=this.getEvent(e);
		if(ev){this.stopEventPropagation(ev);}
		return this.hideCtl(menuId,true);
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.selectTab =
	function(tabGroupId,aId,focusable)
	{
		var currTab=this.getElementNs(this.selectedTab[tabGroupId]+'_tab');
		var newTab=this.getElementNs(aId+'_tab');
		if(currTab&&newTab) {
			currTab.className='synd-tab-'+tabGroupId+'-unselected';
			this.hideCtl(this.selectedTab[tabGroupId]+'_page');
			newTab.className='synd-tab-'+tabGroupId+'-selected';
			this.showCtl(aId+'_page');
			this.selectedTab[tabGroupId]=aId;
			if(focusable){
				var e=this.getElementNs(focusable);
			}else{
				var e=this.getElementNs(aId+'_page_firstfocus')
				if(e){
					if(e.htmlFor){
						var f=this.getElement(e.htmlFor);
						if(f&&f.focus){f.focus();}
					}else{
						if(e.focus){e.focus();}
					}
				}
			}
		}	
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.initSelectedTab =
	function(tabGroupId,aId)
	{	
		this.selectedTab[tabGroupId]=aId;
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.toggleExpansion =
	function(aId,focusable)
	{
		var e=this.getElementNs(aId);
		if(e) {
			if(e.isCollapsed===undefined){
				e.isCollapsed=(this.getComputedStyle(e).display.toLowerCase()=='none');
			}
			var aImg=this.getElementNs(aId+'_drill');
			var src2=(e.isCollapsed?this.collapseImage.src:this.expandImage.src);
			if(aImg){aImg.src=src2;var alt2=aImg.getAttribute('alt2');if(alt2){aImg.alt2=aImg.alt;aImg.alt=aImg.title=alt2;}}
			var aButton=this.getElementNs(aId+"_button");
			if(aButton){var title2=aButton.getAttribute('title2');if(title2){aButton.title2=aButton.title;aButton.title=title2;}}			
			if(!e.isCollapsed){
				e.style.display='none';
				e.style.visibility='hidden';
				e.isCollapsed=true;
			}else{
				e.style.display='block';
				e.style.visibility='visible';
				e.isCollapsed=false;	
				if(focusable){
					var f=this.getElementNs(focusable);
					if(f&&f.focus){f.focus();}
				}					
			}			
		}
	};
			
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.toggleCtlGroup =
	function(parentCtl,switchCtl)
	{
		var e=this.getElementNs(switchCtl);
		var e2=this.getElementNs(parentCtl);
		if(e&&e2){
			var enabled=e.checked;
			var inputs=['input','select','textarea','button'];
			for(var uu=0;uu<inputs.length;uu++) {
				var elements=e2.getElementsByTagName(inputs[uu]);
				if(elements&&elements.length>0){
					for(var vv=0;vv<elements.length;vv++){
						var ele=elements[vv];
						if('locked'==ele.getAttribute('lock')){
							ele.disabled=true;
						}else{
							ele.disabled=!enabled;
						}
					}		
				}
			}	
			var labels=e2.getElementsByTagName('label');
			if(labels&&labels.length>0){
				for(var vv=0;vv<labels.length;vv++){
					var label=labels[vv];
					var ee=this.getElement(label.htmlFor);
					if(ee&&'locked'==ee.getAttribute('lock')){
						label.className='synd-input-disabled';
					}else{
						label.className=(enabled?'':'synd-input-disabled');
					}
				}
			}
		}
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.showLightBoxCtl =
	function(lbox,ctl,focusable)
	{
		var e=this.getElementNs(lbox);
		var e2=this.getElementNs(ctl);
		if(e&&e2) {
			this.showCtl(lbox);
			this.showCtl(ctl);
			if(focusable){
				var f=this.getElementNs(focusable);
				if(f&&f.focus){f.focus();}
			}
		}
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.hideLightBoxCtl =
	function(lbox,ctl)
	{
		var e=this.getElementNs(lbox);
		var e2=this.getElementNs(ctl);
		if(e&&e2) {
			this.hideCtl(lbox);
			this.hideCtl(ctl);
		}
	};
					
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.toggleTreeNodeExpansion =
	function(aId)
	{
		var catId=aId+'_cat';
		var e=this.getElementNs(catId);
		if(e) {			
			if(e.isCollapsed===undefined){
				e.isCollapsed=(this.getComputedStyle(e).display.toLowerCase()=='none');
			}		
			var aImg=this.getElementNs(aId+'_drill');
			var src2=(e.isCollapsed?this.collapseNodeImage.src:this.expandNodeImage.src);
			if(aImg){aImg.src=src2;var alt2=aImg.getAttribute('alt2');if(alt2){aImg.alt2=aImg.alt;aImg.alt=aImg.title=alt2;}}
			var aIcon=this.getElementNs(aId+"_icon");
			src2=(e.isCollapsed?this.expandedNodeImage.src:this.collapsedNodeImage.src);
			if(aIcon){aIcon.src=src2;var alt2=aIcon.getAttribute('alt2');if(alt2){aIcon.alt2=aIcon.alt;aIcon.alt=aIcon.title=alt2;}}
			var aButton=this.getElementNs(aId+"_button");
			if(aButton){var title2=aButton.getAttribute('title2');if(title2){aButton.title2=aButton.title;aButton.title=title2;}}			
			if(e.isCollapsed){
				var parent=e.parentNode;
				if(parent){
					var trs=parent.getElementsByTagName('tr');
					var currCollapsedParentId=null;
					if(trs&&trs.length){
						var ii;
						for(ii=0;ii<trs.length;ii++){
							var e2=trs[ii];
							var id=this.stripNamespace(e2.id);
							if(id!=catId&&this.strStartsWith(id,aId)){
								var isCat=this.strEndsWith(id,"_cat");
								if(!currCollapsedParentId||!(currCollapsedParentId&&this.strStartsWith(id,currCollapsedParentId))){
									currCollapsedParentId=null;
									if(isCat){
										this.showCtl(id);
										if(e2.isCollapsed!==undefined&&e2.isCollapsed){
											var catId2=id.substring(0,id.length-4);
											currCollapsedParentId=catId2;
										}
									}
									else{
										this.showCtl(id);
									}
								}
							}
						}
					}
				}
				e.isCollapsed=false;
			}else{				
				var parent=e.parentNode;
				if(parent){
					var trs=parent.getElementsByTagName('tr');
					if(trs&&trs.length){
						var ii;
						for(ii=0;ii<trs.length;ii++){
							var e2=trs[ii];
							var id=this.stripNamespace(e2.id);
							if(id!=catId&&this.strStartsWith(id,aId)){
								var isCat=this.strEndsWith(id,"_cat");
								if(isCat){this.hideCtl(id);}
								else{this.hideCtl(id);}
							}
						}
					}
				}
				e.isCollapsed=true;
			}
		}
	return false;
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.getLightBoxOffset =
	function(e,lb)
	{
		if(e!=null && lb!=null) {
			//TODO There are 2 IDs that are synd_list, use the synd_list_lightbox to check for visibility
			if(lb.style.visibility&&lb.style.visibility.toLowerCase()=='hidden'){return {x:0,y:0};}	
			var xx=e.offsetLeft-e.scrollLeft;
			var yy=e.offsetTop-e.scrollTop;
			return {x:xx,y:yy};
			}
		else return {x:0,y:0};
	};
		
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.startDrag =
	function(ev,e,pathId,srcId,fn,xfn)
	{
		ev=this.getEvent(ev);
		var draggable=this.getElementNs(pathId+'_drag_title');
		var src=this.getElementNs(srcId);
		var lbox=this.getElementNs('synd_list');
		var lbox_lb=this.getElementNs('synd_lightbox');
		if(src!=null&&draggable&&this.dropTargets&&this.dropTargets.length>0){
			var pt=this.getScreenOrigin(e);
			draggable.dragData={src:src,left:pt.x,top:pt.y,originX:pt.x,originY:pt.y,currX:ev.clientX,currY:ev.clientY,currTarget:null};
			draggable.className='synd-draggable';
			draggable.style.display='block';
			draggable.style.visibility='visible';
			draggable.style.left=pt.x+'px';
			draggable.style.top=pt.y+'px';
			draggable.ctx=this;
			document.draggable=draggable;
			document.onmouseup=
				function(evt){
					evt=this.draggable.ctx.getEvent(evt);
					this.draggable.style.display='none';
					if(this.draggable.dragData.currTarget!=null){
						this.draggable.dragData.currTarget.className=this.draggable.dragData.currTarget.dndSavedClassname;
						if(this.draggable.dragData.currTarget!=this.draggable.dragData.src&&(!xfn||xfn.apply(this.draggable.ctx,[this.draggable.dragData.src,this.draggable.dragData.currTarget]))){
							if(fn){fn.apply(this.draggable.ctx,[this.draggable.dragData.src,this.draggable.dragData.currTarget]);}
						}
					}
					document.draggable=null;
					document.onmousemove=null;
					document.onmouseup=null;
				};
			document.onmousemove=
				function(evt){
					evt=this.draggable.ctx.getEvent(evt);
					var dx=evt.clientX-this.draggable.dragData.currX;
					var dy=evt.clientY-this.draggable.dragData.currY;
					var off=com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.getDsocOrigin();
					var lboff=com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.getLightBoxOffset(lbox,lbox_lb);
					var moved=false;
					off.y-=lboff.y;
					off.x-=lboff.x;
					if(Math.abs(dx)>2){moved=true;this.draggable.dragData.currX=evt.clientX;this.draggable.dragData.left+=dx;this.draggable.style.left=this.draggable.dragData.left+'px';}
					if(Math.abs(dy)>2){moved=true;this.draggable.dragData.currY=evt.clientY;this.draggable.dragData.top+=dy;this.draggable.style.top=this.draggable.dragData.top+'px';}
					
					if(moved){
						var isOver=false;
						for(var ii=0;ii<this.draggable.ctx.dropTargets.length;ii++){
							var target=this.draggable.ctx.dropTargets[ii];
							var r2=this.draggable.ctx.getBounds(target);
							if(this.draggable.ctx.ptIntersectsRect(evt.clientX+off.x,evt.clientY+off.y,r2)){
								isOver=true;
								var xallowed=(!xfn||xfn.apply(this.draggable.ctx,[this.draggable.dragData.src,target]));
								if(this.draggable.dragData.currTarget!=target){
									if(this.draggable.dragData.currTarget!=null){this.draggable.dragData.currTarget.className=this.draggable.dragData.currTarget.dndSavedClassname;}
									if(xallowed){
										target.dndSavedClassname=target.className;
										target.className='synd-drag-over';
										this.draggable.dragData.currTarget=target;
									}else{
										this.draggable.dragData.currTarget=null;
									}
								}
								break;
							}
						}
						if(!isOver){
							if(this.draggable.dragData.currTarget!=null){this.draggable.dragData.currTarget.className=this.draggable.dragData.currTarget.dndSavedClassname;}
							this.draggable.dragData.currTarget=null;
						}
					}
				};
		}
		return false;
	};
	
/* ***********************************************************
 * Subscription List Event Handlers
 * *********************************************************** */
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.listUpdateButtons =
	function()
	{
		var e=this.getElementNs('synd_list_edit_btn');
		var eImg=this.getElementNs('synd_list_edit_btn_img');
		if(this.configSelectionCount>0){
			if(e){
				e.disabled=false;	
				e.className='synd-list-action-button';
				if(eImg){eImg.src=this.arrowImage.src;}
			}
		}else{
			if(e){
				e.disabled=true;
				e.className='synd-list-action-button synd-list-action-button-disabled';
				if(eImg){eImg.src=this.arrowDisabledImage.src;}
			}
		}		
	};
		
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.handleListSelectionChanged =
	function(input)
	{
		var parent=this.getAncestorByName(input,'tr');
		if(input.checked){
			if(parent){parent.className='synd-list-row-selected';}
			this.configSelectionCount++;
		}else{
			if(parent){parent.className='synd-list-row-unselected';}
			this.configSelectionCount--;
		}
		this.listUpdateButtons();
	this.isSelectionDirty=true;
	};

com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.handleMultifeedListSelectionChanged =
	function(input,path,itemID,stEnable,stDisable)
	{
		var e=this.getElementNs(itemID);
		var parent=this.getAncestorByName(input,'tr');
		if(e.value == ""){
			if(parent){parent.className='synd-list-row-selected';}
			input.innerHTML = stEnable;
			e.value=path;
			this.configSelectionCount++;
		}else{//Item is going from enabled to disabled
			if(parent){parent.className='synd-list-row-unselected';}
			input.innerHTML = stDisable;
			e.value="";
			this.configSelectionCount--;
		}
		this.listUpdateButtons();
	this.isSelectionDirty=true;
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.handleCatDelete =
	function(path)
	{		
	//NOTE: THIS METHOD IS NOT USED .. handleDelete does it all
		var e=this.getElementNs('synd_list_form');
		if(e){
			if(confirm('Are you sure you want to delete this category?  All items and categories contains by this category will also be deleted.  This action cannot be undone.')){
				e.synd_list_edit_catdelete.value=path;
				e.submit();
			}
		}
		return false;
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.handleEdit =
	function(act,path,path2)
	{		
		var e=this.getElementNs('synd_list_form');
		if(e){
			e.synd_list_edit_act.value=act;
			if(path){e.synd_list_edit_path.value=path;}
			if(path2){e.synd_list_edit_path2.value=path2;}
			e.submit();
		}
		return false;
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.handleRename =
	function(path)
	{		
		return this.handleEdit('synd_list_edit_rename',path);
	};
	 
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.handleDelete =
	function(path)
	{		
		return this.handleEdit('synd_list_edit_delete',path);
	};
		 
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.handleListCatSelectAll =
	function(aPathId)
	{
		var e=this.getElementNs('synd_list_form');
		if(e){
			var inputs=e.getElementsByTagName('input');
			if(inputs&&inputs.length>0){
				for(var uu=0;uu<inputs.length;uu++){
					var input=inputs[uu];
					if(input.type.toLowerCase()=='checkbox'&&input.id&&this.strStartsWith(input.id,(this.namespace+aPathId))&&!input.checked){input.checked=true;this.configSelectionCount++;}
				}
			}
			this.listUpdateButtons();
		}
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.handleListCatDeselectAll =
	function(aPathId)
	{
		var e=this.getElementNs('synd_list_form');
		if(e){
			var inputs=e.getElementsByTagName('input');
			if(inputs&&inputs.length>0){
				for(var uu=0;uu<inputs.length;uu++){
					var input=inputs[uu];
					if(input.type.toLowerCase()=='checkbox'&&input.id&&this.strStartsWith(input.id,(this.namespace+aPathId))&&input.checked){input.checked=false;this.configSelectionCount--;}
				}
			}
			this.listUpdateButtons();
		}
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.handleListItemDrop =
	function(src,target)
	{
		var srcid=this.stripSuffix(this.stripNamespace(src.id),'_');
		var targid=this.stripSuffix(this.stripNamespace(target.id),'_');
		var srcpath=srcid.replace(/_/gi,'/');
		var targpath=targid.replace(/_/gi,'/');
		this.handleEdit('synd_list_edit_move',srcpath,targpath);
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.checkListItemDrop =
	function(src,target)
	{
		var srciscat=this.strEndsWith(src.id,'_cat');
		if(!srciscat){return true;}
		else if(src==target){return true;}
		else{
			var srcid=this.stripSuffix(this.stripNamespace(src.id),'_');
			var targid=this.stripSuffix(this.stripNamespace(target.id),'_');
			return !this.strStartsWith(targid,srcid);
		}
	};
					 
/* ***********************************************************
 * Config Mode
 * *********************************************************** */
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.selectConfigPresentationStyle =
	function(aStyle)
	{
		if(aStyle!=this.selectedConfigPresentationStyle){
			var currImg=this.getElementNs('synd_prefs_pres_style_'+this.selectedConfigPresentationStyle);
			var newImg=this.getElementNs('synd_prefs_pres_style_'+aStyle);
			var form=this.getElementNs('synd_apprnc_form');
			if(currImg&&newImg&&form) {
				currImg.className='synd-pref-apprnc-imgopt-unselected';
				newImg.className='synd-pref-apprnc-imgopt-selected';
				this.selectedConfigPresentationStyle=aStyle;
				form.synd_prefs_pres_style.value=aStyle;
			}
		}	
	};

com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.handleAction =
function(act, value)
	{
		
		var e=this.getElementNs('synd_list_form');
		if(e){

				
			
			e.synd_list_action.value=act;

			if (value != null) {
				e.synd_list_action_value.value = value;
			}

			e.submit();
		}
		return false;
	};

com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.isSelDirty =
	function()
	{		
		return this.isSelectionDirty;
	};
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.handleCancel =
	function(url)
	{		
		var e=this.getElementNs('synd_list_form');
		if(e){
			e.action=url;
			e.submit();
		}
		return false;
	};

com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.handleAppearanceOverrideChanged =
	function(prefNs,parentCtl,switchCtl)
	{		
		this.toggleCtlGroup(parentCtl,switchCtl);
		var e=this.getElementNs(switchCtl);
		if(e&&e.checked){this.initWindowTitleEnablement(prefNs);}
	};
	
com_ibm_wps_portlets_FeedspaceScriptingContext.prototype.initWindowTitleEnablement=
	function(prefNs){
		var winId=this.namespace.replace(/^PC_(.*)_$/i,'$1');
		if(winId){
			winId='title.'+winId;
			var e=this.getElement(winId);
			var disabled=(!e);
			var select=this.getElementNs(prefNs+'synd_prefs_window_title_typ');
			var label=this.getElementNs(prefNs+'synd_prefs_window_title_typ_label');
			if(select&&label&&'locked'!=select.getAttribute('lock')){
				select.disabled=disabled;
				label.className=(disabled?'synd-input-disabled':'');
			}
		}
	};

