function showPicture(galleryid) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 600;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open("showPictureFrame.php?galleryid=" + galleryid, "pictureGallery", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	return;
}

function closeWindow() {
	parent.window.opener.window.focus();
	parent.window.close();
}

function printWindow() {
	parent.mainFrame.focus();
	window.print(parent.mainFrame);
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  
  if(!d) d=document; 
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all) x=d.all[n]; 
  for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); 
  return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { 
	v=args[i+2];
    if (obj.style) { 
		obj=obj.style; 
		v=(v=='show')?'visible':(v=='hide')?'hidden':v; 
	}
    obj.visibility=v; 
  }
}

function printRegistration() {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 650;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open("regFormFrame.php", "regForm", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	return;
}

function checkRegistration() {
	if(trimSpaces(document.forms[0].username.value).length <= 0) {
		alert("Please provide a username");
		document.forms[0].username.focus();
		return false;
	}
	if(trimSpaces(document.forms[0].password.value).length <= 0) {
		alert("Please provide a password");
		document.forms[0].password.focus();
		return false;
	}
	document.forms[0].frmAction.value = "update";
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function showNews(newsid, pageType) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 600;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	
	if(pageType == "home") {
		pageUrl = "php/";
	}
	else {
		pageUrl = "";
	}

	window.open(pageUrl + "showNewsFrame.php?newsid=" + newsid, "news", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	return;
}

function checkMemberCategory(optVal) {
	if(optVal.length <= 0) {
//		document.forms[0].otherCategory.readonly = false;
		document.forms[0].otherCategory.focus();
	}
	else {
//		document.forms[0].otherCategory.blur();
//		document.forms[0].otherCategory.readonly = true;
	}
}

function checkSubscription() {
	
	firstName = trimSpaces(document.forms[0].firstName.value);
	if(firstName.length <= 0) {
		alert("Please enter your first name.");
		document.forms[0].firstName.focus();
		return false;
	}
	
	lastName = trimSpaces(document.forms[0].lastName.value);
	if(lastName.length <= 0) {
		alert("Please enter your last name.");
		document.forms[0].lastName.focus();
		return false;
	}
	
	subscriberEmail = trimSpaces(document.forms[0].subscriberemail.value);
	if(subscriberEmail.length <= 0) {
		alert("Please enter your email.");
		document.forms[0].subscriberemail.focus();
		return false;
	}
	if(subscriberEmail.length > 0){
		if(!checkEmail(subscriberEmail)){
			document.forms[0].subscriberemail.focus();
			return false;
		}
	}
	
	document.forms[0].frmAction.value = "update";

}

function showMemberList(catId, pageType) {
	if(catId.length > 0) {
		if(pageType == "home") {
			document.forms[0].action = "php/0100fram.php";
			document.forms[0].linkid.value = "3";
		}
		document.forms[0].submit();
	}
}

function goDiscoverPage(linkId, pageType) {
	if(linkId.length > 0) {
		document.forms[0].submit();
	}
}

function takeToEvent(eventRef) {
	window.location.href = window.location.href + "#" + eventRef;
	return;
}

function checkContact() {
	visitorName = trimSpaces(document.forms[0].visitorName.value);
	visitorEmail = trimSpaces(document.forms[0].visitorEmail.value);
	visitorPhone = trimSpaces(document.forms[0].visitorPhone.value);
	visitorComments = trimSpaces(document.forms[0].visitorComments.value);
	
	if(visitorName.length <= 0) {
		alert("Please provide your name before submitting the form");
		document.forms[0].visitorName.focus();
		return false;
	}
	
	if(visitorEmail.length <= 0) {
		alert("Please provide your email address before submitting the form");
		document.forms[0].visitorEmail.focus();
		return false;
	}
	
	if(!checkEmail(visitorEmail)) {
		document.forms[0].visitorEmail.focus();
		return false;
	}
	
	if(visitorComments.length <= 0) {
		alert("Please mention your queries or suggestions before submitting the form");
		document.forms[0].visitorComments.focus();
		return false;
	}
	document.forms[0].frmAction.value = "send";
}

function checkSelectDD() {
	category = document.topform.categoryidtop.options[document.topform.categoryidtop.selectedIndex].value;
	if(category.length > 0) {
		document.topform.submit();
	}
	return;
}

function goDropDown(pageType) {
	if(document.forms[0].categoryid.selectedIndex == 0) {
		document.forms[0].linkid.value = 1;
		document.forms[0].submit();
	}
	else if(document.forms[0].categoryid.selectedIndex > 1) {
		document.forms[0].linkid.value = 1;
		document.forms[0].submit();
	}
}

function showEvents(eventid, eventtype) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 600;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	
	window.open("showEventFrame.php?eventid=" + eventid + "&eventtype=" + eventtype, "events", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	return;
}
function checkFeedBack() {
	document.forms[0].visitorName.value = trimSpaces(document.forms[0].visitorName.value);
	if(document.forms[0].visitorName.value.length <= 0) {
		alert("Please enter your name");
		document.forms[0].visitorName.focus();
		return false;
	}

	document.forms[0].emailAddress.value = trimSpaces(document.forms[0].emailAddress.value);
	if(document.forms[0].emailAddress.value.length <= 0) {
		alert("Please enter your email address");
		document.forms[0].emailAddress.focus();
		return false;
	}
	if(!checkEmail(document.forms[0].emailAddress.value)) {
		document.forms[0].emailAddress.focus();
		document.forms[0].emailAddress.select();
		return false;
	}

	document.forms[0].visitorComments.value = trimSpaces(document.forms[0].visitorComments.value);
	if((document.forms[0].visitorComments.value).length <= 0) {
		alert("Please enter your comments");
		document.forms[0].visitorComments.focus();
		return false;
	}
	document.forms[0].frmAction.value = "update";
}
function checkLogin() {
	/*document.forms[0].username.value = trimSpaces(document.forms[0].username.value);
	if(document.forms[0].username.value.length <= 0) {
		alert("Please enter the username");
		document.forms[0].username.focus();
		return false;
	}*/
	document.forms[0].password.value = trimSpaces(document.forms[0].password.value);
	if(document.forms[0].password.value.length <= 0) {
		alert("Please enter password");
		document.forms[0].password.focus();
		return false;
	}
}
