// JavaScript Document
WINDOW_CREATED = false;
createWindow = function(WIDTH, HEIGHT, area, table_id){
	var loader = document.createElement("div");
	loader.id = table_id+"_loader";
	loader.style.visibility = "hidden";
	var docBody = document.getElementById("window_area");
	docBody.style.visibility = "hidden";
	myTable = document.createElement("TABLE");
	try{
	myTable.attributes.getNamedItem("cellpadding").value="0";
	myTable.attributes.getNamedItem("cellspacing").value="0";
	myTable.attributes.getNamedItem("align").value = "center";
	}catch(e){
		myTable.setAttribute("cellpadding","0");
	    myTable.setAttribute("cellspacing","0");
		myTable.setAttribute("align","center");
	}
	if(LANGUAGE == "en"){
	loader_txt = document.createTextNode("loading...");
	}
	if(LANGUAGE == "es"){
	loader_txt = document.createTextNode("cargando...");
	}
	loader.appendChild(loader_txt);
	docBody.appendChild(loader);
    myTable.id =table_id;
 
  myTableBody = document.createElement("TBODY");
  
  for (i = 0; i < 7; i++){
    row = document.createElement("TR");
    for (j = 0; j < 3; j++){
      cell = document.createElement("TD");
	  cell.style.background = "#99C487";
	  try{
		  cell.attributes.getNamedItem("align").value="left";
		  }catch(e){
			    cell.setAttribute("align","left");
		  }
	  
	  if(i==0){
		  if(j==0){
		  img_corner = document.createElement("img");
		  img_corner.setAttribute("src","images/images/w_corners_01.jpg");
		  cell.appendChild(img_corner);
		   cell.style.background = "none";
		  }
		  if(j==2){
		  img_corner = document.createElement("img");
		  img_corner.setAttribute("src","images/images/w_corners_03.jpg");
		  cell.appendChild(img_corner);
		  cell.style.background = "none";
		  }
	  }
	   if(i==6){
		  if(j==0){
		  img_corner = document.createElement("img");
		  img_corner.setAttribute("src","images/images/w_corners_07.jpg");
		  cell.appendChild(img_corner);
		  cell.style.background = "none";
		  }
		  if(j==2){
		  img_corner = document.createElement("img");
		  img_corner.setAttribute("src","images/images/w_corners_09.jpg");
		  cell.appendChild(img_corner);
		  cell.style.background = "none";
		  }
	  }
	  
	  if(j==1){
		  try{
	   cell.attributes.getNamedItem("width").value=WIDTH;
		  }catch(e){
			  cell.setAttribute("width",WIDTH);
			  }
	  }
	  if(i==3){
		  try{
	   cell.attributes.getNamedItem("height").value=HEIGHT;
		  }catch(e){
			  cell.setAttribute("height",HEIGHT);
			  }
	  }
	  //CREAR CAMPOS DE CONTENIDO DINÁMICO
	  if(i==1 && j ==1){
      textNode = document.createTextNode("{Title}");
      cell.appendChild(textNode);
	  try{
		cell.attributes.getNamedItem("class").value ="td_white";
		}catch(e){
	  cell.setAttribute("class","td_white");
	  }
	  cell.style.textAlign = "left";
	  
	  cell.id = table_id+"_title";
	  }
	   if(i==2 && j ==1){
		     try{
	   cell.attributes.getNamedItem("height").value=10;
		  }catch(e){
			  cell.setAttribute("height",10);
			  }
	  cell.style.backgroundImage = "url(images/line.jpg)";
	  cell.style.backgroundRepeat = "repeat-x";
	  cell.id = table_id+"_line";
	  }
	  if(i==3 && j ==1){
      textNode = document.createTextNode("{Content}");
      cell.appendChild(textNode);
	  cell.id = table_id+"_content";
	     try{
	   cell.attributes.getNamedItem("valign").value="top";
		  }catch(e){
			  cell.setAttribute("valign","top");
			  }
	  }
	  if(i==4 && j ==1){
          try{
	   cell.attributes.getNamedItem("height").value=10;
		  }catch(e){
			  cell.setAttribute("height",10);
			  }
	  cell.style.backgroundImage = "url(images/line.jpg)";
	  cell.style.backgroundRepeat = "repeat-x";
	  cell.id = table_id+"_line2";
	  }
	  if(i==5 && j ==1){
      textNode = document.createTextNode("{pagefoot}");
      cell.appendChild(textNode);
	  cell.id = table_id+"_pagefoot";
	  }
      row.appendChild(cell);
    }
    myTableBody.appendChild(row);
  }
  myTable.appendChild(myTableBody);
  docBody.appendChild(myTable);
  myTable.style.background = "#99C487";
}
loadWContent = function(table_id,content){
	if(!WINDOW_CREATED){
	createWindow(718,200,"window_area","mywindow");
	WINDOW_CREATED=true;
	}
	var table = document.getElementById(table_id);
	table.style.visibility = "hidden";
	var loader = document.getElementById(table_id+"_loader");
	loader.style.visibility = "visible";
	if(LANGUAGE == "en"){
	loader.firstChild.nodeValue = "loading...";
	}
	if(LANGUAGE == "es"){
	loader.firstChild.nodeValue = "cargando...";
	}
	ACTUAL_CONTENT = content;
	var language_loader = new net.CargadorContenidos(IDIOMS_DIR+LANGUAGE+"/"+content+".xml",parse_certXML);
		function parse_certXML(){
			//
		 var content = this.req.responseXML;
		 var root = content.getElementsByTagName("window_body")[0];
		 var title = root.getElementsByTagName("title")[0].firstChild.nodeValue;
		 var content = root.getElementsByTagName("content")[0].firstChild.nodeValue;
		 var pagefoot = root.getElementsByTagName("pagefoot")[0].firstChild.nodeValue;		
		 
		 window_title = document.getElementById(table_id+"_title");
		 window_content = document.getElementById(table_id+"_content");
		 window_pagefoot = document.getElementById(table_id+"_pagefoot");
		 window_title.firstChild.nodeValue = title;
		 window_content.innerHTML = content;
		 window_pagefoot.innerHTML= pagefoot;
		 showContent(table_id);
	 
	}
	
}
	
showContent = function(table_id){
	var table = document.getElementById(table_id);
	table.style.visibility = "visible";
	var loader = document.getElementById(table_id+"_loader");
	loader.style.visibility = "hidden";
	if(ACTUAL_CONTENT=="contact"){
		activateContact();
		}
	if(ACTUAL_CONTENT=="birth" || ACTUAL_CONTENT=="death"){
		activateBirth(ACTUAL_CONTENT);
		}
	if(ACTUAL_CONTENT=="marriage" || ACTUAL_CONTENT=="divorce"){
		activateMarriage(ACTUAL_CONTENT);
		}
		
///SCROLL SITE
  window.scrollTo(0,600);
	
	}
