window.onload = fixWindow;

function fixWindow() {
//        newWinLinks();
//		initMenu();
//		newFooter();
//        initTopNav();
//        addMenu2();
//      sfHover();
//    fixDropDowns();
//   fixHover();
//    initMenu();
	initPicCycle();
		}
/*
   Set up some global variables for the java script
   USE WITH CARE   
*/

var thisImg = 0;
var frontImages = new Array("_MG_0511bw.jpg","_MG_1128.jpg","_MG_3576.jpg","_MG_6598.jpg","_MG_7713.jpg","_MG_9019.jpg","_MG_9257.jpg");
var imagetype = new Array("P","P","P","P","P","P","P");
var opacityMax = 999;
var Opacvar = 100;
var browser, timerVar, opacTim;
  if (navigator.appName == "Netscape") {
   browser = 1;
   timerVar = 3000;
   opacTim = 100;
   opTim = 17;
   }
   else {
   browser = 0;
   timerVar = 3000;
   opacTim = 10;
   opTim = 17;
   }
numphotos = frontImages.length;
//alert(numphotos);
var x = document.getElementsByTagName("meta");
    if ((x[0].name == "Home") &&(!preload)) {
        var preload=new Array;
                        for (var i=0; i< numphotos; i++ ) {
                        preload[i] = new Image();
                        preload[i].src = "frontPage/" + frontImages[i];
                        }
		}

/*
--------------------------End Global Variables----------------------------
*/

function initPicCycle() {
    var x = document.getElementsByTagName("meta");
    if (x[0].name == "Home") {
            thisImg = Math.floor((Math.random() * numphotos));
            document.getElementById("frontPage").src = "frontPage/" + frontImages[thisImg];
 //          rotate();
 setInterval("rotate()",timerVar);
         }
    }

function rotate() {
     var y =document.getElementById("frontPage");
         thisImg++;
		 y.style.visibility = "hidden";
         if (thisImg == numphotos) {
               thisImg = 0;
    	   }
         if (imagetype[thisImg] == "P"){
            y.className = "port";
           }
        else {
            y.className = "land";
        }
        y.src = "frontPage/" + frontImages[thisImg];
        Opacvar = 100;
        //setOpacity();
    y.style.visibility = "visible";
//       setTimeout("rotate()",timerVar);
		
       }

function setOpacity(){
   Opacvar += opacTim;
   var opacvar2 = Opacvar/10;
   var y =document.getElementById("frontPage");
   if (Opacvar <= opacityMax) {

// IE/Win
      y.style.filter = "alpha(opacity:"+opacvar2+")";

// Safari<1.2, Konqueror
       y.style.KHTMLOpacity = Opacvar/1000;

// Older Mozilla and Firefox
      y.style.MozOpacity = Opacvar/1000;

// Safari 1.2, newer Firefox and Mozilla, CSS3
      y.style.opacity = Opacvar/1000;

      setTimeout('setOpacity()',opTim);
       }
    else
      {
       Opacvar = 0;
       setTimeout("rotate()",timerVar);
     }
}


 

	
function initMenu() {
	var allLinks = document.getElementById("leftcol").getElementsByTagName("a");
	
	for (var i=0; i<allLinks.length; i++) {
		if (allLinks[i].className.indexOf("menuLink") > -1) {
			allLinks[i].onclick = function() {return false;}
			allLinks[i].onmouseover = toggleMenu;
		}
      }
  }
function toggleMenu() {
	var startMenu = this.href.lastIndexOf("/")+1;
	var stopMenu = this.href.lastIndexOf(".");
	var thisMenuName = this.href.substring(startMenu,stopMenu);
 //   var what = thisMenuName+"Img";
	
//	document.getElementById(what).src = what + "Over.bmp";
	
	document.getElementById(thisMenuName).style.display = "block";

	this.parentNode.className = thisMenuName;
	this.parentNode.onmouseout = toggleDivOff;
	this.parentNode.onmouseover = toggleDivOn;	
}

function toggleDivOn() {
    var n = this.className;
	var temp = n + "top";
//    var imgSrc = n +"Img";
	var test = document.getElementById(temp);
	test.style.color = "white";
	test.style.backgroundColor = "blue";
//	this.style.borderBottom = "none";
//	this.style.borderWidth = "3px";
//    document.getElementById(imgSrc).src = n + "Over.bmp";   
	document.getElementById(n).style.display = "block";

	}

function toggleDivOff() {
    var n = this.className;
//    var imgSrc = n +"Img";
	var temp = n + "top";
	var test = document.getElementById(temp);
	test.style.color = "blue";
	test.style.backgroundColor = "black";
//	this.style.backgroundColor = "black";
//	this.style.borderBottom = "3px #a7a7a7 ridge";
//	this.style.borderWidth = "3px 0px 3px 0px";
//	document.getElementById(imgSrc).src = n + "Off.bmp";
	document.getElementById(n).style.display = "none";
}

function fixHover() {
	var sfEls = document.getElementById("DD").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}		
function resizeWindow()
{
alert('resizin');
    var y = resizeTo(500);
alert('done');
	}
		

function fixDropDowns() {

	var y = document.getElementById("leftcol").getElementsByTagName("a");
	    for (var i=0;i < y.length ; i++) {
     		if (y[i].className == "portfolio") {
	        	y[i].onmouseover=addDD1;
		       }
     		else if (y[i].className == "services") {
	        	y[i].onmouseover=addDD2;
		       }
			else if (y[i].className == "nodrop"){
                y[i].onmouseover = clearAll;
              }				
	     }
	 }
function clearAll(){
   clearDD1();
   clearDD2();
   return false;
   }
function clearDD1()  {
    var y = document.getElementById("x1");
	y.style.display = "none";
	}
function addDD1() {
  clearDD2(); 
    var y = document.getElementById("x1");
	y.style.display = "block";
		return false;
}
function clearDD2()  {
    var y = document.getElementById("x2");
	y.style.display = "none";
	}
function addDD2() {
  clearDD1(); 
    var y = document.getElementById("x2");
	y.style.display = "block";
		return false;
}

function newWinLinks() {
	for (var i=0; i<document.links.length; i++) {
		if (document.links[i].className == "newWinLand") {
			document.links[i].onclick = newWindowLand;
		}
		else if(document.links[i].className == "newWinPort") {
			document.links[i].onclick = newWindowPort;
		}
	}
}

function newWindowLand() {
		 
	var bookWindow = window.open(this.href,"newLand","status,scrollbars,resizable,width=700,height=600");
	bookWindow.resizeTo(750,850);
	bookWindow.focus();
	return false;
}

function newWindowPort() {
		 
	var bookWindow = window.open(this.href,"newPort","status,scrollbars,resizable,width=500,height=800");
	bookWindow.resizeTo(750,850);
	bookWindow.focus();
	return false;
}

function newFooter() {
    var x = document.getElementsByTagName("meta");
    if (x[0].name == "Home") {
        document.getElementById("footer").style.top = 600;
		}
    else if (x[0].name == "Gallery") {
        document.getElementById("footer").style.top = 800;
		}

	else 
	    { 
        document.getElementById("footer").style.top = 300;
        }
    document.getElementById("footerdata").innerHTML = "This is where I'll put the footer data © Jeff Stebbins";
	return false;
}
function initTopNav() {
     var startName, stopName, refName;
     var allLinks = document.getElementById("topnav").getElementsByTagName("a");
	 
     for (var i=0; i<allLinks.length; i++) {
	     if(allLinks[i].className == "no_bottom") {
		 	startName = allLinks[i].href.lastIndexOf("/")+1;
	        stopName = allLinks[i].href.lastIndexOf(".");
	        refName = allLinks[i].href.substring(startName,stopName);
            if ((refName == "index") || (refName =="about") || (refName =="contact")  ) {
                allLinks[i].onmouseover = RestoreAction;
				}
//			else if (refName == "about") {
//                allLinks[i].onmouseover = RestoreAction;
//				}
//			else if (refName == "contact") {
//                allLinks[i].onmouseover = RestoreAction;
//				}
            else
			   ;
		 }
		 else if (allLinks[i].className == "bottom_menu") {
		 	startName = allLinks[i].href.lastIndexOf("/")+1;
	        stopName = allLinks[i].href.lastIndexOf(".");
	        refName = allLinks[i].href.substring(startName,stopName);
		     allLinks[i].onclick = function() {return false;}
			 if (refName == "portfolio") {
			     allLinks[i].onmouseover = AddPortfolio;
				 }
		    else if (refName == "services") {
                 allLinks[i].onmouseover = AddServices;
                 }
         	}
         else
           {}
		   }
		  return false; 
		 }

function RestoreAction() {
          var x = document.getElementsByTagName("meta");
    if (x[0].name == "Home") {
        RestoreIndex();
		}
    else if (x[0].name == "About") {
        RestoreAbout();
		}
    else if (x[0].name == "Contact") {
        RestoreContact();
		}

       }		 
		 
function clearBottom() {
      var y = document.getElementById("botnav");
      var z = y.firstChild;
// Check for children
	  if (z) {
	  var w = y.lastChild;
	  var p =w.previousSibling;
	  var i=0;
// If so remove em
	  while(w != z) {
	  y.removeChild(w);
      w = y.lastChild;
	  }  //end while
	  y.removeChild(z);
      } //end if
	  } //end function
	  
function clearTop() {
     var w = document.getElementById("container").getElementsByTagName("img");
     for (i=0; i < w.length; i++)
 	 {
      w[i].parentNode.removeChild(w[i]);
	  }
     w = document.getElementById("container").getElementsByTagName("p");
     for (i=0; i < w.length; i++)
 	 {
      w[i].parentNode.removeChild(w[i]);
	  }

      }
function RestoreIndex() {
      clearBottom();
	  clearTop();
	  var i = 0;
	  var w = document.getElementById("container");
      w.innerHTML = '<img class="IndexData" src="_mg_8577.jpg" alt="Coyote Ugly"   />';
	 }
function RestoreAbout() {
      clearBottom();
	  clearTop();
	  var w = document.getElementById("container");
	  w.innerHTML = "<p>This is new about data</p>";
	 }
function RestoreContact() {
      clearBottom();
	  clearTop();
	  var w = document.getElementById("container");
	  w.innerHTML = "<p>This is new about data</p>";
	  }
function AddPortfolio() {
      clearBottom();
	  clearTop();
	  var w = document.getElementById("container");
      w.innerHTML = '<p class="PortfolioData"> Testing this new load</p>';
      w = document.getElementById("botnav");
   	w.innerHTML='<p>|</p><a href="WeddingPort.html" >Wedding Portfolio</a><p>|</p><a href="Portrait.html" >Portrait Portfolio</a><p>|</p><a href="event.html" >Event Portfolio</a><p>|</p><a href="Commercial.html" >Commercial Portfolio</a><p>|</p>';
	  }
function AddServices() {
      clearBottom();
	  clearTop();
	  var w = document.getElementById("container").getElementsByTagName("p");
      for (i=0; i<w.length; i++) {
	      if (w[i].className == "ServiceData") {
		       w[i].style.fontSize = "1.2em";
		       w[i].style.fontWeight = "bold";
		       w[i].innerHTML = "Testing";
			   }
	     else {
		       w[i].innerHTML = "";
			   }
	 }
      var y = document.getElementById("botnav");
	  
   	y.innerHTML='<p>|</p><a href="WeddingSer.html" >Wedding Services</a><p>|</p><a href="PortraitSer.html" >Portrait Services</a><p>|</p><a href="EventSer.html" >Event Services</a><p>|</p><a href="CommercialSer.html" >Commercial Services</a><p>|</p>';
	  }
		 	 
/*
function initMenu() {
	var allLinks = document.getElementsByTagName("a");
	
	for (var i=0; i<allLinks.length; i++) {
		if (allLinks[i].className.indexOf("menuLink") > -1) {
			allLinks[i].onclick = function() {return false;}
			allLinks[i].onmouseover = toggleMenu;
		}
		if (allLinks[i].className =="pageLink") {
			allLinks[i].onmouseover = toggleLink;
			}
	}
}

function toggleMenu() {
	var startMenu = this.href.lastIndexOf("/")+1;
	var stopMenu = this.href.lastIndexOf(".");
	var thisMenuName = this.href.substring(startMenu,stopMenu);
    var what = thisMenuName+"Img";
	
	document.getElementById(what).src = "SandNew" + what + ".bmp";
	
	document.getElementById(thisMenuName).style.display = "block";

	this.parentNode.className = thisMenuName;
	this.parentNode.onmouseout = toggleDivOff;
	this.parentNode.onmouseover = toggleDivOn;	
}

function toggleDivOn() {

    var n = this.className;
    var imgSrc = n +"Img";
//	this.style.backgroundColor = "#980321";
//	this.style.borderColor = "#fdf3bc";
//	this.style.borderWidth = "3px";
    document.getElementById(imgSrc).src = "SandNew" + n + ".bmp";   
	document.getElementById(n).style.display = "block";

	}

function toggleDivOff() {
    var n = this.className;
    var imgSrc = n +"Img";
//	this.style.backgroundColor = "#fdf3bc";
//	this.style.borderColor = "a7a7a7";
//	this.style.borderWidth = "3px 0px 3px 0px";
	document.getElementById(imgSrc).src = "RedNew" + n + ".bmp";
	document.getElementById(n).style.display = "none";
}

function toggleLink() {
	var startMenu = this.href.lastIndexOf("/")+1;
	var stopMenu = this.href.lastIndexOf(".");
	var thisMenuName = this.href.substring(startMenu,stopMenu);
    var what = thisMenuName+"Img";
	document.getElementById(what).src = "SandNew" + what + ".bmp";

	this.parentNode.className = thisMenuName;
	this.parentNode.onmouseout = toggleLinkOff;
	this.parentNode.onmouseover = toggleLinkOn;	
}

function toggleLinkOn() {

    var n = this.className;
    var imgSrc = n +"Img";
//	this.style.backgroundColor = "#980321";
//	this.style.borderColor = "#fdf3bc";
	document.getElementById(imgSrc).src = "SandNew" + n + ".bmp";   
}

function toggleLinkOff() {
    var n = this.className;
    var imgSrc = n +"Img";
//	this.style.backgroundColor = "#fdf3bc";
//	this.style.borderColor = "a7a7a7";
	document.getElementById(imgSrc).src = "RedNew" + n + ".bmp";
}
*/
function addMenu() {
    var y;
    var x = document.getElementsByTagName("meta");
    if (x[0].name == "Home") {
        y = document.getElementById("BotNav");
		}
	y.innerHTML='<p>|</p><a href="WeddingPort.html" >Wedding Portfolio</a><p>|</p><a href="Portrait.html" >Portrait Portfolio</a><p>|</p>';
	}
function addMenu2() {
    var y;
    var x = document.getElementsByTagName("meta");
    if (x[0].name == "Home") {
        y = document.getElementById("BotNav");
		}
        var z = y.firstChild;
		z.innerHTML="Testtime";
		z = y.firstChild.nextSibling;
		z.innerHTML = "NewTezs";

//	y.innerHTML='<p>|</p><a href="WeddingPort.html" >Wedding Portfolio</a><p>|</p><a href="Portrait.html" >Portrait Portfolio</a><p>|</p>';
	}

						