/* This variable is necessary to keep track of which div is being hidden to avoid animation glitch */
var currentlyHidingDiv = "";

pageInit = function() {
	/* Popup summary */
	/* We find all items with the articleTitle class */
	var els = YAHOO.util.Dom.getElementsByClassName('articleTitle', 'a');
	for( var i=0; i < els.length; i++ )
	{
		/* Get the hover div */
		sDivId = els[i].getAttribute('hoverId');
		sDiv = document.getElementById( sDivId ); 
		YAHOO.util.Dom.setStyle( sDiv , 'opacity', '0');
		
		/* Unhide the Summary layer when mouse over/ out*/
		YAHOO.util.Event.addListener( els[i], "mouseover", hoverOver ); 
		YAHOO.util.Event.addListener( els[i], "mouseout", hoverOut ); 
	}
}


/* This function is to unhide the div, then do a smooth very web2.0 fade-in effect */
function hoverOver()
{
	var sDivId = this.getAttribute('hoverId');
	var sDiv = document.getElementById( sDivId ); 
	onDivId = sDiv;
	
	if (sDivId == 'hover3') {
	sDiv.style.left  = YAHOO.util.Dom.getX( this ) + this.offsetHeight + -250  +'px';
	} else {
	sDiv.style.left  = YAHOO.util.Dom.getX( this ) +'px';
	}
	
	if (sDivId == 'hover1') {
	sDiv.style.top  = (YAHOO.util.Dom.getY( this ) + this.offsetHeight + -150 ) +'px';
	} else if (sDivId == 'hover2') {
	sDiv.style.top  = (YAHOO.util.Dom.getY( this ) + this.offsetHeight + -260 ) +'px';
	} else if (sDivId == 'hover3') {
	sDiv.style.top  = (YAHOO.util.Dom.getY( this ) + this.offsetHeight + -240 ) +'px';
	}
	sDiv.style.display = '';
	var animIn = new YAHOO.util.Anim( sDiv, { opacity: { to: 1 } }, 0.25, YAHOO.util.Easing.easeOut);
	animIn.animate();
}

/* This function is to hide the div with a dramatic web2.0 fade effect */
function hoverOut()
{
	var sDivId = this.getAttribute('hoverId');
	var sDiv = document.getElementById( sDivId ); 	
	currentlyHidingDiv = sDivId ;
	var animOut = new YAHOO.util.Anim( sDiv, { opacity: { to: 0 } }, 0.25, YAHOO.util.Easing.easeOut);
	animOut.animate();
	animOut.onComplete.subscribe( hoverHide );
}

/* Call back function used in hoverOut() */
function hoverHide()
{
	//alert( this.getEl().id );
	this.getEl().style.display = 'none';
}

YAHOO.util.Event.addListener( window, "load", pageInit ); 

if (document.images)
    {
      preload_image_object = new Image();
      // set image url
      image_url = new Array();
      image_url[0] = "images/games1.jpg";
      image_url[1] = "images/games2.jpg";
      image_url[2] = "images/games3.jpg";

       var i = 0;
       for(i=0; i<=3; i++) 
         preload_image_object.src = image_url[i];
    }

    //-->

