page= document.location.href.match(/.+\/([^?]*)/)[1];
page = (page.split(".")[0]).toLowerCase();
if (page=="") page="index";

var menu = new Array("index","documentaries","commercials","gallery","about","links","films","contact");
var text = new Array("Home","Documentaries","Commercials","Gallery","About Horacio","Links","Feature Films","Contact");

function showmenu() {
 var str="";
 for (var i=0;i<menu.length;i++) {
  if (i==6 && page=="films") str+="<li>Feature Films 1 <a style=\"text-decoration:underline;\" href=\"films2.htm\">2</a> <a style=\"text-decoration:underline;\" href=\"films3.htm\">3</a><\/li>";
  else if (i==6 && page=="films2") str+="<li>Feature Films <a style=\"text-decoration:underline;\" href=\"films.htm\">1</a> 2 <a style=\"text-decoration:underline;\" href=\"films3.htm\">3</a><\/li>";
  else if (i==6 && page=="films3") str+="<li>Feature Films <a style=\"text-decoration:underline;\" href=\"films.htm\">1</a> <a style=\"text-decoration:underline;\" href=\"films2.htm\">2</a> 3<\/li>";
  else if (i==6) str+="<li><a href=\"films.htm\">Feature Films</a> <a style=\"text-decoration:underline;\" href=\"films.htm\">1</a> <a style=\"text-decoration:underline;\" href=\"films2.htm\">2</a> <a style=\"text-decoration:underline;\" href=\"films3.htm\">3</a><\/li>";
  else if (page==menu[i]) str+="<li>"+text[i]+"<\/li>";
  else str+="<li><a href=\""+menu[i]+".htm\">"+text[i]+"<\/a><\/li>";
 }
 document.getElementById("top-menu").innerHTML=str;
}

/*var total=21;
var eachrow=7;
var s=Math.ceil(Gallery.length/total);*/

function showgallery () {
 var str;
 str="<table border=0 cellpadding=0 cellspacing=0>";
 for (i = 0; i < s*total; i++) {
  if (i % eachrow == 0) str+="<tr>";
  if (i<Gallery.length) str+="<td valign=\"top\"><a rel=\"lightbox[1]\" title=\""+Gallery[i]["name"]+"\" id=\""+Gallery[i]["info"]+"\" href=\"gallery/"+Gallery[i]["image"]+"\" onclick=\"myLightbox.start(this);return false;\"><img style=\"padding:8px;\" id=\"img"+i+"\" class=\"imgs\" src=\"gallery_thumb/"+Gallery[i]["image"]+"\"></a></td>";
  else str+="<td width=\"100px\"></td>";
  if (i % eachrow == eachrow-1) str+="</tr>";
 }
 str+="<tr><td colspan=\""+eachrow+"\" align=\"right\" style=\"padding-right:8px;\"><ul id=\"gallery-page\"></ul></td></tr></table>";
 document.getElementById("page-list").innerHTML+=str;
 for (i = 0; i < Gallery.length; i++) Wa_SetImgAutoSize(document.getElementById("img"+i));
}

function gallerypage(n) {
 for (i = 0; i < (n-1)*total; i++) document.getElementById("img"+i).style.display="none";
 if (n<s) {
  for (i = (n-1)*total; i < n*total; i++) document.getElementById("img"+i).style.display="inline";
  for (i = (n)*total; i < Gallery.length; i++) document.getElementById("img"+i).style.display="none";
 }
 else for (i = (n-1)*total; i < Gallery.length; i++) document.getElementById("img"+i).style.display="inline";
 
 if (s>1) {
  document.getElementById("gallery-page").innerHTML="";
  for (var i=s;i>0;i--) {
   if(i==n) document.getElementById("gallery-page").innerHTML+='<li>'+i+'</li>';
   else document.getElementById("gallery-page").innerHTML+='<li><a href="javascript:gallerypage('+i+');">'+i+'</a></li>';
  }
 }
}

function showinfo(n) {
 document.getElementById("info-box").style.display="block";
 document.getElementById("info-name").innerHTML=Films[n]["name"];
 document.getElementById("info-film").innerHTML=Films[n]["film"];
 document.getElementById("info-text").innerHTML=Films[n]["info"];
}

function closeinfo() {
 document.getElementById("info-box").style.display="none";
}

function popup (url) {
 window.open (url, '', 'left='+(screen.width-352)/2+', top='+(screen.height-274)/2+', width=352, height=274, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
}
function popup1 (url) {
 window.open (url, '', 'left='+(screen.width-668)/2+', top='+(screen.height-401)/2+', width=668, height=401, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
}

function Wa_SetImgAutoSize(img) {
 var MaxWidth=100;
 var MaxHeight=400;
 var HeightWidth=img.offsetHeight/img.offsetWidth;
 var WidthHeight=img.offsetWidth/img.offsetHeight;
 if(img.offsetWidth>MaxWidth){
  img.width=MaxWidth;
  img.height=MaxWidth*HeightWidth;
 }
 if(img.offsetHeight>MaxHeight){
  img.height=MaxHeight;
  img.width=MaxHeight*WidthHeight;
 }
}

// correctly handle PNG transparency in Win IE 5.5 and 6.
function correctPNG() {
 var arVersion = navigator.appVersion.split("MSIE")
 var version = parseFloat(arVersion[1])
 if ((version >= 5.5 && version<7) && (document.body.filters)) {
  for(var j=0; j<document.images.length; j++) {
   var img = document.images[j];
   var imgName = img.src.toLowerCase();
   if (imgName.substring(imgName.length-3, imgName.length) == "png") {
    var imgID = (img.id) ? "id='" + img.id + "' " : "";
    var imgClass = (img.className) ? "class='" + img.className + "' " : "";
    var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
    var imgStyle = "display:inline-block;" + img.style.cssText;
    if (img.align == "left") imgStyle = "float:left;" + imgStyle;
    if (img.align == "right") imgStyle = "float:right;" + imgStyle;
    if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
    var strNewHTML = "<span " + imgID + imgClass + imgTitle
    + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
    + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
    + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
    img.outerHTML = strNewHTML;
    j = j-1;
   }
  }
 }
}
