var _heroPath = '';
var _randomHeroLeft = 0;
var _randomHeroRight = 0;
var _openWindow = null;

function populateHeroImages(leftSide,rightSide){
	var _imageBase;
	var _imageCount = 0;
	var heroLeft = document.getElementById(leftSide);
	var heroRight = document.getElementById(rightSide);
	var _pathName = window.location.pathname;
	var _pageName = _pathName.substring(_pathName.lastIndexOf('/') + 1);
	_pageName = _pageName.substring(0, _pageName.lastIndexOf('.aspx')).toLowerCase();

	switch(_pageName){
		case 'about':
		case 'privacy':
		case 'resources':
		case 'volunteer':
			_imageCount = 6;
			break;
		case 'progbhs':
		case 'faqbhs':
		case 'dirbhs':
		case 'linkbhs':
		case 'policybhs':
		case 'medbhs':
			_pageName = 'progbhs';
			_imageCount = 5;
			break;
		case 'cultural':
		case 'donate':
		case 'employment':
		case 'progadmin':
		case 'spanish':
		case 'trustees':
			_imageCount = 5;
			break;
		case 'history':
		case 'progship':
		case 'progrp':
			_imageCount = 4;
			break;
		case 'progccc':
		case 'dirccc':
		case 'faqccc':
		case 'policyccc':
		case 'linkccc':
		    _pageName = 'progccc';
			_imageCount = 4;
			break;
		case 'progfps':
		case 'dirfps':
		case 'faqfps':
		case 'linkfps':
		case 'reqfps':
		    _pageName = 'progfps';
			_imageCount = 4;
			break;
		case 'progcdt':
		case 'dircdt':
		case 'policycdt':
		case 'faqcdt':
		case 'linkcdt':
		    _pageName = 'progcdt';
		    _imageCount = 14;
		    break;
		case 'progcds':
		case 'infocds':
		case 'dircds':
		case 'faqcds':
		case 'linkcds':
		case 'calendarcds':
		case 'summercds':
		    _pageName = 'progcds';
		    _imageCount = 14;
		    break;
		case 'progbhs':
		case 'faqbhs':
		case 'dirbhs':
		case 'linkbhs':
		case 'policybhs':
		case 'medbhs':
		    _pageName = 'progbhs';
		    _imageCount = 7;
		    break;
		case 'progsap':
		case 'dirsap':
		case 'medsap':
		case 'policysap':
		case 'faqsap':
		case 'linksap':
		    _pageName = 'progsap';
		    _imageCount = 7;
		    break;
		case 'news':
			_imageCount = 5;
			break;
		case 'proghiv':
		case 'dirhiv':
		case 'faqhiv':
		case 'linkhiv':
		    _pageName = 'proghiv';
			_imageCount = 3;
			break;
		default:
			_imageCount = 6;
			_pageName = 'home';
	}


	if (_imageCount == 0){
		_pageName = 'home';
		_imageCount = 6;
	}
	_heroPath = 'http://www.fgccorp.org/img/hero/' + _pageName + '/' + _pageName
	if (_imageCount > 1){
		for (var i=1;i<=_imageCount;i++){
			_imageBase = new Image();
			_imageBase.src = _heroPath + i + '.jpg';
			_imageBase.height = 185;
			_imageBase.width = 295;
			heroLeft.appendChild(_imageBase);
			
			_imageBase = new Image();
			_imageBase.src = _heroPath + i + '.jpg';
			_imageBase.height = 185;
			_imageBase.width = 295;
			heroRight.appendChild(_imageBase);
		}
		_randomHeroLeft=Math.floor(Math.random()*(_imageCount)) + 1;
		do{
			_randomHeroRight=Math.floor(Math.random()*(_imageCount)) + 1;
		}while (_randomHeroLeft == _randomHeroRight)
	}
}
function openWindow(myLink,windowName,windowParms)
{
	var _newWindow = null;
	if(window.focus){
		if (openWindow.arguments.length<3){windowParms='myParameters=yes/no,width=400,height=200,dependent=yes,scrollbars=yes,status=yes,resizable=yes';}
		if (window.name.length<1){ window.name='fgcPopup'; }
		if (windowName == '_blank'){
			if (_openWindow == null){
				_newWindow = window.open(myLink,windowName,windowParms);
				_openWindow = _newWindow;
				_newWindow.focus();
			}else{ 
				if (_openWindow.closed){
					_newWindow = window.open(myLink,windowName,windowParms);
					_openWindow = _newWindow
				}else{
					_newWindow = _openWindow
					_newWindow.location.href=myLink;
					_newWindow.focus();
				}
			}
		}else{
			_newWindow = window.open('',windowName,windowParms);
			_newWindow.focus();
			myLink.target=windowName;
		}
	}
	return false;
}
