var ModalWindowDiv = "";

function showModal(urlParam,modalTitle,modalDiv,modalAttributes,modalWidth){

	ModalWindowDiv = modalDiv;
	browserDimensions = getBrowserSize();
	vbrowser = detectBrowser();

	imageWin = dhtmlmodal.open(modalTitle, 'div', modalDiv, '', modalAttributes);
 	
	imageWin.onclose=function(){
		if (vbrowser.name == "Apple Computer, Inc."){
			//this is to fix a bug in Safari where it wouldn't close the flash video player on close of the modal window
			imageWin.contentDoc.getElementById('showDetails').document.getElementById('flashcontent').innerHTML = '';
		}else{
			document.getElementById('ContentDiv').src = "";
		}
		return true;
	}
	//alert(urlParam);
	var vURL = urlParam;
	
	//Added this because of a bug in safari that can't handle obj.src being set
	if (vbrowser.name == "Apple Computer, Inc."){
		imageWin.load('iframe', vURL, '');
		imageWin.frames[0].style.border = "0px";
		imageWin.moveTo("middle", "middle");
		imageWin.setSize(width,height);		
	} else {
	
		if(vbrowser.name != "Netscape"){
			var positionLeft = (browserDimensions.width / 2 - ( modalWidth / 2 ))+"px";
		}else{
			var positionLeft =  (browserDimensions.width / 2 - ( modalWidth / 2 ))+"px";
		}
		//alert(positionLeft);
		parent.document.getElementById(modalTitle).style.left = positionLeft;
		
		
		document.getElementById(modalDiv + 'Frame').src = vURL;
	}
}

/////////// BROWSER DETAILS //////////////
var browser = new Array();
browser["name"];
browser["version"];

var browserDims = new Array();


/*
window.onload = function(){
	browserDimensions = getBrowserSize();
	userBrowser = detectBrowser();
	
	if(userBrowser.name == 'Apple Computer, Inc.'){
		//document.getElementById("searchInput").style.left = ((browserDimensions.width / 2) + 220) +"px";
		//document.getElementById("titleText").style.left = ((browserDimensions.width / 2)- 450) +"px";
		
		if(document.getElementById("googleFrame")){
			document.getElementById("googleFrame").style.width = "530px";
			document.getElementById("googleFrame").style.height = "440px";
		}
		if(document.getElementById("googleMapFrame")){
			document.getElementById("googleMapFrame").style.padding = "5px";
		}
		
		
		
	}else{
		//document.getElementById("searchInput").style.left = ((browserDimensions.width / 2) + 85) +"px";
		//document.getElementById("titleText").style.left = ((browserDimensions.width / 2) - 600) +"px";
	}

	if(userBrowser.name == 'Netscape'){

		//document.getElementById("searchInput").style.left = ((browserDimensions.width / 2) + 10) +"px";
		
		if(document.getElementById("googleFrame")){
			document.getElementById("googleFrame").style.width = "500px";
			document.getElementById("googleFrame").style.height = "420px";
		}
		if(document.getElementById("googleMapFrame")){
			document.getElementById("googleMapFrame").style.padding = "5px";
		}
	}
	
}*/

function detectBrowser(){
	browser["name"] = navigator.vendor;
	if(browser["name"] == undefined || browser["name"] == ''){
		browser["name"]  = navigator.appName;
	}
	browser["version"]=navigator.appVersion;
	var version=parseFloat(browser["version"]);
	//alert(browser);
	return browser;
}

function getBrowserSize() {

  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } 
  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {

    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } 
  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

  browserDims["height"] = myHeight;
  browserDims["width"] = myWidth;

  return browserDims;
}
/////////// END BROWSER DETAILS //////////////



function showPreview(grpID){
	
	browserDimensions = getBrowserSize();
	//videoWin = null;
	
	//centre the window
	var openLeft = browserDimensions.width / 2 - 360;
	var openTop = browserDimensions.height / 2 + 300;
	
	videoWin = dhtmlmodal.open('previewFlash', 'div', ModalWindowDiv, 'Home Page Flash Preview', 'width=770px,height=430px,left='+openLeft+'px,top=100px,resize=0,scrolling=0',"recal");
	
	videoWin.style.zIndex=150;
 	
	videoWin.onclose=function(){
		
		if (vbrowser.name == "Apple Computer, Inc."){
			//this is to fix a bug in Safari where it wouldn't close the flash video player on close of the modal window
			videoWin.contentDoc.getElementById('showDetails').document.getElementById('flashcontent').innerHTML = '';
		}else{
		
		document.getElementById('contentFrame').src = "";
		}
		return true;
	}

	
	
	var vURL = "showpreview.cfm?grpID="+grpID;

	vbrowser = detectBrowser();
		
		//Added this because of a bug in safari that can't handle obj.src being set
		if (vbrowser.name == "Apple Computer, Inc."){
			videoWin.load('iframe', vURL, '');
			videoWin.frames[0].style.border = "0px";
			videoWin.moveTo("middle", "middle");
			videoWin.setSize(800,640);
			
			
		}
		else {

			document.getElementById('contentFrame').src = vURL;
		}
		
	

}


function showImagePreview(imgName){
	
	browserDimensions = getBrowserSize();
	//videoWin = null;
	
	//centre the window
	var openLeft = browserDimensions.width / 2 - 360;
	var openTop = browserDimensions.height / 2 + 300;
	
	videoWin = dhtmlmodal.open('previewFlash', 'div', ModalWindowDiv, 'Image Preview', 'width=770px,height=430px,left='+openLeft+'px,top=100px,resize=0,scrolling=0',"recal");
	
	videoWin.style.zIndex=150;
 	
	videoWin.onclose=function(){
		
		if (vbrowser.name == "Apple Computer, Inc."){
			//this is to fix a bug in Safari where it wouldn't close the flash video player on close of the modal window
			videoWin.contentDoc.getElementById('showDetails').document.getElementById('flashcontent').innerHTML = '';
		}else{
		
		document.getElementById('contentFrame').src = "";
		}
		return true;
	}

	
	
	var vURL = "showImagePreview.cfm?imgName="+imgName;

	vbrowser = detectBrowser();
		
		//Added this because of a bug in safari that can't handle obj.src being set
		if (vbrowser.name == "Apple Computer, Inc."){
			videoWin.load('iframe', vURL, '');
			videoWin.frames[0].style.border = "0px";
			videoWin.moveTo("middle", "middle");
			videoWin.setSize(800,640);
			
			
		}
		else {

			document.getElementById('contentFrame').src = vURL;
		}
}

function highlightSubMenu(currentPage, pageTemplate) {
	var menuLinks = '';

	if (pageTemplate == 'EducationDetails.cfm') {
		currentPage = 'Education_&_Training.cfm';
	} else if (pageTemplate == 'VolunteerDetails.cfm') {
		currentPage = 'Volunteer_Listings.cfm';
	} else if (pageTemplate == 'JobDetails.cfm') {
		currentPage = 'Job_Listings.cfm';
	}

	if (document.getElementById('leftMenuContainer') != null) {
		menuLinks = document.getElementById('leftMenuContainer').getElementsByTagName('a');

		for (i = 0; i < menuLinks.length; i++) {
			menuLink = menuLinks[i].href.split("/");
	
			if (menuLink[menuLink.length - 1].toUpperCase() == currentPage.toUpperCase()) {
				if (menuLinks[i].id == "large" || menuLinks[i].id == "large2")
					menuLinks[i].className = 'LeftLargeColumnCurrent';
				else
					menuLinks[i].className = 'LeftColumnCurrent';
			}
		}
	}
}
