// <script type="text/javascript" src="skyscript.js"></script>

//var urlLength = "http://dev.clarkconstruction.net".length
var CurrentLoc = ""  // TopBar
var CurrentLoc2 = "" // SideBar

// find current loc by parsing URL
function findLoc() {           
  var flip1 = 1
  var flip2 = 0
 // var ParsedUrl = document.URL.substring(urlLength,document.URL.length)
  var FirstSplice = Splice(location.pathname)
//  alert(FirstSplice)
  switch (FirstSplice) {
    case "/":
      CurrentLoc = "home"
      break
    case "/portfolio/":
      CurrentLoc = "portfolio"
      var SecondSplice = Splice(location.pathname.substring(FirstSplice.length-1,location.pathname.length))
      flip2 = 1
      switch (SecondSplice) {
        case "/additions/":
          CurrentLoc2="additions"
          break
        case "/kitchens/":
          CurrentLoc2="kitchens"
          break
        case "/baths/":
          CurrentLoc2="baths"
          break
        case "/garages/":
          CurrentLoc2="garages"
          break
        case "/basements/":
          CurrentLoc2="basements"
          break
		case "/homeoffices/":
          CurrentLoc2="homeoffices"
          break
        case "/other/":
          CurrentLoc2="other"
          break
		default:
          flip2 = 0
      }
      break  
    case "/awards/":
      CurrentLoc = "awards"
      break 
    case "/testimonials/":
      CurrentLoc = "testimonials"
      break
    case "/designbuild/":
      CurrentLoc = "designbuild"
      break
    case "/info/":
      CurrentLoc = "info"
      break
    case "/aboutus/":
      CurrentLoc = "aboutus"
      break
    case "/contactus/":
      CurrentLoc = "contactus"
      break
      
    default:
      flip1 = 0
      //alert("Could not find Location.")
  }
  if (flip1==1) {
    turnOn(CurrentLoc)  
  }
  if (flip2==1) {
    turnOn(CurrentLoc2) 
  }
}

// Current Cut out one part (like /portfolio/)
function Splice(Initial) { // if you input /portfolio/blah.html it will return /portfolio/
  var NxtSlash = Initial.substring(1,Initial.length).indexOf("/")
  if (NxtSlash==-1) {
    return (Initial)
  } else {
    return (Initial.substring(0,NxtSlash+2))
  }
}

// Turn On image for current loc
function turnOn(ImgName) {     
  document[ImgName].src = "/layout/gfx/nav_" +ImgName+ "2.gif"
}

// Flip on for hover over (check to make sure not current loc first)
function flipOn(ImgName) {

  if ( CurrentLoc != ImgName && CurrentLoc2 != ImgName) {
     document[ImgName].src = "/layout/gfx/nav_" +ImgName+ "3.gif"
  }
}
// Flip off for hover over (check to make sure not current loc first)
function flipOff(ImgName) {   
  if ( CurrentLoc != ImgName && CurrentLoc2 != ImgName) {
     document[ImgName].src = "/layout/gfx/nav_" +ImgName+ "1.gif"
  }
}

// Open Pop Up Image with specified width, height, and title.
// function OpenImg(popTitle,popImage,popWidth,popHeight) {
 function OpenImg(popImage,popWidth,popHeight) {
    var OpenWindow = window.open("", "PopUpWin", "resizable=0,scrollbars=0,width=" + popWidth + ",height=" + popHeight)
    OpenWindow.document.write("<HTML>")
    OpenWindow.document.write("<HEAD>")
   // OpenWindow.document.write("<TITLE>"+popTitle+"</TITLE>")
    OpenWindow.document.write("<TITLE>Clark Construction of Ridgefield, Inc.</TITLE>")
    OpenWindow.document.write("</HEAD>")
    OpenWindow.document.write("<BODY leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>")
    OpenWindow.document.write("<IMG SRC='"+popImage+"' width="+popWidth+">")
    OpenWindow.document.write("</BODY>")
    OpenWindow.document.write("</HTML>")
    OpenWindow.document.close()
  }
