Problem with onMouseOver

Discussion in 'JavaScript' started by lostsouler, Mar 16, 2010.

  1. #1
    Hi, I have problem with change images.
    Does somebody have option where I made mistake?

    script:


    userAgent = window.navigator.userAgent;
    browserVers = parseInt(userAgent.charAt(userAgent.indexOf("/")+1),10);
    function newImage(arg) {
    if (document.images) {
    rslt = new Image();
    rslt.src = arg;
    return rslt;
    }
    }

    function findElement(n,ly) {
    if (browserVers < 4) return document[n];
    var curDoc = ly ? ly.document : document;
    var elem = curDoc[n];
    if (!elem) {
    for (var i=0;i<curDoc.layers.length;i++) {
    elem = findElement(n,curDoc.layers);
    if (elem) return elem;
    }
    }
    return elem;
    }

    function changeImages() {
    if (document.images && (preloadFlag == true)) {
    var img;
    for (var i=0; i<changeImages.arguments.length; i+=2) {
    img = null;
    if (document.layers) {
    img = findElement(changeImages.arguments,0);
    }
    else {
    img = document.images[changeImages.arguments];
    }
    if (img) {
    img.src = changeImages.arguments[i+1];
    }
    }
    }
    }

    var preloadFlag = false;
    function preloadImages() {

    if (document.images) {

    pic1= new Image(382,186);
    pic1.src="/fimatest/templates/rhuk_milkyway/mapa-sk-21.gif";

    pic2= new Image(382,186);
    pic2.src="/fimatest/templates/rhuk_milkyway/mapa-sk-22.gif";

    pic3= new Image(382,186);
    pic3.src="/fimatest/templates/rhuk_milkyway/mapa-sk-23.gif";

    pic4= new Image(382,186);
    pic4.src="/fimatest/templates/rhuk_milkyway/mapa-sk-24.gif";

    pic5= new Image(382,186);
    pic5.src="/fimatest/templates/rhuk_milkyway/mapa-sk-25.gif";

    pic6= new Image(382,186);
    pic6.src="/fimatest/templates/rhuk_milkyway/mapa-sk-26.gif";

    pic7= new Image(382,186);
    pic7.src="/fimatest/templates/rhuk_milkyway/mapa-sk-27.gif";

    pic8= new Image(382,186);
    pic8.src="/fimatest/templates/rhuk_milkyway//mapa-sk-28.gif";

    pic9= new Image(382,186);
    pic9.src="/fimatest/templates/rhuk_milkyway/mapa-sk.gif";

    preloadFlag = true;

    }
    }


    html:
    <img name="mapa" id="mapa" src="/fimatest/templates/rhuk_milkyway/mapa-sk-22.gif" usemap="#mapa_Map" width="382" height="186" alt="Slovensko" /><map name="mapa_Map" id="mapa_Map">
    <area shape="poly" alt="Žilinský kraj" title="Žilinský kraj" coords="108,24,112,18,122,8,146,8,150,18,162,18,166,8,178,2,186,16,198,22,200,34,196,42,204,48,212,52,210,68,192,72,182,64,162,72,158,68,146,70,144,80,132,80,126,72,126,62,112,60,120,52,120,42,108,24" href="http://www.google.sk" target="_self" onmouseover="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk-25.gif'); return true;" onmouseout="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk.gif'); return true;" onmousedown="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk-25.gif'); return true;" onmouseup="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk-25.gif'); return true;" />
    <area shape="poly" alt="Trenciansky kraj" title="Trenciansky kraj" coords="108,24,94,28,88,50,82,52,78,50,72,60,68,58,50,68,48,64,42,66,40,70,46,76,48,86,52,86,56,82,60,82,76,90,80,88,78,80,86,82,94,92,92,96,100,104,110,98,116,98,120,90,126,92,132,82,128,74,124,72,126,62,110,60,120,52,120,42,108,24" href="http://www.google.sk" target="_self" onmouseover="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk-23.gif'); return true;" onmouseout="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk.gif'); return true;" onmousedown="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk-23.gif'); return true;" onmouseup="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk-23.gif'); return true;" />
    <area shape="poly" alt="Trnavský kraj" title="Trnavský kraj" coords="40,66,30,58,22,64,10,90,22,90,36,84,40,88,34,100,42,112,44,128,30,134,30,138,26,142,34,150,52,170,54,164,64,158,66,142,60,132,66,128,66,118,76,104,68,98,70,92,76,90,62,82,54,82,54,86,48,86,46,76,42,68" href="http://www.google.sk" target="_self" onmouseover="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk-22.gif'); return true;" onmouseout="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk.gif'); return true;" onmousedown="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk-22.gif'); return true;" onmouseup="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk-22.gif'); return true;" />
    <area shape="poly" alt="Bratislavský kraj" title="Bratislavský kraj" coords="10,92,24,92,36,84,38,88,34,92,34,96,32,100,42,112,44,126,36,132,30,134,26,142,18,142,14,140,16,132,8,126,8,116,2,106,4,98,10,92" href="http://www.google.sk" target="_self" onmouseover="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk-21.gif'); return true;" onmouseout="changeImages('mapa', '//fimatest/templates/rhuk_milkyway/mapa-sk.gif'); return true;" onmousedown="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk-21.gif'); return true;" onmouseup="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk-21.gif'); return true;" />

    <area shape="poly" alt="Nitransky kraj" title="Nitransky kraj" coords="54,172,54,166,64,160,66,144,62,134,66,130,66,118,76,106,70,96,74,92,80,82,94,90,92,96,98,104,108,100,112,104,114,116,110,120,118,120,120,116,124,112,132,126,128,128,126,138,132,140,140,136,142,142,138,148,128,150,122,156,124,164,126,170,120,170,114,176,88,176,74,172,54,172" href="http://www.google.sk" target="_self" onmouseover="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk-24.gif'); return true;" onmouseout="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk.gif'); return true;" onmousedown="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk-24.gif'); return true;" onmouseup="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk-24.gif'); return true;" />
    <area shape="poly" alt="Banskobystrický kraj" title="Banskobystrický kraj" coords="140,148,144,142,144,134,134,138,128,136,132,126,126,112,114,120,114,114,110,98,126,92,134,82,144,82,146,72,160,70,164,74,182,66,192,72,206,70,220,72,224,76,220,88,220,92,230,104,226,114,236,116,224,134,214,136,200,146,184,136,174,140,170,148,158,148,152,150,140,148" href="http://www.google.sk" target="_self" onmouseover="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk-26.gif'); return true;" onmouseout="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk.gif'); return true;" onmousedown="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk-26.gif'); return true;" onmouseup="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk-26.gif'); return true;" />
    <area shape="poly" alt="Prešovský kraj" title="Prešovský kraj" coords="204,42,204,50,212,52,210,60,208,62,210,70,220,72,224,76,230,72,228,68,238,64,250,70,258,66,280,76,288,78,288,84,294,82,298,78,304,78,316,92,322,88,322,78,330,78,334,84,344,84,344,80,350,76,354,82,362,82,372,70,372,60,340,48,336,34,328,30,324,34,314,26,304,28,294,24,288,28,280,26,282,32,274,36,266,38,260,24,250,28,234,26,232,32,228,30,220,34,216,44,210,40,202,44" href="http://www.google.sk" target="_self" onmouseover="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk-27.gif'); return true;" onmouseout="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk.gif'); return true;" onmousedown="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk-27.gif'); return true;" onmouseup="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk-27.gif'); return true;" />
    <area shape="poly" alt="Košický kraj" title="Košický kraj" coords="236,116,226,116,230,106,226,92,220,90,224,80,230,72,230,68,240,64,246,66,250,70,260,68,274,72,290,84,298,78,304,78,306,88,318,92,324,88,324,78,330,80,334,84,344,84,350,76,354,82,362,84,358,100,344,110,344,130,326,132,316,130,310,116,304,114,300,108,278,114,260,106,240,110,234,118" href="http://www.google.sk" target="_self" onmouseover="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk-28.gif'); return true;" onmouseout="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk.gif'); return true;" onmousedown="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk-28.gif'); return true;" onmouseup="changeImages('mapa', '/fimatest/templates/rhuk_milkyway/mapa-sk-28.gif'); return true;" />


    Pls help!

     
    lostsouler, Mar 16, 2010 IP