//Set images
//var loading_image = "images/rel_interstitial_loading.gif"; //Animated Loading/Working Image 
var close_image = "../cameras/close_grey.png"; //Close MsgBox Image 

function showCameras(id){

if(navigator.appName == "Microsoft Internet Explorer"){ //Only perform actions if using IE 
  
  //Get sizes
  var scrW, scrH, docH;
  if(self.innerHeight){ //All Except IE
    scrW = self.innerWidth;
    scrH = self.innerHeight;
    docH = document.getElementById('marker').offsetTop;
  } else if (document.documentElement && document.documentElement.clientHeight){ //IE 6 Strict
    scrW = document.documentElement.clientWidth;
    scrH = document.documentElement.clientHeight;
    docH = document.getElementById('marker').offsetTop;
  } else if (document.body){ //All Other Explorers
    scrW = document.body.clientWidth;
    scrH = document.body.clientHeight;
    docH = document.getElementById('marker').offsetTop;
  }
  //alert(scrW);
  //alert(scrH);
  //alert(docH);


  //Create Container Object
  var container = document.getElementById('cameras');
  var dark = document.getElementById('dark');
  var newdiv = document.createElement('div');
  newdiv.setAttribute('id', id);
  
  //Set Styles for Container
  newdiv.style.zIndex = "999999";
  newdiv.style.position = "relative";
  newdiv.style.width = "300px";
  newdiv.style.height = "125px";
  newdiv.style.backgroundColor = "#FFFFFF";
  //newdiv.style.textAlign = "center";
  newdiv.style.border = "1px black solid";
  newdiv.innerHTML = "<iframe src='cameras/cameras.html' width='675' height='540' frameborder=0 scrolling=no></iframe>" +
                     "<img style='position:absolute;bottom:0px;right:0px;' src='" + close_image + "' onClick='closeCameras(\"" + id + "\")' />";
  //newdiv.style.top = (document.body.clientHeight - parseInt(newdiv.style.height)) / 2;
  newdiv.style.top = (scrH - parseInt(newdiv.style.height)) / 4;
  
  //Fade Out Background
  dark.style.position = "absolute";
  dark.style.top = "0px";
  dark.style.left = "0px";
  dark.style.zIndex = "999998";
  dark.style.backgroundColor = "#000000";
  dark.style.width = document.body.clientWidth;
  //dark.style.height = document.body.clientHeight;
  dark.style.height = docH;
  dark.style.filter = "alpha(opacity=80)";
  dark.style.opacity = ".8";
  dark.style.display = "block";
  
  //Set Styles for container(outer) Div
  container.style.zIndex = "999997";
  container.style.position = "absolute";
  container.style.top = "0px";
  container.style.left = "0px";
  container.style.textAlign = "center";
  container.style.verticalAlign = "middle";
  container.style.width = document.body.clientWidth;
  container.style.height= document.body.offsetHeight;
  container.style.display = "block";
  container.appendChild(newdiv);
  
  } else { //Alert IE is required 
    alert("This feature requires Internet Explorer");
  }
  
}

function closeCameras(id){
  //Get objects
  var container = document.getElementById("cameras");
  var olddiv = document.getElementById(id);
  
  //Remove loading message   
  container.removeChild(olddiv);
  container.style.display = 'none';
}

function reloadCameras(id){
  closeCameras('warpCams');
  showCameras('warpCams');
}

function setCookie(c_name, value){
  document.cookie = c_name + "=" + value;
}

function getCookie(c_name){
  var cookie = document.cookie;
  var cookieArray = cookie.split('; ');
  
  for(i=0; i < cookieArray.length; i++){
    var nameValue = cookieArray[i].split('=');
    if(nameValue[0].toString() == c_name){
      var result = parseInt(nameValue[1]);
    }
  }
  
  return result;
  
}
