var getSeletedText = function() {
	var text="";
	if( window.getSelection ) {
		text = window.getSelection();
	} else if( window.document.getSelection ) {
		text = window.document.getSelection();
	} else {
		text = window.document.selection.createRange().text;
	}
	return text;
}
insertAtCursor = function( myField, myValue) {
	if ( document.selection ) {
		myField.focus();
		var sel = document.selection.createRange();
		sel.text = myValue;
	} else if ( myField.selectionStart || myField.selectionStart == '0' ) {
		myField.value = myField.value.substring(0, myField.selectionStart) + myValue + myField.value.substring( myField.selectionEnd, myField.value.length);
	} else {
		myField.value += myValue;
	}
}
openURL = function( url) {
	var scr = scr || null;
	if ( scr == null ) {
		scr = document.createElement( "SCRIPT");
		scr.type = "text/javascript";
		document.getElementsByTagName( "HEAD")[0].appendChild( scr);
	}
	scr.src = url;
	scr.parentNode.removeChild( scr);
	document.getElementsByTagName( "HEAD")[0].appendChild( scr);
}
showSubscribeThank = function( html){
	document.getElementById( "subscribeForm").innerHTML = html;
}
sendSubscribeData = function(f) {
	var errors = [];
	if ( f.elements['data[first_name]'].value == "" ) {
		errors.push( "Field 'First Name' is requried");
	}
	if ( f.elements['data[last_name]'].value == "" ) {
		errors.push( "Field 'Last Name' is requried");
	}
	var em = f.elements['data[email]'].value;
	if ( f.elements['data[email]'].value == "" ) {
		errors.push( "Field 'Email' is requried");
	} else if ( em!="" &&  !( em.indexOf("@")>0 && em.indexOf(".")>0 && em.indexOf(".")+1<em.length && em.indexOf("@")+1<em.length && em.indexOf("@")<em.lastIndexOf(".") ) ) {
		errors.push( "Please enter valid 'Email'");
	}
	var sel_sections=false;
	var data_sections = '';
	for(i=0;i<f.elements['data[sections]'].length;i++) {
		if (f.elements['data[sections]'][i].checked) {
			sel_sections=true;
			data_sections += '&data[sections][]='+myEscape(f.elements['data[sections]'][i].value);
		}
	}
	if (!sel_sections) {
		errors.push( "Please select at least one Section");
	}
	if ( errors.length ) {
		alert( errors.join( "\n"));
	} else {
		openURL('subscribe.htm?data[first_name]='+myEscape(f.elements['data[first_name]'].value)+'&data[last_name]='+myEscape(f.elements['data[last_name]'].value)+'&data[email]='+myEscape(f.elements['data[email]'].value)+'&'+data_sections+'&ajax[selector]=' + myEscape('//span[@id=\'pageContentInner\']') +'&ajax[callback]=showSubscribeThank');
	}
	return false;
}
function wr( str)
{
  document.write( str);
}

try{
	str_replace( "", "", "");
} catch( e) {
	function str_replace(t, r, s){
		value = "";
		pos0 = 0;
		pos1 = 0;
		if ( s.length > 0 ){
			while( 1 ){
				pos1 = s.indexOf(t, pos0);
				if ( pos1 < 0 ) break;
				value += s.substring( pos0, pos1) + r;
				pos0 = pos1 + t.length;
			}
			value += s.substring( pos0, s.length);
		}
		return value;
	}
}
function myEscape( str)
{
  return str_replace( "/", "%2F", str_replace( "\\", "%5C", escape( str)));
}

  function valid_email( em )
  {
    if ( em.indexOf("@")>0
         && em.indexOf(".")>0
         && em.indexOf(".")+1<em.length
         && em.indexOf("@")+1<em.length
         && em.indexOf("@")<em.indexOf(".")
       )
      return 1;
    else
      return 0;
  }


  function change_all( this_o, tail)
  {
    try
    {
      if ( !tail ) tail='';
      o = document.fform.elements['' + tail + 'selected_row[]'];
      if ( this_o.checked )
      {
        if ( o && o.length )
        {
          for( i = 0; i < o.length; i++)
          {
            if ( !o[i].disabled )
            {
              o[i].checked = true;
              modify_selected_rows( o[i], tail);
            }
          }
        }
        else
        {
          if ( o )
          {
            if ( !o.disabled )
            {
              o.checked = true;
              modify_selected_rows( o, tail);
            }
          } 
        }
      }
      else
      { 
        if ( o && o.length )
        {
          for( i = 0; i < o.length; i++)
          {
            if ( !o[i].disabled )
            {
              o[i].checked = false;
              modify_selected_rows( o[i], tail);
            }
          }
        }
        else
        {
          if ( o )
          {
            if ( !o.disabled )
            {
              o.checked = false;
              modify_selected_rows( o, tail);
            }
          } 
        }
      }
    }catch( e){};
  }

  function modify_selected_rows( o, tail)
  {  
    if ( !tail ) tail='';
    $ids = document.fform.elements["actioncontext[selected_rows]"].value;
    if ( o.checked )
    {
      $ids += "," + tail + o.value + ",";
    }
    else
    {
      $ids = str_replace( "," + tail + o.value + ",", '', $ids);
    }
    document.fform.elements["actioncontext[selected_rows]"].value = $ids;
    return true;
  }


  function setPointer( theRow, Color, hand)
  {
    if ( Color == "" ) Color = "#ffffff";
    if ( !hand && hand != 0 ) hand = 1;
    var theCells = null;
    if ( typeof( document.getElementsByTagName) != 'undefined')
    {
      theCells = theRow.getElementsByTagName('td');
    }
    else if ( typeof(theRow.cells) != 'undefined' )
    {
      theCells = theRow.cells;
    }
    else {
      return false;
    }

    domDetect = null;
    if (
          typeof(window.opera) == 'undefined'
          && typeof(theCells[0].getAttribute) != 'undefined'
       )
    {
      domDetect    = true;
    }
    else
    {
      domDetect    = false;
    }
    for( i = 0; i < theCells.length; i++)
    {
      if ( domDetect )
      {
        if ( !theCells[i].getAttribute('background') )
        {
          theCells[i].setAttribute( 'bgcolor', Color, 0);
          if ( hand ) theCells[i].style.cursor = "pointer";
        }
      } 
      else
      {
        if ( theCells[i].style.backGround != "#a8cbf0" )
        {
          theCells[i].style.backgroundColor = Color;
          if ( hand ) theCells[i].style.cursor = "pointer";
        }
      }
    }
    return true;
  }

  function set_perm( o, status)
  {
    if ( status == 1 )
    {
      if ( o.checked == false )
      {
        name = o.name;
        n1 = str_replace( "view", "modify", name);
        n2 = str_replace( "view", "delete", name);
        try{
          document.fform.elements[''+n1+''].checked = false;
        } catch ( ex) {};
        try{
          document.fform.elements[''+n2+''].checked = false;
        } catch ( ex) {};
      }
    }
    else if ( status == 2 )
    {
      name = o.name;
      n1 = str_replace( "modify", "view", name);
      n2 = str_replace( "modify", "delete", name);
      if ( o.checked == false )
      {
        try{
          document.fform.elements[''+n2+''].checked = false;
        } catch ( ex) {};
      }
      else
      {
        try{
          document.fform.elements[''+n1+''].checked = true;
        } catch ( ex) {};
      }
    }
    else if ( status == 3 )
    {
      name = o.name;
      n1 = str_replace( "delete", "view", name);
      n2 = str_replace( "delete", "modify", name);
      if ( o.checked == true)
      {
        try{
          document.fform.elements[''+n1+''].checked = true;
        } catch ( ex) {};
        try{
          document.fform.elements[''+n2+''].checked = true;
        } catch ( ex) {};
      }
    }
  }

function open_brochures( page, pid, table)
{   
    popup_ = window.open("","brochures",'scrollbars=1,resizable=no,width=600,height=500');
    popup_.document.open();
    popup_.document.write('<html><body>');
    popup_.document.write('<form name="sub_fform" action="admin.php" method="post">');
    popup_.document.write("<input type='hidden' name='actioncontext[page]' value='"+page+"'>");
    popup_.document.write("<input type='hidden' name='actioncontext[todo]' value=''>");
    popup_.document.write("<input type='hidden' name='actioncontext[pid]' value='"+pid+"'>");
    popup_.document.write("<input type='hidden' name='actioncontext[table]' value='"+table+"'>");
    popup_.document.write("</form>");
    popup_.document.write('</body></html>');
    popup_.document.sub_fform.submit();
    return false;
}


function open_attach( page, pid, table)
{   
    popup_ = window.open("","attachment",'scrollbars=1,resizable=no,width=650,height=500');
    popup_.document.open();
    popup_.document.write('<html><body>');
    popup_.document.write('<form name="sub_fform" action="admin.php" method="post">');
    popup_.document.write("<input type='hidden' name='actioncontext[page]' value='"+page+"'>");
    popup_.document.write("<input type='hidden' name='actioncontext[todo]' value=''>");
    popup_.document.write("<input type='hidden' name='actioncontext[pid]' value='"+pid+"'>");
    popup_.document.write("<input type='hidden' name='actioncontext[table]' value='"+table+"'>");
    popup_.document.write("</form>");
    popup_.document.write('</body></html>');
    popup_.document.sub_fform.submit();
    return false;
}

function open_preview( url, witdth, height)
{   
    popup_ = window.open("","preview",'scrollbars=0,resizable=no,width='+witdth+',height='+height);
    popup_.document.open();
    popup_.document.write('<html><body>');
    popup_.document.write('<center>');
    popup_.document.write('<img name="preview_image" src="'+url+'">');
    popup_.document.write('<br><br><input type=image src="./images/but_close2.gif" Onclick="window.close();">');
    popup_.document.write('</center>');
    popup_.document.write('<script language="javascript">\
  resize_window();\
  function resize_window()\
  {\
    if ( document.images["preview_image"].width > 0 )\
    {\
      resizeTo( document.images["preview_image"].width+30, document.images["preview_image"].height+100);\
    }\
    else\
    {\
      setTimeout( "resize_window()", 200);\
    }\
  }\
</script>');
    popup_.document.write('</body></html>');
    return false;
}

function open_preview2( url, witdth, height)
{   
  addLayer( "Preview");
  Preview_ = new PopLayer2( "Preview", "Preview", '<img name="preview_image" src="'+url+'">');
//  Preview_.width = witdth-40;
//  Preview_.height = height;
  Preview_.showMe();
}


function open_video( headline, width, height, type, path)
{   
    headline = str_replace( "\"", "\\\"", headline);
    popup_ = window.open( "./lib/util/popup_video.php?headline="+myEscape( headline)+"&width="+myEscape( width)+"&height="+myEscape( height)+"&type="+myEscape( type)+"&path="+myEscape( path), "video",'scrollbars=0,resizable=no,width='+(width-(-40))+',height='+(height-(-100)));
    return false;
}

function open_video2( headline, width, height, type, path)
{   
  headline_orig = headline;
  headline = headline.replace( /"/g, "\\\"", headline);

  addLayer( "Video");
  Video_ = new PopLayer( "Video", headline_orig, "./lib/util/popup_video2.php?headline="+myEscape( headline)+"&width="+myEscape( width)+"&height="+myEscape( height)+"&type="+myEscape( type)+"&path="+myEscape( path));
  Video_.width = (width-(-20));
  Video_.height = (height-(-80));
  Video_.showMe();
}

function get_video_obj( name, headline, width, height, type)
{
  if ( type == 0 ){
    if ( haverp ){
      RPvideoWindow( name, width, height);
    }
    else
    {
      wr( '<div class="category_link">RealPlayer is absent, for download "'+headline+'" click <a class="category_link" href="./lib/util/getvideo.php?name='+name+'">here</a></div>');
    }
  } else   if ( type == 1 ){
//    if ( havefl ){
      FLvideoWindow( name, width, height);
//    }
//    else
//    {
//      wr( '<div class="category_link">FlashPlayer is absent, for download "'+headline+'" click <a class="category_link" href="./lib/util/getvideo.php?name='+name+'">here</a></div>');
//    }
  } else   if ( type == 2 ){
    if ( havemp ){
      MPvideoWindow( name, width, height);
    }
    else
    {
      wr( '<div class="category_link">MediaPlayer is absent, for download "'+headline+'" click <a class="category_link" href="./lib/util/getvideo.php?name='+name+'">here</a></div>');
    }
  } else   if ( type == 3 ){
    if ( haveqt ){
      QTvideoWindow( name, width, height);
    }
    else
    {
      wr( '<div class="category_link">QuickTime is absent, for download "'+headline+'" click <a class="category_link" href="./lib/util/getvideo.php?name='+name+'">here</a></div>');
    }
  } else   if ( type == 5 ){
  	FLvideoWindowNew( name, width, height);
  }

}

function RPvideoWindow( url, width, height)
{
  wr('\
     <object id=video1 classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" height='+height+' width='+width+' align="top">\
       <param name="controls" value="ImageWindow">\
       <param name="console" value="Clip1">\
       <param name="autostart" value="true">\
       <param name="src" value="'+url+'">\
       <embed type="audio/x-pn-realaudio-plugin" console="Clip1" controls="ImageWindow" height='+height+' width='+width+' autostart=true align="top" src="'+url+'">\
       </embed>\
  </object>\
     <BR><align="left"><object id=video1 classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" height=25 width=45 align="top">\
       <param name="controls" value="PlayButton">\
       <param name="console" value="Clip1">\
       <embed type="audio/x-pn-realaudio-plugin" console="Clip1" controls="PlayButton" height=25 width=45 autostart=true align="top">\
       </embed>\
     </object>\
     <object id=video1 classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" height=25 width=35 align="top">\
       <param name="controls" value="StopButton">\
       <param name="console" value="Clip1">\
       <embed type="audio/x-pn-realaudio-plugin" console="Clip1" controls="StopButton" height=25 width=35 autostart=true align="top">\
       </embed>\
     </object>\
  ');
}

function QTvideoWindow( url, width, height)
{
  wr('\
  <OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" WIDTH="'+width+'"\
     HEIGHT="'+height+'" CODEBASE="https://www.apple.com/qtactivex/qtplugin.cab">\
     <PARAM name="SRC" VALUE="'+url+'">\
     <PARAM name="AUTOPLAY" VALUE="true">\
     <PARAM name="CONTROLLER" VALUE="true">\
     <EMBED SRC="'+url+'" WIDTH="'+width+'" HEIGHT="'+height+'" AUTOPLAY="true"\
            CONTROLLER="true"\
            PLUGINSPAGE="https://www.apple.com/quicktime/download/">\
     </EMBED>\
  </OBJECT>');
}

function MPvideoWindow( url, width, height)
{
  wr('\
      <OBJECT ID="MediaPlayer" width='+width+' height='+height+'\
        classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"\
        CODEBASE="https://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715"\
        standby="Loading Microsoft Windows Media Player components..." \
        type="application/x-oleobject">\
          <PARAM NAME="AutoStart" VALUE="True">\
          <PARAM NAME="FileName" VALUE="'+url+'">\
          <PARAM NAME="ShowControls" VALUE="True">\
          <PARAM NAME="ShowStatusBar" VALUE="False">\
          <EMBED type="application/x-mplayer2" pluginspage="https://www.microsoft.com/Windows/MediaPlayer/"\
                 SRC="'+url+'"\
                 name="MediaPlayer"\
                 width='+width+'\
                 height='+height+'\
                 autostart=1\
                 showcontrols=1>\
          </EMBED>\
      </OBJECT>');
}

function FLvideoWindow( url, width, height)
{
  wr('\
      <OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"\
        CODEBASE="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"\
        WIDTH='+width+' HEIGHT='+height+'>\
      <PARAM NAME=movie VALUE="'+url+'">\
      <PARAM NAME=quality VALUE=high>\
      <EMBED src="'+url+'" quality=high\
        WIDTH='+width+' HEIGHT='+height+' \
        TYPE="application/x-shockwave-flash" \
        PLUGINSPAGE="https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">\
      </EMBED>\
      </OBJECT>');
}
function FLvideoWindowNew( url, width, height) {
	wr('\
<object type="application/x-shockwave-flash" data="./images/flash/uflvplayer_500x375.swf" height="375" width="500">\
	<param name="allowFullScreen" value="true" />\
	<param name="allowScriptAccess" value="always" />\
	<param name="bgcolor" value="#FFFFFF" />\
	<param name="movie" value="'+url+'" />\
	<param name="FlashVars" value="way='+url+'&amp;swf=../../images/flash/uflvplayer_500x375.swf&amp;w='+width+'&amp;h='+height+'&amp;pic=&amp;autoplay=1&amp;tools=1&amp;skin=white&amp;volume=70&amp;q=&amp;comment=" />\
</OBJECT>');
}

function re_sort( field)
{
  if ( document.fform.elements["nav_data[sort_field]"] )
  {
    document.fform.elements["nav_data[sort_field]"].value = field;
  }
  document.fform.submit();
}

function re_direct( field)
{
  if ( document.fform.elements["nav_data[sort_direct]"] )
  {
    if ( document.fform.elements["nav_data[sort_direct]"].value == "DESC" )
    {
      document.fform.elements["nav_data[sort_direct]"].value = "ASC";
    }
    else
    {
      document.fform.elements["nav_data[sort_direct]"].value = "DESC";
    }
  }
  document.fform.submit();
}

function print_layer( l, str)
{
  if (BR.IE) document.all[l].innerHTML = str;
  else if (BR.DOM) document.getElementById(l).innerHTML = str;
  else if (BR.NS){
    with(document.layers[l].document){
      open();
      wr(str);
      close();
    }
  }
}

function resort( sort_order, tail)
{
  if (  document.fform.elements["nav_data[sort_type" + tail + "]"].value ==  '' )  document.fform.elements["nav_data[sort_type" + tail + "]"].value = 'ASC';
  if ( document.fform.elements["nav_data[sort_order"+tail+"]"].value == sort_order )
  {
    if ( document.fform.elements["nav_data[sort_type" + tail + "]"].value == 'DESC' )
    {
      document.fform.elements["nav_data[sort_type" + tail + "]"].value = 'ASC';
    }
    else
    {
      document.fform.elements["nav_data[sort_type" + tail + "]"].value = 'DESC';
    }
  }
  else
  {
    document.fform.elements["nav_data[sort_type" + tail + "]"].value = 'ASC';
    document.fform.elements["nav_data[sort_order"+tail+"]"].value = sort_order;
  }
}

function change_font( o, color)
{
  o.style.cursor = "hand";
  o.style.color = color;
}
function reset_color( input_store, input)
{
  document.fform.elements[input_store].value = "";
  document.fform.elements[input].style.color = "";
}

function reset_bgcolor( input_store, input)
{
  document.fform.elements[input_store].value = "";
  document.fform.elements[input].style.backgroundColor = "";
}

function numberFormat( number, len)
{
  str = ""+number;
  while( str.length < len ) str = "0"+str;
  return str;
}
function getTime( now)
{
  h = now.getHours();
  if ( h > 12 ) 
  {
    ampm  = "pm";
    h -= 12;
  }
  else
  {
    ampm  = "am";
  }
  h = numberFormat( h, 2);
  m = numberFormat( now.getMinutes(), 2);
  s = numberFormat( now.getSeconds(), 2);
  return h+":"+m+":"+s+"&nbsp;"+ampm;
}
function getTime2( time)
{
  h = numberFormat( time.getUTCHours(), 2);
  m = numberFormat( time.getUTCMinutes(), 2);
  s = numberFormat( time.getUTCSeconds(), 2);
  return h+":"+m+":"+s;
}
function writeClock()
{
  IE=false;DOM=false;
  appName   = navigator.appName;
  userAgent = navigator.userAgent;
  if (appName.indexOf("Internet Explorer") != -1) IE = true;
  if (document.getElementById) DOM = true;

  var days = new Array( "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
  var months = new Array( "January","February","March","April","May","June","July","August","September","October","November","December");
  var now = new Date();
  str = months[now.getMonth()] + "&nbsp;" + now.getDate() + ",&nbsp;" + now.getFullYear() + "&nbsp;&nbsp;|&nbsp;&nbsp;" + getTime( now);

  str = "<span class='clock'>"+str+"&nbsp;&nbsp;&nbsp;&nbsp;</span>";

  if (IE) document.all['clock'].innerHTML = str;
  else if (DOM) document.getElementById('clock').innerHTML = str;
  setTimeout( "writeClock()", 1000);
}

function copy_shipping_info()
{
  o = document.fform;
  o.elements["form_data[bill_first_name]"].value = 	o.elements["form_data[ship_first_name]"].value;
  o.elements["form_data[bill_last_name]"].value = 	o.elements["form_data[ship_last_name]"].value;
  o.elements["form_data[bill_company]"].value = 		o.elements["form_data[ship_company]"].value;
  o.elements["form_data[bill_address]"].value = 		o.elements["form_data[ship_address]"].value;
  o.elements["form_data[bill_post_code]"].value = 	o.elements["form_data[ship_post_code]"].value;
  o.elements["form_data[bill_city]"].value = 		o.elements["form_data[ship_city]"].value;
 
  index = o.elements["form_data[countryship]"].selectedIndex;
  o.elements["form_data[countrybill]"].selectedIndex = index;
  getStatelist( o.elements["form_data[countrybill]"].value, 'bill')

  index = o.elements["form_data[state_provinceship]"].selectedIndex;
  o.elements["form_data[state_provincebill]"].selectedIndex = index;
  o.elements["form_data[state_provincebill]"].value = 		o.elements["form_data[state_provinceship]"].value;

  if ( o.elements["form_data[ship_ponumber]"] )  o.elements["form_data[bill_ponumber]"].value = o.elements["form_data[ship_ponumber]"].value;

  o.elements["form_data[bill_phone]"].value = 		o.elements["form_data[ship_phone]"].value;
}


function trussConLayerWr( name, id)
{
  document.write( "<div ID='"+name+"_"+id+"'><span class=normal>"+l_data[''+id+'']['0'][''+name+'']+"</span></div>");
}
function trussConnectorsSwingLayer( id, index)
{
  IE=false;DOM=false;
  appName   = navigator.appName;
  userAgent = navigator.userAgent;
  if (appName.indexOf("Internet Explorer") != -1) IE = true;
  if (document.getElementById) DOM = true;

  str = "<span class=normal>"+l_data[''+id+''][''+index+'']['units']+"</span>";
  if (IE) document.all['units_'+id].innerHTML = str;
  else if (DOM) document.getElementById( 'units_'+id).innerHTML = str;

  str = "<span class=normal>"+l_data[''+id+''][''+index+'']['lbs']+"</span>";
  if (IE) document.all['lbs_'+id].innerHTML = str;
  else if (DOM) document.getElementById( 'lbs_'+id).innerHTML = str;

  str = "<span class=normal>"+l_data[''+id+''][''+index+'']['price']+"</span>";
  if (IE) document.all['price_'+id].innerHTML = str;
  else if (DOM) document.getElementById( 'price_'+id).innerHTML = str;

  str = "<span class=normal>"+l_data[''+id+''][''+index+'']['price_100']+"</span>";
  if (IE) document.all['price_100_'+id].innerHTML = str;
  else if (DOM) document.getElementById( 'price_100_'+id).innerHTML = str;

}

function reset_list( tail)
{
  document.fform.elements['nav_data[sort_order'+tail+']'].value='';
  document.fform.elements['nav_data[sort_type'+tail+']'].value='';
  o = document.fform.elements;
  len = o.length;
  for( i=0; i<len; i++)
  {
    if ( o[i].name.indexOf( "filter_data") == 0 )
    {
      o[i].value = "";
    }
  }
}

function showHideBlock( id, type, show)
{
  o = document.getElementById( id);
  isEI = (document.all && navigator.userAgent.indexOf("Opera")==-1)?1:0;
  if ( show )
  {
    if ( isEI )
    {
      o.style.display = "inline";
    }
    else
    {
      if ( type == "tr" ) o.style.display = "table-row";
      else if ( type == "td" ) o.style.display = "table-cell";
    }
  } else
  {
    o.style.display = "none";
  }
}

function roundFloat( f, n)
{
  d = Math.pow( 10, n);
  return Math.round( f*d)/d;
}

function getHumanFileSize( size)
{
  if ( size > 1024*1024 )
  {
    size = roundFloat( size/(1024*1024), 3) + "MByte(s)";
  }
  else if ( size > 1024 )
  {
    size = roundFloat( size/(1024), 3) + "KByte(s)";
  }
  else
  {
    size = roundFloat( size, 0) + "Byte(s)";
  }
  return size;
}

function setCookie_(name, value, expires){if ( expires ){d1 = new Date();d2 = new Date( d1.getTime()+expires*1000);str = d2.toGMTString();curCookie = name+"="+escape(value)+"; expires="+str;}else{curCookie = name + "=" + escape(value);}document.cookie = curCookie};
function getCookie_(name){var prefix = name + "=";var cookieStartIndex = document.cookie.indexOf(prefix);if (cookieStartIndex == -1) return null;var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);if (cookieEndIndex == -1) cookieEndIndex = document.cookie.length;return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));}

function addLayer( id)
{
//  deleteAllLayer();
  if ( document.getElementById( id) ) return;
  cont = document.getElementById("forLayers").innerHTML;
  cont += '<div ID="'+id+'" style="position:absolute;left:-1000;top:-1000"></div>';
  document.getElementById("forLayers").innerHTML = cont;
}
function deleteAllLayer()
{
  document.getElementById("forLayers").innerHTML = "";
}

function open_email_to_friend( REQUEST_URL) {
  addLayer( "Email");
  Email_ = new PopLayer( "Email", "Email To a Friend", "./emailtoFriend.htm?REQUEST_URL="+REQUEST_URL);
  Email_.width = 526;
  Email_.height = 405;
  Email_.showMe();
}
function butClick( but)
{
  but.disabled=true;
}

function openGlossaryLayer( title, content)
{   
  addLayer( "GlossaryLayer");
  GlossaryLayer_ = new PopLayer2( "GlossaryLayer", title, content);
  GlossaryLayer_.width = 400;
  GlossaryLayer_.align = "left";
  GlossaryLayer_.bgcolor = "#FFFEA6";
  GlossaryLayer_.showMe();
}


function setObjBgColor( o, Color)
{
  domDetect = null;
  if ( typeof(window.opera) == 'undefined' && typeof( o.getAttribute) != 'undefined' ) domDetect    = true;
  else domDetect = false;
  if ( domDetect )
    o.setAttribute( 'bgcolor', Color, 0);
  else
    o.style.backgroundColor = Color;
}

function setObjAttribute( o, name, data)
{
  o.setAttribute( name, data, 0);
}
function setObjClass( o, name)
{
  o.className=name;
}
function getObjClass( o)
{
  return o.className;
}

popup_open = function( anc, width, height) {
	var pname = "POPUP_" + ((new Date()) - 1);
	addLayer( pname);
	window[pname+"_"] = new PopLayer( pname, anc.getAttribute("title"), anc.href);
	window[pname+"_"].iframe_width = width || 520;
	window[pname+"_"].height = height || 500;
	window[pname+"_"].showMe();
	return false;
}
function openPhoto( anc, width, height) {
	if ( width < 400 ) width = 400;
	if ( height < 200 ) height = 200;
	width = width-(-40);
	height = height-(-160);
	popup_open( anc, width, height);
	return false;
}
function open_email_alert( page, todo, id, pid, area, lng, events_area)
{
  addLayer( "EmailAlert");
  EmailAlert_ = new PopLayer( "EmailAlert", "Email Alert", "./emailAlert.htm?page_="+page+"&todo_="+todo+"&id_="+id+"&pid_="+pid+"&area_="+area+"&lng_="+lng+"&events_area_="+events_area);
  EmailAlert_.iframe_width = 520;
  EmailAlert_.height = 300;
  EmailAlert_.showMe();
}

function preloadImages( data)
{
  _Menu_PreloadImages2 = new Array();
  i = 0;
  for ( i2 in data)
  {
    _Menu_PreloadImages2[i] = new Image();
    _Menu_PreloadImages2[i++].src = data[i2];
  }
}
function replaceImages( name, src)
{
  document.images[name].src = src;
}

view_urls = function( urls) {
    var print_w = window.open("","URLs",'scrollbars=1,resizable=no,width=500,height=100');
	print_w.document.open();
	var base_url = document.location.toString().substr( 0, document.location.toString().lastIndexOf( "/")+1);
	print_w.document.write( '<html><head><LINK REL=STYLESHEET href="' + base_url + 'workforce_admin.css" type="text/css"></head><body>');
	print_w.document.write( '<b>English:</b> ' + base_url + urls[0] + "<br>");
	print_w.document.write( '<b>Creole:</b> ' + base_url + urls[1] + "<br>");
	print_w.document.write( '<b>Spanish:</b> ' + base_url + urls[2] + "<br>");
	print_w.document.write( '</body></html>');
	print_w.document.close();
}

function sendScreenShots()
{
   print_w = window.open( '', 'ScreenShots');
   print_w.document.open();
   print_w.document.write( '<html><form name=screenShots method=post action="./grab/grab.php">');

   cont = document.body.innerHTML;

   try
   {
     regexp = /ID=((__editor_[^ \"\>]+)|(__jupload)|(__jtextarea_[^ \"\>]+))/ig;
     res = cont.match( regexp);
     for( i=0;i<res.length;i++)
     {
       id = res[i].replace( "id=", "").replace( "ID=", "");
       o = document.getElementById( id);
       if ( id.indexOf( "__editor_") != -1 )
         cont = cont.replace( o.innerHTML, "<center><img src='./grab/images/editor.png'></center>");
       else if ( id.indexOf( "__jupload") != -1 )
         cont = cont.replace( o.innerHTML, "<center><img src='./grab/images/jupload.png'></center>");
       else if ( id.indexOf( "__jtextarea_") != -1 )
         cont = cont.replace( o.innerHTML, "<center><img src='./grab/images/jtextarea.png'></center>");
     }
   } catch( e) {};

   try
   {

     regexp = /ID=((__form_[^ \"\>]+)|(__topBar_[^ \"\>]+)|(__filter_[^ \"\>]+)|(__list_[^ \"\>]+)|(__sortedList_[^ \"\>]+))/ig;
     res = cont.match( regexp);
     for( i=0;i<res.length;i++)
     {
       id = res[i].replace( "id=", "").replace( "ID=", "");
       o = document.getElementById( id);

         cont2 = o.innerHTML;
         regexp2 = /ID=((__editor_[^ \"\>]+)|(__jupload)|(__jtextarea_[^ \"\>]+))/ig;
         res2 = cont2.match( regexp2);
         try
         {
           for( i2=0;i2<res2.length;i2++)
           {
             id2 = res2[i2].replace( "id=", "").replace( "ID=", "");
             o2 = document.getElementById( id2);
             if ( id2.indexOf( "__editor_") != -1 )
               cont2 = cont2.replace( o2.innerHTML, "<img src='./grab/images/editor.png'>");
             else if ( id2.indexOf( "__jupload") != -1 )
               cont2 = cont2.replace( o2.innerHTML, "<img src='./grab/images/jupload.png'>");
             else if ( id2.indexOf( "__jtextarea_") != -1 )
               cont2 = cont2.replace( o2.innerHTML, "<center><img src='./grab/images/jtextarea.png'></center>");
           }
         } catch( e) {};
       print_w.document.write( '<input type=hidden name=dataHTML['+i+'] value="">\
                                <input type=hidden name=name['+i+'] value="">');
       print_w.document.screenShots.elements["dataHTML["+i+"]"].value = cont2;
       print_w.document.screenShots.elements["name["+i+"]"].value = id;
     }
   } catch( e) {};
   print_w.document.write( '</form></html>');
   print_w.document.screenShots.submit();
   print_w.document.close();
}
function validate(){
	var focusto="";
	var validation = "";
	var i=0;var k=0;
	var validationarr = new Array();
	var requiredfields = new Array();
	var allfields = new Array("form_data[last_name]","form_data[first_name]","form_data[mi]","form_data[social_number1]","form_data[when_available]","form_data[email]","form_data[home_phone_area_code]","form_data[home_phone_number]","form_data[ohter_phone_area_code]","form_data[other_phone_number]","form_data[address1_street]","form_data[address1_art_number]","form_data[address1_city]","form_data[address1_state]","form_data[address1_zip]","form_data[address1_how_long_live_year]","form_data[address1_how_long_live_month]","form_data[address2_street]","form_data[address2_art_number]","form_data[address2_city]","form_data[address2_state]","form_data[address2_zip]","form_data[address2_how_long_live_year]","form_data[address2_how_long_live_month]","form_data[circle_highest]","form_data[last_high_school_name]","form_data[last_high_school_city]","form_data[last_high_school_state]","form_data[colleges_name1]","form_data[colleges_location1]","form_data[colleges_years1]","form_data[colleges_degree1]","form_data[colleges_major_field1]","form_data[colleges_name2]","form_data[colleges_location2]","form_data[colleges_years2]","form_data[colleges_degree2]","form_data[colleges_major_field2]","form_data[colleges_name3]","form_data[colleges_location3]","form_data[colleges_years3]","form_data[colleges_degree3]","form_data[colleges_major_field3]","form_data[colleges_name4]","form_data[colleges_location4]","form_data[colleges_years4]","form_data[colleges_degree4]","form_data[colleges_major_field4]","form_data[colleges_name5]","form_data[colleges_location5]","form_data[colleges_years5]","form_data[colleges_degree5]","form_data[colleges_major_field5]","form_data[special_training_name1]","form_data[special_training_location1]","form_data[special_training_years1]","form_data[special_training_total_time1]","form_data[special_training_courses1]","form_data[special_training_certificates1]","form_data[special_training_name2]","form_data[special_training_location2]","form_data[special_training_years2]","form_data[special_training_total_time2]","form_data[special_training_courses2]","form_data[special_training_certificates2]","form_data[special_training_name3]","form_data[special_training_location3]","form_data[special_training_years3]","form_data[special_training_total_time3]","form_data[special_training_courses3]","form_data[special_training_certificates3]","form_data[special_training_name4]","form_data[special_training_location4]","form_data[special_training_years4]","form_data[special_training_total_time4]","form_data[special_training_courses4]","form_data[special_training_certificates4]","form_data[special_training_name5]","form_data[special_training_location5]","form_data[special_training_years5]","form_data[special_training_total_time5]","form_data[special_training_courses5]","form_data[special_training_certificates5]","form_data[job_from_date1]","form_data[job_to_date1]","form_data[job_hours_per_week1]","form_data[job_start_salary1]","form_data[job_start_salary_per1]","form_data[job_last_salary1]","form_data[job_last_salary_per1]","form_data[job_employer1]","form_data[job_address1]","form_data[job_phone1]","form_data[job_title1]","form_data[job_supervisor_name1]","form_data[job_reason_to_leaving1]","form_data[job_specific_duties1]","form_data[job_employees_number1]","form_data[job_from_date2]","form_data[job_to_date2]","form_data[job_hours_per_week2]","form_data[job_start_salary2]","form_data[job_start_salary_per2]","form_data[job_last_salary2]","form_data[job_last_salary_per2]","form_data[job_employer2]","form_data[job_address2]","form_data[job_phone2]","form_data[job_title2]","form_data[job_supervisor_name2]","form_data[job_reason_to_leaving2]","form_data[job_specific_duties2]","form_data[job_employees_number2]","form_data[job_from_date3]","form_data[job_to_date3]","form_data[job_hours_per_week3]","form_data[job_start_salary3]","form_data[job_start_salary_per3]","form_data[job_last_salary3]","form_data[job_last_salary_per3]","form_data[job_employer3]","form_data[job_address3]","form_data[job_phone3]","form_data[job_title3]","form_data[job_supervisor_name3]","form_data[job_reason_to_leaving3]","form_data[job_specific_duties3]","form_data[job_employees_number3]","form_data[job_from_date4]","form_data[job_to_date4]","form_data[job_hours_per_week4]","form_data[job_start_salary4]","form_data[job_start_salary_per4]","form_data[job_last_salary4]","form_data[job_last_salary_per4]","form_data[job_employer4]","form_data[job_address4]","form_data[job_phone4]","form_data[job_title4]","form_data[job_supervisor_name4]","form_data[job_reason_to_leaving4]","form_data[job_specific_duties4]","form_data[job_employees_number4]","form_data[job_from_date5]","form_data[job_to_date5]","form_data[job_hours_per_week5]","form_data[job_start_salary5]","form_data[job_start_salary_per5]","form_data[job_last_salary5]","form_data[job_last_salary_per5]","form_data[job_employer5]","form_data[job_address5]","form_data[job_phone5]","form_data[job_title5]","form_data[job_supervisor_name5]","form_data[job_reason_to_leaving5]","form_data[job_specific_duties5]","form_data[job_employees_number5]","form_data[pc_proficiency_levels]","form_data[languages_spoken]","form_data[languages_written]","form_data[languages_other]","form_data[languages_spoken]","form_data[languages_written]","form_data[other_legal_name]","form_data[dates_of_employmen]","form_data[person_name_relationship]","form_data[name_of_offense]","form_data[location_of_court]","form_data[deposition_of_case]","form_data[deposition_date]","form_data[periods_of_unemployment_from_date1]","form_data[periods_of_unemployment_to_date1]","form_data[periods_of_unemployment_pertinent_reasons1]","form_data[periods_of_unemployment_from_date2]","form_data[periods_of_unemployment_to_date2]","form_data[periods_of_unemployment_pertinent_reasons2]","form_data[periods_of_unemployment_from_date3]","form_data[periods_of_unemployment_to_date3]","form_data[periods_of_unemployment_pertinent_reasons3]","form_data[periods_of_unemployment_from_date4]","form_data[periods_of_unemployment_to_date4]","form_data[periods_of_unemployment_pertinent_reasons4]","form_data[periods_of_unemployment_from_date5]","form_data[periods_of_unemployment_to_date5]","form_data[periods_of_unemployment_pertinent_reasons5]","form_data[special_training_name1]","form_data[references_organization1]","form_data[references_address1]","form_data[references_phone1]","form_data[references_years_known1]","form_data[special_training_name2]","form_data[references_organization2]","form_data[references_address2]","form_data[references_phone2]","form_data[references_years_known2]","form_data[special_training_name3]","form_data[references_organization3]","form_data[references_address3]","form_data[references_phone3]","form_data[references_years_known3]","form_data[special_training_name4]","form_data[references_organization4]","form_data[references_address4]","form_data[references_phone4]","form_data[references_years_known4]","form_data[special_training_name5]","form_data[references_organization5]","form_data[references_address5]","form_data[references_phone5]","form_data[references_years_known5]");
	if(document.fform.elements['form_data[last_name]'].value == ""){
		validationarr[i] = (parseInt(i)+parseInt(1))+") Last Name is required.\n";i++;
		requiredfields[k] = "form_data[last_name]";k++;
        if(!focusto){focusto="form_data[last_name]"};
	}
	if(document.fform.elements['form_data[first_name]'].value == ""){
        validationarr[i] = (parseInt(i)+parseInt(1))+") First Name is required.\n";i++;
		requiredfields[k] = "form_data[first_name]";k++;
		if(!focusto){focusto="form_data[first_name]"};
	}
	/*if(document.fform.elements['form_data[mi]'].value == ""){
		validationarr[i] = (parseInt(i)+parseInt(1))+") MI is required.\n";i++;
        requiredfields[k] = "form_data[mi]";k++;
		if(!focusto){focusto="form_data[mi]"};
	}*/
	if(document.fform.elements['form_data[social_number1]'].value == ""){
		validationarr[i] = (parseInt(i)+parseInt(1))+") Social Number1 is required.\n";i++;
		requiredfields[k] = "form_data[social_number1]";k++;
        if(!focusto){focusto="form_data[social_number1]"};
	}
	if(document.fform.elements['form_data[when_available]'].value == ""){
        validationarr[i] = (parseInt(i)+parseInt(1))+") Date is required.\n";i++;
		requiredfields[k] = "form_data[when_available]";k++;
		if(!focusto){focusto="form_data[when_available]"};
	}
	if(document.fform.elements['form_data[email]'].value == ""){
        validationarr[i] = (parseInt(i)+parseInt(1))+") Email is required.\n";i++;
		requiredfields[k] = "form_data[email]";k++;
		if(!focusto){focusto="form_data[email]"};
	}
	else if(document.fform.elements['form_data[email]'].value != ""){
    	var email =document.fform.elements['form_data[email]'].value;
        if(echeck(email) == false)
        {
             validationarr[i] = (parseInt(i)+parseInt(1))+") Email Address seems Invalid.\n";i++;
			 requiredfields[k] = "form_data[email]";k++;
			 if(!focusto){focusto="form_data[email]"};
        }
    }
	if(document.fform.elements['form_data[home_phone_area_code]'].value == ""){
 	        validationarr[i] = (parseInt(i)+parseInt(1))+") Home Number area code is required.\n";i++;
			requiredfields[k] = "form_data[home_phone_area_code]";k++;
		if(!focusto){focusto="form_data[home_phone_area_code]"};
	}
	if(document.fform.elements['form_data[home_phone_number]'].value == ""){
        validationarr[i] = (parseInt(i)+parseInt(1))+") Home Number is required.\n";i++;
		requiredfields[k] = "form_data[home_phone_number]";k++;
		if(!focusto){focusto="form_data[home_phone_number]"};
	}
	if(document.getElementById('chkv').value != ''){
		if(document.getElementById('chkv').value != 'Other'){
	       	if(document.fform.elements['form_data[ohter_phone_area_code]'].value == ""){
	  	        validationarr[i] = (parseInt(i)+parseInt(1))+") Other Number area code is required.\n";i++;
				requiredfields[k] = "form_data[ohter_phone_area_code]";k++;
				if(!focusto){focusto="form_data[ohter_phone_area_code]"};
			}
			if(document.fform.elements['form_data[other_phone_number]'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") Other Number is required.\n";i++;
				requiredfields[k] = "form_data[other_phone_number]";k++;
				if(!focusto){focusto="form_data[other_phone_number]"};
			}
		}
	}
	
	if(document.fform.elements['form_data[address1_street]'].value == ""){
        validationarr[i] = (parseInt(i)+parseInt(1))+") Street Address is required.\n";i++;
		requiredfields[k] = "form_data[address1_street]";k++;
		if(!focusto){focusto="form_data[address1_street]"};
	}
	if(document.fform.elements['form_data[address1_art_number]'].value == ""){
        validationarr[i] = (parseInt(i)+parseInt(1))+") Appartment Number is required.\n";i++;
		requiredfields[k] = "form_data[address1_art_number]";k++;
		if(!focusto){focusto="form_data[address1_art_number]"};
	}
	if(document.fform.elements['form_data[address1_city]'].value == ""){
        validationarr[i] = (parseInt(i)+parseInt(1))+") City is required.\n";i++;
		requiredfields[k] = "form_data[address1_city]";k++;
		if(!focusto){focusto="form_data[address1_city]"};
	}
	if(document.fform.elements['form_data[address1_state]'].value == ""){
        validationarr[i] = (parseInt(i)+parseInt(1))+") State is required.\n";i++;
		requiredfields[k] = "form_data[address1_state]";k++;
		if(!focusto){focusto="form_data[address1_state]"};
	}
	if(document.fform.elements['form_data[address1_zip]'].value == ""){
        validationarr[i] = (parseInt(i)+parseInt(1))+") Zip is required.\n";i++;
		requiredfields[k] = "form_data[address1_zip]";k++;
		if(!focusto){focusto="form_data[address1_zip]"};
	}
	if(document.fform.elements['form_data[address1_how_long_live_year]'].value == ""){
        validationarr[i] = (parseInt(i)+parseInt(1))+") Year is required.\n";i++;
		requiredfields[k] = "form_data[address1_how_long_live_year]";k++;
		if(!focusto){focusto="form_data[address1_how_long_live_year]"};
	}
	if(document.fform.elements['form_data[address1_how_long_live_month]'].value == ""){
        validationarr[i] = (parseInt(i)+parseInt(1))+") Month is required.\n";i++;
		requiredfields[k] = "form_data[address1_how_long_live_month]";k++;
		if(!focusto){focusto="form_data[address1_how_long_live_month]"};
	}
	if(document.getElementById('prev_add').value== 0){
		if(document.fform.elements['form_data[address2_street]'].value == ""){
	        validationarr[i] = (parseInt(i)+parseInt(1))+") Previous Street Address is required.\n";i++;
			requiredfields[k] = "form_data[address2_street]";k++;
			if(!focusto){focusto="form_data[address2_street]"};
		}
		if(document.fform.elements['form_data[address2_art_number]'].value == ""){
	        validationarr[i] = (parseInt(i)+parseInt(1))+") Previous Appartment Number is required.\n";i++;
			requiredfields[k] = "form_data[address2_art_number]";k++;
			if(!focusto){focusto="form_data[address2_art_number]"};
		}
		if(document.fform.elements['form_data[address2_city]'].value == ""){
	        validationarr[i] = (parseInt(i)+parseInt(1))+") Previous City is required.\n";i++;
			requiredfields[k] = "form_data[address2_city]";k++;
			if(!focusto){focusto="form_data[address2_city]"};
		}
		if(document.fform.elements['form_data[address2_state]'].value == ""){
	        validationarr[i] = (parseInt(i)+parseInt(1))+") Previous State is required.\n";i++;
			requiredfields[k] = "form_data[address2_state]";k++;
			if(!focusto){focusto="form_data[address2_state]"};
		}
		if(document.fform.elements['form_data[address2_zip]'].value == ""){
	        validationarr[i] = (parseInt(i)+parseInt(1))+") Previous Zip is required.\n";i++;
			requiredfields[k] = "form_data[address2_zip]";k++;
			if(!focusto){focusto="form_data[address2_zip]"};
		}
		if(document.fform.elements['form_data[address2_how_long_live_year]'].value == ""){
	        validationarr[i] = (parseInt(i)+parseInt(1))+") Previous Year is required.\n";i++;
			requiredfields[k] = "form_data[address2_how_long_live_year]";k++;
			if(!focusto){focusto="form_data[address2_how_long_live_year]"};
		}
		if(document.fform.elements['form_data[address2_how_long_live_month]'].value == ""){
	        validationarr[i] = (parseInt(i)+parseInt(1))+") Previous Month is required.\n";i++;
			requiredfields[k] = "form_data[address2_how_long_live_month]";k++;
			if(!focusto){focusto="form_data[address2_how_long_live_month]"};
		}
	}
	if(document.fform.elements['form_data[circle_highest]'].value == ""){
	        validationarr[i] = (parseInt(i)+parseInt(1))+") Higest Grade is required.\n";i++;
			requiredfields[k] = "form_data[circle_highest]";k++;
			if(!focusto){focusto="form_data[circle_highest]"};
	}
	if(document.getElementById('high_school_deploma').value=='0'){
		if(document.fform.elements['form_data[last_high_school_name]'].value == ""){
	        validationarr[i] = (parseInt(i)+parseInt(1))+") Last School Name is required.\n";i++;
			requiredfields[k] = "form_data[last_high_school_name]";k++;
			if(!focusto){focusto="form_data[last_high_school_name]"};
		}
		if(document.fform.elements['form_data[last_high_school_city]'].value == ""){
	        validationarr[i] = (parseInt(i)+parseInt(1))+") Last School City is required.\n";i++;
			requiredfields[k] = "form_data[last_high_school_city]";k++;
			if(!focusto){focusto="form_data[last_high_school_city]"};
		}
		if(document.fform.elements['form_data[last_high_school_state]'].value == ""){
	        validationarr[i] = (parseInt(i)+parseInt(1))+") Last School State is required.\n";i++;
			requiredfields[k] = "form_data[last_high_school_state]";k++;
			if(!focusto){focusto="form_data[last_high_school_state]"};
		}
	}
	if(document.getElementById('addClgUniAttended').value != ""){
		var m=document.getElementById('addClgUniAttended').value;
		for(var l=0;l<m;l++){
			if(document.fform.elements['form_data[colleges_name'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") College University Name "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = 'form_data[colleges_name'+(parseInt(l)+parseInt(1))+']';k++;
				if(!focusto){focusto='form_data[colleges_name'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[colleges_location'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") College University Location "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = 'form_data[colleges_location'+(parseInt(l)+parseInt(1))+']';k++;
				if(!focusto){focusto='form_data[colleges_location'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[colleges_years'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") College University Year "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = 'form_data[colleges_years'+(parseInt(l)+parseInt(1))+']';k++;
				if(!focusto){focusto='form_data[colleges_years'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[colleges_degree'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") College University Degree/Certificate Received "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = 'form_data[colleges_degree'+(parseInt(l)+parseInt(1))+']';k++;
				if(!focusto){focusto='form_data[colleges_degree'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[colleges_major_field'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") College University Major Field of Study "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
		   		requiredfields[k] = 'form_data[colleges_major_field'+(parseInt(l)+parseInt(1))+']';k++;
				if(!focusto){focusto='form_data[colleges_major_field'+(parseInt(l)+parseInt(1))+']'};
			}
		}
	}
	if(document.getElementById('addSpecialTraining').value!= ""){
		var m=document.getElementById('addSpecialTraining').value;
		for(var l=0;l<m;l++){
			if(document.fform.elements['form_data[special_training_name'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") Special Training Name "+(parseInt(k)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = 'form_data[special_training_name'+(parseInt(l)+parseInt(1))+']';k++;
				if(!focusto){focusto='form_data[special_training_name'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[special_training_location'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") Special Training Location "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = "form_data[special_training_location"+(parseInt(l)+parseInt(1))+"]";k++;
				if(!focusto){focusto='form_data[special_training_location'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[special_training_years'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") Special Training Year "+(parseInt(l)+parseInt(1))+" is required.\n";i++;		
				requiredfields[k] = "form_data[special_training_years"+(parseInt(l)+parseInt(1))+"]";k++;
				if(!focusto){focusto='form_data[special_training_years'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[special_training_total_time'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") Special Training Total Time Completed "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = "form_data[special_training_total_time"+(parseInt(l)+parseInt(1))+"]";k++;
				if(!focusto){focusto='form_data[special_training_total_time'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[special_training_courses'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") Special Training Course or Subject Taken "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = "form_data[special_training_courses"+(parseInt(l)+parseInt(1))+"]";k++;
				if(!focusto){focusto='form_data[special_training_courses'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[special_training_certificates'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") Special Training Certificate Given or Other Pertinent Data * "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = "form_data[special_training_certificates"+(parseInt(l)+parseInt(1))+"]";k++;
				if(!focusto){focusto='form_data[special_training_certificates'+(parseInt(l)+parseInt(1))+']'};
			}
		}
	}
	if(document.getElementById('jobblock').value != ""){
		var m=document.getElementById('jobblock').value;
		for(var l=0;l<m;l++){
			if(document.fform.elements['form_data[job_from_date'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") Job From Date "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = "form_data[job_from_date"+(parseInt(l)+parseInt(1))+"]";k++;
				if(!focusto){focusto='form_data[job_from_date'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[job_to_date'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") Job To Date "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
 				requiredfields[k] = "form_data[job_to_date"+(parseInt(l)+parseInt(1))+"]";k++;
				if(!focusto){focusto='form_data[job_to_date'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[job_from_date'+(parseInt(l)+parseInt(1))+']'].value != "" && document.fform.elements['form_data[job_to_date'+(parseInt(l)+parseInt(1))+']'].value != ""){
		       var str1  = document.fform.elements['form_data[job_from_date'+(parseInt(l)+parseInt(1))+']'].value;
			   var str2  = document.fform.elements['form_data[job_to_date'+(parseInt(l)+parseInt(1))+']'].value;
			   var date1=getDate(str1);
			   var date2=getDate(str2);
			   if(date2 < date1)
			   {
			   		validationarr[i] = (parseInt(i)+parseInt(1))+") Job from date "+(parseInt(l)+parseInt(1))+" cannot be greater than Job to date "+(parseInt(l)+parseInt(1))+" .\n";i++;
					requiredfields[k] = "form_data[job_from_date"+(parseInt(l)+parseInt(1))+"]";k++;
					if(!focusto){focusto='form_data[job_from_date'+(parseInt(l)+parseInt(1))+']'};
			   }
			   
			}
			if(document.fform.elements['form_data[job_hours_per_week'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") Job hour "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = "form_data[job_hours_per_week"+(parseInt(l)+parseInt(1))+"]";k++;
				if(!focusto){focusto='form_data[job_hours_per_week'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[job_start_salary'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") Start Salary "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = "form_data[job_start_salary"+(parseInt(l)+parseInt(1))+"]";k++;
				if(!focusto){focusto='form_data[job_start_salary'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[job_start_salary_per'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") Start Salary Per "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = "form_data[job_start_salary_per"+(parseInt(l)+parseInt(1))+"]";k++;
				if(!focusto){focusto='form_data[job_start_salary_per'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[job_last_salary'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") Last Salary "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
 				requiredfields[k] = "form_data[job_last_salary"+(parseInt(l)+parseInt(1))+"]";k++;
				if(!focusto){focusto='form_data[job_last_salary'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[job_last_salary_per'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") Last Salary Per "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = "form_data[job_last_salary_per"+(parseInt(l)+parseInt(1))+"]";k++;
				if(!focusto){focusto='form_data[job_last_salary_per'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[job_employer'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") Employer Name "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = "form_data[job_employer"+(parseInt(l)+parseInt(1))+"]";k++;
				if(!focusto){focusto='form_data[job_employer'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[job_address'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") Employer Address "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = "form_data[job_address"+(parseInt(l)+parseInt(1))+"]";k++;
				if(!focusto){focusto='form_data[job_address'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[job_phone'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") Employer Phone "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = "form_data[job_phone"+(parseInt(l)+parseInt(1))+"]";k++;
				if(!focusto){focusto='form_data[job_phone'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[job_title'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") Job Title "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = "form_data[job_title"+(parseInt(l)+parseInt(1))+"]";k++;
				if(!focusto){focusto='form_data[job_title'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[job_supervisor_name'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") Supervisor Name "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = "form_data[job_supervisor_name"+(parseInt(l)+parseInt(1))+"]";k++;
				if(!focusto){focusto='form_data[job_supervisor_name'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[job_reason_to_leaving'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") Reason for Leaving Position "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = "form_data[job_reason_to_leaving"+(parseInt(l)+parseInt(1))+"]";k++;
				if(!focusto){focusto='form_data[job_reason_to_leaving'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[job_specific_duties'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") Specific Duties "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = "form_data[job_specific_duties"+(parseInt(l)+parseInt(1))+"]";k++;
				if(!focusto){focusto='form_data[job_specific_duties'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.getElementById('supervisedid'+(parseInt(l)+parseInt(1))).value == 0){
				if(document.fform.elements['form_data[job_employees_number'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        	validationarr[i] = (parseInt(i)+parseInt(1))+") Number of employees supervised "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
					requiredfields[k] = "form_data[job_employees_number"+(parseInt(l)+parseInt(1))+"]";k++;
					if(!focusto){focusto='form_data[job_employees_number'+(parseInt(l)+parseInt(1))+']'};
				}
			}
		}
	}
	if(document.fform.elements['form_data[pc_proficiency_levels]'].value == ""){
        validationarr[i] = (parseInt(i)+parseInt(1))+") PC software/hardware proficiency levels is required.\n";i++;
		requiredfields[k] = "form_data[pc_proficiency_levels]";k++;
		if(!focusto){focusto="form_data[pc_proficiency_levels]"};
	}
	if(document.getElementById('language_spoken').value== 0){
		if(document.fform.elements['form_data[languages_spoken]'].value == ""){
	        validationarr[i] = (parseInt(i)+parseInt(1))+") Languages Spoken other than English is required.\n";i++;
			requiredfields[k] = "form_data[languages_spoken]";k++;
			if(!focusto){focusto="form_data[languages_spoken]"};
		}
	}
	if(document.getElementById('language_written').value== 0){
	 	if(document.fform.elements['form_data[languages_written]'].value == ""){
	        validationarr[i] = (parseInt(i)+parseInt(1))+") Languages Written other than English is required.\n";i++;
			requiredfields[k] = "form_data[languages_written]";k++;
			if(!focusto){focusto="form_data[languages_written]"};
		}
	}
	/*if(document.fform.elements['form_data[languages_other]'].value == ""){
        validationarr[i] = (parseInt(i)+parseInt(1))+") Other is required.\n";i++;
		requiredfields[k] = "form_data[languages_other]";k++;
		if(!focusto){focusto="form_data[languages_other]"};
	}*/
	if(document.getElementById('legalnamehid').value== 0){
		if(document.fform.elements['form_data[other_legal_name]'].value == ""){
	        validationarr[i] = (parseInt(i)+parseInt(1))+") Other Legal Name is required.\n";i++;
			requiredfields[k] = "form_data[other_legal_name]";k++;
			if(!focusto){focusto="form_data[other_legal_name]"};
		}
	}
	if(document.getElementById('workedid').value== 0){
		if(document.fform.elements['form_data[dates_of_employmen]'].value == ""){
	        validationarr[i] = (parseInt(i)+parseInt(1))+") Dates of employment is required.\n";i++;
			requiredfields[k] = "form_data[dates_of_employmen]";k++;
			if(!focusto){focusto="form_data[dates_of_employmen]"};
		}
	}
	if(document.getElementById('workedid1').value== 0){
		if(document.fform.elements['form_data[person_name_relationship]'].value == ""){
	        validationarr[i] = (parseInt(i)+parseInt(1))+") person's Name and Relationship to you is required.\n";i++;
			requiredfields[k] = "form_data[person_name_relationship]";k++;
			if(!focusto){focusto="form_data[person_name_relationship]"};
		}
	}
	if(document.getElementById('convincedid').value== 0){
		if(document.fform.elements['form_data[name_of_offense]'].value == ""){
	        validationarr[i] = (parseInt(i)+parseInt(1))+") Name of offense is required.\n";i++;
			requiredfields[k] = "form_data[name_of_offense]";k++;
			if(!focusto){focusto="form_data[name_of_offense]"};
		}
		if(document.fform.elements['form_data[location_of_court]'].value == ""){
	        validationarr[i] = (parseInt(i)+parseInt(1))+") Name of and location of court  is required.\n";i++;
			requiredfields[k] = "form_data[location_of_court]";k++;
			if(!focusto){focusto="form_data[location_of_court]"};
		}
		if(document.fform.elements['form_data[deposition_of_case]'].value == ""){
	        validationarr[i] = (parseInt(i)+parseInt(1))+") Deposition of case is required.\n";i++;
			requiredfields[k] = "form_data[deposition_of_case]";k++;
			if(!focusto){focusto="form_data[deposition_of_case]"};
		}
		if(document.fform.elements['form_data[deposition_date]'].value == ""){
	        validationarr[i] = (parseInt(i)+parseInt(1))+") Date is required.\n";i++;
			requiredfields[k] = "form_data[deposition_date]";k++;
			if(!focusto){focusto="form_data[deposition_date]"};
		}
	}
	if(document.getElementById('addUnemploymentPeriod').value!= ""){
		var m=document.getElementById('addUnemploymentPeriod').value;
		for(var l=0;l<m;l++){
			if(document.getElementById('unemployment'+(parseInt(l)+parseInt(1))).value == "0"){
				if(document.fform.elements['form_data[periods_of_unemployment_from_date'+(parseInt(l)+parseInt(1))+']'].value == ""){
			        validationarr[i] = (parseInt(i)+parseInt(1))+") Periods of Unemployment From Date "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
					requiredfields[k] = "form_data[periods_of_unemployment_from_date"+(parseInt(l)+parseInt(1))+"]";k++;
					if(!focusto){focusto='form_data[periods_of_unemployment_from_date'+(parseInt(l)+parseInt(1))+']'};
				}
				if(document.fform.elements['form_data[periods_of_unemployment_to_date'+(parseInt(l)+parseInt(1))+']'].value == ""){
			        validationarr[i] = (parseInt(i)+parseInt(1))+") Periods of Unemployment To Date "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
					requiredfields[k] = "form_data[periods_of_unemployment_to_date"+(parseInt(l)+parseInt(1))+"]";k++;
					if(!focusto){focusto='form_data[periods_of_unemployment_to_date'+(parseInt(l)+parseInt(1))+']'};
				}
				if(document.fform.elements['form_data[periods_of_unemployment_from_date'+(parseInt(l)+parseInt(1))+']'].value != "" && document.fform.elements['form_data[job_to_date'+(parseInt(l)+parseInt(1))+']'].value != ""){
			       var str1  = document.fform.elements['form_data[periods_of_unemployment_from_date'+(parseInt(l)+parseInt(1))+']'].value;
				   var str2  = document.fform.elements['form_data[periods_of_unemployment_to_date'+(parseInt(l)+parseInt(1))+']'].value;
				   var date1=getDate(str1);
				   var date2=getDate(str2);
				   if(date2 < date1)
				   {
				   		validationarr[i] = (parseInt(i)+parseInt(1))+") Periods of Unemployment from date "+(parseInt(l)+parseInt(1))+" cannot be greater than Periods of Unemployment to date "+(parseInt(l)+parseInt(1))+" .\n";i++;
						requiredfields[k] = "form_data[periods_of_unemployment_from_date"+(parseInt(l)+parseInt(1))+"]";k++;
						if(!focusto){focusto='form_data[periods_of_unemployment_from_date'+(parseInt(l)+parseInt(1))+']'};
				   }
				   
				}
				if(document.fform.elements['form_data[periods_of_unemployment_pertinent_reasons'+(parseInt(l)+parseInt(1))+']'].value == ""){
			        validationarr[i] = (parseInt(i)+parseInt(1))+") Periods of Unemployment Pertinent Reasons "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
					requiredfields[k] = "form_data[periods_of_unemployment_pertinent_reasons"+(parseInt(l)+parseInt(1))+"]";k++;
					if(!focusto){focusto='form_data[periods_of_unemployment_pertinent_reasons'+(parseInt(l)+parseInt(1))+']'};
				}
			}
		}
	}
	if(document.getElementById('addReference').value!= ""){
		var m=document.getElementById('addReference').value;
		for(var l=0;l<m;l++){
			if(document.fform.elements['form_data[references_name'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") Reference Name "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = "form_data[references_name"+(parseInt(l)+parseInt(1))+"]";k++;
				if(!focusto){focusto='form_data[references_name'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[references_organization'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") Reference Organization "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = "form_data[references_organization"+(parseInt(l)+parseInt(1))+"]";k++;
				if(!focusto){focusto='form_data[references_organization'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[references_address'+(parseInt(l)+parseInt(1))+']'].value == ""){
		        validationarr[i] = (parseInt(i)+parseInt(1))+") Reference Address "+(parseInt(l)+parseInt(1))+" is required.\n";i++;	
				requiredfields[k] = "form_data[references_address"+(parseInt(l)+parseInt(1))+"]";k++;
				if(!focusto){focusto='form_data[references_address'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[references_phone'+(parseInt(l)+parseInt(1))+']'].value == ""){
				validationarr[i] = (parseInt(i)+parseInt(1))+") Reference Telephone Number "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = "form_data[references_phone"+(parseInt(l)+parseInt(1))+"]";k++;
				if(!focusto){focusto='form_data[references_phone'+(parseInt(l)+parseInt(1))+']'};
			}
			if(document.fform.elements['form_data[references_years_known'+(parseInt(l)+parseInt(1))+']'].value == ""){
				validationarr[i] = (parseInt(i)+parseInt(1))+") Reference Years Known "+(parseInt(l)+parseInt(1))+" is required.\n";i++;
				requiredfields[k] = "form_data[references_years_known"+(parseInt(l)+parseInt(1))+"]";k++;
				if(!focusto){focusto='form_data[references_years_known'+(parseInt(l)+parseInt(1))+']'};
			}
		}
	}
	if(validationarr.length != "")
    {
//    	alert("allfields.length: "+allfields.length);
    	for(var m=0;m<allfields.length;m++){
//    		alert(m+" : "+allfields[m]);
	    	document.fform.elements[allfields[m]].style.border = "1px solid black";
    	}
		for(var j=0;j<requiredfields.length;j++){
 			document.fform.elements[requiredfields[j]].style.border = "1px solid red";
		}
        for(var j=0;j<validationarr.length;j++){
			validation +=validationarr[j] ;
			if(j==49){
				break;
			}
		}
		//document.getElementById('errmessage').innerHTML = validation;
		alert(validation);
	    document.fform.elements[focusto].focus();
	    return false;
	}
    else
    {
        return true;
    }
	return false;
}
function getDate(v){
   var date   = parseInt(v.substring(0,2),10); 
   var month  = parseInt(v.substring(3,5),10);
   var year   = parseInt(v.substring(6,10),10); 
   return date = new Date(year, month, date); 
}
function add_new_job(){
	var j =document.getElementById('jobblock').value;
	console.log(j);

	var i = (parseInt(j)+parseInt(1)); 
	document.getElementById('jobblock').value = i;
	document.getElementById('job'+i).style.display = 'inline';
	document.getElementById('jobblock'+i).style.display = 'inline';
	if(i == 10){
		document.getElementById('add_job').style.display = "none"
	}
}
function add_new_clg_uni(){
	var j =document.getElementById('addClgUniAttended').value;
	var i = (parseInt(j)+parseInt(1)); 
	document.getElementById('addClgUniAttended').value = i;
	document.getElementById('clguniattend'+i).style.display = 'inline';
	if(i == 10){
		document.getElementById('add_clg_uni').style.display = "none"
	}
	
	/*var j =document.getElementById('addClgUniAttended').value;
	var i = (parseInt(j)+parseInt(1)); 
	var laststr = "";
	var str = '<table width="100%"><tr><td colspan="20"><table width="100%"><tr><td class="form_label" valign="bottom" width="1%">Name&nbsp;<font color="red" size="3"><b>*</b></font></td><td class="input_field" valign="bottom"><input onblur="" name="form_data[colleges_name##]" class="input_field" value="" size="30" type="text"></td><td class="form_label" valign="bottom" width="1%">Location&nbsp;<font color="red" size="3"><b>*</b></font></td><td class="input_field" valign="bottom"><input onblur="" name="form_data[colleges_location##]" class="input_field" value="" size="30" type="text"></td></tr><tr><td class="form_label" valign="bottom" width="1%">Years Attended&nbsp;<font color="red" size="3"><b>*</b></font></td><td class="input_field" valign="bottom"><input onblur="" name="form_data[colleges_years##]" class="input_field" value="" size="5" type="text"></td><td colspan="20"><table cellpadding="0" cellspacing="0" width="1%"><tbody><tr><td  colspan="1" class="simple_label" valign="bottom"><b>Did&nbsp;You&nbsp;Graduate?</b></td><td colspan="1" valign="top"><table cellpadding="0" cellspacing="0" width="1%"><tbody><tr><td valign="bottom"><input value="Yes" name="form_data[colleges_graduate##]" onclick="checkgrade(this.value)" type="radio"></td><td class="form_label" nowrap="nowrap" valign="bottom" width="50%">Yes</td><td valign="bottom"><input value="No" name="form_data[colleges_graduate##]" onclick="checkgrade(this.value)" type="radio"></td><td class="form_label" nowrap="nowrap" valign="bottom" width="50%">No</td></tr></tbody></table></td></tr></tbody></table></td></tr></table></td></tr><tr><td colspan="20"><table style="display:none;" id="credithours" width="100%"><tbody><tr><td class="form_label" nowrap="nowrap" valign="bottom" width="1%">If Not, # of Years Attended or Credit Hours Earned&nbsp;<font color="red" size="3"><b>*</b></font></td><td class="input_field" valign="bottom"><input onblur="" name="form_data[colleges_credit_hours##]" class="input_field" value="" size="8" type="text"></td></tr></tbody></table></td></tr><tr><td colspan="20"><table width="100%"><tbody><tr><td class="form_label" nowrap="nowrap" valign="bottom" width="1%">Degree/Certificate Received&nbsp;<font color="red" size="3"><b>*</b></font></td><td class="input_field" valign="bottom"><input onblur="" name="form_data[colleges_degree##]" class="input_field" value="" size="30" type="text"></td></tr></tbody></table></td></tr><tr><td colspan="20"><table width="100%"><tbody><tr><td class="form_label" nowrap="nowrap" valign="bottom" width="1%">Major Field of Study&nbsp;<font color="red" size="3"><b>*</b></font></td><td class="input_field" valign="bottom"><input onblur="" name="form_data[colleges_major_field##]" class="input_field" value="" size="30" type="text"></td></tr></tbody></table></td></tr></tbody></table><br/><br/>';
	
	
	document.getElementById('addClgUniAttended').value = i;
	for(var k=1;k<=i;k++){
		laststr += str.replace(/##/gi,k);
	}
	document.getElementById('clguniattend').innerHTML = laststr;*/
}
function add_new_special_training(){
	var j =document.getElementById('addSpecialTraining').value;
	var i = (parseInt(j)+parseInt(1)); 
	document.getElementById('addSpecialTraining').value = i;
	document.getElementById('SpecialTraining'+i).style.display = 'inline';
	if(i == 10){
		document.getElementById('add_spe_tra').style.display = "none"
	}
	/*var j =document.getElementById('addSpecialTraining').value;
	var i = (parseInt(j)+parseInt(1)); 
	var laststr = "";
	var str = '<table width="100%"><tr></tr><tr><td colspan="20"><table width="100%"><tbody><tr><td width="1%" valign="bottom" class="form_label">Name&nbsp;<font size="3" color="red"><b>*</b></font></td><td valign="bottom" class="input_field"><input type="text" size="15" value="" class="input_field" name="form_data[special_training_name##]" onblur=""></td><td width="1%" valign="bottom" class="form_label">Location&nbsp;<font size="3" color="red"><b>*</b></font></td><td valign="bottom" class="input_field"><input type="text" size="15" value="" class="input_field" name="form_data[special_training_location##]" onblur=""></td></tr><tr><td width="1%" valign="bottom" class="form_label">Years Attended&nbsp;<font size="3" color="red"><b>*</b></font></td><td valign="bottom" class="input_field"><input type="text" size="15" value="" class="input_field" name="form_data[special_training_years##]" onblur=""></td><td width="1%" valign="bottom" class="form_label">Total&nbsp;Time&nbsp;Completed&nbsp;<font size="3" color="red"><b>*</b></font></td><td valign="bottom" class="input_field"><input type="text" size="15" value="" class="input_field" name="form_data[special_training_total_time##]" onblur=""></td></tr></tbody></table></td></tr><tr><td colspan="20"><table width="100%"><tbody><tr><td width="1%" valign="top" nowrap="" class="form_label">Courses or Subjects Taken&nbsp;<font size="3" color="red"><b>*</b></font></td><td valign="top" class="input_field"><div><div><textarea cols="50" rows="5" class="input_field" name="form_data[special_training_courses##]" size="30" maxlength="500" value=""></textarea><div id="disp##"><small><span>0</span><span> characters entered.&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;</span><span>500</span><span> characters remaining.</span></small></div></div><div><small><span>0</span><span> characters entered.&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;</span><span>500</span><span> characters remaining.</span></small></div></div></td></tr></tbody></table></td></tr><tr><td colspan="20"><table width="100%"><tbody><tr><td width="1%" valign="top" nowrap="" class="form_label">Certificates Given or Other Pertinent Data&nbsp;<font size="3" color="red"><b>*</b></font></td><td valign="top" class="input_field"><div><div><textarea cols="50" rows="5" class="input_field" name="form_data[special_training_certificates##]" size="30" maxlength="500" value=""></textarea><div id="disp1##"><small><span>0</span><span> characters entered.&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;</span><span>500</span><span> characters remaining.</span></small></div></div><div><small><span>0</span><span> characters entered.&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;</span><span>500</span><span> characters remaining.</span></small></div></div></td></tr></tbody></table></td></tr></table><br/><br/>';
	
	
	document.getElementById('addSpecialTraining').value = i;
	
	for(var k=1;k<=i;k++){
		laststr += str.replace(/##/gi,k);
	}
	document.getElementById('SpecialTraining').innerHTML = laststr;
	for(var k=1;k<=i;k++){
		document.getElementById('disp'+k).style.display = 'none';
		document.getElementById('disp1'+k).style.display = 'none';
	}	*/
}
function add_new_unemployment_period(){
	var j =document.getElementById('addUnemploymentPeriod').value;
	var i = (parseInt(j)+parseInt(1)); 
	document.getElementById('addUnemploymentPeriod').value = i;
	document.getElementById('UnemploymentPeriod'+i).style.display = 'inline';
	if(i == 10){
		document.getElementById('add_unemployd').style.display = "none"
	}
	
	/*var j =document.getElementById('addUnemploymentPeriod').value;
	var i = (parseInt(j)+parseInt(1)); 
	var laststr = "";
	var str = '<table width="100%"><tbody><tr><td valign="bottom" width="5%" colspan="1" class="simple_label"><b>From:</b></td><td valign="bottom" class="form_label" width="95%"><input type="text" style="color: ;" name="form_data[periods_of_unemployment_from_date##]" class="input_field" value="" size="20">&nbsp;<a onclick="popUpCalendar( document.fform.elements[\'form_data[periods_of_unemployment_from_date##]\'], document.fform.elements[\'form_data[periods_of_unemployment_from_date##]\'], \'mm/dd/yyyy\');return false;" href=\'./\'><img border="0" src="./../images/cal.gif"></a></td></tr><tr><td valign="bottom" width="5%" colspan="1" class="simple_label"><b>To:</b></td><td width="1%" valign="bottom" class="form_label"><input type="text" style="color: ;" name="form_data[periods_of_unemployment_to_date##]" class="input_field" value="" size="20">&nbsp;<a onclick="popUpCalendar( document.fform.elements[\'form_data[periods_of_unemployment_to_date##]\'], document.fform.elements[\'form_data[periods_of_unemployment_to_date##]\'], \'mm/dd/yyyy\');return false;" href=\'./\'><img border="0" src="./../images/cal.gif"></a></td></tr><tr><td colspan="20"><table width="100%"><tbody><tr><td width="1%" valign="bottom" nowrap="" class="form_label">Pertinent Reasons&nbsp;<font size="3" color="red"><b>*</b></font></td><td valign="bottom" class="input_field"><input type="text" onblur="" name="form_data[periods_of_unemployment_pertinent_reasons##]" class="input_field" value="" size="60"></td></tr></tbody></table></td></tr></tbody></table><br/><br/>';
	
	
	document.getElementById('addUnemploymentPeriod').value = i;
	for(var k=1;k<=i;k++){
		laststr += str.replace(/##/gi,k);
	}
	document.getElementById('UnemploymentPeriod').innerHTML = laststr;
	*/
}
function add_new_reference(){
	var j =document.getElementById('addReference').value;
	var i = (parseInt(j)+parseInt(1)); 
	document.getElementById('addReference').value = i;
	document.getElementById('ReferenceDetail'+i).style.display = 'inline';
	if(i == 10){
		document.getElementById('add_ref').style.display = "none"
	}
	
	/*var j =document.getElementById('addReference').value;
	var i = (parseInt(j)+parseInt(1)); 
	var laststr = "";
	var str = '<table width="100%"><tr><td colspan="20"><table width="100%"><tbody><tr><td width="1%" valign="bottom" class="form_label">Name&nbsp;<font size="3" color="red"><b>*</b></font></td><td valign="bottom" class="input_field"><input type="text" onblur="" name="form_data[references_name##]" class="input_field" value="" size="20"></td><td width="1%" valign="bottom" class="form_label">Organization&nbsp;<font size="3" color="red"><b>*</b></font></td><td valign="bottom" class="input_field"><input type="text" onblur="" name="form_data[references_organization##]" class="input_field" value="" size="20"></td></tr><tr><td width="1%" valign="bottom" class="form_label">Address&nbsp;<font size="3" color="red"><b>*</b></font></td><td valign="bottom" colspan="3" class="input_field"><input type="text" onblur="" name="form_data[references_address##]" class="input_field" value="" size="60"></td></tr><tr><td width="1%" valign="bottom" class="form_label">Telephone Number&nbsp;<font size="3" color="red"><b>*</b></font></td><td valign="bottom" class="input_field"><input type="text" onblur="" name="form_data[references_phone##]" class="input_field" value="" size="20"></td><td width="1%" valign="bottom" class="form_label">Years&nbsp;Known&nbsp;<font size="3" color="red"><b>*</b></font></td><td valign="bottom" class="input_field"><input type="text" onblur="" name="form_data[references_years_known##]" class="input_field" value="" size="20"></td></tr></tbody></table></td></tr></table><br/><br/>';
	
	
	document.getElementById('addReference').value = i;
	for(var k=1;k<=i;k++){
		laststr += str.replace(/##/gi,k);
	}
	document.getElementById('ReferenceDetail').innerHTML = laststr;
	*/
}
function echeck(str){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(str.match(emailExp)){
 		return true;
 	}
	else{
 		return false;
 	}
}
function checkyears(v){
	if(v>=7){
		document.getElementById('previousadd').style.display='none';
		document.getElementById('prev_add').value='1';
	}
	else{
		document.getElementById('previousadd').style.display='inline';
		document.getElementById('prev_add').value='0';
	}
}
function checkgrade(v){
	if(v=='Yes'){
		document.getElementById('credithours').style.display='none';
		document.getElementById('grade').value='1';
	}
	else{
		document.getElementById('credithours').style.display='inline';
		document.getElementById('grade').value='0';
	}
}
function checkgrade1(v){
	if(v=='Yes'){
		document.getElementById('credithours1').style.display='none';
		document.getElementById('grade1').value='1';
	}
	else{
		document.getElementById('credithours1').style.display='inline';
		document.getElementById('grade1').value='0';
	}
}
function checklegal(v){
	if(v=='No'){
		document.getElementById('legalname').style.display='none';
		document.getElementById('legalnamehid').value='1';
	}
	else{
		document.getElementById('legalname').style.display='inline';
		document.getElementById('legalnamehid').value='0';
	}
}
function ArmedForse(v){
	if(v=='No'){
		document.getElementById('armedforse').style.display='none';
		document.getElementById('armedforseid').value='1';
	}
	else{
		document.getElementById('armedforse').style.display='inline';
		document.getElementById('armedforseid').value='0';
	}
}
function Wrokedfor(v){
	if(v=='No'){
		document.getElementById('worked1').style.display='none';
//		document.getElementById('worked2').style.display='none';
		document.getElementById('workedid').value='1';
	}
	else{
		document.getElementById('worked1').style.display='inline';
//		document.getElementById('worked2').style.display='inline';
		document.getElementById('workedid').value='0';
	}
}
function Wrokedfor1(v){
	if(v=='No'){
		document.getElementById('worked3').style.display='none';
	 	document.getElementById('workedid1').value='1';
	}
	else{
		document.getElementById('worked3').style.display='inline';
		document.getElementById('workedid1').value='0';
	}
}
function Convinced(v){
	if(v=='No'){
		document.getElementById('convinced').style.display='none';
		document.getElementById('convinced1').style.display='none';
		document.getElementById('convinced2').style.display='none';
		document.getElementById('convinced3').style.display='none';
		document.getElementById('convincedid').value='1';
	}
	else{
		document.getElementById('convinced').style.display='inline';
		document.getElementById('convinced1').style.display='inline';
		document.getElementById('convinced2').style.display='inline';
		document.getElementById('convinced3').style.display='inline';
		document.getElementById('convincedid').value='0';
	}
}
function checksupervisor(v,sid,hidid){
	if(v=='No'){
		document.getElementById(sid).style.display='none';
		document.getElementById(hidid).value='1';
	}
	else{
		document.getElementById(sid).style.display='inline';
		document.getElementById(hidid).value='0';
	}
}
function Checkotherrequired(v){
	document.getElementById('checkvalue').value = v;
	if(v== 'Other'){
		document.getElementById('otherNumber').innerHTML = '<table width="100%"><tr><td width="1%" valign="bottom" class="form_label">Area&nbsp;Code</td><td valign="bottom" class="input_field"><input id="area2" onkeypress="return checkItphone(event,this.id,\'number2\')" maxlength="3" type="text" onblur="" name="form_data[ohter_phone_area_code]" class="input_field" value="" size="10"></td><td width="1%" valign="bottom" class="form_label">Number</td><td valign="bottom" class="input_field"><input id="number2" onkeypress="return checkItphone(event,this.id,\'valid_licence\',\'8\',this.value)" maxlength="8" type="text" onblur="" name="form_data[other_phone_number]" class="input_field" value="" size="47"><input id="chkv" type="hidden" value="'+v+'" size="10"></td></tr></table>';
		
	}
	else{
		document.getElementById('otherNumber').innerHTML = '<table width="100%"><tr><td width="1%" valign="bottom" class="form_label">Area&nbsp;Code&nbsp;<font size="3" color="red"><b>*</b></font></td><td valign="bottom" class="input_field"><input id="area2" onkeypress="return checkItphone(event,this.id,\'number2\')" maxlength="3" type="text" onblur="" name="form_data[ohter_phone_area_code]" class="input_field" value="" size="10"></td><td width="1%" valign="bottom" class="form_label">Number&nbsp;<font size="3" color="red"><b>*</b></font></td><td valign="bottom" class="input_field"><input id="number2" onkeypress="return checkItphone(event,this.id,\'valid_licence\',\'8\',this.value)" maxlength="8" type="text" onblur="" name="form_data[other_phone_number]" class="input_field" value="" size="47"></td><input id="chkv" type="hidden" value="'+v+'" size="10"></tr></table>';
	}
	
}
function checkIt(evt,id,nextid,maxlen,v) {
	/*var str =document.getElementById(id).value;*/
	var len = maxlen;
	evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode;
	if ((charCode < 48 || charCode > 57) && charCode != 8 && (charCode < 96 || charCode > 105)) {
        return false;
    }else{
    	if(v.length == len){
    		document.getElementById(nextid).focus();
    	}
    	return true;
	}
}
function checkItphone(evt,id,nextid,maxlen,v) {
	//var str =document.getElementById(id).value;
	var len = maxlen;
	evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode;
	if ((charCode < 48 || charCode > 57) && charCode != 8 && (charCode < 96 || charCode > 105)) {
        return false;
    }else{
    	if(v.length == len){
    		document.getElementById(nextid).focus();
    	}
    	return true;
	}
}
function High_School_Diploma(v){
	if(v=='No'){
	 	document.getElementById('high_school_deploma').value='1';
	}
	else{
		document.getElementById('high_school_deploma').value='0';
	}
}
function UnemploymentYes(v,id,hidid){
   if(v=='No'){	
		document.getElementById(id).style.display='none';
		document.getElementById(hidid).value='1';
	}
	else{
		document.getElementById(id).style.display='inline';
		document.getElementById(hidid).value='0';
	}
}
function LanguageSpokenO(v){
   if(v=='No'){	
		document.getElementById('EngSpokn').style.display='none';
		document.getElementById('language_spoken').value='1';
	}
	else{
		document.getElementById('EngSpokn').style.display='inline';
		document.getElementById('language_spoken').value='0';
	}
}
function LanguageWritenO(v){
   if(v=='No'){	
		document.getElementById('EngWriten').style.display='none';
		document.getElementById('language_written').value='1';
	}
	else{
		document.getElementById('EngWriten').style.display='inline';
		document.getElementById('language_written').value='0';
	}
}
