function campo( name, label, value, displayValue ){
	this.name = name;
	this.value = value;
	this.displayValue = displayValue;
}

function valueObject( name ){
	this.name = name;
}

var firstLoad = true;

function divObject( name , label){
  
  this.name = name;
	this.label = label;
  this.HTML = "";
  this.isDisplayed = false;
  this.updated = false;
  this.isLoaded = false;
  this.display = displayDiv;
  this.load = load;
	this.deleteItem = deleteItem;
	this.notifyDelete = notifyDelete;
  this.displayNoLoad = displayNoLoad;
  this.displayFirst = displayFirst;
}

function deleteItem( codigo ){
	this.isLoaded = false;
	this.isDisplayed = false;
	setStatusLabel ( "Excluido item " + this.label + ", esperando resposta do servidor.");
	if ( document.all )
    parent.serverFrame.location = "../deleteItem.asp?divName=" + this.name + "&c=" + codigo;
  else
    parent.serverFrame.location = "deleteItem.asp?divName=" + this.name + "&c=" + codigo;
}

function notifyDelete(){
	setStatusLabel( this.label + " excluido com sucesso" );
	top.innerFrame.corpo.notifyMe();
}

var infoPessoalDiv;
var perfilDiv;
var objetivosDiv;
var formacaoDiv;
var cursoDiv;
var idiomaDiv;
var habilidadeDiv;
var expProfDiv;
var atividadesDiv;
var comentarioDiv;
limpaCache();

function limpaCache(){
  infoPessoalDiv = new divObject( 'infoPessoalDiv', "Informações pessoais" );
  perfilDiv = new divObject( 'perfilDiv', "Tipo de currículo" );
  objetivosDiv = new divObject( 'objetivosDiv', "Objetivos profissionais" );
  formacaoDiv = new divObject( 'formacaoDiv', "Formação" );
  cursoDiv = new divObject( 'cursoDiv', "Cursos extracurriculares" );
  idiomaDiv = new divObject( 'idiomaDiv', "Idiomas" );
  habilidadeDiv = new divObject( 'habilidadeDiv', "Habilidades" );
  expProfDiv = new divObject( 'expProfDiv', "Experiência profissional" );
  atividadesDiv = new divObject( 'atividadesDiv', "Atividades extracurriculares" );
  comentarioDiv = new divObject( 'comentarioDiv', "Comentários gerais" );
  firstLoad = true;
}

function displayDiv(){
	try{
	  if ( !this.isLoaded ){
			setStatusLabel ( "Carregando " + this.label + ", esperando resposta do servidor." );
	    if ( document.all )
	      parent.serverFrame.location = "../divLoader.asp?divName=" + this.name;
	    else
	      parent.serverFrame.location = "divLoader.asp?divName=" + this.name;
        this.updated = true;
	  }
	  else{
	    top.innerFrame.corpo.document.getElementById( this.name ).innerHTML = this.HTML;
	    this.isDisplayed = true;
      if ( this.updated )
        top.innerFrame.corpo.document.getElementById( this.name.substr (0, this.name.length-3 ) ).scrollIntoView();
      this.updated = false;
			setStatusLabel ( this.label + " carregado com sucesso" );
	    top.innerFrame.corpo.notifyMe();
	  }
	}catch( ignore ){ alert(ignore );
  }
}

function displayNoLoad(){
  this.isDisplayed = false;
  if ( this.isLoaded ){
      top.innerFrame.corpo.document.getElementById( this.name ).innerHTML = this.HTML;
	    this.isDisplayed = true;
      if ( this.updated )
        top.innerFrame.corpo.document.getElementById( this.name.substr (0, this.name.length-3 ) ).scrollIntoView();
      this.updated = false;
  }
}

function displayFirst(){
      this.HTML = top.innerFrame.corpo.document.getElementById( this.name ).innerHTML;
	    this.isDisplayed = true;
      this.updated = false;
      this.isLoaded = true;
}

function load( HTML ){
  this.HTML = HTML;
  this.isLoaded = true;
  this.display();
}
