
function slideBillForm(val){
  if(val == 'company'){
    Effect.BlindUp('new');
  }else{
    new Effect.BlindDown('new');
  }
}



function slideJobApplicationForm(val){
  if(val == 'company'){
    Effect.BlindUp('new');
  }else{
    new Effect.BlindDown('new');
  }
}


function setCssClass(div1, hash){
 var d1;
 d1 = document.getElementById(div1);
 document.getElementById('services_item_'+hash).className='package_info_item';
 document.getElementById('benefits_item_'+hash).className='package_info_item';
 document.getElementById('feedback_item_'+hash).className='package_info_item';
 d1.className = 'package_info_item_active';
}


function getTextFromTextarea(id, headline){
  var text = document.getElementById(id).value;
  document.getElementById('box_preview_content').innerHTML = text;
  document.getElementById('box_preview_headline').innerHTML = headline;
  document.getElementById('overlay').style.display = 'block';

  if(document.getElementById(id+'_ifr') != null){
    var iframe_text = document.getElementById(id+'_ifr').contentWindow.document.body.innerHTML;
    document.getElementById('box_preview_content').innerHTML = iframe_text;
  }else{
    var textarea_text = document.getElementById(id).value;
    var newstr = '';
    var strArray = textarea_text.split('\n');
    
    for(i=0;i<strArray.length;i++){
       newstr=newstr+strArray[i] + "<br />";
    }
    var clean_string = newstr;
    document.getElementById('box_preview_content').innerHTML = clean_string;
  }
  
  TagToTip('preview_box', COPYCONTENT, false, BORDERWIDTH, 0, PADDING, 0, BGCOLOR, '',STICKY, true, CENTERWINDOW, true, CENTERALWAYS, true);
}

function showPackageDetails()
{
  showOverlay();
  TagToTip('package_detail', COPYCONTENT, false, BORDERWIDTH, 0, PADDING, 0, BGCOLOR, '',STICKY, true, CENTERWINDOW, true, CENTERALWAYS, true, OFFSETY, 300);
}

function showOverlay()
{
  document.getElementById('overlay').style.display = 'block';
}

function hideOverlay(){
  document.getElementById('overlay').style.display = 'none';
}

function openUploadForm(name, hash) {
  document.getElementById('upload_frame').src = '/ag.php/profile/upload?name='+name;
  document.getElementById('overlay').style.display = 'block';
  sleep(1000);

  document.getElementById('close_link').onclick = function(){ setImage(hash, name); };
  TagToTip('upload', COPYCONTENT, false, BORDERWIDTH, 0, PADDING, 0, BGCOLOR, '',STICKY, true, CENTERWINDOW, true, CENTERALWAYS, true);
}

function setFormHandlers(hash)
{
  var theIframeDocument = document.getElementById('upload_frame').contentDocument;
  if (theIframeDocument.getElementById('the_upload_form') != null)
  {
    var theForm = theIframeDocument.getElementById('the_upload_form');
    var imageName = theIframeDocument.getElementById('mk_company_image_file_name').value;
    //theForm.onsubmit = function(){setImage(hash, imageName);};
  }

}

function setImage(chash, prefix){
  if(prefix == 'logo')
  {
    new Ajax.Updater('company_logo_container', '/ag.php/profile/getLogoPartial?company_hash='+chash);
  }
  else
  {
    new Ajax.Updater('company_pictures_container', '/ag.php/profile/getPicturePartial?company_hash='+chash);
  }
  hideOverlay();
  tt_HideInit();
}




function sleep(ms)
{
  var zeit=(new Date()).getTime();
  var stoppZeit=zeit+ms;
  while((new Date()).getTime()<stoppZeit){};
}


function insertButton(counter){
  var input_field ='<? echo "<p>".input_tag ("company_awards['+counter+']")."</p>"?>';
  var new_counter = parseInt(counter)+1;
  new Insertion.Bottom('modern_major_general', input_field);
  document.getElementById(counter).id = new_counter;
}




