// JavaScript Document

function show_result(z)
{
	document.getElementById('preloader').style.visibility = 'hidden';
    var x = document.getElementById('check');
	
	if(z==1)
	   x.innerHTML="<font color='#FF0000'>Not Available</font>";
	else
	   x.innerHTML="<font color='#A6C052'>Available</font>";
}



function validate()
{
  var name=document.getElementById("name").value;
  var gender=document.getElementById("gender");
  var gender1=gender.options[gender.selectedIndex].text;
  var day=document.getElementById("day");
  var day1=day.options[day.selectedIndex].text;
  var month=document.getElementById("month");
  var month1=month.options[month.selectedIndex].text;
  var year=document.getElementById("year");
  var year1=year.options[year.selectedIndex].text;
  var nationality=document.getElementById("nationality").value;
  var conPhone=document.getElementById("conPhone").value;
  var at=document.getElementById("email").value.indexOf("@");
  var email=document.getElementById("email").value; 
  var selected_Cat = document.getElementById("selected_Cat").value;
  var fresh=document.getElementById("fresh");
  var fresh1=fresh.options[fresh.selectedIndex].text; 
  var username=document.getElementById("username").value;
  var pass=document.getElementById("pass").value;
  var confpass=document.getElementById("confpass").value;
  
  submitOK="true";
  
  if(name.length<1)
  {
    alert("Name field can't be blank");
    submitOK="false";
    document.getElementById("name").focus();
    return false;
  }
  
  if(gender1.match("Select"))
  {
    alert("Select your Gender");
    submitOK="false";
    document.getElementById("gender").focus();
    return false;
  }
 
  if(day1.match("Day") || month1.match("Month") || year1.match("Year"))
  {
    alert("Select your Date of Birth");
    submitOK="false";
    return false;
  }
  
  if(nationality.length<1)
  {
    alert("Nationality field can't be blank");
    submitOK="false";
    document.getElementById("nationality").focus();
    return false;
  }
  
  if(conPhone.length<1)
  {
    alert("Contact phone field can't be blank");
    submitOK="false";
    document.getElementById("conPhone").focus();
    return false;
  }

  if(email.length<1)
  {
    alert("Email field can't be blank");
    submitOK="false";
    document.getElementById("email").focus();
    return false;
  }

  if(at==-1)
  {
    alert("Not a valid e-mail address!");
    submitOK="false";
    document.getElementById("email").focus();
    return false;
  }
  
  if(username.length<1)
  {
    alert("Username field can't be blank");
    submitOK="false";
    document.getElementById("username").focus();
    return false;
  }

  if(pass.length<1)
  {
    alert("Password field can't be blank");
    submitOK="false";
    document.getElementById("pass").focus();
    return false;
  }

  if(confpass.length<1)
  {
    alert("Confirm Password field can't be blank");
    submitOK="false";
    document.getElementById("confpass").focus();
    return false;
  }

  if(pass != confpass)
  {
    alert("Password Can't match");
    document.getElementById("confpass").focus();
    return false;
  }
 
  if(selected_Cat.length<1)
  {
    alert("Area of Interest field can't be blank");
    submitOK="false";
    return false;
  }

  //---Educational Information---//
  
  var education="";
  var tag=0;
  var index = document.getElementById("edu").value;
 
  for(i=1;i<=index;i++)
  {
     text = "degree"+i;
	 text1 = "major"+i;
	 text2 = "year"+i;
	 text3 = "institution"+i;
	 text4 = "division"+i;
	 
	 var a=document.getElementById(text);
     var a1=a.options[a.selectedIndex].text;
	 if(a1.match("Other"))
	    a1= document.getElementById("degr"+i).value;
	 var b=document.getElementById(text1);
     var b1=b.options[b.selectedIndex].text;
	 if(b1.match("Others"))
	    b1= document.getElementById("maj"+i).value;
	 var c=document.getElementById(text2);
     var c1=c.options[c.selectedIndex].text;
	 var d=document.getElementById(text3).value;
	 var e=document.getElementById(text4);
     var e1=e.options[e.selectedIndex].text;
	 if(e1.match("Grade"))
	 {
	    if(a1.match("A Level") || a1.match("O Level"))
		{
		   var sg = document.getElementById("subgr"+i).value;
		   
		   if(sg.length<1)
	       {
	          alert("Educational Information : All fields are required!");
	          submitOK="false";
	          return false;  
	       }
		   
		   e1= e1+"x|x"+sg;
		}
		else
		{
		   var cgpa = document.getElementById("cgpa"+i).value;
		   var out = document.getElementById("out"+i).value;
		   var f=document.getElementById("gr"+i);
           var f1=f.options[f.selectedIndex].text;  
		
		   if(cgpa.length<1 || out.length<1)
	       {
	          alert("Educational Information : All fields are required!");
	          submitOK="false";
	          return false;  
	       }
	  
		   e1= e1+"x|x"+cgpa+"x|x"+out+"x|x"+f1;
		}
     }
	 else if(e1.match("Appeared"))
	    e1="Appeared";
	 else if(e1.match("Select"))
	    e1="Select";	
     else
	 { 
		var mark = document.getElementById("mark"+i).value;
		
		if(mark.length<1)
	    {
	      alert("Educational Information : All fields are required!");
	      submitOK="false";
	      return false;  
	    }
		
		e1=e1+"x|x"+mark;		
	 }	
		 
	 if(a1.match("Select") || a1.length<1 || b1.match("Select") || b1.length<1 || c1.match("Select") || d.length<1 || e1 == "Select")
	 {
	   alert("Educational Information : All fields are required!");
	   submitOK="false";
	   return false;  
	 }
	  
	 if(tag==0)
	 {
	    education=a1+"$|$"+b1+"$|$"+c1+"$|$"+d+"$|$"+e1;
		tag=1; 
	 }
	 else
	    education=education+"~|~"+a1+"$|$"+b1+"$|$"+c1+"$|$"+d+"$|$"+e1;
  }
  document.getElementById("education_detail").value=education;
  
  //---End---//
  
  //---Work Experience/Employment Information---//
  
  if(fresh1.match("Yes"))
  {   
   var job="";
   var tag=0;
   var index = document.getElementById("jobi").value;
  
   for(i=1;i<=index;i++)
   {
     text1="designation"+i;
	 text2="comname"+i;
	 text3="fd"+i;
	 text4="fm"+i;
	 text5="fy"+i;
	 text9="jobresponsibility"+i;
	 
	 
	 if(i==1)
	 {
		var p=document.getElementById("jobperiod");
        var p1=p.options[p.selectedIndex].text; 
		if(p1.match("Present Job") || p1.match("Select"))
	    {
	       var f1="Present Job";
		   var g1="";
		   var h1="";
	    }
		else
		{
		   var f=document.getElementById("td1");
           var f1=f.options[f.selectedIndex].text;
		   var g=document.getElementById("tm1");
           var g1=g.options[g.selectedIndex].text;
	       var h=document.getElementById("ty1");
           var h1=h.options[h.selectedIndex].text; 	
		}
	 }
	 else
	 {
		text6="td"+i;
	    text7="tm"+i;
	    text8="ty"+i;
		   
		var f=document.getElementById(text6);
        var f1=f.options[f.selectedIndex].text;
		var g=document.getElementById(text7);
        var g1=g.options[g.selectedIndex].text;
	    var h=document.getElementById(text8);
        var h1=h.options[h.selectedIndex].text; 
	 }
	   
	 var a=document.getElementById(text1).value;
	 var b=document.getElementById(text2).value;
	 var c=document.getElementById(text3);
     var c1=c.options[c.selectedIndex].text;
	 var d=document.getElementById(text4);
     var d1=d.options[d.selectedIndex].text;
	 var e=document.getElementById(text5);
     var e1=e.options[e.selectedIndex].text;
	 var k=document.getElementById(text9).value;
	 
	 if(a.length<1 || b.length<1 || c1.match("Day") || d1.match("Month") || e1.match("Year") || f1.match("Day") || g1.match("Month") || h1.match("Year") || p1.match("Select") || k.length<1)
	 {
	   alert("Work Experience/Employment Information : All fields are required!");
	   submitOK="false";
	   return false;  
	 }
	 
	 from=c1+"-"+d1+"-"+e1;
	 to=f1+"-"+g1+"-"+h1;
	 
	 if(tag==0)
	 {
	   job=a+"$|$"+b+"$|$"+from+"$|$"+to+"$|$"+k;
	   tag=1;   
	 }
	 else
	   job=job+"~|~"+a+"$|$"+b+"$|$"+from+"$|$"+to+"$|$"+k;
   }
   document.getElementById("work_exp").value=job;
 }
 else
   document.getElementById("work_exp").value="";
   
 //---End---// 

 if (submitOK=="false")
 {
   return false
 }
}

function is_loaded()
{ //DOM

	if(document.getElementById)
	   document.getElementById('chakri_ad_content').style.visibility = 'visible';
	else
	{
		if(document.layers)
		   document.chakri_ad_content.visibility = 'visible';
		else
		   document.all.chakri_ad_content.style.visibility = 'visible';
	}
}

function append(fromSel,theSel,hID,maxSize)
{
   var selIndex;
   var IDCollection;
   var TempID;
   FSel=document.getElementById(fromSel);
   TSel=document.getElementById(theSel);

   selIndex = FSel.selectedIndex;
				
   if(maxSize>TSel.length)
   {
     if(selIndex>=0)
     {
	   newValue=FSel.options[selIndex].value;
	   newText=FSel.options[selIndex].text;
			
	   for(i = 0 ; i < TSel.length ; i++)// find duplicate
	   {									
		 if(newValue==TSel.options[i].value) 
		 { 
			return false;
		 }
	   }//end for
						
	   var newOpt1 = new Option(newText, newValue);
				
	   TSel.options[TSel.length] = newOpt1;
				
	   TSel.selectedIndex =TSel.length-1;
	   IDCollection=ListBox_IDCollection(theSel);
	   document.getElementById(hID).value=IDCollection;
			
     }
   }
   else
      alert("You cann't add more than 3 categories!");			
}

function remove(tSel,hID)
{
  theSel=document.getElementById(tSel);
  var selIndex = theSel.selectedIndex;
  if (selIndex != -1)
	 { 
		  if(theSel.options[selIndex].selected)
				  {
					theSel.options[selIndex] = null;//alert(selIndex)
				  }
					
			if (theSel.length > 0)
			{
			  theSel.selectedIndex = selIndex == 0 ? 0 : selIndex - 1;
			}	
			document.getElementById(hID).value=ListBox_IDCollection(tSel);
									
  }//outer if
 }
 
function ListBox_IDCollection(theSel)
{
   var TempID;	
   var TSel;
   TempID="";
   TSel=document.getElementById(theSel);	
   if(TSel.length>0)
   {				
	  for(i=0; i<TSel.length; i++)
	  {
		  if(TempID != "") //add new id to temp id
		  { 
			 TempID = TempID  + ", " + TSel.options[i].value;
		  }	
		  else
		  { 
			 TempID = TSel.options[i].value;
		  }
	  }//end for
			
   }//outer if
		
   return TempID;
}

function insert_degree(i)
{  
   document.getElementById("edu").value = i;
   var x=document.getElementById('education').insertRow(i);
   var y=x.insertCell(0);
   y.align='left';
   y.vAlign='top';
   y.innerHTML="<select size='1' id='degree"+i+"' name='degree"+i+"' onChange='show_degree(this.parentNode.parentNode.rowIndex);' class='dropdown' style='width:100px;'><option>Select</option><option>A Level</option><option>ACA/ACMA</option><option>B A(Hons)</option><option>B A(Pass)</option><option>B Ag</option><option>B Arch</option><option>BBA</option><option>B Com(Hons)</option><option>B Com(Pass)</option><option>B Ed(Hons)</option><option>B Ed(Pass)</option><option>BFA</option><option>B Sc(Engr)</option><option>B Sc(Hons)</option><option>B Sc(Pass)</option><option>BSS(Hons)</option><option>BSS(Pass)</option><option>Bachelor</option><option>CA</option><option>Diploma</option><option>FCA/FCMA</option><option>HSC</option><option>LLB(Hons)</option><option>LLB(Pass)</option><option>LLM</option><option>M A</option><option>M Ag</option><option>M Arch</option><option>MBA</option><option>M Com</option><option>M Ed</option><option>MFA</option><option>MSS</option><option>M Sc</option><option>M Sc(Engr)</option><option>Masters</option><option>MBBS</option><option>O Level</option><option>Ph D</option><option>SSC</option><option>Other</option></select><span id='sp_degree"+i+"'></span>";
   var z=x.insertCell(1);
   z.align='left';
   z.vAlign='top';
   z.innerHTML="<select id='major"+i+"' name='major"+i+"' onChange='show_major(this.parentNode.parentNode.rowIndex);' class='dropdown' style='width:240px;'><option selected='selected'>Select</option><option>Accounting & Information System</option><option>Agronomy & Agricultural Studies</option><option>Animal Husbandry & Veterinary Science</option><option>Anthropology</option><option>Applied Chemistry & Chemical Technology</option><option>Applied Physics & Electronics</option><option>Applied Statistics</option><option>Arabic</option><option>Architecture</option><option>Arts Group</option><option>Banking</option><option>Bengali</option><option>Biochemistry and Molecular Biology</option><option>Botany</option><option>Business Economics</option><option>Chemical Engineering</option><option>Chemistry</option><option>Civil Engineering</option><option>Clinical Pharmacy and Pharmacology</option><option>Clinical Psychology</option><option>Commerce Group</option><option>Computer Science and Engineering</option><option>Developement Studies</option><option>Economics</option><option>Education and Research</option><option>Electrical & Electronic Engineering</option><option>Electronics & Communication Engineering</option><option>English</option><option>Finance</option><option>Fine Arts</option><option>Fisheries</option><option>Folklore</option><option>Forestry</option><option>Genetic Engineering and Bio-Technology</option><option>Geography & Environment</option><option>Geology</option><option>Health Economics</option><option>History</option><option>Human Resource Management</option><option>Humanities</option><option>Industrial & Production Engineering</option><option>Information Science & Library Management</option<option>Interior Design</option><option>International Relations</option><option>Islamic History & Culture</option><option>Islamic Studies</option><option>Linguistics</option><option>Management</option><option>Management Information System</option><option>Marketing</option><option>Mass Communication & Journalism</option><option>Materials & Metallurgical Engineering</option><option>Mathematics</option><option>Mechanical Engineering</option><option>Medicine</option><option>Microbiology</option><option>Mineralogy  and Petroleum Technology</option><option>Naval Architecture & Marine Engineering</option><option>Nutrition and Food Sciences</option><option>Peace and Conflict Studies</option><option>Petroleum & Mineral Resources Engineering</option><option>Pharmaceutical Chemistry</option><option>Pharmacy</option><option>Philosophy</option><option>Physics</option><option>Political Science</option><option>Polymer Science</option><option>Population Science</option><option>Psychology</option><option>Public Administration</option><option>Sanskrit & Pali</option><option>Science Group</option><option>Social Welfare and Research</option><option>Sociology</option><option>Soil, Water & Environment</option><option>Statistics</option><option>Strategic Management</option><option>Tea Technology</option><option>Telecommunications</option><option>Textile Engineering</option><option>Theater & Music</option><option>Urban & Regional Planning</option><option>Urdu & Persian</option><option>Women Studies</option><option>World Religions</option><option>Zoology</option><option>Others</option></select><span id='sp_major"+i+"'></span>";
   var a=x.insertCell(2);
   a.align='left';
   a.vAlign='top';
   var msg="<select id='year"+i+"' name='year"+i+"' class='dropdown' style='width:70px;'><option selected='selected'>Select</option>";
   for(j=1950;j<2011;j++)
      msg = msg+"<option>"+j+"</option>";
   a.innerHTML = msg+"</select>";
   var b=x.insertCell(3);
   b.align='left';
   b.vAlign='top';
   b.innerHTML="<input id='institution"+i+"' name='institution"+i+"' type='text' class='textbox' style='width:170px;'/>";
   var c=x.insertCell(4)
   c.align='left';
   c.vAlign='top';
   c.innerHTML="<select id='division"+i+"' name='division"+i+"' onChange='show_marks(this.parentNode.parentNode.rowIndex);' class='dropdown' style='width:80px;'><option>Select</option><option>First</option><option>Second</option><option>Third</option><option>Grade</option><option>Appeared</option></select><span id='sp_division"+i+"'></span>";
}

function delete_degree(i)
{
   var index=i-1;
   
   if(index>1)
   {
      document.getElementById("edu").value = index-1;
	  document.getElementById('education').deleteRow(index);
   }
   else
      alert("You have to fill atleast 1 educational qualification.");	  
}

function insert_job(i)
{
   var index = (i/6)+1;
   document.getElementById("jobi").value = index;
   var x=document.getElementById('jobtitle').insertRow(i);
   var y=x.insertCell(0);
   y.align='left';
   y.innerHTML="Designation";
   var z=x.insertCell(1);
   z.align='left';
   z.innerHTML="<input id='designation"+index+"' name='designation"+index+"' type='text' class='textbox' style='width:120px;'/>";
   
   var c=document.getElementById('jobtitle').insertRow(++i);
   var y=c.insertCell(0);
   y.align='left';
   y.innerHTML="Company Name";
   var z=c.insertCell(1);
   z.align='left';
   z.innerHTML="<input id='comname"+index+"' name='comname"+index+"' type='text' class='textbox' id='pass4' style='width:120px;'/>";
   
   var r=document.getElementById('jobtitle').insertRow(++i);
   var y=r.insertCell(0);
   y.align='left';
   y.vAlign='top';
   y.innerHTML="Job Responsibility";
   var z=r.insertCell(1);
   z.align='left';
   z.innerHTML="<textarea class='textarea' name='jobresponsibility"+index+"' id='jobresponsibility"+index+"' style='width:200px; height:40px; overflow:auto;'></textarea>";
   
   var f=document.getElementById('jobtitle').insertRow(++i);
   var y=f.insertCell(0);
   y.align='left';
   y.innerHTML="From";
   var z=f.insertCell(1);
   z.align='left';
   var msg="<select id='fd"+index+"' name='fd"+index+"' class='dropdown' style='width:50px;'><option selected='selected'>Day</option>";
   for(j=1;j<=31;j++)
       msg = msg+"<option>"+j+"</option>";
   msg = msg+"</select>"; 
   msg = msg+"<select id='fm"+index+"' name='fm"+index+"' class='dropdown' style='width:62px;'><option selected='selected'>Month</option><option>Jan</option><option>Feb</option><option>Mar</option><option>Apr</option><option>May</option><option>Jun</option><option>Jul</option><option>Aug</option><option>Sep</option><option>Oct</option><option>Nov</option><option>Dec</option></select>";
   msg = msg+"<select id='fy"+index+"' name='fy"+index+"' class='dropdown' style='width:52px;'><option selected='selected'>Year</option>";	
   for(j=1950;j<2011;j++)
       msg = msg+"<option>"+j+"</option>";
   msg = msg+"</select>"; 
   z.innerHTML = msg;
   
   var t=document.getElementById('jobtitle').insertRow(++i);
   var y=t.insertCell(0);
   y.align='left';
   y.innerHTML="To";
   var z=t.insertCell(1);
   z.align='left';
   var msg1="<select id='td"+index+"' name='td"+index+"' class='dropdown' style='width:50px;'><option selected='selected'>Day</option>";
   for(j=1;j<=31;j++)
       msg1 = msg1+"<option>"+j+"</option>";
   msg1 = msg1+"</select>"; 
   msg1 = msg1+"<select id='tm"+index+"' name='tm"+index+"' class='dropdown' style='width:62px;'><option selected='selected'>Month</option><option>Jan</option><option>Feb</option><option>Mar</option><option>Apr</option><option>May</option><option>Jun</option><option>Jul</option><option>Aug</option><option>Sep</option><option>Oct</option><option>Nov</option><option>Dec</option></select>";
   msg1 = msg1+"<select id='ty"+index+"' name='ty"+index+"' class='dropdown' style='width:52px;'><option selected='selected'>Year</option>";	
   for(j=1950;j<2011;j++)
       msg1 = msg1+"<option>"+j+"</option>";
   msg1 = msg1+"</select>";
   z.innerHTML=msg1;
   
   var h=document.getElementById('jobtitle').insertRow(++i);
   var y=h.insertCell(0);
   y.innerHTML="<hr style='height:1px; text-align:left; color:#A6C052;' />";
   var z=h.insertCell(1);
   z.innerHTML="<hr style='width:250px; height:1px; text-align:left; color:#A6C052;' />";
}

function delete_job(i)
{
   var index=(i/6)+1;
   
   if(--index>1)
   {
	  document.getElementById("jobi").value=--index;
	  document.getElementById('jobtitle').deleteRow(--i);
	  document.getElementById('jobtitle').deleteRow(--i);
	  document.getElementById('jobtitle').deleteRow(--i);
	  document.getElementById('jobtitle').deleteRow(--i);
	  document.getElementById('jobtitle').deleteRow(--i);
	  document.getElementById('jobtitle').deleteRow(--i);
   }
   else
      alert("You have to minimum job experience.");	  
}

function show_degree(i)
{ 
   text = "degree"+i;
   inst = "sp_degree"+i;
   
   var x=document.getElementById(inst);
   var t=document.getElementById(text);
   var t1=t.options[t.selectedIndex].text;
   
   if(t1.match("Other"))
      x.innerHTML="<br /><input id='degr"+i+"' name='degr"+i+"' type='text' class='textbox' style='width:100px;'/>"; 
   else
      x.innerHTML="";	   
} 

function show_major(i)
{ 
   text = "major"+i;
   inst = "sp_major"+i;
      
   var x=document.getElementById(inst);
   var t=document.getElementById(text);
   var t1=t.options[t.selectedIndex].text;
   
   if(t1.match("Others"))
      x.innerHTML="<br /><input id='maj"+i+"' name='maj"+i+"' type='text' class='textbox' style='width:240px;'/>";
   else
      x.innerHTML="";	  
}

function show_marks(i)
{
   text = "division"+i;
   text1 = "degree"+i;
   inst = "sp_division"+i;
      
   var x=document.getElementById(inst);
   var t=document.getElementById(text);
   var t1=t.options[t.selectedIndex].text;
   var d=document.getElementById(text1);
   var d1=d.options[d.selectedIndex].text;
   
   if(d1.match("Select"))
   {
	  alert("Select your degree!");
	  return false;
   }
   
   if(t1.match("Grade"))
   {
      if(d1.match("A Level") || d1.match("O Level"))
	     x.innerHTML="<br />Subject Grade<br /><input id='subgr"+i+"' name='subgr"+i+"' type='text' class='textbox' style='width:80px;'/>"; 
	  else
	     x.innerHTML="<br />CGPA&nbsp;&nbsp;&nbsp;<input id='cgpa"+i+"' name='cgpa"+i+"' type='text' class='textbox' style='width:32px;'/><br />OUT OF&nbsp;<input id='out"+i+"' name='out"+i+"' type='text' class='textbox' style='width:32px;'/><br />GRADE&nbsp;<select id='gr"+i+"' name='gr"+i+"' class='dropdown' style='width:35px;'><option>--</option><option>A+</option><option>A</option><option>A-</option><option>B+</option><option>B</option><option>B-</option><option>C+</option><option>C</option><option>C-</option><option>D+</option><option>D</option><option>D-</option></select>";
   }
   else if(t1.match("Select") || t1.match("Appeared"))
      x.innerHTML="";
   else
      x.innerHTML="<br/>Marks(%)<br /><input id='mark"+i+"' name='mark"+i+"' type='text' class='textbox' style='width:80px;'/>";
}

function show_work()
{
  var t=document.getElementById("fresh");
  var t1=t.options[t.selectedIndex].text;
   
  if(t1.match("No"))
  {  
    document.getElementById('work').style.visibility = 'hidden';
    document.getElementById('work').style.position = 'absolute';
  }
  else
  {
    document.getElementById('work').style.position = 'relative'; 
	document.getElementById('work').style.visibility = 'visible';
	
  }		
}

function show_period()
{
  var x=document.getElementById("dv_to1");
  var t=document.getElementById("jobperiod");
  var t1=t.options[t.selectedIndex].text;
  
  if(t1.match("Previous Job"))
  {  
    var msg="<select id='td1' name='td1' class='dropdown' style='width:50px;'><option selected='selected'>Day</option>";
    for(j=1;j<=31;j++)
        msg = msg+"<option>"+j+"</option>";
    msg = msg+"</select>"; 
    msg = msg+"<select id='tm1' name='tm1' class='dropdown' style='width:62px;'><option selected='selected'>Month</option><option>Jan</option><option>Feb</option><option>Mar</option><option>Apr</option><option>May</option><option>Jun</option><option>Jul</option><option>Aug</option><option>Sep</option><option>Oct</option><option>Nov</option><option>Dec</option></select>";
    msg = msg+"<select id='ty1' name='ty1' class='dropdown' style='width:52px;'><option selected='selected'>Year</option>";	
    for(j=1950;j<2011;j++)
        msg = msg+"<option>"+j+"</option>";
    msg = msg+"</select>";
  	msg = msg+"&nbsp;&nbsp;&nbsp;<select id='jobperiod' name='jobperiod' onChange='show_period();' class='dropdown' style='width:112px;'><option>Select</option><option>Present Job</option><option selected='selected'>Previous Job</option></select>";								  
    x.innerHTML=msg;
  }
  else if(t1.match("Present Job"))
	x.innerHTML="<select id='jobperiod' name='jobperiod' onChange='show_period();' class='dropdown' style='width:112px;'><option>Select</option><option selected='selected'>Present Job</option><option>Previous Job</option></select>"; 
  else	
    x.innerHTML="<select id='jobperiod' name='jobperiod' onChange='show_period();' class='dropdown' style='width:112px;'><option selected='selected'>Select</option><option>Present Job</option><option>Previous Job</option></select>";
}

function valid_username()
{
   var username=document.getElementById("username").value; 
   var submitOK="true";
   
   if(username.length<1)
   {
     alert("Username field can't be blank")
     submitOK="false"
     document.getElementById("username").focus()
     return false
   }
   
   if(submitOK=="false")
   {
     return false
   }
   else
   {	
     while(username.indexOf("+")!=-1)
		   username=username.replace("+","&plus;");
	
	 document.getElementById('preloader').style.visibility = 'visible';
     document.getElementById('preloader').innerHTML = 'Checking ...';
	 x_check_username(username,show_result);
   }
}