﻿var imgAjax = new Image;
imgAjax.src = "/images/Misc/loading_reloaded1.gif";

section_on = new Image;
section_off = new Image;
section_on.src = "/images/Misc/expand_hover.gif";
section_off.src = "/images/Misc/collapse.gif";
	
title_on = new Image;
title_off = new Image;
title_on.src = "/images/Misc/plus.gif";
title_off.src = "/images/Misc/minus.gif";

function wiggle( sDiv, sImg )
{	
	Effect.toggle(sDiv, 'blind',
		{
			duration: 0.5
		}
	);
		
	if ( $(sImg).className == "section" )
		$(sImg).src = ( $(sImg).src == title_off.src ) ? title_on.src : title_off.src;
		
	if ( $(sImg).className == "title" )			
		$(sImg).src = ( $(sImg).src == section_off.src ) ? section_on.src : section_off.src;	
}

function showContent(sDiv, iID, sType, iPID)
{
	$(sDiv).update( "<img src='" + imgAjax.src + "' title='loading...please wait'><strong>Loading....</strong>" );
	
	//generate random string for IE caching issues
	var sRan = "&ran=" + Math.random();
	
	switch (sType) 
	{
		case "Mem":			
			var ajax = new Ajax.Request('/Site_content/GetFondMemContent.php?id=' + iID + "&pid=" + iPID + sRan,
				{
					method: 'get',
					onSuccess: dlOutputContent,
					onFailure: dlOutputContentError
				}
			);
			
			break;
		case "Ann":		
			var ajax = new Ajax.Request('/Site_content/GetAnnouncementContent.asp?id=' + iID + sRan,
				{
					method: 'get',
					onSuccess: dlOutputContent,
					onFailure: dlOutputContentError
				}
			);			
			break
	}
	
	function dlOutputContent(transport)
	{
		$(sDiv).hide();		
		$(sDiv).update( transport.responseText );
		
		Effect.toggle(sDiv, 'appear',
			{
				duration: 1.4
			}
		);
	}
	
	function dlOutputContentError(transport)
	{
		$(sDiv).update();
	}	
}

function downloadPage( sSection, coDiv22 )
{
	//generate random string for IE caching issues
	var sRan = "&ran=" + Math.random();	
	
	$(coDiv22).innerHTML = "<img src='" + imgAjax.src + "' title='loading...please wait'><strong>Loading....</strong>";
	
	var ajax = new Ajax.Request('/Site_Content/' + sSection + sRan,
		{
			method: 'get',
			onSuccess: dlOutputResult,
			onFailure: dlOutputError
		}
	);
	
	function dlOutputResult(transport)
	{
		$(coDiv22).hide();		
		$(coDiv22).update( transport.responseText );
		
		Effect.toggle(coDiv22, 'appear',
			{
				duration: 1.4
			}
		);
	}
	
	function dlOutputError(transport)
	{
		$(coDiv22).innerHTML = 'Please alert the webmaster.';
	}
}

function loadPage()
{
	if ( typeof document.getElementById(aCon[0]) != 'undefined')
	{
		if ( aLinks.length != 0 )
		{
			downloadPage( aLinks.shift(), aCon.shift() );
			setTimeout( loadPage, 800 );
			return;
		}
	}
	
	if( aCon.length != 0 )
	{
		setTimeout( loadPage, 800 );
	}
	else
	{
		if (typeof cowhatsNew != 'undefined')
		{
			Effect.toggle('AlumniPics', 'appear',
				{
					duration: 1.4
				}
			);
		}
	}
}
