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 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 MM_swapImgRestore() { //v2.0
  if (document.MM_swapImgData != null)
    for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
      document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];
}

function MM_preloadImages() { //v2.0
  if (document.images) {
    var imgFiles = MM_preloadImages.arguments;
    if (document.preloadArray==null) document.preloadArray = new Array();
    var i = document.preloadArray.length;
    with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){
      preloadArray[i] = new Image;
      preloadArray[i++].src = imgFiles[j];
  } }
}

function MM_swapImage() { //v2.0
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
  for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {
    objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) {
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = MM_swapImage.arguments[i+2];
  } }
  document.MM_swapImgData = swapArray; //used for restore
}

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() {
	name = trimSpaces(document.forms[0].name.value);
	email = trimSpaces(document.forms[0].email.value);
	
	if(name.length <= 0) {
		alert("Please provide your name before submitting the form");
		document.forms[0].name.focus();
		return false;
	}
	
	if(email.length <= 0) {
		alert("Please provide your email address before submitting the form");
		document.forms[0].email.focus();
		return false;
	}
	
	if(!checkEmail(email)) {
		document.forms[0].email.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 checkWeddingRegistration() {

email = trimSpaces(document.forms[0].email.value);
	if(email.length > 0) {
		if(!checkEmail(email)){
			document.forms[0].email.focus();
			return false;
		}
	}

	if(trimSpaces(document.forms[0].gfullname.value).length <= 0) {
		alert("Please provide groom name");
		document.forms[0].gfullname.focus();
		return false;
	}
	if(trimSpaces(document.forms[0].gstreetaddress.value).length <= 0) {
		alert("Please provide groom's street address");
		document.forms[0].gstreetaddress.focus();
		return false;
	}
	if(trimSpaces(document.forms[0].gcity.value).length <= 0) {
		alert("Please provide groom's city");
		document.forms[0].gcity.focus();
		return false;
	}
	if(trimSpaces(document.forms[0].gstate.value).length <= 0) {
		alert("Please provide groom's state");
		document.forms[0].gstate.focus();
		return false;
	}
	if(trimSpaces(document.forms[0].gtelephone.value).length <= 0) {
		alert("Please provide groom's phone number");
		document.forms[0].gtelephone.focus();
		return false;
	}	
	if(trimSpaces(document.forms[0].bfullname.value).length <= 0) {
		alert("Please provide brides name");
		document.forms[0].bfullname.focus();
		return false;
	}
	if(trimSpaces(document.forms[0].bstreetaddress.value).length <= 0) {
		alert("Please provide brides's street address");
		document.forms[0].bstreetaddress.focus();
		return false;
	}
	if(trimSpaces(document.forms[0].bcity.value).length <= 0) {
		alert("Please provide brides's city");
		document.forms[0].bcity.focus();
		return false;
	}
	if(trimSpaces(document.forms[0].bstate.value).length <= 0) {
		alert("Please provide brides's state");
		document.forms[0].bstate.focus();
		return false;
	}
	if(trimSpaces(document.forms[0].wdate.value).length <= 0) {
		alert("Please provide wedding date");
		document.forms[0].wdate.focus();
		return false;
	}
	if(trimSpaces(document.forms[0].wtime.value).length <= 0) {
		alert("Please provide wedding time");
		document.forms[0].wtime.focus();
		return false;
	}
	if(trimSpaces(document.forms[0].wlocation.value).length <= 0) {
		alert("Please provide wedding location");
		document.forms[0].wlocation.focus();
		return false;
	}	
	document.forms[0].frmAction.value = "send";
	document.forms[0].submit();
}

function sendMail(couponid)
{	
  	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	winWidth = 450;
	winHeight = 350;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open("sendMail.php?couponid=" + couponid, "picture", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");

  //window.open("sendMail.php?volumeid=" + volId);
  return;
}

function checkSendMail() {
	senderName = trimSpaces(document.forms[0].senderName.value);
	senderEmail = trimSpaces(document.forms[0].senderEmail.value);
	receiverEmail = trimSpaces(document.forms[0].receiverEmail.value);
	if(senderName.length <= 0) {
		alert("You have to enter your name.");
		document.forms[0].senderName.focus();
		return false;
	}
	if(senderEmail.length <= 0) {
		alert("You have to enter your email address.");
		document.forms[0].senderEmail.focus();
		return false;
	}
	if(!checkEmail(senderEmail)) {
		document.forms[0].senderEmail.focus();
		return false;
	}
	if(receiverEmail.length <= 0) {
		alert("You have to enter your friend's email address.");
		document.forms[0].receiverEmail.focus();
		return false;
	}
	if(!checkEmail(receiverEmail)) {
		document.forms[0].receiverEmail.focus();
		return false;
	}
	document.forms[0].frmAction.value = "yes";
}

function printCoupon(couponid,flag){
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;

	
	winWidth = 600;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	

	window.open("showCouponFrame.php?flag=" + flag + "&couponid=" + couponid, "printCoupon", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	return;
}
function checkCouponMail() {
	senderName = trimSpaces(document.forms[0].senderName.value);
	senderEmail = trimSpaces(document.forms[0].senderEmail.value);
	receiverEmail = trimSpaces(document.forms[0].receiverEmail.value);
	if(senderName.length <= 0) {
		alert("You have to enter your name.");
		document.forms[0].senderName.focus();
		return false;
	}
	if(senderEmail.length <= 0) {
		alert("You have to enter your email address.");
		document.forms[0].senderEmail.focus();
		return false;
	}
	if(!checkEmail(senderEmail)) {
		document.forms[0].senderEmail.focus();
		return false;
	}
	if(receiverEmail.length <= 0) {
		alert("You have to enter your friend's email address.");
		document.forms[0].receiverEmail.focus();
		return false;
	}
	if(!checkEmail(receiverEmail)) {
		document.forms[0].receiverEmail.focus();
		return false;
	}
	document.forms[0].frmAction.value = "yes";
}


