
	function wo(elem) {
		if (elem.target) {
			window.open(elem.href,elem.target,'width=525,height=600,resizable=yes,scrollbars=yes');
			return false;
		} else {
			return true;
		}
	}


	
	var edittingEnabled = 0;

	function toggleEditting(elem) {
		if( !Prototype.Browser.IE || ( Prototype.Browser.IE && parseInt( navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) != 6 ) ) {
		
			if(edittingEnabled) {
	
				$$('.element_shade').each( function(elem) {
					elem.setStyle({display: 'none'});
				});
	
				edittingEnabled = 0;
				elem.innerHTML = 'Select (Disabled)';
	
			} else {
	
				$$('.element_shade').each( function(elem) { 
					elem.setStyle({display: 'block'});
					
					elem.observe('mouseover', function () {
						this.addClassName('hover');
					});
	
					elem.observe('mouseout', function () {
						this.removeClassName('hover');
					});
				});
	
				edittingEnabled = 1;
				elem.innerHTML = 'Select (Enabled)';
				setTimeout( slideSideBar, 200 );
	
			}

		} else {
			alert('Directly selecting an element to edit is not supported in IE 6. Please try a different browser to take advantage of this feature.');
		}
	}



	var isExtended = 0;
			
	function slideSideBar() {
		var btnImg = $$('#sideBarTab img')[0];

		new Effect.toggle('sideBarContents', 'blind', {scaleX: 'true', scaleY: 'true', scaleContent: false, duration: 0.3});

		if(!isExtended) {
			btnImg.src = btnImg.src.replace(/(\.[^.]+)$/, '-active$1');
			new Effect.Fade('sideBarContents', { from: 0.0, to: 0.9999, duration: 0.3});
			isExtended++;
		} else {
			btnImg.src = btnImg.src.replace(/-active(\.[^.]+)$/, '$1');
			new Effect.Fade('sideBarContents', { from: 0.9999, to: 0.0, duration: 0.3 });
			isExtended = 0;
		}
	}

	Event.observe(window, 'load', function (e) {
		if ($('sideBarTab'))
			Event.observe('sideBarTab', 'click', slideSideBar, true);


		if( !Prototype.Browser.IE || ( Prototype.Browser.IE && parseInt( navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) != 6 ) ) {
			if(!$('cms-inline')) {
				$(document.body).insert({ bottom: '<div id="cms-inline" class="loading" style="display: none;"><div id="cms-inline-container" style="display: none;"><span id="cms-inline-close"></span><iframe src="about:blank" style="background-color: #fff; border: none;"></iframe></div></div>' });
	
				Event.observe('cms-inline-close', 'click', hideAdmin );
				Event.observe(window, 'resize', resizeAdmin );
	
			}
		}
		
	});
	


	
	
	function loadAdmin( url ) {

		if( !Prototype.Browser.IE || ( Prototype.Browser.IE && parseInt( navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) != 6 ) ) {
	
			var container = $('cms-inline');
			
			if (container) {
				var frame = container.down('iframe');
				
				
				resizeAdmin();

				if( Prototype.Browser.IE ) {
					container.show();
					showAdmin();
				}

				else {
					container.appear({duration: 0.3, from: 0, to: 0.8});
					frame.onload = showAdmin;
				}

				frame.src = url + '&r=direct';
	
				return false;

			}
		}
		
		return true;
	}
	
	function showAdmin() {
		$('cms-inline-container').show();
		$('cms-inline').removeClassName('loading');
		$('cms-inline').setOpacity(1);
	}
	
	function hideAdmin() {
		$('cms-inline').hide();
		$('cms-inline-container').hide();
		$('cms-inline').addClassName('loading');
	}
	
	function resizeAdmin() {
		$('cms-inline').setStyle({width: document.viewport.getWidth()-160+'px', height: document.viewport.getHeight()-40+'px' });
		$('cms-inline-container').setStyle({width: document.viewport.getWidth()-180+'px', height: document.viewport.getHeight()-60+'px' });
	}
	
	
	
	
	
	function onBlurFunction (e) {
		e.UpdateLinkedField();
	}

	function FCKeditor_OnComplete( editorInstance ) {
	    editorInstance.Events.AttachEvent( 'OnBlur', onBlurFunction ) ;
	    editorInstance.Events.AttachEvent( 'OnSelectionChange', onBlurFunction ) ;
	}
	
	
	
