var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the the FSCommand messages in a Flash movie
function Chat_DoFSCommand(command, args) {
  var ChatObj = InternetExplorer ? Chat : document.Chat;
   if (command == "jsResizeChatBox"){
	objFlashWhosOnline = eval(FlashWhosOnline)
    if(args.toUpperCase()=="TRUE"){
		objFlashWhosOnline.style.width = "550"
	}else{
		objFlashWhosOnline.style.width = "166"
	}
 }
 
 if (command == "jsChatBoxAlert"){
 	alert(args)
 }
 
}
// Hook for Internet Explorer 
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
	  navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('Sub Chat_FSCommand(ByVal command, ByVal args)\n');
	document.write('  call Chat_DoFSCommand(command, args)\n');
	document.write('end sub\n');
	document.write('</SCRIPT\> \n');
}

  
 



function js_validateDateTime(szControlName,szformname){

obj_dateobjects1 = eval(szformname+"."+szControlName+"1")
obj_dateobjects2 = eval(szformname+"."+szControlName+"2")
obj_dateobjects3 = eval(szformname+"."+szControlName+"3")

if (obj_dateobjects1.value=="31"){
if(obj_dateobjects2.value=="2" || obj_dateobjects2.value=="4" || obj_dateobjects2.value=="6" || obj_dateobjects2.value=="9" || obj_dateobjects2.value=="11"){
obj_dateobjects1.value="30"
}
}
if (obj_dateobjects2.value=="2"){
	if (obj_dateobjects3.value == "1996" || obj_dateobjects3.value == "2000" || obj_dateobjects3.value == "2004" || obj_dateobjects3.value == "2008" || obj_dateobjects3.value == "2012" || obj_dateobjects3.value == "2016" || obj_dateobjects3.value == "2020" || obj_dateobjects3.value == "2024" || obj_dateobjects3.value == "2028" || obj_dateobjects3.value == "2032" || obj_dateobjects3.value == "2036" || obj_dateobjects3.value == "2040"){
		if (obj_dateobjects1.value > 29 ){
			obj_dateobjects1.value="29"
		}
	}else{
		if (obj_dateobjects1.value > 28 ){
			obj_dateobjects1.value="28"
		}
	}
}
}

function isEmpty(str_content){
	string_input = str_content
	while(string_input.search(" ")>-1){
		string_input = string_input.replace(" ","")
	} 
	if (string_input == ""){
		return true
	}else{
		return false
	}
}

function confirmDelete(strAlert,strLocation){
	if (confirm(strAlert)){
		document.location = strLocation
	}
}

function isEmail(str_content){
	string_input = str_content
	blnReturn = true
	if(string_input.indexOf("@")<0){
		blnReturn = false
	}
	if(string_input.indexOf(".")<0){
		blnReturn = false
	}
	return blnReturn	
}

function goto_location(goto_location){
	document.location = goto_location
}
function jsSubmitgalleries(){
intFlag = 0
StrError = "Please supply the following values: \n"

if(isEmpty(document.frmgalleries.nvcGalleries.value)==true){
intFlag = 1
StrError = StrError + "- Gallery Title \n"
}

Editor = document.getElementById("divnvcDescription")
hdnEditor = document.getElementById("nvcDescription")
hdnEditor.value = Editor.innerHTML

if(isEmpty(document.frmgalleries.fidDisplay.value)==true){
intFlag = 1
StrError = StrError + "- Display \n"
}

if(intFlag==0){
document.frmgalleries.submit()
}else{
alert(StrError)
}
}


function jsSubmitnotes(){
intFlag = 0
StrError = "Please supply the following values: \n"

if(isEmpty(document.frmnotes.nvcNotes.value)==true){
intFlag = 1
StrError = StrError + "- Note \n"
}


if(isEmpty(document.frmnotes.nvcThanksTo.value)==true){
intFlag = 1
StrError = StrError + "- Thanks To \n"
}

if(intFlag==0){
document.frmnotes.submit()
}else{
alert(StrError)
}
}

function jsSubmitPersonalPages(){
intFlag = 0
StrError = "Please supply the following values: \n"

if(isEmpty(document.frmnvcPersonalPage.nvcPersonalPage.value)==true){
intFlag = 1
StrError = StrError + "- Page Title \n"
}

Editor = document.getElementById("divnvcDescription")
hdnEditor = document.getElementById("nvcDescription")
hdnEditor.value = Editor.innerHTML

if(isEmpty(document.frmnvcPersonalPage.fidDisplay.value)==true){
intFlag = 1
StrError = StrError + "- Display \n"
}

if(intFlag==0){
document.frmnvcPersonalPage.submit()
}else{
alert(StrError)
}
}


function jsSubmitnews(){
intFlag = 0
StrError = "Please supply the following values: \n"

if(isEmpty(document.frmnews.nvcNews.value)==true){
intFlag = 1
StrError = StrError + "- News Title \n"
}

Editor = document.getElementById("divnvcDescription")
hdnEditor = document.getElementById("nvcDescription")
hdnEditor.value = Editor.innerHTML

if(isEmpty(document.frmnews.fidDisplay.value)==true){
intFlag = 1
StrError = StrError + "- Display \n"
}

if(intFlag==0){
document.frmnews.submit()
}else{
alert(StrError)
}
}


function jsSubmitpages(){
intFlag = 0
StrError = "Please supply the following values: \n"

if(isEmpty(document.frmpages.nvcPages.value)==true){
intFlag = 1
StrError = StrError + "- Page Title \n"
}


if(isEmpty(document.frmpages.nvcContent.value)==true){
intFlag = 1
StrError = StrError + "- Content \n"
}

if(intFlag==0){
document.frmpages.submit()
}else{
alert(StrError)
}
}


function jsSubmitevents(){
intFlag = 0
StrError = "Please supply the following values: \n"

if(isEmpty(document.frmevents.nvcEvents.value)==true){
intFlag = 1
StrError = StrError + "- Event Title \n"
}



if(document.frmevents.intCoordinateFormat[1].checked==true){
	if (isEmpty(document.frmevents.nvcLong.value)==false || isEmpty(document.frmevents.nvcLat.value)==false){
		if (isEmpty(document.frmevents.nvcLong.value)==true || isNaN(document.frmevents.nvcLong.value)==true || isEmpty(document.frmevents.nvcLat.value)==true || isNaN(document.frmevents.nvcLat.value)==true  ){
			intFlag = 1
			StrError = StrError + "- Please enter valid Longitude and Latitude values \n"
		}
	}
}

if(document.frmevents.intCoordinateFormat[0].checked==true){
	if (isEmpty(document.frmevents.nvcXdeg.value)==false || isEmpty(document.frmevents.nvcXmin.value)==false || isEmpty(document.frmevents.nvcXsec.value)==false || isEmpty(document.frmevents.nvcYdeg.value)==false || isEmpty(document.frmevents.nvcYmin.value)==false || isEmpty(document.frmevents.nvcYsec.value)==false){
		if (isEmpty(document.frmevents.nvcXdeg.value)==true || isNaN(document.frmevents.nvcXdeg.value)==true || isEmpty(document.frmevents.nvcXmin.value)==true || isNaN(document.frmevents.nvcXmin.value)==true || isEmpty(document.frmevents.nvcXsec.value)==true || isNaN(document.frmevents.nvcXsec.value)==true || isEmpty(document.frmevents.nvcYdeg.value)==true || isNaN(document.frmevents.nvcYdeg.value)==true || isEmpty(document.frmevents.nvcYmin.value)==true || isNaN(document.frmevents.nvcYmin.value)==true || isEmpty(document.frmevents.nvcYsec.value)==true || isNaN(document.frmevents.nvcYsec.value)==true){
			intFlag = 1
			StrError = StrError + "- Please enter valid GPS values \n"
		}
	}
}

Editor = document.getElementById("divnvcDescription")
hdnEditor = document.getElementById("nvcDescription")
hdnEditor.value = Editor.innerHTML

Editor = document.getElementById("divnvcFeedback")
hdnEditor = document.getElementById("nvcFeedback")
hdnEditor.value = Editor.innerHTML


if(isEmpty(document.frmevents.fidDisplay.value)==true){
intFlag = 1
StrError = StrError + "- Display \n"
}

if(intFlag==0){
document.frmevents.submit()
}else{
alert(StrError)
}
}


function jsSubmitforums(){
intFlag = 0
StrError = "Please supply the following values: \n"

if(isEmpty(document.frmforums.nvcForums.value)==true){
intFlag = 1
StrError = StrError + "- Forum Title \n"
}


if(isEmpty(document.frmforums.nvcContent.value)==true){
intFlag = 1
StrError = StrError + "- Content \n"
}


if(isEmpty(document.frmforums.fidDisplay.value)==true){
intFlag = 1
StrError = StrError + "- Display \n"
}

if(intFlag==0){
document.frmforums.submit()
}else{
alert(StrError)
}
}


function jsSubmitpolls(){
intFlag = 0
StrError = "Please supply the following values: \n"

if(isEmpty(document.frmpolls.nvcPolls.value)==true){
intFlag = 1
StrError = StrError + "- Poll Title \n"
}


if(isEmpty(document.frmpolls.nvcContent.value)==true){
intFlag = 1
StrError = StrError + "- Content \n"
}


if(isEmpty(document.frmpolls.fidDisplay.value)==true){
intFlag = 1
StrError = StrError + "- Display \n"
}

if(intFlag==0){
document.frmpolls.submit()
}else{
alert(StrError)
}
}


function jsSubmitmemberrights(){
intFlag = 0
StrError = "Please supply the following values: \n"

if(isEmpty(document.frmmemberrights.nvcMemberRights.value)==true){
intFlag = 1
StrError = StrError + "- Member Right Title \n"
}

if(intFlag==0){
document.frmmemberrights.submit()
}else{
alert(StrError)
}
}


function jsSubmitmembersrights(){
intFlag = 0
StrError = "Please supply the following values: \n"

if(isEmpty(document.frmmembersrights.fidMemberRights.value)==true){
intFlag = 1
StrError = StrError + "- Member Right Title \n"
}

if(intFlag==0){
document.frmmembersrights.submit()
}else{
alert(StrError)
}
}


function jsSubmitpollquestions(){
intFlag = 0
StrError = "Please supply the following values: \n"


if(isEmpty(document.frmpollquestions.nvcPollQuestions.value)==true){
intFlag = 1
StrError = StrError + "- Poll Question \n"
}

if(intFlag==0){
document.frmpollquestions.submit()
}else{
alert(StrError)
}
}


function jsSubmitpollanswers(){
intFlag = 0
StrError = "Please supply the following values: \n"


if(intFlag==0){
document.frmpollanswers.submit()
}else{
alert(StrError)
}
}


function jsSubmitguestbook(){
intFlag = 0
StrError = "Please supply the following values: \n"

if(isEmpty(document.frmguestbook.nvcGuestbook.value)==true){
intFlag = 1
StrError = StrError + "- Guestbook Note \n"
}


if(isEmpty(document.frmguestbook.nvcVisitor.value)==true){
intFlag = 1
StrError = StrError + "- Visitor Name \n"
}



if(isEmpty(document.frmguestbook.strCAPTCHA.value)==true){
intFlag = 1
StrError = StrError + "- Security Code \n"
}



if(intFlag==0){
document.frmguestbook.submit()
}else{
alert(StrError)
}
}


function jsSubmitnewsfeed(){
intFlag = 0
StrError = "Please supply the following values: \n"

if(isEmpty(document.frmnewsfeed.nvcNewsFeed.value)==true){
intFlag = 1
StrError = StrError + "- News Feed \n"
}

if(intFlag==0){
document.frmnewsfeed.submit()
}else{
alert(StrError)
}
}


function jsSubmitdisplay(){
intFlag = 0
StrError = "Please supply the following values: \n"

if(isEmpty(document.frmdisplay.nvcDisplay.value)==true){
intFlag = 1
StrError = StrError + "- Display \n"
}

if(intFlag==0){
document.frmdisplay.submit()
}else{
alert(StrError)
}
}


function jsSubmitnewsfeedarticles(){
intFlag = 0
StrError = "Please supply the following values: \n"

if(isEmpty(document.frmnewsfeedarticles.nvcLink.value)==true){
intFlag = 1
StrError = StrError + "- Link \n"
}


if(isEmpty(document.frmnewsfeedarticles.nvcTitle.value)==true){
intFlag = 1
StrError = StrError + "- Title \n"
}


if(isEmpty(document.frmnewsfeedarticles.nvcSummary.value)==true){
intFlag = 1
StrError = StrError + "- Summary \n"
}


if(isEmpty(document.frmnewsfeedarticles.nvcPubDate.value)==true){
intFlag = 1
StrError = StrError + "- Pub Date \n"
}


if(isEmpty(document.frmnewsfeedarticles.fidNewsFeed.value)==true){
intFlag = 1
StrError = StrError + "- News Feed \n"
}

if(intFlag==0){
document.frmnewsfeedarticles.submit()
}else{
alert(StrError)
}
}


function jsSubmitmembers(){
intFlag = 0
StrError = "Please supply the following values: \n"

if(isEmpty(document.frmmembers.nvcMembers.value)==true){
intFlag = 1
StrError = StrError + "- Name \n"
}


if(isEmpty(document.frmmembers.nvcSurname.value)==true){
intFlag = 1
StrError = StrError + "- Surname \n"
}


//if(isEmpty(document.frmmembers.nvcClubName.value)==true){
//intFlag = 1
//StrError = StrError + "- Club Name \n"
//}


//if(isEmpty(document.frmmembers.nvcID.value)==true){
//intFlag = 1
//StrError = StrError + "- I D \n"
//}


//if(isEmpty(document.frmmembers.nvcMedicalCompany.value)==true){
//intFlag = 1
//StrError = StrError + "- Medical Company \n"
//}


//if(isEmpty(document.frmmembers.nvcMedicalPlan.value)==true){
//intFlag = 1
//StrError = StrError + "- Medical Plan \n"
//}


//if(isEmpty(document.frmmembers.nvcMedicalNumber.value)==true){
//intFlag = 1
//StrError = StrError + "- Medical Number \n"
//}


//if(isEmpty(document.frmmembers.nvcMedicalAllergies.value)==true){
//intFlag = 1
//StrError = StrError + "- Medical Allergies \n"
//}


//if(isEmpty(document.frmmembers.nvcNextOfKin.value)==true){
//intFlag = 1
//StrError = StrError + "- Next Of Kin \n"
//}


//if(isEmpty(document.frmmembers.nvcCellPhone.value)==true){
//intFlag = 1
//StrError = StrError + "- Cell Phone \n"
//}


//if(isEmpty(document.frmmembers.nvcEmail.value)==true){
//intFlag = 1
//StrError = StrError + "- Email \n"
//}


if(isEmpty(document.frmmembers.nvcUserName.value)==true){
intFlag = 1
StrError = StrError + "- User Name \n"
}


if(isEmpty(document.frmmembers.nvcPassword.value)==true){
intFlag = 1
StrError = StrError + "- Password \n"
}

if(document.frmmembers.nvcPassword.value!=document.frmmembers.nvcConfirmPassword.value){
intFlag = 1
StrError = StrError + "- Passwords do not match \n"
}




//if(isEmpty(document.frmmembers.bitSendEmailNotifications.value)==true){
//intFlag = 1
//StrError = StrError + "- Send Email Notifications \n"
//}


//if(isEmpty(document.frmmembers.bitSendSMSNotifications.value)==true){
//intFlag = 1
//StrError = StrError + "- Send S M S Notifications \n"
//}


//if(isEmpty(document.frmmembers.bitMember.value)==true){
//intFlag = 1
//StrError = StrError + "- Member \n"
//}


//if(isEmpty(document.frmmembers.bitLoggedIn.value)==true){
//intFlag = 1
//StrError = StrError + "- Logged In \n"
//}

if(intFlag==0){
document.frmmembers.submit()
}else{
alert(StrError)
}
}


function jsSubmiteventsimages(){
intFlag = 0
StrError = "Please supply the following values: \n"

if(isEmpty(document.frmeventsimages.nvcEventsImages.value)==true){
intFlag = 1
StrError = StrError + "- Image Title \n"
}

if(intFlag==0){
document.frmeventsimages.submit()
}else{
alert(StrError)
}
}


function jsSubmitgalleriesimages(){
intFlag = 0
StrError = "Please supply the following values: \n"

if(isEmpty(document.frmgalleriesimages.nvcGalleriesImages.value)==true){
intFlag = 1
StrError = StrError + "- Image Title \n"
}

if(intFlag==0){
document.frmgalleriesimages.submit()
}else{
alert(StrError)
}
}

function jsSubmitPersonalPageimages(){
intFlag = 0
StrError = "Please supply the following values: \n"

if(isEmpty(document.frmPersonalPageimages.nvcPersonalPageImages.value)==true){
intFlag = 1
StrError = StrError + "- Image Title \n"
}

if(intFlag==0){
document.frmPersonalPageimages.submit()
}else{
alert(StrError)
}
}

function jsSubmitnewsimages(){
intFlag = 0
StrError = "Please supply the following values: \n"

if(isEmpty(document.frmnewsimages.nvcNewsImages.value)==true){
intFlag = 1
StrError = StrError + "- Image Title \n"
}

if(intFlag==0){
document.frmnewsimages.submit()
}else{
alert(StrError)
}
}

function jsSubmitContactUs(){

intFlag = 0
StrError = "Please supply the following values: \n"

if(isEmpty(document.frmcontactus.nvcName.value)==true){
intFlag = 1
StrError = StrError + "- Name \n"
}

if(isEmpty(document.frmcontactus.nvcEmail.value)==true){
intFlag = 1
StrError = StrError + "- Email \n"
}else{
	if(isEmail(document.frmcontactus.nvcEmail.value)==false){
		intFlag = 1
		StrError = StrError + "- Valid Email address \n"
	}
}

if(isEmpty(document.frmcontactus.nvcComment.value)==true){
intFlag = 1
StrError = StrError + "- Comment \n"
}

if(isEmpty(document.frmcontactus.strCAPTCHA.value)==true){
intFlag = 1
StrError = StrError + "- Security code \n"
}



if(intFlag==0){
document.frmcontactus.submit()
}else{
alert(StrError)
}
}

function jsChangeStyleForDiv(obj,strNewStyle){
	obj.className = strNewStyle
}

function jsInsertImageIntoContent(strPreviewImageURL, strTitle){
	if (strPreviewImageURL==""){
		alert("Please select an image to insert")
	}else{
	
		strImageTag = ""
		strImageTag = strImageTag + "<table align=\"center\">"
		strImageTag = strImageTag + "<tr>"
		strImageTag = strImageTag + "<td><img src=\""+ strPreviewImageURL + "\" class=\"ImageViewer\" border=\"0\" alt=\""+ strTitle +"\"></td>"
		strImageTag = strImageTag + "</tr>"
		strImageTag = strImageTag + "<tr>"
		strImageTag = strImageTag + "<td class=\"ImageViewerText\" align=\"center\" >"
		strImageTag = strImageTag + ""+ strTitle +""
		strImageTag = strImageTag + "</td>"
		strImageTag = strImageTag + "</tr>"
		strImageTag = strImageTag + "</table>"
		window.returnValue = strImageTag
		window.close();
	}
}

function changeDiv(divShow,divHide){
	divShow = document.getElementById(divShow);
	divHide = document.getElementById(divHide);
	
	divHide.style.display = "none";
	divShow.style.display = "block";
	
}


activeDropDownDiv = null
blnContinueHiding = true

function showOrHideMenuDiv(blnShow,strTopMenuID){
	
	ObjTopMenu = document.getElementById(strTopMenuID);
	
	if (ObjTopMenu!=null){
		var idValue = ObjTopMenu.id
		var subMenuDiv = "sub" + idValue;
		
		if (blnShow==true){
			//alert("show: " + strTopMenuID)
			jsChangeStyleForDiv(ObjTopMenu,"topNavFillOver")
			showMenuDiv(subMenuDiv,ObjTopMenu)	
		}else{
		
			//alert("hide: " + strTopMenuID)
			jsChangeStyleForDiv(ObjTopMenu,"topNavFill")
			hideMenuDiv(subMenuDiv)		
		}
	}
}

function findPos(obj){
	var bw=new cm_bwcheck()
  if(bw.ns4){   //Netscape 4
    x = obj.pageX
    y = obj.pageY
  }else{ //other browsers
    x=0; y=0; var el,temp
    el = obj //bw.ie4?document.all["imgCategories"]:document.getElementById("imgCategories");
    if(el.offsetParent){
      temp = el
      while(temp.offsetParent){ //Looping parent elements to get the offset of them as well
        temp=temp.offsetParent; 
        x+=temp.offsetLeft
        y+=temp.offsetTop;
      }
    }
    x+=el.offsetLeft
    y+=el.offsetTop
  }
  //Returning the x and y as an array
  return [x,y]
}

function cm_bwcheck(){
	//In theory we should use object detection, but this script needs work-arounds for almost every browser...
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent.toLowerCase()
	this.dom=document.getElementById?1:0
	this.ns4=(!this.dom && document.layers)?1:0;
	this.op=window.opera 
	this.moz=(this.agent.indexOf("gecko")>-1 || window.sidebar)
	this.ie=this.agent.indexOf("msie")>-1 && !this.op
	if(this.op){
		this.op5=(this.agent.indexOf("opera 5")>-1 || this.agent.indexOf("opera/5")>-1)
		this.op6=(this.agent.indexOf("opera 6")>-1 || this.agent.indexOf("opera/6")>-1)
		this.op7=this.dom&&!this.op5&&!this.op6 //So all higher opera versions will use it
	}else if(this.moz) this.ns6 = 1
	else if(this.ie){
		this.ie4 = !this.dom && document.all
  	this.ie5 = (this.agent.indexOf("msie 5")>-1)
  	this.ie55 = (this.ie5 && this.agent.indexOf("msie 5.5")>-1)
  	this.ie6 = this.dom && !this.ie4 && !this.ie5 && ! this.ie55
	}
	this.mac=(this.agent.indexOf("mac")>-1)
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.op5 || this.op6 || this.op7)
  this.usedom= this.ns6||this.op7//Use dom creation
  this.reuse = this.ie||this.op7||this.usedom //Reuse layers
  this.px=this.dom&&!this.op5?"px":""
	return this
}

function showMenuDiv(divShow, ObjTopMenu){

	positions = findPos(ObjTopMenu)
	blnContinueHiding = false
	if (activeDropDownDiv!=null){
		activeDropDownDiv.style.display = "none";
	}

	divShow = document.getElementById(divShow);
	
	if (divShow!=null){
		activeDropDownDiv = divShow
		divShow.style.top = positions[1] + 26
		divShow.style.left = positions[0]
		divShow.style.display = "block";
	}
}

function hideMenuDiv(divShow){
	blnContinueHiding = true
	setTimeout("hideDiv('"+divShow+"')",500)
}

function hideDiv(divShow){
	divShow = document.getElementById(divShow);
	if (divShow!=null){
		if (blnContinueHiding==true){
			divShow.style.display = "none";
		}
	}
}

window.onload = function hide(){
	for(i = 0; i < document.all.length; i++){
		if(document.all(i).className.toUpperCase()=="TOPNAVFILL"){
		 var idValue = document.all(i).id;
		 if (idValue.toUpperCase()!=""){
			document.all(i).onmouseover = new Function("showOrHideMenuDiv(true, '"+ idValue +"')");
			document.all(i).onmouseout = new Function("showOrHideMenuDiv(false, '"+ idValue +"')");
			
			var subMenuDiv = "sub" + idValue;
			var objChildItems = document.getElementById(subMenuDiv);
			
			if (objChildItems!=null){
				objChildItems.onmouseover = new Function("showOrHideMenuDiv(true, '"+ idValue +"')");
				objChildItems.onmouseout = new Function("showOrHideMenuDiv(false, '"+ idValue +"')");	
			}
		}
	   }
	   
		if(document.all(i).className.toUpperCase()=="DROPDOWNMENUITEM"){
			document.all(i).onmouseover = new Function("jsChangeStyleForDiv(this,'dropdownMenuItemOver')");
			document.all(i).onmouseout = new Function("jsChangeStyleForDiv(this,'dropdownMenuItem')");
		}
	   
	}
}
