currentCamera2= 2;

errorimg2= 0;

document.images.webcam2.onload = DoIt2;

document.images.webcam2.onerror = ErrorImage2;

function LoadImage2()

{

        uniq2 = Math.random();

        document.images.webcam2.src = "http://195.146.153.126:8080/cam_" + currentCamera2 + ".jpg?uniq="+uniq2;

        document.images.webcam2.onload = DoIt2;

}

function PTZMouseDown2(e)

{

        var IE = document.all?true:false;

        var x,y;

        var myx,myy;

        var myifr = document.getElementById("_iframe-ptz");

        tp = getElPos2();

        myx = tp[0];

        myy = tp[1];

        if(IE){

        x = event.clientX - myx + document.body.scrollLeft;

        y = event.clientY - myy + document.body.scrollTop;

        } else {

        x = e.pageX - myx;

        y = e.pageY - myy;

        }

        //alert(x + " :: " + y);

        if (width_array[currentCamera2] > 0) x = Math.round((x * 400) / width_array[currentCamera2]);

        if (height_array[currentCamera2] > 0) y = Math.round((y * 300) / height_array[currentCamera2]);

        //alert(x + " :: " + y);

        if (myifr != null) myifr.src = "http://195.146.153.126:8080/ptz?src=" + currentCamera2 + "&moveto_x=" + x + "&moveto_y=" + y +"";

        return true;

}

function getElPos2()

{

            el = document.images.webcam2;

            x = el.offsetLeft;

            y = el.offsetTop;

            elp = el.offsetParent;

            while(elp!=null)

              { x+=elp.offsetLeft;

                y+=elp.offsetTop;

                elp=elp.offsetParent;

              }

            return new Array(x,y);

}

function ErrorImage2()

{

        errorimg2++;

        if (errorimg2>3){

              document.images.webcam2.onload = "";

              document.images.webcam2.onerror = "";

              document.images.webcam2.src = "offline.jpg";

              }else{

                uniq2 = Math.random();

            document.images.webcam2.src = "http://195.146.153.126:8080/cam_" + currentCamera2 + ".jpg?uniq="+uniq2;

              }

}

function DoIt2()

{

        errorimg2=0;

        window.setTimeout("LoadImage2();", 40);

}

