      function toggle_section(ele)
      {


      element=ele+"_data"
      element_add_link="add_"+ele+"_link"
      element_plus=ele+"_plus"
      element_minus=ele+"_minus"
      new Effect[Element.visible(element) ?
            'BlindUp' : 'BlindDown'](element, {duration: 0.25});
       if(Element.visible(element))
       {
         Element.hide(element_plus);
         if($(element_add_link))
             {
                 Element.hide(element_add_link);
             }
         Element.show(element_minus);         
       }
       else
         {
           Element.hide(element_minus);
           if($(element_add_link))
             {
                 Element.show(element_add_link);
             }
           Element.show(element_plus);

         }
      }
      function moveUp(ele)
      {
       $$('div.tooltip-wrapper-box').invoke('hide');
       var element=  $(ele);
       var element_previous = element.previous();
       //alert(element_previous.id);

       UnloadTinymce(element.id.toString());
       UnloadTinymce(element_previous.id.toString());

    element.parentNode.insertBefore(element,element_previous);

        LoadTinymce(element);
        LoadTinymce(element_previous);

       check_disabled_up(element.id);
       check_disabled_down(element.id);
       if (element_previous.firstChild.id.toString().search("new") == -1)
         {
             check_disabled_up(element_previous.id);
             check_disabled_down(element_previous.id);
         }

      }

      function moveDown(ele)
      {
       $$('div.tooltip-wrapper-box').invoke('hide');
       var element=  $(ele);
       var element_next = element.next();
       

       UnloadTinymce(element.id.toString());
       UnloadTinymce(element_next.id.toString());



    element.parentNode.insertBefore(element_next,element);

        LoadTinymce(element);
        LoadTinymce(element_next);

       check_disabled_up(element.id);
       check_disabled_down(element.id);
       if (element_next.firstChild.id.toString().search("new") == -1)
         {
             check_disabled_up(element_next.id);
             check_disabled_down(element_next.id);
         }
       
    
       }
      function check_disabled_up(ele)
      {

          var div=$(ele);
          var element=$(ele+"_up");
          var element_disabled=$(ele+"_up_disabled");
          if(div.previous() == null)
              {
                  element.hide();
                  element_disabled.show();
              }
          else
              {
                  element_disabled.hide();
                  element.show();
              }

      }
function check_disabled_down(ele)
      {

          var div=$(ele);
          var element=$(ele+"_down");
          var element_disabled=$(ele+"_down_disabled");
          if(div.next() == null)
              {
                  element.hide();
                  element_disabled.show()
              }
          else
              {
                  element_disabled.hide()
                  element.show();
              }

      }

function check_disabled_up_down(ele)
      {

          var element=$(ele);
          if(element.previous() != null)
              {
                  var element_previous = element.previous();
                  if (element_previous.firstChild.id.toString().search("new") == -1)
                      {
                          check_disabled_up(element_previous.id);
                          check_disabled_down(element_previous.id);
                      }
                  
              }

           if(element.next() != null)
              {
                  var element_next = element.next();
                  if (element_next.firstChild.id.toString().search("new") == -1)
                      {
                          check_disabled_up(element_next.id);
                          check_disabled_down(element_next.id);
                      }
              }
           check_disabled_up(element.id);
           check_disabled_down(element.id);


      }

function check_disabled_up_down_remove(ele)
      {

          var element=$(ele);
          var element_previous = null;
          var element_next = null;
          if(element.previous() != null)
              {
                  element_previous = element.previous();
              }

           if(element.next() != null)
              {
                  element_next = element.next();
              }
           element.remove();
          
           if(element_previous != null)
              {
                  if (element_previous.firstChild.id.toString().search("new") == -1)
                      {
                          check_disabled_up(element_previous.id);
                          check_disabled_down(element_previous.id);
                      }
              }

           if(element_next != null)
              {
                  if (element_next.firstChild.id.toString().search("new") == -1)
                      {
                          check_disabled_up(element_next.id);
                          check_disabled_down(element_next.id);
                      }
              }

              


      }

function check_disabled_up_down_add(ele)
      {

          var element=$(ele);
          var element_previous = null;
          var element_next = null;
          if(element.previous() != null)
              {
                  element_previous = element.previous();
              }

           if(element.next() != null)
              {
                  element_next = element.next();
              }
          
           if(element_previous != null)
              {
                  if (element_previous.firstChild.id.toString().search("new") == -1)
                      {
                          check_disabled_up(element_previous.id);
                          check_disabled_down(element_previous.id);
                      }
              }

           if(element_next != null)
              {
                  if (element_next.firstChild.id.toString().search("new") == -1)
                      {
                          check_disabled_up(element_next.id);
                          check_disabled_down(element_next.id);
                      }
              }




      }

function LoadTinymce(element)
{
var counter=0;
var div1=$(element.id.toString());
var tinymce_div_array=div1.getElementsByTagName("textarea");
while(counter<tinymce_div_array.length)
    {
        tinyMCE.execCommand('mceAddControl', true, tinymce_div_array[counter].id);
        counter=counter+1;
    }
}

function UnloadTinymce(element)
{
    var counter=0;
    var div1=$(element);
    var tinymce_div_array=div1.getElementsByTagName("textarea");
    while(counter<tinymce_div_array.length)
        {
          tinyMCE.execCommand("mceRemoveControl" , true, tinymce_div_array[counter].id);
          counter=counter+1;
        }
}


function submit_form(form_name)
      {

        document.forms[form_name].submit();
        $('photo_spinner').show()
      }




function show_spinner(element,spinner)
{
    $(element).hide();
    $(spinner).show();
    
}

function updateNewSectionList()
{
    if($('objective'))
        {
            $('add_new_objective_dropdown').hide()
            
        }
    else
        {
            $('add_new_objective_dropdown').show()
            
        }
    if($('education'))
        {
            $('add_new_education_dropdown').hide()
            
        }
    else
        {
            $('add_new_education_dropdown').show()
            
        }
    if($('experience'))
        {
            $('add_new_experience_dropdown').hide()
            
        }
    else
        {
            $('add_new_experience_dropdown').show()
           
        }
    if($('skill'))
        {
            $('add_new_skill_dropdown').hide()
            
        }
    else
        {
            $('add_new_skill_dropdown').show()
            
        }
    if($('certification'))
        {
            $('add_new_certification_dropdown').hide()
            
        }
    else
        {
            $('add_new_certification_dropdown').show()
            
        }
    if($('reference'))
        {
            $('add_new_reference_dropdown').hide()
            
        }
    else
        {
            $('add_new_reference_dropdown').show()
            
        }
    
}
function toggleAddNewSection()
{
    if($('addnewsection').visible())
        {
            Effect.BlindUp('addnewsection', { duration: 0.1 });
        }
    else
        {
            Effect.BlindDown('addnewsection', { duration: 0.1 });
        }
}

function addContactNo()
{
    for (var i = 1; i < 4; i++)
            {
                if(!$('contact_'+i).visible())
                    {
                        $('contact_detail_phone'+i).value=""
                        $('contact_'+i).show()
                        if(i==1)
                            {
                                $('remove_contact_link').show()
                            }
                        if(i==3)
                            {
                                $('add_contact_link').hide()
                            }
                        break
                    }
            }
}

function removeContactNo()
{
    for (var i = 3; i > 0; i--)
            {
                if($('contact_'+i).visible())
                    {
                        $('contact_'+i).hide();
                        $('contact_detail_phone'+i).value=""
                        $('add_contact_link').show()
                        if(i==1)
                            {
                                $('remove_contact_link').hide()
                            }
                        break
                    }
            }
}
function addWebsite()
{
    for (var i = 1; i < 4; i++)
            {
                if(!$('website_'+i).visible())
                    {
                        $('contact_detail_website'+i).value="Title"
                        $('contact_detail_website_url'+i).value="URL"
                        $('website_'+i).show()
                        if(i==1)
                            {
                                $('remove_website_link').show()
                            }
                        if(i==3)
                            {
                                $('add_website_link').hide()
                            }
                        break
                    }
            }
}

function removeWebsite()
{
    for (var i = 3; i > 0; i--)
            {
                if($('website_'+i).visible())
                    {
                        $('website_'+i).hide();
                        $('contact_detail_website'+i).value=""
                        $('contact_detail_website_url'+i).value=""
                        $('add_website_link').show()
                        if(i==1)
                            {
                                $('remove_website_link').hide()
                            }
                        break
                    }
            }
}

function addNewSectionFromDropDown(section_name)
{
    if($(section_name) && section_name != "custom_item")
        {
            Effect.ScrollTo(section_name,{ duration: 1.0,offset: -10 });
        }
    else
        {
            $('addSectionMenu').hide();
            $('add_section_drop_down_spinner').show();
            new Ajax.Request('/resume/new_section?section_name='+section_name, {asynchronous:true, evalScripts:true, onComplete:function(request){Effect.ScrollTo($('main').childElements().last(),{ duration: 1.0,offset: -10 });$('add_section_drop_down_spinner').hide();$('addSectionMenu').show();}});

        }
    
    return false;
}

function addNewSectionFromIcon(section_name)
{
    if($(section_name) && section_name != "custom_item")
        {
            Effect.ScrollTo(section_name,{ duration: 1.0,offset: -10 });
        }
    else
        {
            $(section_name+"_icon").hide();
            $(section_name+"_icon_spinner").show();
            new Ajax.Request('/resume/new_section?section_name='+section_name, {asynchronous:true, evalScripts:true, onComplete:function(request){Effect.ScrollTo($('main').childElements().last(),{ duration: 1.0,offset: -10 });$(section_name+"_icon_spinner").hide();$(section_name+"_icon").show();}});
            
        }

    return false;
}

function defaultTextInWebsiteTitleOnFocus(field){
    if ($(field).value == 'Title')
    {
      $(field).value='';
      $(field).removeClassName('textbox_small-margin_grey');
      $(field).addClassName('textbox_small-margin')};
  }

  function defaultTextInWebsiteTitleOnBlur(field){
    if ($(field).value == '')
    {
      $(field).value='Title';
      $(field).removeClassName('textbox_small-margin');
      $(field).addClassName('textbox_small-margin_grey')};
  }
  function defaultTextInWebsiteUrlOnFocus(field){
    if ($(field).value == 'URL')
    {
      $(field).value='';
      $(field).removeClassName('textbox_small_grey');
      $(field).addClassName('textbox_small')};
  }

  function defaultTextInWebsiteUrlOnBlur(field){
    if ($(field).value == '')
    {
      $(field).value='URL';
      $(field).removeClassName('textbox_small');
      $(field).addClassName('textbox_small_grey')};
  }
  function confirm_box(url,elementId,spinnerId)
  {
      var str="Are you sure you want to remove this section?"
      var response_function = "\'confirm_box_response(\""+url+"\",\""+elementId+"\",\""+spinnerId+"\")"
      showDialog('Confirmation','<img class="center" src="/images/icon_alert.png"/>&nbsp;'+str+'<br /><br /><a href=\'#\' onclick='+response_function+'; hideDialog();return false\'>yes</a> | <a href=\'#\' onclick=\'hideDialog();return false;\'>no</a>','prompt');
  }
  function confirm_box_response(url,elementId,spinnerId)
  {
      if(url != 0)
          {
              $(elementId).hide();
              $(spinnerId).show();
              new Ajax.Request(url, {asynchronous:true, evalScripts:true});
          }
      return false

  }
  function alert_box(str)
  {
      showDialog('Error','<img class="center" src="/images/icon_alert.png"/>&nbsp;'+str+'<br /><br /><a href=\'#\' onclick=\'hideDialog();return false;\'>Ok</a> ','prompt');
      return false;
  }
  function update_name_in_title(fname,lname)
  {
      document.title = fname +" "+lname+" | Resume | Jobrary"
  }
  function moving_dialog_box()
  {
      showDialog('Error','<br/><br/><p style="text-align :center"><img class="center" src="/images/spinner.gif" />&nbsp;Moving..</p>','prompt');
  }
  function present_click(element_id,value)
  {
    if(value == "1")
        {
          $(element_id).hide();
          $(element_id.replace('_end_year_month','s')+"_end_year").value = ""
          $(element_id+"_present").hide();
          remove_end_year_error_msg(element_id.replace('_end_year_month','')+'_end_date_error')
        }
    else
        {
          $(element_id+"_present").hide();
          $(element_id).show();
        }


  }
  function remove_end_year_error_msg(element_id)
  {
      if(($(element_id).nextSiblings().length) > 0)
          {
              $(element_id).next().remove();
          }
  }