initPortletScripts = function(){

	//to mainContentLoaded event of WcmPortalFramework for after DOM updates
	//console.debug("..initing mainContentLoaded event");
	dojo.connect(geminisystems.handler, "mainContentLoaded", function(container) {
		
		
		
		var geminiTabs 	 = $$('.geminiTab');
		var geminiTabPanes = $$('.geminiTabPane');

		var handleTabClick = function(event) {
			var currentTab = event.element();
			if (currentTab == null) return false;
			geminiTabPanes.invoke('hide');
			geminiTabs.invoke('removeClassName','geminiTabChecked');
			console.debug(currentTab);
			if (!currentTab.hasClassName('geminiTab'))  
				currentTab = currentTab.up('.geminiTab');
			currentTab.addClassName('geminiTabChecked');
			var tabIndex = geminiTabs.indexOf(currentTab);
			console.debug(tabIndex);
			if(tabIndex != -1){
				geminiTabPanes[tabIndex].show();
			}
			return false;
		};

		geminiTabs.each(function(tab) {
			tab.observe("click", handleTabClick);
		});
		
		
		console.debug("..handling mainContentLoaded event");
		
		// 
		// For Government Serivices ZOOM effect. It's almost like Fisheye.
		// 
		var situationsGroup = $(container).select('div.situationsGroupZoomWrapper');
		var situationsGroupImgs = $(container).select('div.situationsGroupZoomWrapper img');
		console.debug("situationsGroup.size: " + situationsGroup.size());
		console.debug("situationsGroupImgs.size: " + situationsGroupImgs.size());
		
		var currentSituationGroupImg = null;
		
		situationsGroupImgs.each(function(img){
			img.lastScale = 1;
		});
		
		handleMouseMove = function(e){
			clearTimeout(timerObj.resetTimer);
			var p = { x : Event.pointerX(e), y : Event.pointerY(e) };
			situationsGroupImgs.each(function(groupImg) {
					handleFishEye(groupImg, p);
				});
		}
		
		var timerObj =  Class.create();
		
		handleMouseOut = function(e){
			timerObj.resetTimer = setTimeout(resetElements, 1000);
		}
		handleMouseOver = function(e){
			clearTimeout(timerObj.resetTimer);
		}
		
		resetElements = function(){
			situationsGroupImgs.each(function(groupImg) {
				resetElement(groupImg);
			});
		}
		
		getCenterAxis = function(ele){
			var p =  Position.cumulativeOffset(ele);
			var res = { 
				x : Math.floor(p.left + 150 + (((36/2)) * ele.lastScale)),
				y : Math.floor(p.top + 20 + (((36/2)) * ele.lastScale))
			};
			return res;
		};
		
		resetElement = function(ele){
			ele.setStyle({ zIndex : 1, height : "36px", width : "36px" });
		};
		
		scaleElement = function(ele,scale){				
			/*marginBottom : this.originalMarginBottom - ((scale * this.originalHeight) - this.originalHeight) + "px",  */		
			ele.setStyle({ zIndex : scale * 100, height : (scale * 12) + 36 + "px", width : (scale * 12) + 36 + "px"});
		}
		
		var rangeProximity = 80;
		var greenZoneProximity = 90; // should be less than rangeProximity, 0 to cancel.
		handleFishEye = function(ele,p){
			var offset = getCenterAxis(ele);
			var distance = Math.sqrt( Math.pow((p.x - offset.x), 2) + Math.pow(p.y - offset.y, 2)) - greenZoneProximity;
			if(distance > rangeProximity){
				resetElement(ele);
				//return true;
			} else {
				if(distance < 0){
					distance = 0;
				}
				
				var scale = Math.abs(rangeProximity - distance) / rangeProximity;
				ele.lastScale = scale;
				scaleElement(ele,scale);
			}
		}

		//Event.observe(this.container, "mouseout", this.mouseOutHandle);
		//Event.observe(this.container, "mouseover", this.cancelTimerHandle);
		
		var contentPanes = $$('.geminiContentPane');
		//Event.observe(contentPanes.first(), "mousemove", handleMouseMove);
		//Event.observe(contentPanes.first(), "mouseover", handleMouseOver);
		//Event.observe(contentPanes.first(), "mouseout", handleMouseOut);
		contentPanes.each(function(pane){
			Event.observe(pane, "mousemove", handleMouseMove);
			//Event.observe(pane, "mouseover", handleMouseOver);
			//Event.observe(pane, "mouseout", handleMouseOut);
		});
	});

}
