Создание web-узла для демонстрации навыков web-программирования, полученных в курсе лабораторных работ, страница 5

#m4 {position:absolute; z-index:4; visibility:visible; width:213px; height:345px;}

#m5 {position:absolute; z-index:5; visibility:visible; width:183px; height:345px;}

#m6 {position:absolute; z-index:6; visibility:visible; width:174px; height:346px;}

#m7 {position:absolute; z-index:7; visibility:hidden; width:174px; height:346px;}

</style>

<script language="javaScript">

var IE4 = 0; var IE5 = 0; var NS4 = 0; var NS6 = 0; var Opera = 0; var Mac = 0; var Moz = 0;

var cookie_x = new Array(0,0,0,0,0,0);

var cookie_y = new Array(0,0,0,0,0,0);

function Init()<!-- Initialisation -->

{

    if (navigator.userAgent.indexOf("Opera") != -1) Opera = 1;

    else if (document.getElementById)

    {

        if ((navigator.userAgent.indexOf("Gecko") != -1) && (navigator.userAgent.indexOf("Netscape") == -1)) Moz = 1;

        else if (navigator.userAgent.indexOf("Gecko") != -1) NS6 = 1;

        else IE5 = 1;

    }

    else if (document.all) IE4 = 1;

    else if (document.layers) NS4 = 1;

    if (navigator.appVersion.indexOf("Mac") != -1) Mac = 1;

}

function GetObject(name)

{

    if (Moz || NS6 || IE5 || Opera) return document.getElementById(name);

    else if (IE4) return document.all[name];

}

var catched = "none";

var catched_x = 0;

var catched_y = 0;

var catched_obj_x = 0;

var catched_obj_y = 0;

var catched_click = false;

function catchObj(obj)

{

    if (catched == "none")

    {

        var x = event.x;

        var y = event.y;

        catched = obj;

        catched_x = x;

        catched_y = y;

        catched_obj_x = x - obj.style.left.toString().substr(0, obj.style.left.toString().length-2);

        catched_obj_y = y - obj.style.top.toString().substr(0, obj.style.top.toString().length-2);

        status = "Catched " + catched.id + ". Coordinates: " + "x: " + event.x + " y: " + event.y;

    }  

    else releaseObj();

}

function releaseObj()

{

    var x = event.x;

    var y = event.y;

    if (catched != "none" && x != catched_x && y != catched_y)

    {

        if (!catched_click)

        {

            x -= catched_obj_x;

            y -= catched_obj_y;       

        }

        catched.style.left = x;

        catched.style.top = y;

        catched = "none";

        catched_x = 0;

        catched_y = 0;

        catched_obj_x = 0;

        catched_obj_y = 0;

        catched_click = false;

        status= "Released";

        setCookie();

    }

    else if (catched != "none") catched_click = true;

}

function moveObj()

    var x = event.x;

    var y = event.y;

    if (!catched_click && catched != "none" && x != catched_x && y != catched_y)

    {

        catched.style.left = x - catched_obj_x;

        catched.style.top = y - catched_obj_y;

        status = "Catched " + catched.id + ". Coordinates: " + "x: " + event.x + " y: " + event.y;

    }

    return false;

}

document.onmousemove = moveObj;    

document.onmouseup = releaseObj;

function setCookie()

{

    var obj;

    for (i=1; i<7; i++)

    {

        eval('obj = GetObject("m' + i + '");');

        cookie_x[i-1] = obj.style.left;

        cookie_y[i-1] = obj.style.top;

    }

      tmp=new Date();

            tmp.setTime(tmp.getTime()+365*24*60*60*100);

            expiryDate=tmp.toGMTString();

document.cookie = "x=" + cookie_x.join("|") + ";expires="+expiryDate;

    document.cookie = "y=" + cookie_y.join("|") + ";expires="+expiryDate;

}

function getCookie()

{

    var obj;

    var tmp_x = new Array(0,0,0,0,0,0);

    var tmp_y = new Array(0,0,0,0,0,0);

    if (document.cookie.indexOf("x=") !=  -1)

    {

        start = document.cookie.indexOf("x=");