function showPicture(galleryid, photoType,categoryid) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 600;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open("showPictureFrame.php?galleryid=" + galleryid + "&photoType=" + photoType + "&category="+categoryid, "picture", "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);
	window.print(self);
}
function printWindow1() {
	parent.mainFrame.focus();
	window.print(parent.mainFrame);
	window.print(self);
}


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_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 showNews(newsid, pageType,linkid) {
	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+"&linkid="+linkid, "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(fromPage) {
	
	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;
	}
	address_st = trimSpaces(document.forms[0].address_st.value);
	if(address_st.length <= 0) {
		alert("Please enter your Address.");
		document.forms[0].address_st.focus();
		return false;
	}
	address_apt = trimSpaces(document.forms[0].address_apt.value);
	if(address_apt.length <= 0) {
		alert("Please enter your Address (Suite).");
		document.forms[0].address_apt.focus();
		return false;
	}	
	city = trimSpaces(document.forms[0].city.value);
	if(city.length <= 0) {
		alert("Please enter your City.");
		document.forms[0].city.focus();
		return false;
	}		
	state = trimSpaces(document.forms[0].state.value);
	if(state.length <= 0) {
		alert("Please enter your state.");
		document.forms[0].state.focus();
		return false;	
	}
	zip = trimSpaces(document.forms[0].zip.value);
	if(zip.length <= 0) {
		alert("Please enter zip.");
		document.forms[0].zip.focus();
		return false;
	}
	country = trimSpaces(document.forms[0].country.value);
	if(country.length <= 0) {
		alert("Please enter country.");
		document.forms[0].country.focus();
		return false;	
	}
	
	county = trimSpaces(document.forms[0].county.value);
	if(county.length <= 0) {
		alert("Please enter county.");
		document.forms[0].county.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;
		}
	}*/
	if(fromPage == 'home')
	{
	document.forms[0].submit();
	}
	else
	{
	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 checkPrayer() {
	
	/*if(!checkEmail(document.forms[0].visitorEmail.value)) {
		document.forms[0].visitorEmail.focus();
		document.forms[0].visitorEmail.select();
		return false;
	}*/
	
	document.forms[0].FirstName.value = trimSpaces(document.forms[0].FirstName.value);
	if(document.forms[0].FirstName.value.length <= 0) {
		alert("Please enter your first name");
		document.forms[0].FirstName.focus();
		return false;
	}
	
	document.forms[0].LastName.value = trimSpaces(document.forms[0].LastName.value);
	if(document.forms[0].LastName.value.length <= 0) {
		alert("Please enter your last name");
		document.forms[0].LastName.focus();
		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 prayer");
		document.forms[0].visitorComments.focus();
		return false;
	}
	
	
	document.forms[0].frmAction.value = "update";
}




function checkemailSend()
{
	
  	document.forms[0].remail.value=trimSpaces(document.forms[0].remail.value);
	if(document.forms[0].remail.value.length<=0)
	 {
	 	alert("Enter Recepients Email Id");
		document.forms[0].remail.focus();
		return false;
	 }
	else
	 {
	   if(!checkEmail(document.forms[0].remail.value))
	   {
	    return false;
	   }
	 }  	 
	 
	if(document.forms[0].yemail.value.length<=0)
	 {
	 	alert("Enter your Email Id");
		document.forms[0].yemail.focus();
		return false;
	 }
	else
	 {
	   if(!checkEmail(document.forms[0].yemail.value))
	   {
	    return false;
	   }
	 }  	 
	document.forms[0].frmAction.value="update";
    return;
}

function showCalendar(frmElement, dispElement) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 375;
	winHeight = 300;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open("showCalendar.php?frmElement=" + frmElement + "&dispElement=" + dispElement, "Calendar", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=0,resizable=0");
	return;
}	
function showCoupon(galleryid) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 600;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open("showCouponFrame.php?member_coupons_id=" + galleryid , "picture", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	return;
}



function checkMemApplication() {
	
	dec_name = trimSpaces(document.forms[0].dec_name.value);
	if(dec_name.length <= 0) {
		alert("Please enter name of the deceased.");
		document.forms[0].dec_name.focus();
		return false;
	}
	
	
	dec_place = trimSpaces(document.forms[0].dec_place.value);
	if(dec_place.length <= 0) {
		alert("Please enter native place.");
		document.forms[0].dec_place.focus();
		return false;
	}
	rel_fname = trimSpaces(document.forms[0].rel_fname.value);
	if(rel_fname.length <= 0) {
		alert("Please enter relative's first name.");
		document.forms[0].rel_fname.focus();
		return false;
	}
	
	rel_lname = trimSpaces(document.forms[0].rel_lname.value);
	if(rel_lname.length <= 0) {
		alert("Please enter relative's last name.");
		document.forms[0].rel_lname.focus();
		return false;
	}
		
		
		rel_address = trimSpaces(document.forms[0].rel_address.value);
	if(rel_address.length <= 0) {
		alert("Please enter relative's address.");
		document.forms[0].rel_address.focus();
		return false;
	}
		
		
		rel_city = trimSpaces(document.forms[0].rel_city.value);
	if(rel_city.length <= 0) {
		alert("Please enter city.");
		document.forms[0].rel_city.focus();
		return false;
	}
		
		
		rel_state = trimSpaces(document.forms[0].rel_state.value);
	if(rel_state.length <= 0) {
		alert("Please enter state.");
		document.forms[0].rel_state.focus();
		return false;
	}	
			
		zip = trimSpaces(document.forms[0].zip.value);
	if(zip.length <= 0) {
		alert("Please enter zip.");
		document.forms[0].zip.focus();
		return false;
	}	
	email = trimSpaces(document.forms[0].email.value);
	if(email.length <= 0) {
		alert("Please provide your email");
		document.forms[0].email.focus();
		return false;
	}
	
if(!checkEmail(email)) {
		document.forms[0].email.focus();
		return false;
	}
		phone = trimSpaces(document.forms[0].phone.value);
	if(phone.length <= 0) {
		alert("Please enter phone no.");
		document.forms[0].phone.focus();
		return false;
	}	
	comments = trimSpaces(document.forms[0].comments.value);
	if(comments.length > 600) {
		alert("Please enter less than 600 characters in comments.");
		document.forms[0].comments.focus();
		return false;
	}

comments = trimSpaces(document.forms[0].comments.value);
	if(comments.length > 600) {
		alert("Please enter less than 600 characters in comments.");
		document.forms[0].comments.focus();
		return false;
	}
	special_req = trimSpaces(document.forms[0].special_req.value);
	if(special_req.length > 300) {
		alert("Please enter less than 300 characters in special requests.");
		document.forms[0].special_req.focus();
		return false;
	}
	
document.forms[0].frmAction.value = "update";
	document.forms[0].submit();
}