function closeWindow() {
	parent.window.opener.window.focus();
	parent.window.close();
}

function printWindow() 
{
	window.print();
}

function ChkReg(f){
	f.first_name.value = trimSpaces(f.first_name.value);
	if(f.first_name.value.length <= 0) {
		alert("Please enter your first name");
		f.first_name.focus();
		return false;
	}
	f.last_name.value = trimSpaces(f.last_name.value);
	if(f.last_name.value.length <= 0) {
		alert("Please enter your last name");
		f.last_name.focus();
		return false;
	}
	f.email.value = trimSpaces(f.email.value);
	if(!checkEmail(f.email.value)) {
		f.email.focus();
		return false;
	}
	
	f.city.value = trimSpaces(f.city.value);
	if(f.city.value.length <= 0) {
		alert("Please enter your city");
		f.city.focus();
		return false;
	}
	count = trimSpaces(f.country.options[f.country.selectedIndex].value);
	if(count.length <= 0) {
		alert("Please enter your country");
		f.country.focus();
		return false;
	}
	if(trimSpaces(f.birth_mon.options[f.birth_mon.selectedIndex].value).length <= 0) 
	{
		alert("Please select the birth month");
		f.birth_mon.focus();
		return false;
	}	
	if(trimSpaces(f.birth_year.options[f.birth_year.selectedIndex].value).length <= 0) 
	{
		alert("Please select the birth year");
		f.birth_year.focus();
		return false;
	}	
	f.folder_name.value = trimSpaces(f.folder_name.value);
	if(f.folder_name.value.length <= 0) {
		alert("Please enter your folder name");
		f.folder_name.focus();
		return false;
	}
/*	if(f.flag.value == 'exist'){
		alert("Please enter another folder name");
		f.folder_name.focus();
		return false;
	}*/
	
}


function ChkMsgFrm(f){
	var flag	= 0;
	f.first_name.value = trimSpaces(f.first_name.value);
	if(f.first_name.value.length <= 0) {
		alert("Please enter your first name");
		f.first_name.focus();
		return false;
	}
	for(i=0;i<2;i++){
		if(f.email_type[i].checked && flag == 0){
			flag	=	1;
		}
	}
	if(flag == 0){
		alert("Please select your email type ");
		return false;
	}
	if(f.email_type[0].checked){
		f.email.value = trimSpaces(f.email.value);
		if(!checkEmail(f.email.value)) {
			f.email.focus();
			return false;
		}
	}else{
		if(f.yspan.value.length <= 0) {
			alert("Please enter your yspan id");
			f.yspan.focus();
			return false;
		}
	}
	
	f.subject.value = trimSpaces(f.subject.value);
	if(f.subject.value.length <= 0) {
		alert("Please enter your subject");
		f.subject.focus();
		return false;
	}
	
	if(trimSpaces(getEditorValue('contents')) == "") {
		alert("Enter message");
		return false;
	}
	
	f.checkno.value = trimSpaces(f.checkno.value);
	if(f.checkno.value.length <= 0) {
		alert("Please enter your the number as seen in the image above");
		f.checkno.focus();
		return false;
	}
}

function showPhoto(photoUrl) {
	//photoUrl="../"+photoUrl;
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 600;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	
	window.open("showIcon.php?iconUrl=" + photoUrl,"photoURL","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}
function openNewWindow(pagepath) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 550;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	window.open(pagepath,"Details","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}
	function del(f,c){
		count		=	c;
		flag		=	0;
		if(count==0){
			alert("Nothing to delete");
			return false;
		}
		if(count>1){
			for(i=0;i<count;i++){
				if(f.elements["delid[]"][i].checked&&flag==0){
					flag	=	1;
				}
		
			}
		}else if(count==1)		
			if(f.elements["delid[]"].checked&&flag==0){
				flag	=	1;
			}
		if(flag == 0){
			alert("Nothing selected for deletion");
			return false;
		}else{
			if(!confirm("Do you really want to delete these items?")) {
				return false;
			}
		}
		
		f.frmAction.value='delete';
		f.submit();
	}
function ChkEmails(f,countNew,count){
	flag		=	0;
	flagNew		=	0;

	if(countNew>1){
		for(i=0;i<countNew;i++){
			if(f.elements["emailnew[]"][i].value&&flagNew==0){
				flagNew	=	1;
			}
	
			if(f.elements["emailnew[]"][i].value){
				if(!checkEmail(f.elements["emailnew[]"][i].value)){
					f.elements["emailnew[]"][i].select();
					return false;
				}
			}
		}
	}else if(countNew==1)
		 if(f.elements["emailnew[]"].value&&flagNew==0){
			flagNew	=	1;
		 }
		
	if(count>1){
		for(i=0;i<count;i++){
			if(f.elements["email[]"][i].value&&flag==0){
				flag	=	1;
			}
	
			if(f.elements["email[]"][i].value){
				if(!checkEmail(f.elements["email[]"][i].value)){
					f.elements["email[]"][i].select();
					return false;
				}
			}
		}
	}else if(count==1){
		 if(f.elements["email[]"].value&&flag==0){
			flag	=	1;
		 }
	}
	if(!(flag||flagNew)){
		alert("No Emails to add/update");
		return false;
	}
}	
function Login(f){
	f.username.value = trimSpaces(f.username.value);
	if(!checkEmail(f.username.value)) {
		f.username.focus();
		return false;
	}
	f.password.value = trimSpaces(f.password.value);
	if(f.password.value.length <= 0) {
		alert("Please enter your login password");
		f.password.focus();
		return false;
	}
	
}