// JavaScript Document
/////////////////////////////////afficher par page///////////


function input_page(valeur) {
	//var nom_input = nom_input;
	document.prof.page.value=valeur;
	document.prof.submit();
	//window.alert(nom_input);
}

function ShowPic(url,title,x1,y1) {

	window.open('image.php?i='+url+'&t='+title+'', 'MyWin', 'top=1,width=' + x1 + ', height=' + y1 + '');

}

function popupWindow(url) {
	window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}

function CheckLogin() {

	if(document.lform.us.value=="")
	{
		window.alert('Please Enter your Email');
		document.lform.us.focus();
		return false;
	}

	if(document.lform.ps.value=="")
	{
		window.alert('Please enter your password');
		document.lform.ps.focus();
		return false;
	}

}

function CheckForgot() {

	if(document.ForgotForm.u2.value=="")
	{
		window.alert('Enter your username, please!');
		document.ForgotForm.u2.focus();
		return false;
	}
}


////////////////////////Check Register/////////////////////////////////////
function CheckRegister() {
	

	if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.RegForm.email.value))
	{
		alert("Please enter your email address");
		document.RegForm.email.focus();
		return false;
	}

	if(document.RegForm.p1.value=="")
	{
		window.alert('Please enter your password');
		document.RegForm.p1.focus();
		return false;
	}

	if(document.RegForm.p2.value=="")
	{
		window.alert('Please confirm your password');
		document.RegForm.p2.focus();
		return false;
	}

	if(document.RegForm.p1.value != "" && document.RegForm.p2.value != "" && document.RegForm.p1.value != document.RegForm.p2.value)
	{
		window.alert('Please enter and confirm your password again');
		document.RegForm.p1.value="";
		document.RegForm.p2.value="";
		document.RegForm.p1.focus();
		return false;
	}

	if(document.RegForm.FamilyName.value=="")
	{
		window.alert('Please enter your Family name/Hamoula/Ashira');
		document.RegForm.FamilyName.focus();
		return false;
	}

	if(document.RegForm.FirstName.value=="")
	{
		window.alert('Please enter your First name');
		document.RegForm.FirstName.focus();
		return false;
	}
	
	
	if(document.RegForm.Address.value=="")
	{
		window.alert('Please enter your Address');
		document.RegForm.Address.focus();
		return false;
	}
	
	if(document.RegForm.City.value=="")
	{
		window.alert('Please enter your City');
		document.RegForm.City.focus();
		return false;
	}

	if(document.RegForm.CountryResd.value=="")
	{
		window.alert('Please enter your Country of residence');
		document.RegForm.CountryResd.focus();
		return false;
	}

	if(document.RegForm.GfatherP_Name.value=="")
	{
		window.alert('Please enter your Grandfather/ Paternal name');
		document.RegForm.GfatherP_Name.focus();
		return false;
	}

	if(document.RegForm.GfatherM_Name.value=="")
	{
		window.alert('Please enter your Grandfather/ Maternal name');
		document.RegForm.GfatherM_Name.focus();
		return false;
	}
	
	if(document.RegForm.FatherName.value=="")
	{
		window.alert('Please enter your Father name');
		document.RegForm.FatherName.focus();
		return false;
	}

	if(document.RegForm.MotherName.value=="")
	{
		window.alert('Please enter your Mother name');
		document.RegForm.MotherName.focus();
		return false;
	}

	if(document.RegForm.HometownP.value=="")
	{
		window.alert('Please enter your Home town/village in Palestine');
		document.RegForm.HometownP.focus();
		return false;
	}
		
	if(document.RegForm.CountryCtzn.value=="" && document.RegForm.UNrefugeesDoc.value=="")
	{
		window.alert('Please enter your Country of citizenship');
		document.RegForm.CountryCtzn.focus();
		return false;
	}
		
	function cmtrim(str) {
		return str.replace(/^ */,"").replace(/ *$/,"");
	}
	
	var frm = document.RegForm;
		fld = frm.UNrefugeesDoc; 
		val = cmtrim(fld.value);
		var valext = '';
		if (val!='') {
			if (val.toLowerCase().indexOf('.pdf')>=0) valext = '.pdf';
			else if (val.toLowerCase().indexOf('.doc')>=0) valext = '.doc';
			if (valext=='') {
				fld.focus();
				alert('Only PDF and DOC files are suitable for uploading to this web site.');
				return false;
			}
		}
	
		
	if(!document.RegForm.subscribe.checked)
	{
		window.alert('You have to give your authorization to the Team from the Palestine Agency / Palestine Documentation Center to represent your interests and claims in courts.');
		document.RegForm.subscribe.focus();
		return false;
	}
}



/////////////////////////Check Edit Personal Info////////////////////////////////////
function CheckEditPersonalInfo() {

	if(document.RegForm.FamilyName.value=="")
	{
		window.alert('Please enter your Family name/Hamoula/Ashira');
		document.RegForm.FamilyName.focus();
		return false;
	}

	if(document.RegForm.FirstName.value=="")
	{
		window.alert('Please enter your First name');
		document.RegForm.FirstName.focus();
		return false;
	}

	if(document.RegForm.GfatherP_Name.value=="")
	{
		window.alert('Please enter your Grandfather/ Paternal name');
		document.RegForm.GfatherP_Name.focus();
		return false;
	}

	if(document.RegForm.GfatherM_Name.value=="")
	{
		window.alert('Please enter your Grandfather/ Maternal name');
		document.RegForm.GfatherM_Name.focus();
		return false;
	}
	
	if(document.RegForm.FatherName.value=="")
	{
		window.alert('Please enter your Father name');
		document.RegForm.FatherName.focus();
		return false;
	}

	if(document.RegForm.MotherName.value=="")
	{
		window.alert('Please enter your Mother name');
		document.RegForm.MotherName.focus();
		return false;
	}

	if(document.RegForm.HometownP.value=="")
	{
		window.alert('Please enter your Home town/village in Palestine');
		document.RegForm.HometownP.focus();
		return false;
	}
	
	if(document.RegForm.CountryResd.value=="")
	{
		window.alert('Please enter your Country of residence');
		document.RegForm.CountryResd.focus();
		return false;
	}
	
	if(document.RegForm.CountryCtzn.value=="" && document.RegForm.UNrefugeesDoc.value=="")
	{
		window.alert('Please enter your Country of citizenship');
		document.RegForm.CountryCtzn.focus();
		return false;
	}
	
	if(document.RegForm.UNrefugeesDoc.value=="" && document.RegForm.CountryCtzn.value=="")
	{
		window.alert('Please enter UN refugees document');
		document.RegForm.UNrefugeesDoc.focus();
		return false;
	}
		
	if(document.RegForm.Address.value=="")
	{
		window.alert('Please enter your Address');
		document.RegForm.Address.focus();
		return false;
	}
	
	if(document.RegForm.City.value=="")
	{
		window.alert('Please enter your City');
		document.RegForm.City.focus();
		return false;
	}
	
	if(document.RegForm.PostalCode.value=="")
	{
		window.alert('Please enter your Postal code');
		document.RegForm.PostalCode.focus();
		return false;
	}
	
}



////////////////////////Check Change Password/////////////////////////////////////
function CheckChangePassword() {

	if(document.RegForm.oldpass.value=="")
	{
		window.alert('Please enter your password');
		document.RegForm.oldpass.focus();
		return false;
	}

	if(document.RegForm.p1.value=="")
	{
		window.alert('Please enter your new password');
		document.RegForm.p1.focus();
		return false;
	}

	if(document.RegForm.p2.value=="")
	{
		window.alert('Please confirm your new password');
		document.RegForm.p2.focus();
		return false;
	}

	if(document.RegForm.p1.value != "" && document.RegForm.p2.value != "" && document.RegForm.p1.value != document.RegForm.p2.value)
	{
		window.alert('Please enter and confirm your password again');
		document.RegForm.p1.value="";
		document.RegForm.p2.value="";
		document.RegForm.p1.focus();
		return false;
	}
	
}	



/////////////////////Confirm Delete/////////////////////////////////////
function ConfirmDelete(w) {

	if(confirm('Are you sure you want to delete '+w+'?'))
	{
		return true;
	}
	else
	{
		return false;
	}

}

	function toggle(id)
	{
		if (document.getElementById) { obj = document.getElementById(id); }
		if (document.all) { obj = document.all[id]; }
		if (document.layers) { obj = document.layers[id]; }
		if (obj) {
			if (obj.style.display == "none") {
				obj.style.display = "";
			} else {
				obj.style.display = "none";
			}
		}
		return false;
	}	
	
<!-- Begin
function show_hidden(id_object) {

		if (document.getElementById) { obj = document.getElementById(id_object); }
		if (document.all) { obj = document.all[id_object]; }
		if (document.layers) { obj = document.layers[id_object]; }
		if (obj) {
				obj.style.display = "";
		}
		return false;

//document.getElementById(id_object).style.height = 'auto';
//document.getElementById(id_object).style.visibility = 'visible';
}

function hide_visible(id_object) {
		if (document.getElementById) { obj = document.getElementById(id_object); }
		if (document.all) { obj = document.all[id_object]; }
		if (document.layers) { obj = document.layers[id_object]; }
		if (obj) {
				obj.style.display = "none";
		}
		return false;
	
	
//document.getElementById(id_object).style.height = '1px';
//document.getElementById(id_object).style.visibility = 'hidden';

}
//  End -->

function ConfirmDelete(w) {

	if(confirm(w))
	{
		return true;
	}
	else
	{
		return false;
	}

}


function open_url(path,wname) {
  window.open(path,wname);
}

function clearHTML(id_object){
var htmlinside = document.getElementById(id_object).innerHTML;
document.getElementById(id_object).innerHTML = '';

}