// JavaScript Document
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_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(6,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
}}

function compare(pass1,pass2){
	
	if(pass1 != pass2){
		alert("Password and Confirmed Password not match!");
		
		document.getElementById("Password").value = "";
		document.getElementById("Password2").value = "";
		document.getElementById("Password").focus();
	} else {
		checkPassLength(2)
	}
}

function compare_pass(){
		if(document.getElementById("NewPassword").value != document.getElementById("ConfirmedPassword").value){
			alert("New Password and Confirm Password not match!");
			document.getElementById("NewPassword").value = "";
			document.getElementById("ConfirmedPassword").value = "";
			document.getElementById("NewPassword").focus();
			return false;
		}
		return true;
}
function checkPassLength(qid){
	
	if(qid == 1 && document.getElementById("Password").value.length != 0){	
		if(document.getElementById("Password").value.length < 6){
			alert("Password must be 6 characters!");
			document.getElementById("Password").value = "";
			document.getElementById("Password").focus();
		}
	}
	
	if(qid == 2 && document.getElementById("Password2").value.length != 0){
		if(document.getElementById("Password2").value.length < 6){
			alert("Password must be 6 characters!");
			document.getElementById("Password2").value = "";
			document.getElementById("Password2").focus();
		}
	}
}

function checkPassLength2(qid){
	
	if(qid == 1 && document.getElementById("NewPassword").value.length != 0){	
		if(document.getElementById("NewPassword").value.length < 6){
			alert("New Password must be 6 characters!");
			document.getElementById("NewPassword").value = "";
			document.getElementById("NewPassword").focus();
		}
	}
	
	if(qid == 2 && document.getElementById("ConfirmedPassword").value.length != 0){
		if(document.getElementById("ConfirmedPassword").value.length < 6){
			alert("Confirm Password must be 6 characters!");
			document.getElementById("ConfirmedPassword").value = "";
			document.getElementById("ConfirmedPassword").focus();
		}
	}
}

function checkPhone(){
	if(isNaN(document.getElementById("Phone").value)){
		alert("This Phone field accepts numbers only!");
		document.getElementById("Phone").value = "";
		document.getElementById("Phone").focus();


	} else {
	
		if(document.getElementById("Phone").value.length < 10){
			alert("Phone Number must have 10 digits.");
			document.getElementById("Phone").value = "";
			document.getElementById("Phone").focus();
		}

	}
}
function checkTerms(){
	if(document.registration.Terms.checked == false){
		alert("Please read or check the Terms of Service before creating the JabberEmail Account");
		return false;
	}
	return true;
}

function clearFname(){
		
		if(document.getElementById("fname").value == "First Name"){
			document.getElementById("fname").value = "";
		}
}

function clearLname(){
		
		if(document.getElementById("lname").value == "Last Name"){
			document.getElementById("lname").value = "";
		}
}

function clearEmail(){
		
		if(document.getElementById("Email").value == "Email"){
			document.getElementById("Email").value = "";
		}
}

function clearQuickFind(){
		if(document.getElementById("TextSearch").value == "Quick Find"){
			document.getElementById("TextSearch").value = "";
		}
}

function deletecontact(qid,u){
		
		var ans;
		
		ans = confirm("Are you sure to delete this contact?")
		
		if(ans == true){
				window.location.href = "http://www.jabbergroups.com/deletecontacts.php?id="+qid+"&url="+u;
		}
}

function deletephoto(qid,contactID){
		
		var ans;
		
		ans = confirm("Are you sure to delete this Photo?")
		
		if(ans == true){
			window.location.href = "http://www.jabbergroups.com/uploadphoto/deletephoto.php?photoID="+qid+"&contactID="+contactID;		
		}
}

function deleteEventDoc(qid,docName,url){
		var ans = confirm("Are you sure to delete this document?");
		if(ans == true){
				window.location.href = "http://www.jabbergroups.com/deleteEventDoc.php?docID="+qid+"&docName="+docName+"&returnURL="+url;
		}
}
function deleteGroupphoto(qid,contactID){
		
		var ans;
		
		ans = confirm("Are you sure to delete this Group Photo?")
		
		if(ans == true){
			window.location.href = "http://www.jabbergroups.com/uploadphoto/deleteGroupphoto.php?photoID="+qid+"&contactID="+contactID;		
		}
}

function deleteFamily(famID,url){
		var ans ;
		ans = confirm("Are you sure to delete this Family?");
		if(ans == true){
				window.location.href = "http://www.jabbergroups.com/deletefamily.php?qid="+famID+"&url="+url;
		}
}

function deletelogo(qid,contactID){
		
		var ans;
		
		ans = confirm("Are you sure to delete this Logo?")
		
		if(ans == true){
			window.location.href = "http://www.jabbergroups.com/userAccount/deletephoto.php?logoID="+qid+"&userID="+contactID;		
		}
}


function checkPhoto(){
		if(document.getElementById("PhotoFile").value == ""){
				alert("Browse and select desired photo to be upload.");
				return false;
		}
		document.getElementById("Upload").disabled = true;
		document.getElementById("EditContacts").disabled = true;
		return true;
}

function checkNote(){
		if(document.getElementById("txtNote").value == ""){
				alert("Please type your note first.");
				return false;
		}
		return true;

}