
function go_top(){
window.scroll(0,0);
}

  function bookmark()
  {
    title = document.title;
    url = document.location;

    if (window.sidebar) { // Mozilla Firefox Bookmark
      window.sidebar.addPanel(title, url, '');
    }
    else if(window.external) { // IE Favorite
    window.external.AddFavorite( url, title);
    }
    else if(window.opera && window.print) { // Opera Hotlist
      return true;
    }
  }
  
  function get_letter(obj){
  	  document.location.replace('#' + obj.options[obj.selectedIndex].value)
  }
  
  function init_cal(){
					        cal = new calendar2(document.getElementById('date_edit'));
					        cal.year_scroll = true;
					        cal.time_comp = true;

					        doctype_changed();	  
  }
  
  
  function country_check()
 {
   country =  document.getElementById('country').value;
   if(country=='3'){document.getElementById('state_id').style.display='inline';
                   }
   else{            document.getElementById('state_id').style.display='none';
                   }

 }
  
  function services_disable(a)
 {
  document.getElementById(a).disabled='disabled';
 }
  function services_able(a)
 {
  document.getElementById(a).disabled='';
 }

 function DoSub(f){
  alert('f');
 document.profile.submit();

 }


  function doctype_changed()
  {
	          ds = document.getElementById('doctype_select');
	          index = ds.options[ds.selectedIndex].value;
	          if (index=='67') {
	            document.getElementById('target_field').style.display = 'none';
	            document.getElementById('source_label').innerHTML = 'Language';
	          } else {
	            document.getElementById('target_field').style.display = 'block';
	            document.getElementById('source_label').innerHTML = 'Source Language';
	          }
  }

  function submit_form(id){
  	 document.getElementById(id).submit();
  }

              var num = 1;
              var last = 0;
              var maxnum = 10;

function fd(objSel,value) {
for(el in a)
  {
 addOption(objSel, a[el], el,value);
  }


}

function add_upload(code,value_left,value_right)
              {
                if (num >= 7)
                {
                  return;
                }
                var f='';
                var div = document.getElementById('upload_container');
                var newDiv = document.createElement('div');
                newDiv.setAttribute('id', 'div' + (last + 1));
                if(code=='no'){
                newDiv.innerHTML = '<div class=\'field_input\' name=\"file' + (last + 1) + '\">'+
                                    '<select id=\"pair_left' + (last + 1) + '\" name=\"pair_left' + (last + 1) + '\"  style=\"width:120px;display:inline\" />'+
                                    '<input type=\"hidden\" name=\"sasha\" value=\"1\">'+
                                    '</select><select id=\"pair_right' + (last + 1) + '\" name=\"pair_right' + (last + 1) + '\"  style=\"width:120px;display:inline\" /></select></div>';



                }else{
                newDiv.innerHTML = '<div class=\'field_input\' name=\"file' + (last + 1) + '\"><select id=\"pair_left' + (last + 1) + '\" name=\"pair_left' + (last + 1) + '\" style=\"width:120px;display:inline\"/></select><select id=\"pair_right' + (last + 1) + '\" name=\"pair_right' + (last + 1) + '\" style=\"width:120px;display:inline\" /></select><a title=\"Delete file\" onclick=\"javascript:delete_upload(' + (last + 1) + ');\" class=\'file_delete\'></a></div>';
                }

                last++;
                num++;
                div.appendChild(newDiv);
              if(num==2){fd(document.getElementById("pair_left1"),value_left);fd(document.getElementById("pair_right1"),value_right);}
              else {fd(document.getElementById("pair_left"+last),value_left);fd(document.getElementById("pair_right"+last),value_right);}}


              function delete_upload(number)
              {
                if (num <= 1)
                {
                  return;
                }
                if (confirm('Are you sure you want to delete this language pair?'))
                {
                  var divParent = document.getElementById('upload_container');
                  var div = document.getElementById('div' + number);
                  divParent.removeChild(div);
                  num--;
                }
              }

              function delete_uploaded(id)
              {
              	if (confirm('Are you sure you want to delete this language pair?')){
	              	var obj = document.getElementById('delete['+id+']');
	              	obj.value = 1;
	              	var obj2 = document.getElementById('div_delete['+id+']');
	              	obj2.style.display='none';
              	}
              }

function addOption (oListbox, text, value,value_left_or_right)
{
  var oOption = document.createElement("option");
  oOption.appendChild(document.createTextNode(text));
  oOption.setAttribute("value", value);
  if(value==value_left_or_right){oOption.selected = true; }
  else{oOption.defaultSelected = false;}


  oListbox.appendChild(oOption);
}


function xstooltip_findPosX(obj)
{
  var curleft = 0;
  if (obj.offsetParent)
  {
    while (obj.offsetParent)
        {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}

function xstooltip_findPosY(obj) 
{
    var curtop = 0;
    if (obj.offsetParent) 
    {
        while (obj.offsetParent) 
        {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}

function xstooltip_show(tooltipId, parentId, posX, posY)
{
    it = document.getElementById(tooltipId);
    
    if ((it.style.top == '' || it.style.top == 0) 
        && (it.style.left == '' || it.style.left == 0))
    {
        // need to fixate default size (MSIE problem)
        it.style.width = it.offsetWidth + 'px';
        it.style.height = it.offsetHeight + 'px';
        
        img = document.getElementById(parentId); 

        // if tooltip is too wide, shift left to be within parent 
        if (posX + it.offsetWidth > img.offsetWidth) posX = img.offsetWidth - it.offsetWidth;
        if (posX < 0 ) posX = 0; 
        
        x = xstooltip_findPosX(img) + posX;
        y = xstooltip_findPosY(img) + posY;
        
//        it.style.top = y + 'px';
 //       it.style.left = x + 'px';
    }
    
    it.style.visibility = 'visible'; 
}

function xstooltip_hide(id)
{
    it = document.getElementById(id); 
    it.style.visibility = 'hidden'; 
}

function checkregform()
{
  if (document.getElementById('firstname').value == '' || document.getElementById('lastname').value == ''
      || document.getElementById('email').value == '' || document.getElementById('country').value == ''
      || document.getElementById('city').value == '' || document.getElementById('state').value == ''
      || document.getElementById('street').value == '' || document.getElementById('zip').value == ''
      || document.getElementById('phonenumer').value == '' || document.getElementById('cert').value == ''
      || document.getElementById('references').value == '' || document.getElementById('file').value == '')
  {
    alert('All fields are required!');
  }
  else
  {
    submit_form('registration_form');
  }
}

      function load() {
        height = 600;
        width = 800;
        leftVal = (screen.width - width) / 2;
        topVal = (screen.height - height) / 2;
        window.open('terms_and_conditions.html','','scrollbars=yes,menubar=no,height='+height+',width='+width+',left='+leftVal+',top='+topVal+',resizable=yes,toolbar=no,location=no,status=no');
      }
