var OnDisplay = null;
var LayerYPos = 10;
var adsHeight = 0;

function getMenu(cat,letter){  

  Hide('mapDiv');
  Hide('personDiv');
  Hide('infoDiv');
  Hide('crossDiv');

  url = 'http://www.armenica.org/cgi-bin/history/en/getMenuList.cgi?' + cat + '=' + letter;    
  top.frames[4].location.href = url;  
}

function getContents(language,marker){  	
  url = 'http://www.armenica.org/cgi-bin/history/en/getContents.cgi?' + language + '=' + marker;
  top.frames[5].location.href = url;
}

function makePage(pageNr,pattern,layout,fontSize){  

  Hide('mapDiv');
  Hide('personDiv');
  Hide('infoDiv');
  Hide('crossDiv');

  url1 = 'http://www.armenica.org/cgi-bin/history/en/makePage.cgi?' + pageNr + '=' + pattern + '=' + layout + '=' + fontSize + '=0';
  url2 = 'http://www.armenica.org/cgi-bin/history/en/getIconRow.cgi?' + pageNr + '=' + pattern + '=' + layout + '=' + fontSize + '=0';

  if (top.frames.length == 8){
    top.frames[5].location.href = url2;  
    setTimeout("top.frames[6].location.href = url1;",800);
  }
  else{
    top.frames[4].location.href = url2;  
    setTimeout("top.frames[5].location.href = url1;",800);  
  }
}

function Show(LayerId,Name){  
  if (LayerId == "mapDiv"){
    top.frames[0].location.href = "http://www.armenica.org/cgi-bin/history/en/showInfo.cgi?3=" + Name;  
  }  
  else if (LayerId == "personDiv"){    
    top.frames[1].location.href = "http://www.armenica.org/cgi-bin/history/en/showInfo.cgi?4=" + Name;  
  }
  else if (LayerId == "personDiv1"){    
    top.frames[6].location.href = "http://www.armenica.org/cgi-bin/history/en/showInfo.cgi?4=" + Name;  
  } 
  else if (LayerId == "infoDiv"){    
    top.frames[2].location.href = "http://www.armenica.org/cgi-bin/history/en/showInfo.cgi?5=" + Name;  
  } 
  else if (LayerId == "infoDiv1"){    
    top.frames[6].location.href = "http://www.armenica.org/cgi-bin/history/en/showInfo.cgi?5=" + Name;  
  }  
  else if (LayerId == "crossDiv"){    
    top.frames[3].location.href = "http://www.armenica.org/cgi-bin/history/en/showInfo.cgi?6=" + Name;  
  }
  else if (LayerId == "videoDiv"){
    top.frames[0].location.href = "http://www.armenica.org/cgi-bin/history/en/getVideo.cgi?" + Name + "=" + 1;
  }
  else if (LayerId == "collectionDiv"){
    top.frames[0].location.href = "http://www.armenica.org/cgi-bin/history/getCollectionObject.cgi?" + Name;
  }
  

  //alert("LayerId = " + LayerId);	
  if (document.getElementById){
    if (OnDisplay != null)
      OnDisplay.style.visibility = 'hidden';	      
      OnDisplay = top.document.getElementById(LayerId);		
    if (navigator.userAgent.indexOf ('Gecko') == -1 || navigator.userAgent.indexOf ('Opera') == -1) // Alla utom Mozilla/Ns6 och Opera			
      OnDisplay.style.top = (LayerYPos + top.document.body.scrollTop) + "px";		
    else // Mozilla/Ns6 och Opera			
      OnDisplay.style.top = (LayerYPos + pageYOffset) + "px";
      OnDisplay.style.visibility = 'visible';	
   }	
   else if (document.all){
      if (OnDisplay != null){	    
        OnDisplay.style.visibility = 'hidden';	    
        OnDisplay = top.frames[0].document.all[LayerId];	    
        top.document.all[LayerId].style.visibility = 'visible';	  
      }	
   }	
   else if (document.layers){
      if (OnDisplay != null){	    
        OnDisplay.visibility = 'hide';	    
        OnDisplay = eval ("document." + LayerId);	    
        OnDisplay.visibility = 'show';	    
        OnDisplay.top = LayerYPos + pageYOffset;	  
      }	
   }
}

function Hide (LayerId){   
  if (document.getElementById){    
    top.document.getElementById(LayerId).style.visibility = 'hidden';  
  }  
  else if (document.all){    
    top.document.all[LayerId].style.visibility = 'hidden';  
  }  
  else if (document.layers){    
    eval("top.document." + LayerId + ".visibility = 'hide'");  
  }

  if (LayerId == "mapDiv"){
    top.frames[0].location.href = "http://www.armenica.org/history/blank.html";  
  }  
  else if (LayerId == "personDiv"){    
    top.frames[1].location.href = "http://www.armenica.org/history/blank.html";  
  }  
  else if (LayerId == "infoDiv"){    
    top.frames[2].location.href = "http://www.armenica.org/history/blank.html";  
  }  
  else if (LayerId == "crossDiv"){    
    top.frames[3].location.href = "http://www.armenica.org/history/blank.html";  
  }
  else if (LayerId == "videoDiv"){    
    top.frames[0].location.href = "http://www.armenica.org/history/blank.html";  
  }
  else if (LayerId == "collectionDiv"){    
    top.frames[0].location.href = "http://www.armenica.org/history/blank.html";  
  }

}

function markMe(mark){
  top.frames[4].document.open();
  top.frames[4].document.writeln("<html><head>\n");
  top.frames[4].document.writeln("<link rel=\"stylesheet\" href=\"http://www.armenica.org/history/en/includes/styles.css\" type=\"text/css\">\n");
  top.frames[4].document.writeln("</head>\n");

  top.frames[4].document.writeln("<body bgcolor=\"#FFFFFF\" leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\n");
  top.frames[4].document.writeln("<table width=\"860\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" class=\"table-bg\">\n");
  top.frames[4].document.writeln("<tr>\n");
  top.frames[4].document.writeln("<td class=\"search\" nowrap valign=\"middle\">\n");
  top.frames[4].document.writeln("Innehåll :: <a class=\"search\" href=\"javascript:top.getContents(1," + mark + ");\">Back to index</a>\n");
  top.frames[4].document.writeln("</td>\n");
  top.frames[4].document.writeln("</tr>\n");
  top.frames[4].document.writeln("</table>\n");
  top.frames[4].document.writeln("</body></html>\n");
  top.frames[4].document.close();
}

function getMain(page){
  
  var nrOfFrames = top.frames.length;

  if (page == 1){

    url = 'http://www.armenica.org/se/about.html';
    
    top.frames[nrOfFrames - 2].location.href = url;
  }
  else if (page == 2){
    url = 'http://www.armenica.org/se/contact.html';
    
    top.frames[nrOfFrames - 2].location.href = url;
  }
}

function iFrameHeight() {

  if(document.getElementById && !(document.all)) {
    
    h = document.body.scrollHeight - 185;

    if (h < top.adsHeight){
      h = top.adsHeight;
    }

    //alert (document.body.scrollHeight + " => " + h);
    
    if (document.getElementById('main')){
      document.getElementById('main').height = h;
    }

    if (document.getElementById('lMenu')){
      document.getElementById('lMenu').height = h;
    }
    
    if (document.getElementById('ads')){
      document.getElementById('ads').height = h;
    }


  }
  else if(document.all) {
    
    h = document.body.clientHeight - 185;
    
    if (h < top.adsHeight){
      h = top.adsHeight;
    }

    if (document.all.main){
      document.all.main.height = h;
    }

    //    alert(document.body.clientHeight + " => " + h);

    if (document.all.lMenu){
      document.all.lMenu.height = h;
    }
    
    if (document.all.ads){
      document.all.ads.height = h;
    }
    
  }
}

function showMap(map){
   top.frames[0].location.href = "http://www.armenica.org/cgi-bin/history/en/showInfo.cgi?7=" + map;
 
   LayerId = 'mapDiv';

 //alert("LayerId = " + LayerId);	
  if (document.getElementById){
    if (OnDisplay != null)
      OnDisplay.style.visibility = 'hidden';	      
      OnDisplay = top.document.getElementById(LayerId);		
    if (navigator.userAgent.indexOf ('Gecko') == -1 || navigator.userAgent.indexOf ('Opera') == -1) // Alla utom Mozilla/Ns6 och Opera			
      OnDisplay.style.top = (LayerYPos + top.document.body.scrollTop) + "px";		
    else // Mozilla/Ns6 och Opera			
      OnDisplay.style.top = (LayerYPos + pageYOffset) + "px";
      OnDisplay.style.visibility = 'visible';	
   }	
   else if (document.all){
      if (OnDisplay != null){	    
        OnDisplay.style.visibility = 'hidden';	    
        OnDisplay = top.frames[0].document.all[LayerId];	    
        top.document.all[LayerId].style.visibility = 'visible';	  
      }	
   }	
   else if (document.layers){
      if (OnDisplay != null){	    
        OnDisplay.visibility = 'hide';	    
        OnDisplay = eval ("document." + LayerId);	    
        OnDisplay.visibility = 'show';	    
        OnDisplay.top = LayerYPos + pageYOffset;	  
      }	
   }

}

function preCheck(){
  var allOk = true;
  var text = "";
  data = new Array(4);

  if (document.contact.fname.value.length < 2){
   data[0] = "First name";
   allOk = false;
  }

  if (document.contact.lname.value.length < 3){
   data[1] = "Last name"; 
   allOk = false;
  }

  if (document.contact.email.value.length < 6){
   data[2] = "Email";
   allOk = false;
  }

  if ((document.contact.type.value != 4) && (document.contact.message.value.length < 10)){
   data[3] = "Message";
   allOk = false;
  }

  if (allOk){
    return true;
  }
  else{    
    text += "Please complete the following information:\n\n";

    for (i=0; i < 4; i++){
     if (data[i]){
       text += "* ";
       text += data[i];
       text += "\n";
     }
    }

    alert(text);
    return false;
  }
}

function getMapMenu(mapName){

  switch (mapName){
  case "armenia" :
    top.frames[6].location.href = "http://www.armenica.org/history/en/mapArmenia.html";
    break;
  case "yerevan" :
    top.frames[6].location.href = "http://www.armenica.org/history/en/mapYerevan.html";
    break;
  case "cilicia" :
    top.frames[6].location.href = "http://www.armenica.org/history/en/mapCilicia.html";
    break;
  case "genocide" :
    top.frames[6].location.href = "http://www.armenica.org/history/en/mapGenocide.html";
    break;
  case "karabakh" :
    top.frames[6].location.href = "http://www.armenica.org/history/en/mapKarabakh.html";
    break;
  case "historical" :
    top.frames[6].location.href = "http://www.armenica.org/history/en/mapHistorical.html";
    break;
  case "battle" :
    top.frames[6].location.href = "http://www.armenica.org/history/en/mapBattle.html";
    break;
  case "latest" :
    top.frames[6].location.href = "http://www.armenica.org/history/en/map_tom.html";
    break;
  default :
    top.frames[6].location.href = "http://www.armenica.org/history/en/mapOther.html";
  }
}

function ShowDiv(LayerId){  
  //alert("LayerId = " + LayerId);	
  if (document.getElementById){
    if (OnDisplay != null)
      OnDisplay.style.visibility = 'hidden';	      
      OnDisplay = top.document.getElementById(LayerId);		
    if (navigator.userAgent.indexOf ('Gecko') == -1 || navigator.userAgent.indexOf ('Opera') == -1) // Alla utom Mozilla/Ns6 och Opera			
      OnDisplay.style.top = (LayerYPos + top.document.body.scrollTop) + "px";		
    else // Mozilla/Ns6 och Opera			
      OnDisplay.style.top = (LayerYPos + pageYOffset) + "px";
      OnDisplay.style.visibility = 'visible';	
   }	
   else if (document.all){
      if (OnDisplay != null){	    
        OnDisplay.style.visibility = 'hidden';	    
        OnDisplay = top.frames[0].document.all[LayerId];	    
        top.document.all[LayerId].style.visibility = 'visible';	  
      }	
   }	
   else if (document.layers){
      if (OnDisplay != null){	    
        OnDisplay.visibility = 'hide';	    
        OnDisplay = eval ("document." + LayerId);	    
        OnDisplay.visibility = 'show';	    
        OnDisplay.top = LayerYPos + pageYOffset;	  
      }	
   }
}

