// Move an element directly on top of another element (and optionally
            // make it the same size)
            function Cover(bottom, top, ignoreSize) {
                var location = Sys.UI.DomElement.getLocation(bottom);
                top.style.position = 'absolute';
                top.style.top = location.y + 'px';
                top.style.left = location.x + 'px';
                if (!ignoreSize) {
                    top.style.height = bottom.offsetHeight + 'px';
                    top.style.width = bottom.offsetWidth + 'px';
                }
            }

function changeCamera(data)
{
	var camType = data.substring(0,data.indexOf('+'));
	
	var URL = "vsf.vsftransportation.com:800" + data.substring(data.indexOf('+')+1,data.indexOf('~'));
	var camText = data.substring(data.indexOf('~')+1,data.length);

  if (camType == 'AXIS'){
	// Set the BaseURL to the URL of your camera
	
	var BaseURL = "http://" + URL + "/";
	
	// DisplayWidth & DisplayHeight specifies the displayed width & height of the image.
	// You may change these numbers, the effect will be a stretched or a shrunk image
	var DisplayWidth = "320";
	var DisplayHeight = "240";
	
	// This is the path to the image generating file inside the camera itself
	var File = "axis-cgi/mjpg/video.cgi?resolution=320x240&compression=70&clock=1&date=1&text=1&textstring=" + camText;
	// No changes required below this point
	var output = "";
	
  if ((navigator.appName == "Microsoft Internet Explorer") &&
   (navigator.platform != "MacPPC") && (navigator.platform != "Mac68k"))
	{

  // If Internet Explorer under Windows then use ActiveX 
  output  = "<OBJECT ID='Player' width='";
  output += DisplayWidth;
  output += "' height='";
  output += DisplayHeight;
  output += "' CLASSID='CLSID:DE625294-70E6-45ED-B895-CFFA13AEB044' ";
  output += "CODEBASE='";
  /*output += BaseURL;*/
  output += "AMC.cab#version=3,32,19,0'>";
  output += "<PARAM NAME='MediaURL' VALUE='";
  output += BaseURL;
  output += File + "'>";
  output += "<param name='MediaType' value='mjpeg-unicast'>";
  output += "<param name='ShowStatusBar' value='0'>";
  output += "<param name='ShowToolbar' value='0'>";
  output += "<param name='AutoStart' value='1'>";
  output += "<param name='StretchToFit' value='1'>";
  output += "<BR><B>Axis Media Control</B><BR>";
  output += "The AXIS Media Control, which enables you ";
  output += "to view live image streams in Microsoft Internet";
  output += " Explorer, could not be registered on your computer.";
  output += " Install the contoller by clicking on the drop down";
  output += " on top of the web page and click on install ActiveX. ";
  output += "If you do not see the drop down on top Hit refresh on ";
  output += "your browser or select another camera.";
  output += "<BR></OBJECT>";
} else {
  // If not IE for Windows use the browser itself to display
  theDate = new Date();
  output  = '<IMG SRC="';
  output += BaseURL;
  output += File;
  output += '&dummy=' + theDate.getTime().toString(10);
  output += '" HEIGHT="';
  output += DisplayHeight;
  output += '" WIDTH="';
  output += DisplayWidth;
  output += '" ALT="Camera Image">';
}
      	WriteLayer('cam',null,output);
	
  }else if(camType == 'VIVOTEK'){
	if ((navigator.appName == "Microsoft Internet Explorer")&&(navigator.platform != "MacPPC"))
	{
	output = ("<OBJECT ID='MjpegControl' WIDTH=352 HEIGHT=240 ");
	output += ("CLASSID='CLSID:EAA105FE-7BBD-4196-8B96-D46743894195' ");
	output += ("CODEBASE='mjpegcontrol.cab#version=2,0,0,0'>");
	output += ("<PARAM NAME='VSize' VALUE='2'>");
	output += ("<PARAM NAME='Url' VALUE='http://" + URL + "/cgi-bin/video.jpg");
	output += ("?cam=1&quality=3&size=2'>");
	output += "<BR><B>Active X Video Controller</B><BR>";
    output += "The Active X Video Control, which enables you ";
    output += "to view live image streams in Microsoft Internet";
    output += " Explorer, could not be registered on your computer.";
    output += " Install the contoller by clicking on the drop down";
  output += " on top of the web page and click on install ActiveX. ";
  output += "If you do not see the drop down on top Hit refresh on ";
  output += "your browser or select another camera.";
    output += "<BR>";
	output += ("</OBJECT>");
	} else {
	output = ("<img width=352 height=240 ");
	output += ("src='http://" + URL + "/cgi-bin/video.jpg?cam=1&quality=3&size=2'>");
	}
	
	WriteLayer('cam',null,output);
}
	else{
		WriteLayer('cam',null,'No camera selected. Please select a camera to view.');
       }
}

function WriteLayer(ID,parentID,sText) {
 if (document.layers) {
   var oLayer;
   if(parentID){
     oLayer = eval('document.' + parentID + '.document.' + ID + '.document');
   }else{
     oLayer = document.layers[ID].document;
   }
   oLayer.open();
   oLayer.write(sText);
   oLayer.close();
 }
 else if (parseInt(navigator.appVersion)>=5&&navigator.
appName=="Netscape") {
   document.getElementById(ID).innerHTML = sText;
 }
 else if (document.all){
	document.all[ID].innerHTML = sText;
	//document.all[ID].Player.ToolbarConfiguration = "play,+snapshot,+fullscreen"
}

} 


function MM_swapImgRestore() 
{ //v2.0
  if (document.MM_swapImgData != null)
    for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
      document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];
}

function MM_preloadImages() 
{ //v2.0
  if (document.images) {
    var imgFiles = MM_preloadImages.arguments;
    if (document.preloadArray==null) document.preloadArray = new Array();
    var i = document.preloadArray.length;
    with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#")
{
      preloadArray[i] = new Image;
      preloadArray[i++].src = imgFiles[j];
  }
 }
}

function MM_swapImage() 
{ //v2.0
	
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
  for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) 
{
    objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) 
{
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = MM_swapImage.arguments[i+2];
  }
 }
  document.MM_swapImgData = swapArray; //used for restore
  	
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function PNN() {
var load = window.open('http://www.vsftransportation.com/PNNWebForm.aspx','mywindow','left=0,top=0,width=400,height=720,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=yes');
}

function ShowMyModalPopup(loadid)
{ 
 var modal = $find('_ctl0_ContentPlaceHolder1_ModalPopupExtender1'); 
 
 modal.show(); 
 
 vsf.web.WebService.FetchOneLoad(loadid,DisplayResult);
}

function DisplayResult(result)
{
  var label=document.getElementById('_ctl0_ContentPlaceHolder1_Label1'); 
        label.innerHTML=result; 
        document.getElementById('_ctl0_ContentPlaceHolder1_Label1').value=result; 
}

 function HideModalPopup()
{
  var modal = $find('_ctl0_ContentPlaceHolder1_ModalPopupExtender1');
  var label=document.getElementById('_ctl0_ContentPlaceHolder1_Label1'); 
        label.innerHTML='Loading...'; 
        document.getElementById('_ctl0_ContentPlaceHolder1_Label1').value='Loading...'; 
  modal.hide();
}

function ViewLoadDetails(loadid)
{
    var load = window.open('view_load_details.aspx?loadid=' + loadid,'myload','width=400,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=yes');
}