// <![CDATA[
			
	/*
	*	CWF
	*	@author: alex.smoljanovic@thewebshop.ca
	*/
	
	
	function ct_clickednode( catid, changeall )
	{
			
		var el,
			paramex = 'refresh=true';
			
		if( changeall/* not a child node */ )
		{
			el = 'cattree';		
			paramex = 'refresh=true';
		}
		else
		{
			el ='cat-tree-active-cat';
			paramex = 'refresh=false';
		}
		
		var elCat = null,
			elStatus = null;
		
		try
		{
			elCat = findObj('inner-navigation-container'); //cat-tree-active-cat
			elStatus = findObj('cat-tree-status');
		}	catch(e){  }
		
		
		
		new Ajax.Updater(
			el, 
			cat_tree_uri+"treerpc.php?txtCatID="+ catid + "&" + paramex,
			{
				onLoading:function(request){
					try{	elCat.className = 'cat-tree-waiter';			}catch(e){  }
					try{	elStatus.className = 'cat-tree-status-visible';	}catch(e){  }
				},
				onComplete:function(request){
					try{	elCat.className = '';							}catch(e){}
					try{	elStatus.className = 'cat-tree-status-hidden';	}catch(e){}
					try
					{
						//if( changeall )
						//	blk_el( findObj('cat-tree-selected'), 700, new Array('cat-tree-opened', 'cat-tree-opened-blink') );
							// blink the newly opend cat.. (sub root)

						
						var json = request.responseText.replace(/.*<\!--\[json(.*)\]-->.*/i, "$1");
						if( json == request.responseText )
							json = '';
						//var wndo = new dw_scrollObj('navigationcontainersub', 'cattree'/*, 'imgTbl'*/);
						//wndo.setUpScrollbar("dragbar1", "track1", "v", 1, 1);
						if( !nocatscroll )
							init_scndry();
						eval( json );
						
						//dw_scrollObj.scrollTo('navigationcontainersub', 0, cnt , 1);
							
					}catch(e)
					{
						//alert( e.toString() );
					}
				},
				onError:function(v){
					//well, we had a boo boo... so lets just reload the page with out changing content and sync the nav :) 
					window.location = "?txtCatID="+ catid;
				},
				parameters:
					"txtCatID="+ catid + "&" + paramex,
					insertion:Element.update , 
					asynchronous:true
			}
	
		);
		
		return false; /* block <a>nchors raiseEvent behavior since we don't want to reload the page anymore ... */

	}
	
	function ct_clickedbrowsenode( ruri, changeall )
	{
			
		var el,
			paramex = 'refresh=true';
			
		if( changeall/* not a child node */ )
		{
			el = 'cattree';		
			paramex = 'refresh=true';
		}
		else
		{
			el ='cat-tree-active-cat';
			paramex = 'refresh=false';
		}
		
		var elCat = null,
			elStatus = null;
		
		try
		{
			elCat = findObj('inner-navigation-container');
			elStatus = findObj('cat-tree-status');
		}	catch(e){}
		
		
		try
		{
			brandsactive = ruri.replace(/.*pbmode=([^&]+).*/gi, "$1") == "brands";

			findObj('pbmode-brands').className = brandsactive ? 'active' : '';
			findObj('pbmode-types').className = !brandsactive ? 'active' : '';

		}
		catch(e){}
		
		
		new Ajax.Updater(
			el, 
			cat_tree_uri+"treerpc.php?"+ ruri + "&" + paramex,
			{
				onLoading:function(request){
					try{	elCat.className = 'cat-tree-waiter';			}catch(e){}
					try{	elStatus.className = 'cat-tree-status-visible';	}catch(e){}
				},
				onComplete:function(request){
					try{	elCat.className = '';							}catch(e){}
					try{	elStatus.className = 'cat-tree-status-hidden';	}catch(e){}
					try
					{
						//if( changeall )
						//	blk_el( findObj('cat-tree-selected'), 700, new Array('cat-tree-opened', 'cat-tree-opened-blink') );
							// blink the newly opend cat.. (sub root)
						
						
						//var wndo = new dw_scrollObj('navigationcontainersub', 'cattree'/*, 'imgTbl'*/);
						//wndo.setUpScrollbar("dragbar1", "track1", "v", 1, 1);
						
						
						var json = request.responseText.replace(/.*<\!--\[json(.*)\]-->.*/i, "$1");
						if( json == request.responseText )
							json = '';
					
						//var wndo = new dw_scrollObj('navigationcontainersub', 'cattree'/*, 'imgTbl'*/);
						//wndo.setUpScrollbar("dragbar1", "track1", "v", 1, 1);
						if( !nocatscroll )
							init_scndry();
						eval( json );
						
						//dw_scrollObj.scrollTo('navigationcontainersub', 0, cnt , 1);
							
					}catch(e)
					{
						//alert( e.toString() );
					}
				},
				onError:function(v){
					//well, we had a boo boo... so lets just reload the page with out changing content and sync the nav :) 
					window.location = ruri;
				},
				parameters:
					ruri + "&" + paramex,
					insertion:Element.update , 
					asynchronous:true
			}
	
		);
		
		return false; /* block <a>nchors raiseEvent behavior since we don't want to reload the page anymore ... */

	}
	
	
	var _blk_target,
		_blk_timeout,
		_blk_classes,
		_blk_flagz,
		_blk_flagbool,
		_blk_htimeout;
		
	function blk_el( target, timeout, /*[]*/classes )
	{
		_blk_target=target;
		_blk_timeout=timeout;
		_blk_classes=classes;
		
		_blk_flagz = 5; /* iteration counter */
		_blk_flagbool = false;
		
		if( _blk_htimeout )
			_blk_htimeout = clearTimeout( _blk_htimeout );	
			
		_blk_htimeout = setTimeout(	'blk_imp()', _blk_timeout );
		
	}
	
	
	function blk_imp()
	{
		_blk_flagbool = !_blk_flagbool;
		_blk_target.className = _blk_classes[ _blk_flagbool ? 1 : 0 ];
		
		if( _blk_flagz > 0 )
			_blk_htimeout = setTimeout(	'blk_imp()', _blk_timeout );
		
		_blk_flagz--;
	}
			
// ]]>