// JavaScript Document

function navigateToPage(pageName,anchrName) {
	//alert(pageName +" " + anchrName );
	var page = pageName
	var ext = ".asp"  ;
	var anchr = anchrName ;
	
	
	
	if (anchr ==""  || anchr == undefined || anchr=="null") {
		//alert(page + ext);
		window.location = page + ext   ;
	}
	else {
		//alert("2" + page + ext  + anchr);
		window.location = page + ext + "#" + anchr  ;
	}
	
}

function populateiFrame(iFrameName,anchrName) {
	
	//alert(iFrameName);
	var frameSrc =	document.getElementById("ifrmMainContent") ;
	var ext = ".htm"  ;
	var anchr = anchrName ;
	
/*	alert(frameSrc);

	if (frameSrc =="" || frameSrc == undefined) {
		window.location.replace("home.htm")  ;
	}
*/	
	if (frameSrc =="" || frameSrc == undefined || frameSrc=="null") {
		window.location.replace("../home.htm")  ;
	}
	else {
				
		frameSrc.src = iFrameName + (ext) ;
	}
	//alert(anchrName) ;
	
	if (anchr == undefined) {
	
		frameSrc.src = iFrameName + (ext) ;
	}
	else {
		
		ext = ".htm#" + (anchr)
		frameSrc.src = iFrameName + (ext) ;
	}
	
		
	//	alert ("populateiFrame function called with ..." + frameSrc);
	//frameSrc.src = iFrameName + ltrim(ext) + anchr;
	//	alert ("populateiFrame function called with ..." + frameSrc.src);

}


function populateiFrameAsp(iFrameName,anchrName) {

	var frameSrc =	document.getElementById("ifrmMainContent") ;
	var ext = ".asp"
	var anchr = anchrName 
	
	//alert(anchrName) ;
	
	if (anchr == undefined) {
	
		frameSrc.src = iFrameName + (ext) ;
	}
	else {
		
		ext = ".asp#" + (anchr)
		frameSrc.src = iFrameName + (ext) ;
	}
	
		
	//	alert ("populateiFrame function called with ..." + frameSrc);
	//frameSrc.src = iFrameName + ltrim(ext) + anchr;
	//	alert ("populateiFrame function called with ..." + frameSrc.src);

}


function enterLodgePrompt() {

   	var retVal = prompt("Who comes here? ", "Please enter your name here");
   
	// TEST TO SEE IF NULL OR STRING RETURNED
	
	if (retVal !== null) {
		if (retVal == "Please enter your name here") {
			retVal = "Great Unknown One,"
		}
		alert("\n\n    " + retVal +" thank you for visiting our website.\n\n\The Brethren hope that you'll enjoy the visit!!!\n\n     " );		
		location.href = "main.shtml"  ;  //redirect to index page
	} else {
		// do nothing
	}

}

function enterLodge() {
	
		location.href = "main.asp"  ;  //redirect to index page
}


function popHelp() {

	strUrl = "help/contents.htm";
	intH = 0;
	intW = 0;

	 var _intH = 800;
	 var _intW = 700;
	 var intTop = 15
	 var intLft =15
	 if (intH) {intH=intH } else {intH=_intH } ;
	 if (intW) {intW=intW } else {intW=_intW } ;
	 
	 myWin = window.open(strUrl, "el736PopupWin","height="+ intH +",width=" + intW +",status=yes,toolbar=no,menubar=no,location=no,z-index=1,resizable=yes,focus=true,scrollbars=default,top="+ intTop +",left="+ intLft +""); 
	 myWin.focus() ;
	 
	 document.body.style.cursor = "default";

}


function memberLogin() {

	alert("This feature unfortunately is still a work in progress... \n\nCOMING SOON!!!\n\nWe will keep you posted on further developments.") ;

}

function fnShowLogin(strUrl, intH, intW) 
{
	//alert(strUrl + "  "+ intH + "  "+ intW);
 document.body.style.cursor = "wait";

 var _intH = 200;
 var _intW = 380;
 var intTop = 15
 var intLft =15
 if (intH) {intH=intH } else {intH=_intH } ;
 if (intW) {intW=intW } else {intW=_intW } ;
 
 myWin = window.open(strUrl, "el736LoginWin","height="+ intH +",width=" + intW +",status=no,toolbar=no,menubar=no,location=no,z-index=1,resizable=no,focus=true,scrollbars=no,top="+ intTop +",left="+ intLft +""); //,top="+ intTop +",left="+ intLft +"); "
 myWin.focus() ;
 
 document.body.style.cursor = "default";
 
}

function showPhotoLayer(strLyr, selIndx) {
	 //alert("This feature unfortunately is still a work in progress... \n\nCOMING SOON!!!\n\nWe will keep you posted on further developments.") ;
	//alert("function called " + strLyr +" index " + selIndx) ;      // FOR DEBUG INFO

	var frameSrc =	document.getElementById("ifrmPhotos") ;
	var ext = ".htm"  ;
	var iFrameName ;
	var baseFolder ;
	
	baseFolder = ""  ;  					
										
	switch(selIndx)
		{
		case 1:
			iFrameName =  baseFolder + strLyr ;
			//alert("index " + selIndx + "src " + strLyr) ; // FOR DEBUG INFO
		  	frameSrc.src = iFrameName + ext ;
		  	break;    
		case 2:
			iFrameName = baseFolder + strLyr ;
			//alert("index " + selIndx + "src " + strLyr) ;  // FOR DEBUG INFO
		  	frameSrc.src = iFrameName + ext ;
		  	break;
		 case 3:
			 iFrameName = baseFolder + strLyr ; 
			//alert("index " + selIndx + "src " + strLyr) ;  // FOR DEBUG INFO
		 	frameSrc.src = iFrameName + ext ;
			break;
		default:
		  alert("Please select a valid period...");
		}
}

function showSummonsLayer(strLyr, selIndx) {
	 //alert("This feature unfortunately is still a work in progress... \n\nCOMING SOON!!!\n\nWe will keep you posted on further developments.") ;
	//alert("function called " + strLyr +" index " + selIndx) ;      // FOR DEBUG INFO

	var frameSrc =	document.getElementById("ifrmSummons") ;
	var ext = ".htm"  ;
	var iFrameName ;
	var baseFolder ;
	
	baseFolder = "/summons"  ;  					
										
	switch(selIndx)
		{
		case 1:
			iFrameName =  baseFolder + strLyr ;
			//alert("index " + selIndx + "src " + strLyr) ; // FOR DEBUG INFO
		  	frameSrc.src = iFrameName + ext ;
		  	break;    
		case 2:
			iFrameName = baseFolder + strLyr ;
			//alert("index " + selIndx + "src " + strLyr) ;  // FOR DEBUG INFO
		  	frameSrc.src = iFrameName + ext ;
		  	break;
		 case 3:
			 iFrameName = baseFolder + strLyr ; 
			//alert("index " + selIndx + "src " + strLyr) ;  // FOR DEBUG INFO
		 	frameSrc.src = iFrameName + ext ;
			break;
		default:
		  alert("Please select a valid period...");
		}
}


/*
Close spawn window function
*/
function fnCloseWindow() {
	parent.window.close()
}

/*
Added by RRF to handle different display mode for Context Help
specifically popup mode. This function should be called from all
help bubbles and display and bring window to forefront if minimized
*/
function fnPopup(strUrl, intH, intW) 
{
	document.body.style.cursor = "wait";
	alert("This may take a minute to load, please be patient...");
 

	 var _intH = 200;
	 var _intW = 380;
	 var intTop = 15
	 var intLft =15
	 if (intH) {intH=intH } else {intH=_intH } ;
	 if (intW) {intW=intW } else {intW=_intW } ;
	 
	 myWin = window.open(strUrl, "el736PopupWin","height="+ intH +",width=" + intW +",status=yes,toolbar=no,menubar=no,location=no,z-index=1,resizable=yes,focus=true,scrollbars=yes,top="+ intTop +",left="+ intLft +""); 
	 myWin.focus() ;
	 
	 document.body.style.cursor = "default";
	 
}
 
/*
Added by RRF to handle different display mode for About, FAQ, Definitions
specifically static page mode. This function should be called from all
sidebar, footer, links to display and bring window to forefront if minimized
*/
function fnStatic(strUrl, intH, intW) 
{
	 var _intH = 400;
	 var _intW = 680;
	 var intTop =15
	 var intLft =15
	 if (intH) {intH=intH } else {intH=_intH } ;
	 if (intW) {intW=intW } else {intW=_intW } ;
	  
	 myWin = window.open(strUrl, "el736StaticWin","height="+ intH +",width=" + intW +",status=yes,toolbar=yes,menubar=yes,location=yes,z-index=1,resizable=yes,focus=true,scrollbars=1,top="+ intTop +",left="+ intLft +""); 
	 myWin.focus() ;
}

function showPicture(picture, intH, intW) {

	var _intH = 380;
	 var _intW = 580;
	 var intTop = 15
	 var intLft =15
	 if (intH) {intH=intH } else {intH=_intH } ;
	 if (intW) {intW=intW } else {intW=_intW } ;
	 
	 myWin = window.open(picture, "el736PhotoWin","height="+ intH +",width=" + intW +",status=yes,toolbar=no,menubar=no,location=no,z-index=1,resizable=yes,focus=true,scrollbars=yes,top="+ intTop +",left="+ intLft +""); 
	 document.body.style.cursor = "default";
	 myWin.document.writeln('<div align="center"><img src="'+ picture +'" name="img_1" id="imgId_1"></td><td class="photoCell" align="center">')
	  myWin = myWin + myWin.document.writeln('<br /><br /><input name="btnClose" type="button" onClick="window.close() ;" value="Close" /></div>')  ;
	myWin.focus() ;
}


function openWin(url,largeur,hauteur) {
 
                if(parseInt(navigator.appVersion)>=4)
                        {
                        gauche = (screen.width / 2) - (largeur / 2); 
                        haut = (screen.height / 2) - (hauteur / 2); 
                        }
                window.open(url,'el736window','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+largeur+',height='+hauteur+',top=' + haut + ',left=' + gauche);
				
}

function closeWin() {

	self.close();
}

function forgotPwdRequest(){

	//alert("forgotPwdRequest called:")  ;
		var retVal = prompt("PASSWORD RESET REQUEST", "Please enter your user ID here");
   		var emdash = "\u2014"
	// TEST TO SEE IF NULL OR STRING RETURNED
	if (retVal !== null) {
		alert("\n\n\Your password will be reset shortly\n\nYou may try login again in a few minutes.\n\nIf you have still experience problems login in the system, please contact the site Webmaster " + emdash + " webmaster@edinburgh736.ca\n\n" );		
		location.href = "/EL736/app/includes/password_Reset.asp?userId=" + retVal  ;  //redirect to index page
	} else {
		
	}
}

var nw=false;
var myTitle = "myAlert";

function myAlert(mytitle, mytext){
  html = "<html><head><title>" + mytitle +"</title></head>"
  +"<body bgcolor=white>" + mytext +"</body></html>"
  args = "status=no,toolbar=no,menubar=no,location=no,z-index=1,resizable=no,focus=true,scrollbars=no,width=200,height=100"
  nw = window.open('',"myAlert",args)
  nw.document.write(html)
  //alert("This is standard alert box:\n"+ html)
}


function setOther() {
	
	var defVal  ;
	defVal ="Field will become enabled when topic selcted is Other" ;
	
	selIndx = document.forms["frmGuestBook"].selTopic.selectedIndex;
	
	//alert("selIndx :" + selIndx)  ;
	
	if (selIndx == 6) {
		document.forms["frmGuestBook"].txtOther.disabled = false ;
		document.forms["frmGuestBook"].txtOther.value = ""  ;
	}
	else {
	
		document.forms["frmGuestBook"].txtOther.disabled = true ;
		document.forms["frmGuestBook"].txtOther.value = defVal  ;
		document.forms["frmGuestBook"].txtOther.focus()  ;
	}
	
	//optId = document.forms["frmGuestBook"].selTopic.options[selIndx].value;
	//alert("optId :" + optId)  ;
}


// used to check Manadatory fields
function checkManadatoryField(field, val) {

	//alert(field.id) ;
	//alert("val :" +val);
	switch(field.name)
			{
			case "txtFname":
				//alert("case " + val) ;
				if (val == "" || val.length==0 || val == undefined) {
					alert("You cannot have a blank value for a mandatory field, please enter data to proceed." ) ;
					//elem = document.getElementById(field.id).name ;
					//alert(elem) ;
					document.forms[0].txtFname.focus() ;

				}
				break;    
			case "txtName":
				//alert("case " + val) ;
				if (val == "" || val.length==0 || val == undefined) {
					alert("You cannot have a blank value for a mandatory field, please enter data to proceed." ) ;
					//elem = document.getElementById(field.id).name ;
					//alert(elem) ;
					document.forms[0].txtName.focus() ;
				}
				break;    
			case "txtEmail":
				if (val == "" || val.length==0 || val == undefined) {
					alert("You cannot have a blank value for a mandatory field, please enter data to proceed." ) ;
					document.forms[0].txtEmail.focus() ;
				}
				break;
			 case "txtComment":
				 if (val == "" || val.length==0 || val == undefined) {
					alert("You cannot have a blank value for a mandatory field, please enter data to proceed." ) ;
					document.forms[0].txtComments.focus() ;
				}
				break;
			default:
			  alert("You must enter a value in mandatory field...");
	}
}

function guestBookFormValidation() {

	var  bolFlag

	if (document.getElementById("txtFnameId").value == "" || document.getElementById("txtFnameId").value == undefined) {
			bolFlag = false ;
			alert("You did not enter a value for First Name, please enter data to proceed." ) ;
			document.forms[0].txtFname.focus() ;
	} else {
			
			bolFlag = true  ;
			document.forms[0].txtComment.focus() ;
	}
	if  (document.getElementById("txtCommentId").value == "" || document.getElementById("txtCommentId").value == undefined)  {
			bolFlag = false ;
			alert("You did not enter a value for Comment, please enter data to proceed." ) ;
			document.forms[0].txtComment.focus() ;
	} else {			
			bolFlag = true ;
			document.forms[0].txtFname.focus() ;			
	}

	if (bolFlag == false) {

		alert("You must enter a value for mandatory fields...");
		if (document.getElementById("txtFnameId").value == "" || document.getElementById("txtFnameId").value == undefined) {
			document.forms[0].txtFname.focus() ;
		} else {
			document.forms[0].txtComment.focus() ;
		}				 
	}
	else {
		 //alert("SUBMIT FORM happens... " + bolFlag);
		 document.forms[0].submit()  ;
	}			
}

function displayNewsArticles() {
	
	//alert("displayNewsArticles func called") ;
	var arrNewsArt = new Array();
	
	arrNewsArt[arrNewsArt.length] = new Array("<p>Blood drive volunteers are always needed, so if you can give please do so ASAP.</p><hr class='news' />") ;
	arrNewsArt[arrNewsArt.length] = new Array("<p>The Grand Master M.W. Bro. D. Garry Dowling will be attending the Edinburgh Lodge No.736 Remembrance Service on November 2, 2011 at the Westboro Masonic Hall, 430 Churchill Ave Ottawa.</p><p>We will tyle at 1930 hrs.</p><p>Proper military attire and medals may be worn. The annual Table Lodge will follow.</p><hr class='news' />") ;	
	
	
	
	//arrNewsArt[arrNewsArt.length] = new Array("<p align='left'>The Installation & Investiture Ceremony will take place at Edinburgh Lodge No. 736 on Wednesday, 05 May 2010 at 18:30 hrs. All brethren are invited to join us.</p><p align='center'>&loz; &loz; &loz; </p><br /><p>&nbsp;</p>") ;
	//arrNewsArt[arrNewsArt.length] = new Array("<p class='center'><br /><p>&nbsp;</p>") ;	
	
	//arrNewsArt[arrNewsArt.length] = new Array("<p class='center'>Don't forget Brethren:</p><p class='currMotto' style='text-align: center;'>&quot;A Lodge Alive is Worth the Drive&quot;</p><p class='currMotto' style='text-align: center;'>See You In Lodge</p><p class='currMotto' style='text-align: center;'> &loz; &loz; &loz; </p><br /><p>&nbsp;</p>") ;
	
	displayNewsArticles = arrNewsArt[0] + arrNewsArt[1] ;
	document.write(displayNewsArticles) ;
}
//03 MayDistrict Meeting @ Walkley Rd 1930 hrs  -- Monday, May 3rd 2010 at 7:30 pm


function setFeedbackOther(indx) {
	
	var elem ;
	elem = document.getElementById("txtOtherId") ;

	if (indx == 5) {

		elem.style.visibility = "visible";
		elem.value="Please enter your other type of Topic here..." ;
	}
	else {
		elem.style.visibility = "collapse";

	}
}

function feedbackFormValidation() {
	
	var dialog
	var bolFlag
	

	if (document.getElementById("txtEmailId").value == "" || document.getElementById("txtEmailId").value == null)  {
			dialog = 0
			bolFlag = false
	}
	else if  (document.getElementById("txtCommentId").value == "" || document.getElementById("txtCommentId").value == null)  {
			dialog = 1
			bolFlag = false
	}
	
	switch(dialog)
		{
		case 0:
			alert("You did not enter a value for Email, please enter data to proceed." ) ;
			document.forms[0].txtEmail.focus() ;
				
		case 1:
			alert("You did not enter a value for Comment, please enter data to proceed." ) ;
			document.forms[0].txtComment.focus() ;
		
		default:
			if (bolFlag == false) {
				 alert("You must enter a value for mandatory fields...");
				 document.forms[0].txtEmail.focus() ;
			}
			else {
				 //alert("SUBMIT FORM happens...");
				 document.forms[0].submit()  ;
			}			
		
		}
}

function checkEmail(inputvalue){	
    var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
	
    if(pattern.test(inputvalue)){         
		//alert("true");   
    }else{   
		
		alert("The email address entered is not valid, \nplease check to make sure it contains the necesary 5 parts:\n(1) name\n(2)  @\n(3) domain\n(4) .\n(5) ext\n[ e.g. name@domain.net ]");
		 document.forms[0].txtEmail.focus() ; 
    }
}

/*
Added by RRF to handle different status bar display
with can be called from all href(s)
sidebar, footer, links to display proper text to browser satus bar
*/
function fnSetStatus(pstrText) {

	if (pstrText=="") {
		pstrText = "Edinburgh Lodge No. 736"
	}
	window.status = pstrText;
}

/*
Added by RRF to handle different status bar display
with can be called from all href(s)
sidebar, footer, links to reset browser satus bar to blank
*/
function fnResetStatus() 
{
	window.status = "";
	return true;
}


function fnSetFieldAccess() {
	
	var defVal  ;
	defVal ="Field will become enabled when Yes is selected" ;

	selRad = document.getElementsByName("radGrpKnowMason") ;

	if (selRad[0].checked == true) {
		//alert(selRad[0].value);
		
		document.forms["frmRequest"].txtMasonNameId.disabled = false ;
		document.forms["frmRequest"].txtMasonNameId.value = ""  ;
	}
	else {
		//alert(selRad[1].value);
	
		document.forms["frmRequest"].txtMasonNameId.disabled = true ;
		document.forms["frmRequest"].txtMasonNameId.value = defVal  ;
		document.forms["frmRequest"].txtMasonNameId.focus()  ;
	}
}

function bookmark(title,url){
	if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "http://www.edinburghlodge736.ca");
	
	else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	}
	else if(document.all)// ie
	
	window.external.AddFavorite(url, title);
}

// End -->



