function numcheck(strng) {
	var illegalChars = /[\W_]/; // allow only letters and numbers
	if (illegalChars.test(strng)) {
	 alert("Name contains iilegal letters")
	 return false
	}
	if (( (strng.search(/[0-9]+/) > -1))) 
	{
 alert("The name must contain only letters")
	return false
  }
  return true
}
function money(monstr) {
var moneypat = /^(\d{1,9}).(\d{2})?$/;

var matchArray = monstr.match(moneypat);
if (matchArray == null) {
alert("Enter Money  in valid format eg 12400.30");
return false;
    }	
return true;
}
function phone(phstr) {
if (( (phstr.search(/[A-Z]+/) > -1))|| ((phstr.search(/[a-z]+/) > -1)))
{
 alert("Phone does not contain  letters")
	return false
  }
  return true
}

function echeck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function isPassword(strng) {
	var illegalChars = /[\W_]/; // allow only letters and numbers
	if ((strng.length < 6) || (strng.length > 16)) {
	  alert("Invalid Password ! \n Length should be of 6-8 characters")
	   return false
	}
	if (illegalChars.test(strng)) {
	 alert("The password contains illegal characters")
	 return false
	}
	//if (!((strng.search(/[a-z]+/) > -1)&& (strng.search(/[A-Z]+/) > -1)&& (strng.search(/[0-9]+/) > -1)))
	if (( (strng.search(/[A-Z]+/) > -1))) 
	{
 alert("The password must contain  lowercase letters or  numeral or both \n but does not contain uppercase letters")
	return false
  }
  return true
}
var dtCh= "-";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
		//alert("Please enter an integer")
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	 var strYear=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strDay=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : yyyy-mm-dd")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}
function IsValidTime(timeStr) {
// Checks if time is in HH:MM:SS AM/PM format.
// The seconds and AM/PM are optional.

var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;

var matchArray = timeStr.match(timePat);
if (matchArray == null) {
alert("Time is not in a valid format.");
return false;
}
hour = matchArray[1];
minute = matchArray[2];
second = matchArray[4];
ampm = matchArray[6];
if (second=="") { second = null}
if (ampm=="") { ampm = null }

if (hour < 0  || hour > 23) {
alert("Hour must be between 1 and 12 for standard time OR between  0 and 23 for Military Time(24 hours)");
return false;
}
if (hour <= 12 && ampm ==null) {
if (confirm("Please indicate which time format you are using.  OK = Standard Time, CANCEL = Military Time(24 hrs)")) {
alert("Enter stardard time only.");
return false;
   }
}
if  (hour > 12 && ampm != null) {
alert ("You can't specify AM or PM for military time.");
return false;
}
if (minute<0 || minute > 59) {
alert ("Minute must be between 0 and 59.");
return false;
}
if (second != null && (second < 0 || second > 59)) {
alert ("Second must be between 0 and 59.");
return false;
}
return true;
}

 
 function updatingForm(){
	       //alert("called")
           // var Fn=document.updating.fname
		   //var Ln=document.updating.lname
			var Regno=document.updating.regno
		    var ad=document.updating.poataladdress
			var LPh=document.updating.landphone
			var MPh=document.updating.mobphone
			var Fax=document.updating.fax
			var em=document.updating.email
			var Plno=document.updating.plotno
			var Bno=document.updating.blockno
			var Str=document.updating.street
			var city=document.updating.city
			
			
			/*if (Fn.value==""){
			alert("Fill you First name")
			Fn.focus()
			return false
			}
			if(numcheck(Fn.value)==false){
		    Fn.focus()
	        return false
	         }
			 
			if (Ln.value==""){
			alert("Fill you last name")
			Ln.focus()
			return false
			}
			if(numcheck(Ln.value)==false){
		    Ln.focus()
	        return false
	         }*/
			if (Regno.value==""){
			alert("Please fil your registration number")
			Regno.focus()
			return false
			}
			
			if (ad.value==""){
			alert("Please fill your address")
			ad.focus()
			return false
			}
			
			if (LPh.value==""){
			alert("Please fill your landline number")
			LPh.focus()
			return false
			}
			if(phone(LPh.value)==false){
		    LPh.focus()
	        return false
	        }
			if (MPh.value==""){
			alert("Please fill your phone number")
			MPh.focus()
			return false
			}
			if(phone(MPh.value)==false){
		    MPh.focus()
	        return false
	        }
			if (Fax.value==""){
			alert("Please fill your fax number")
			Fax.focus()
			return false
			}
			if (em.value==""){
				alert("Please Enter your Email ID")
				em.focus()
				return false
			}
			if (echeck(em.value)==false){
				em.focus()
				return false
			}
			if (Plno.value==""){
			alert("Fill you plot number")
			Plno.focus()
			return false
			}
			if (Bno.value==""){
			alert("Please fill the block number")
			Bno.focus()
			return false
			}
			if (Str.value==""){
			alert("Please fill the street")
			Str.focus()
			return false
			}
			if(numcheck(Str.value)==false){
		    city.focus()
	        return false
	         }
			
            if (city.value==""){
			alert("Please fill the city")
			city.focus()
			return false
			}
			if(numcheck(city.value)==false){
		    city.focus()
	        return false
	         }
			
			
			//alert ("pass to end of function")
return true
 }
//---------------------------------------------------------------------------- 
 function usercpdpontsfrm(){
	       //alert("called")
           // var Fn=document.updating.fname
		   //var Ln=document.updating.lname
			var Regno=document.cpdpoint.employer
		    var ad=document.cpdpoint.yearofactivity
			var LPh=document.cpdpoint.title
			var MPh=document.cpdpoint.sponser
			var Fax=document.cpdpoint.representatives
			var em=document.cpdpoint.topic
			var Plno=document.cpdpoint.role
			var Bno=document.cpdpoint.time
			//var Str=document.usercpdponts.street
			//var city=document.usercpdponts.city
			
			
			/*if (Fn.value==""){
			alert("Fill you First name")
			Fn.focus()
			return false
			}
			if(numcheck(Fn.value)==false){
		    Fn.focus()
	        return false
	         }
			 
			if (Ln.value==""){
			alert("Fill you last name")
			Ln.focus()
			return false
			}
			if(numcheck(Ln.value)==false){
		    Ln.focus()
	        return false
	         }*/
			if (Regno.value==""){
			alert("Please fil your employer ")
			Regno.focus()
			return false
			}
			
			if (ad.value==""){
			alert("Please fill the activity")
			ad.focus()
			return false
			}
			
			if (LPh.value==""){
			alert("Please fill the title")
			LPh.focus()
			return false
			}
			
			if (MPh.value==""){
			alert("Please fill sponser(s)")
			MPh.focus()
			return false
			}
			
			if (Fax.value==""){
			alert("Please fill representatives")
			Fax.focus()
			return false
			}
			if (em.value==""){
				alert("Please Enter topic")
				em.focus()
				return false
			}
			
			if (Plno.value==""){
			alert("Fill you role")
			Plno.focus()
			return false
			}
			if (Bno.value==""){
			alert("Please enter hours in whole number")
			Bno.focus()
			return false
			}
						
            if(isInteger(Bno.value)==false){
		    Bno.focus()
	        return false
	         }
			
			
			//alert ("pass to end of function")
return true
 }
 //-------------------------------------------------------------------------
 
 function newsForm(){
	//alert("Called")
		    var Nh=document.frmnews.newsheading
			var Ns=document.frmnews.newssummary
			var Nb=document.frmnews.newsbody
			if (Nh.value==""){
			alert("Enter news heading")
			Nh.focus()
			return false
			}
			if (Ns.value==""){
			alert("Enter news summary")
			Ns.focus()
			return false
			}
			if (Nb.value==""){
			alert("Enter news dody")
			Nb.focus()
			return false
			}
return true
}
 function maressForm(){
	//alert("Called")
		    var Nh=document.frmmaress.name
			var Ns=document.frmmaress.foreword
			//var Nb=document.frmmaress.mbody
			if (Nh.value==""){
			alert("Enter name")
			Nh.focus()
			return false
			}
			if (Ns.value==""){
			alert("Enter forewords")
			Ns.focus()
			return false
			}
			//if (Nb.value==""){
			//alert("Enter dody")
			//Nb.focus()
			//return false
			//}
return true
}
 function comentForm(){
	//alert("Called")
		    var Nh=document.comentfrm.name
			var Ns=document.comentfrm.contacts
			var Nb=document.comentfrm.comments
			if (Nh.value==""){
			alert("Enter name")
			Nh.focus()
			return false
			}
			if (Ns.value==""){
			alert("Give us your contacts")
			Ns.focus()
			return false
			}
			if (Nb.value==""){
			alert("Enter the comment")
			Nb.focus()
			return false
			}
return true
}


function viewimage(img_path){
	document.getElementById('pic_holder').src=img_path;
	
	
}

function loadothers(){
	//alert ("nipo")
	var El=document.archqsapplfrm.edulevel
	if (El.value=="Other"){
		//alert ("nipo")
		   var jl="If others specify ";
			var jm="<input type=\"text\" name=\"ifother\" size=\"40\" >";
			document.getElementById('m').innerHTML=jm;
			document.getElementById('l').innerHTML=jl;
			El.focus()
			return false
			}else{
				var jl="";
				var jm="";
				document.getElementById('l').innerHTML=jl;
				document.getElementById('m').innerHTML=jm;
				El.focus()
				}
			return true
}
/* function loadlevel(){
    //alert ("nipo")
	 var lv=document.archapplfrm.level
	if (lv.value=="Architect"){
			alert("Enter name")
	 var le="<input type=\"radio\" name=\"category\" value=\"Local\" checked>Local ";
       
          var fa=" <input type=\"radio\" name=\"category\" value=\"Foreign\" >Foreigner ";
			document.getElementById('ct').innerHTML=le;
			document.getElementById('f').innerHTML=fa;
			lv.focus()
			return false
			}else{
				var le="";
				var fa="";
				document.getElementById('ct').innerHTML=le;
			    document.getElementById('f').innerHTML=fa;
				El.focus()
				}
			return true
}*/	


function qsindividualapplfrm(){
	//alert ("nipo")
            var Fn=document.archqsapplfrm.fname
			var Mn=document.archqsapplfrm.mname
			var Ln=document.archqsapplfrm.lname
			//var Fin=document.applfrm.firmname
			//var Ew=document.applfrm.employedwith
		    var ad=document.archqsapplfrm.poataladdress
			var LPh=document.archqsapplfrm.landphone
			var MPh=document.archqsapplfrm.mobphone
			var fx=document.archqsapplfrm.fax
			var em=document.archqsapplfrm.email
			var Pt=document.archqsapplfrm.plotno
			var Bn=document.archqsapplfrm.blockno
			var St=document.archqsapplfrm.street
			var Ct=document.archqsapplfrm.city
			var El=document.archqsapplfrm.edulevel
			var Io=document.archqsapplfrm.ifother
			var Co=document.archqsapplfrm.college
			var Cn=document.archqsapplfrm.country
			var Io=document.archqsapplfrm.category
			var Al=document.archqsapplfrm.level
			
			
			
		if (Fn.value==""){
			alert("Fill you First name")
			Fn.focus()
			return false
			}
			if(numcheck(Fn.value)==false){
		    Fn.focus()
	        return false
	         }
			if (Mn.value==""){
			
			}else{
			if(numcheck(Mn.value)==false){
		    Mn.focus()
	        return false
	         } 
			}
			if (Ln.value==""){
			alert("Fill you last name")
			Ln.focus()
			return false
			}
			if(numcheck(Ln.value)==false){
		    Ln.focus()
	        return false
	         }
			 
			if (LPh.value==""){
			
			}
			else{
			if(phone(LPh.value)==false){
		    LPh.focus()
	        return false
	          }
			}
			if (MPh.value==""){
			
			}else{
			if(phone(MPh.value)==false){
		    MPh.focus()
	        return false
	        }
			}
			if (em.value==""){
			alert("Enter email")
			em.focus()
			return false
				
			}
			
			if (echeck(em.value)==false){
				em.focus()
				return false
			 }
			
			if (Pt.value==""){
			alert("Enter house number")
			Pt.focus()
			return false
			}
			
            if (Bn.value==""){
			alert("Please enter block number")
			Bn.focus()
			return false
			}
			if (St.value==""){
			alert("Enter street name")
			St.focus()
			return false
			}
			if (Ct.value==""){
			alert("Enter street name")
			Ct.focus()
			return false
			}
			if (El.value=="-select level-"){
			alert("Select level your of education")
			El.focus()
			return false
			}
			
			if (Co.value==""){
			alert("Please enter institution")
			Co.focus()
			return false
			}
			if (Cn.value==""){
			alert("Select country")
			Cn.focus()
			return false
			}
			if (Al.value=="-select-"){
			alert("What are u applying for?")
			Al.focus()
			return false
			}
			
			
			
			
			
			
			
			//if(isyear(Sy.value)==false){
		   // Sy.focus()
	       // return false
	        // }
			
			
			
			//alert ("pass to end of function")
return true

   }

function individualapplfrm(){
	//alert("mimi")
            var Fn=document.archqsapplfrm.fname
			var Mn=document.archqsapplfrm.mname
			var Ln=document.archqsapplfrm.lname
			//var Fin=document.applfrm.firmname
			//var Ew=document.applfrm.employedwith
		    var ad=document.archqsapplfrm.poataladdress
			var LPh=document.archqsapplfrm.landphone
			var MPh=document.archqsapplfrm.mobphone
			var fx=document.archqsapplfrm.fax
			var em=document.archqsapplfrm.email
			var Pt=document.archqsapplfrm.plotno
			var Bn=document.archqsapplfrm.blockno
			var St=document.archqsapplfrm.street
			var Ct=document.archqsapplfrm.city
			var El=document.archqsapplfrm.edulevel
			var Io=document.archqsapplfrm.ifother
			var Co=document.archqsapplfrm.college
			var Cn=document.archqsapplfrm.country
			var Io=document.archqsapplfrm.category
			var Al=document.archqsapplfrm.level
			
			
			
			if (Fn.value==""){
			alert("Fill you First name")
			Fn.focus()
			return false
			}
			if(numcheck(Fn.value)==false){
		    Fn.focus()
	        return false
	         }
			if (Mn.value==""){
			
			}else{
			if(numcheck(Mn.value)==false){
		    Mn.focus()
	        return false
	         } 
			}
			if (Ln.value==""){
			alert("Fill you last name")
			Ln.focus()
			return false
			}
			if(numcheck(Ln.value)==false){
		    Ln.focus()
	        return false
	         }
			 
			if (LPh.value==""){
			
			}
			else{
			if(phone(LPh.value)==false){
		    LPh.focus()
	        return false
	          }
			}
			if (MPh.value==""){
			
			}else{
			if(phone(MPh.value)==false){
		    MPh.focus()
	        return false
	        }
			}
			if (em.value==""){
			alert("Enter email")
			em.focus()
			return false
				
			}
			
			if (echeck(em.value)==false){
				em.focus()
				return false
			 }
			
			if (Pt.value==""){
			alert("Enter house number")
			Pt.focus()
			return false
			}
			
            if (Bn.value==""){
			alert("Please enter block number")
			Bn.focus()
			return false
			}
			if (St.value==""){
			alert("Enter street name")
			St.focus()
			return false
			}
			if (Ct.value==""){
			alert("Enter street name")
			Ct.focus()
			return false
			}
			
			if (El.value=="-select level-"){
			alert("Select level your of education")
			El.focus()
			return false
			}
			
			if (Co.value==""){
			alert("Please enter institution")
			Co.focus()
			return false
			}
			if (Cn.value==""){
			alert("Select country")
			Cn.focus()
			return false
			}
			if (Al.value=="-select-"){
			alert("What are u applying for?")
			Al.focus()
			return false
			}
			
			
			
			
			//if(isyear(Sy.value)==false){
		   // Sy.focus()
	       // return false
	        // }
			
			
			
			//alert ("pass to end of function")
return true
}

function archfirmreg(){
	//alert ("called")
	        var Fn=document.firmreg.fname
           // var ad=document.firmreg.poataladdress
			var LPh=document.firmreg.landphone
			var MPh=document.firmreg.mobphone
			var fx=document.firmreg.fax
			var em=document.firmreg.email
			var Pt=document.firmreg.plotno
			var Bn=document.firmreg.blockno
			var St=document.firmreg.street
			var Tw=document.firmreg.town
			
				if (Fn.value==""){
			alert("Fill the firm name")
			Fn.focus()
			return false
			}
			if(numcheck(Fn.value)==false){
		    Fn.focus()
	        return false
	         }
			
			if (LPh.value==""){
			
			}
			else{
			if(phone(LPh.value)==false){
		    LPh.focus()
	        return false
	          }
			}
			if (MPh.value==""){
			
			}
			else{
			if(phone(MPh.value)==false){
		    MPh.focus()
	        return false
	          }
			}
			
			if(phone(MPh.value)==false){
		    MPh.focus()
	        return false
	        }
			if (em.value==""){
			alert("Please fill your email")
			em.focus()
			return false
			}
			if (echeck(em.value)==false){
				em.focus()
				return false
			 }
		    if (Pt.value==""){
			alert("Enter house/plot number")
			Pt.focus()
			return false
			}
			
            if (Bn.value==""){
			alert("Please enter block number")
			Bn.focus()
			return false
			}
			if (St.value==""){
			alert("Enter street name")
			St.focus()
			return false
			}
			if (Tw.value==""){
			alert("Enter street name")
			Tw.focus()
			return false
			}
			
return true	
}

function eventfrm(){
	 var dc=document.eventefrm.edate
	 var En=document.eventefrm.evente
	  if (dc.value==""){
			alert("Fill the date of the event")
			dc.focus()
			return false
			}
	 if (En.value==""){
			alert("Fill the firm name")
			En.focus()
			return false
			}
		return true
}

function winclose()
{
window.close();
}
