﻿// global variables

var sPreviousHeaderContent = '';

window.onload = function(){
	/*hideSubpages();
	hideSubnav();
	hideSubpageBodies();*/
	addOnClickEventToSubpageTitle();
	//clickTeamProfile();
}
ajaxLoadGallery = function(gallery_id)
{
	loadXMLDoc('/inc/gallery.ajax.asp?gallery_id=' + gallery_id, 'positionGallery');
	//makes window jump back to top.
	window.scrollTo(0,0); 
	return false;
}

positionGallery= function(xmlobj)
{
	sPreviousHeaderContent = $('header').innerHTML;
	$('header').innerHTML = xmlobj.responseText;
	$('gallery-container').style.display= 'none';
	Effect.Appear($('gallery-container'), {duration:1.0});
}

function revertHeader()
{
	if (sPreviousHeaderContent != '')
	{
		$('header').innerHTML = sPreviousHeaderContent;
		sPreviousHeaderContent = '';
	}
	
}

positionGalleryList= function(xmlobj)
{
	$('body').innerHTML = xmlobj.responseText;
	$('gallery-list-container').style.display= 'none';
	Effect.Appear($('gallery-list-container'), {duration:1.0});
}
ajaxLoadGalleryList = function(site_id)
{
	loadXMLDoc('/inc/gallerylist.ajax.asp?site_id=' + site_id, 'positionGalleryList');	
}
		

hideSubpages = function(){
	var subpagesNode = $('subpages');
	if( subpagesNode){
		if( jh.string.trim(subpagesNode.innerHTML) == '' ){
			subpagesNode.style.display = 'none';
		}
	}
}
hideSubnav = function(){
	var subnavNode = $('subnav');
	if( subnavNode){
		if( jh.string.trim(subnavNode.innerHTML) == '' ){
			subnavNode.style.visibility = 'hidden';
		}
	}
}
hideSubpageBodies = function()
{
	counter = 1
	var subpage_body = $('subpage_body_'+ counter);
	while(subpage_body){
		if(subpage_body.className=='body'){
			subpage_body.style.display = 'none';
		}
		subpage_body = $('subpage_body_'+ ++counter);
		
	}
	
}
addOnClickEventToSubpageTitle = function(){
	var counter = 1
	var subpage_title = $('subpage_title_' +counter);
	while(subpage_title)
	{
		subpage_title.counter = counter;
		subpage_title.onclick = subpageTitleOnClick;
		subpage_title = $('subpage_title_' + ++counter);
	}
}

subpageTitleOnClick = function(){
	revertHeader();
	var counter2 = 1
	var subpage_body = $('subpage_body_'+ counter2);
	while( subpage_body )
	{
		if( counter2 == this.counter && subpage_body.style.display == 'none')
		{
			//Effect.SlideDown(subpage_body, {duration:1.0});
			Effect.Appear(subpage_body, {duration:3.0});
		}else{
			if(counter2 == this.counter){
				Effect.Fade(subpage_body, {duration:2.0});							
			}else{
				subpage_body.style.display = 'none';	
				subpage_title = $('subpage_title_' + counter2);
				subpage_title.className = 'subpage_off';
			}
		}
		subpage_body = $('subpage_body_'+ ++counter2);
	}
	this.className = this.className =='subpage_on' ?  'subpage_off':'subpage_on';		
}

showArchiveOnClick = function() {
	var showArchiveLink = document.getElementById('showArchiveLink');
	var newsArchiveBlock = document.getElementById('newsArchiveBlock');
	
	if (showArchiveLink.innerHTML == 'Show archive list')
	{
		Effect.Appear(newsArchiveBlock, {duration:1.0});
		showArchiveLink.innerHTML = 'Hide archive list';
	} else {
		Effect.Fade(newsArchiveBlock, {duration:1.0});
		showArchiveLink.innerHTML = 'Show archive list';
	}
	
	return false;
}


clickTeamProfile = function() {
	//var subpageids = document.getElementById('subpageids').innerHtml;
	//var subpages = subpageids.split(",");
	
	
	var counter = 1
	var subpage_title = $('teamlist_' +counter);
	while(subpage_title)
	{
		subpage_title.counter = counter;
		subpage_title.onclick = showTeamProfile(counter);
		subpage_title = $('teamlist_' + ++counter);
	}
	
}

//add to add event to whole page and time it because if
//the user moves the mouse too quickly the onmouse events can't keep up
//and you get more than one box appearing.
hideAllTeamProfile = function() {
	var tl = $('teamlist');
	
	if (tl!=null)
	{
		var counter = 1
		var teamdetail = $('teamdetail_' +counter);
		var teamlist = $('teamlist_' + counter);
		
		while(teamdetail)
		{
			if (counter != currentelement)
			{
				teamdetail.style.display = 'none';
				
				teamlist.className = "noclass";
			}	
			
			teamdetail = $('teamdetail_' + ++counter);
			teamlist = $('teamlist_' + counter);
			
		}
	}  
}

document.onmouseout = function() {
	setTimeout("hideAllTeamProfile()",200);
}


hideTeamProfile = function(counter) {
	
	var teamdetailid = $('teamdetail_' + counter);
	
	teamdetailid.style.display = 'none';
	
	var teamlist = $('teamlist_' + counter);
	teamlist.className = "noclass";
}

var currentelement = 0;

showTeamProfile = function(counter) {
	
	var teamdetail = document.getElementById('teamdetail_' + counter);
	var teamlist = document.getElementById('teamlist_' + counter);

	Effect.Appear(teamdetail, {duration:1.0});
	teamlist.className = "teamselected";
	
	currentelement = counter;	
}

forwardPopUp = function(s,p,su)
{
	window.open("/forwardpage.asp?section=" + s + "&page=" + p + "&subpage=" + su,"Sendfriend","height=200,width=300,resizeable=yes");
}

showPopUp = function (page, width, height)
{
	window.open( page, 'popup', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=yes,width=' + width + ',height='+ height);
}