//------------------------------------------------------------
// $Id: Camera.js 1531 2007-05-22 23:18:30Z samuel_igc $
// Camera object used to form oCamera collection in index.jsp
//------------------------------------------------------------

function CameraEntry( id, direction, url )
{
   this.id = id;
   this.direction = direction;
   this.url = url;
}

function Camera(longitude, lat, description, id, corridor, mount, streamType) {
    this.corridor = corridor;
    this.mount = mount;
    this.streamType = streamType;
    Camera(longitude, lat, description, id);
}
    
function Camera(longitude, lat, description, id, cameraEntries ) {
    this.longitude = longitude;
    this.lat = lat;
    this.latitude = lat;
    this.description = description;
    this.id = id;
    this.cameraEntries = cameraEntries;

    this.img = document.createElement('img');
    this.img.src = './images/icon_camera.gif';
    this.img.type = 'camera';
    this.img.style.cursor = 'pointer';

    this.img.referencedObject  = this;

    this.img.onclick     = this.onClick;
    this.img.onmouseover = this.mouseOver;
    this.img.onmouseout  = this.mouseOut;
    this.icon_sizes =  { 290000:{ h:12,w:12} ,195000:{h:16,w:16},135000:{h:20,w:20},55000:{h:20,w:20},12000:{h:28,w:28}};
}

Camera.prototype.setScale = function (scale) { 

 if(this.icon_sizes[scale] != null) {
        this.img.width=this.icon_sizes[scale].w;
        this.img.height=this.icon_sizes[scale].h;
   }
}

// Display the tooltip box
Camera.prototype.mouseOver = function(e) {
    e=(e)?e:window.event;
    var d = document.getElementById('hoverBox');
    d.style.visibility = "visible";
    if ((getInsideWindowWidth() - e.clientX) < 100) {
        d.style.left = (e.clientX) + (-130) + 'px';
    } else {
        d.style.left = (e.clientX) + (20) + 'px';
    }

    if ((getInsideWindowHeight() - e.clientY) < 20) {
        d.style.top = (e.clientY) + (10) +'px';
    } else {
        d.style.top = (e.clientY) + (-10) +'px';
    }
    d.innerHTML = this.referencedObject.description;
}

// Hide the tooltip box
Camera.prototype.mouseOut = function(e) {
    var d = document.getElementById('hoverBox');
    d.style.visibility = "hidden";
}

// Handle clicks on camera icon (-> popup)
Camera.prototype.onClick = function(e) {
    this.referencedObject.drawCameraPopup();
}

// This generates the popup
Camera.prototype.drawCameraPopup = function() {    
    window.open('campopup.jsp?-1&' + this.id,
                '_blank',
                "width=414,height=450,scrollbars=0,toolbar=0,"
                + "titlebar=0,directories=0,menubar=0,resizable=1,status=0");
}
