function off(D,myS)
{   document.getElementById('givaro').style.display = "none";
    if (myS==window.currentS) setTimeout("on(700,"+myS+")",D);
}
function on(D,myS)
{   if (myS==window.currentS)
    {  document.getElementById('givaro').style.display = "inline";
       setTimeout("off(700,"+myS+")",D);
    }
}
function next(S)
{   document.getElementById('gifts').style.backgroundImage='url(../img/maps/Gifts'+S+'.jpg)';
    window.currentS = S;
    off(5000,S);
    switch(S)
    {   case 0: document.getElementById('situation').innerHTML="In the initial situation shown in the map, Israeli forces are occupying the West Bank and the Golan Heights and Israel is controlling all access points to the Gaza Strip.&nbsp; The State of Palestine does not yet exist and no donations of territory have taken place yet.<p>In the <a href='javascript:next(1)'>first step</a>, a peace treaty is agreed between Syria and Israel (perhaps linked to adoption of the Just Peace Agreement), leading to Israeli withdrawal from the Golan Heights...</p><p><center><a href='javascript:next(1)'>FIRST STEP</a></center></p>";
        document.getElementById('Israel').innerHTML = "20330";
        document.getElementById('Occupied').innerHTML = "7295";
        document.getElementById('Palestine').innerHTML = "0";
        document.getElementById('Syria').innerHTML = "182755";
        document.getElementById('Egypt').innerHTML = "995450";
        document.getElementById('Arabia').innerHTML = "2149690";
        document.getElementById('Jordan').innerHTML = "91971";
        document.getElementById('Lebanon').innerHTML = "10230";
        document.getElementById('givaro').style.top = "30px";
        document.getElementById('givaro').style.left = "205px";
        break;
        case 1: document.getElementById('situation').innerHTML="After the <b>first step</b> Israeli forces have withdrawn from the Golan Heights, which has therefore returned to Syrian sovereignty.&nbsp; Israel has not withdrawn from the West Bank yet, and is still controlling all access points to the Gaza Strip.<p>In the <a href='javascript:next(2)'>next step</a>, Israel withdraws from the West Bank as part of the process of implementing the Just Peace Agreement, and the State of Palestine comes into being...</p><p><center><a href='javascript:next(2)'>NEXT STEP</a></center></p>";
        document.getElementById('Occupied').innerHTML = "6000";
        document.getElementById('Syria').innerHTML = "184050";
        document.getElementById('givaro').style.top = "130px";
        document.getElementById('givaro').style.left = "145px";
        break;
        case 2: document.getElementById('situation').innerHTML="Israeli forces have withdrawn from the West Bank and the State of Palestine is established on territory occupied in 1967.&nbsp; The territorial exchange has not yet taken place and the corridor between the West Bank and Gaza Strip is not yet open.<p>The <a href='javascript:next(3)'>next step</a> is the first and biggest territorial donation (land gift), which is from Egypt to Palestine.  It more than triples the size of the territory of the new state...</p><p><center><a href='javascript:next(3)'>NEXT STEP</a></center></p>";
        document.getElementById('Occupied').innerHTML = "0";
        document.getElementById('Palestine').innerHTML = "6000";
        document.getElementById('givaro').style.top = "390px";
        document.getElementById('givaro').style.left = "70px";
        document.getElementById('givaro').style.backgroundImage='url(../img/maps/givarup.gif)';
        break;
        case 3: document.getElementById('situation').innerHTML="Egypt has given over 13000 square kilometers of the Sinai to Palestine, more than tripling the land area of the new state.&nbsp; Even so, Palestine is smaller in area than Israel, and the territorial exchange between the states has not yet taken place.<p>In the <a href='javascript:next(4)'>next step</a>, immediately after the gift from Egypt to Palestine, Saudi Arabia gives to Egypt an equivalent area of land on the other side of the Gulf of Aqaba... </p><p><center><a href='javascript:next(4)'>NEXT STEP</a></center></p>";
        document.getElementById('Egypt').innerHTML = "982440";
        document.getElementById('Palestine').innerHTML = "19010";
        document.getElementById('givaro').style.top = "490px";
        document.getElementById('givaro').style.left = "160px";
        document.getElementById('givaro').style.backgroundImage='url(../img/maps/givaro.gif)';
        break;
        case 4: document.getElementById('situation').innerHTML="In spite of giving over 13000 square kilometers of territory to Palestine, Egypt now has exactly the same area as before, because Saudi Arabia has fully compensated Egypt with land on the other side of the Gulf of Aqaba, up as far as the border with Jordan. <p>In the <a href='javascript:next(5)'>next step</a>, Jordan makes a smaller but highly significant donation of territory to Palestine, in the northwest corner of the kingdom on the east bank of the Jordan river...</p><p><center><a href='javascript:next(5)'>NEXT STEP</a></center></p>";
        document.getElementById('Arabia').innerHTML = "2136680";
        document.getElementById('Egypt').innerHTML = "995450";
        document.getElementById('givaro').style.top = "80px";
        document.getElementById('givaro').style.left = "190px";
        break;
        case 5: document.getElementById('situation').innerHTML="Jordan has donated 330 square kilometers of its territory to Palestine, including the fertile river valley along the bank of the river Jordan and mountain slopes to the east.&nbsp; This creates a wide corridor linking the West Bank to the Golan.<p>In the <a href='javascript:next(4)'>next step</a>, Syria responds to Jordan's move by giving the same amount of territory to Palestine in the southern Golan, linked to the West Bank by the corridor given by Jordan...</p><p><center><a href='javascript:next(6)'>NEXT STEP</a></center></p>";
        document.getElementById('Jordan').innerHTML = "91641";
        document.getElementById('Palestine').innerHTML = "19340";
        document.getElementById('givaro').style.top = "50px";
        document.getElementById('givaro').style.left = "190px";
        break;
        case 6: document.getElementById('situation').innerHTML="Syria has donated 330 square km of its recently recovered territory in the Golan to Palestine.&nbsp; These gifts from Jordan and Syria to the new state have halved the remaining difference in the land areas of Israel and Palestine to just 660 square km.<p>The <a href='javascript:next(7)'>next step</a> is the one-to-one land-swap between Israel and Palestine, in which people living close to the mutual border can vote for their home to be in the other state... </p><p><center><a href='javascript:next(7)'>NEXT STEP</a></center></p>";
        document.getElementById('Syria').innerHTML = "183720";
        document.getElementById('Palestine').innerHTML = "19670";
        document.getElementById('givaro').style.top = "197px";
        document.getElementById('givaro').style.left = "118px";
        break;
        case 7: document.getElementById('situation').innerHTML="After the territorial exchange (the one-to-one land-swap), the areas of Israel and Palestine have not changed and differ by just 660 square km.&nbsp; The corridor linking the West Bank and Gaza Strip is now open (but note that this is Israeli sovereign territory).<p>In the <a href='javascript:next(8)'>final step</a>, Israel makes a (surprise!) donation of 330 square kilometers of territory to Palestine, its neighbor, along the Gaza strip and the edge of the Sinai...</p><p><center><a href='javascript:next(8)'>LAST STEP</a></center></p>";
        document.getElementById('Israel').innerHTML = "20330";
        document.getElementById('Palestine').innerHTML = "19670";
        document.getElementById('givaro').style.top = "230px";
        document.getElementById('givaro').style.left = "70px";
        break;
        case 8: document.getElementById('situation').innerHTML="After the final donation of 330 square kilometers from Israel to Palestine (additional to the land-swap), the land areas of the two states are both 20000 square kilometers.&nbsp; In another friendly gesture, the Shaba'a Farms in the extreme north of the Golan Heights have been returned to Lebanon by Syria, clearing the way for a possible peace treaty between Lebanon and Israel as this resolves the last of the disputes left over from decades of war in the region.<p><center><a href='javascript:next(0)'>START AGAIN</a></center></p>";
        document.getElementById('Israel').innerHTML = "20000";
        document.getElementById('Palestine').innerHTML = "20000";
        document.getElementById('Syria').innerHTML = "183698";
        document.getElementById('Lebanon').innerHTML = "10252";
        document.getElementById('givaro').style.display = "none";
        window.currentS = 999;
        break;
    }
}
var Iabs = 1;
function app(I)
{   Iabs = I;
    var X = document.getElementById('iX');
    var O = document.getElementById('i'+I);
    var S = document.getElementById('sh').style;
    var P = document.getElementById('popup').style;
    X.src = O.src;
    var H = O.height * 4;
    if (H < 5 || H > 540 ) H = '540';
    X.height = H;
    // X.width = '540'; default
    X.useMap = "#q"+I;
    P.height = H+"px";
    P.display = 'inline';
    S.opacity = 0.5;
    S.MozOpacity = 0.5;
    S.KhtmlOpacity = 0.5;
    S.filter = 'alpha(opacity=50)';
    S.display = 'inline';
    if (I=="key" || I=="hlp") document.getElementById('in').style.display = 'none';
    else document.getElementById('in').style.display = 'inline';
    // document.getElementById('info').style.display = 'none';
    // document.getElementById('refuse').style.display = 'none';
}
function dis()
{   document.getElementById('popup').style.display = 'none';
    document.getElementById('info').style.display = 'none';
    document.getElementById('info').style.visibility = 'hidden';
    document.getElementById('refuse').style.display = 'none';
    document.getElementById('refuse').style.visibility = 'hidden';
    document.getElementById('sh').style.display = 'none';
    Iabs = 0;
}
document.onmousemove = captureMousePosition;
var xM = 0; var yM = 0;
function captureMousePosition(e)
{   if (document.all) { xM = window.event.x - document.documentElement.clientWidth/5;
        yM = window.event.y - document.documentElement.scrollTop;  }
    else { xM = e.pageX - window.innerWidth/5; yM = e.pageY - window.pageYOffset; }
}
var swaps = [0,0,0,0,0,0,0,0,0,0,0];
var area = [ [0,0,0], [-42,9,-9], [-3,1,2], [3,-3,6], [6,0,3], [3,3,3], [6,24,0],[3,0,0], [3,0,0] ];
var ixtot = 0;
function terx(I,S)
{ if (S==0)
  {  var R = document.getElementById('refuse').style;
     R.left = (xM-0)+"px";
     R.top  = (yM+12)+"px";
     R.display = 'inline';
     R.visibility = 'visible';
  }
  else
  { var i = document.getElementById('i9').src.indexOf("TX9-");
    path = document.getElementById('i9').src.substring(0,i);
    var W = S-1;
    if (W==3) W = 2;
    var A = area[I][W];
    if (S & swaps[I]) ixtot -= A;
    else ixtot += A;
    rep();
    swaps[I] = swaps[I] ^ S;
    document.getElementById('iX').src = path+"TX"+I+"-"+swaps[I]+".jpg";
    document.getElementById('i'+I).src = document.getElementById('iX').src;
    bal();
  }
}
function rep()
{   var pxtot = -ixtot;
    if (pxtot>0) pxstr = "+"+pxtot+" "; else pxstr = pxtot+" ";
    if (ixtot>0) ixstr = "+"+ixtot+" "; else ixstr= ixtot+" ";
    document.getElementById('ptot').innerHTML = " "+pxstr;
    document.getElementById('itot').innerHTML = " "+ixstr;
    document.getElementById('btot').innerHTML = " "+ixtot;
}
function bal()
{   var i = document.getElementById('i9').src.indexOf("TX9-");
    path = document.getElementById('i9').src.substring(0,i);
    var A = 0;
    var B = 0;
    n = "-"+swaps[7]+".";
    if (ixtot > 0)
    {  B = ixtot / 3;
       B = 2 * parseInt(B+" ") + (swaps[7] % 2);
       swaps[7] = B;
    }
    else if (ixtot < 0)
    {  A = (9-ixtot) / 9;
       A = parseInt(A+" ");
       B = swaps[7] % 2;
    }
    document.getElementById('i7').src = path+"TX7-"+B+".jpg";
    if (Iabs==7) document.getElementById('iX').src = path+"TX7-"+B+".jpg";
    document.getElementById('i9').src = path+"TX9-"+A+".jpg";
    rep();
}
var L = [0,340,320,300,365,365,220,320,365];
var T = [0,370,150,250,50,50,270,240,50];
var W = [0,180,200,200,160,160,200,180,160];
function infopop()
{   var I = document.getElementById('info').style;
    if (I.display!='inline')
    {  I.display = 'inline';
       I.visibility = 'visible';
       I.left = L[Iabs]+'px';
       I.top = T[Iabs]+'px';
       I.width = W[Iabs]+'px';
       switch(Iabs)
       {   case 1: t1 = "This tile has three areas that are allowed ";
           t1 += "territorial exchange: the entire region of the Wadi Ara with all ";
           t1 += "its Arab towns and villages; the Arab-Iraeli city of Baqa al-Gharbiya; ";
           t1 += "and the Israeli settlement group around Tal Manashe.&nbsp; Point at any of ";
           t1 += "these regions and click to vote for a land-swap.&nbsp; Click again to reverse.";
           break;
           case 2: t1 = "This tile shows what might happen if an Arab town in ";
           t1 += "Israel (Taibe) votes 50% for exchange and 50% against; half ";
           t1 += "the town is in Israel and half in Palestine, but the border ";
           t1 += "will be open inside the city, like in Jerusalem.<br/>";
           t1 += "The small Israeli settlements of Sal'it and Zufin are allowed to exchange ";
           t1 += "on this map, but the block of Ma'ale Shomeron and Immanu'el is not, ";
           t1 += "and neither is Alfe Manashe nor Avne Hefez.";
           break;
           case 3: t1 = "This tile shows a complicated situation where three nearby ";
           t1 += "towns may all want to exchange: Oranit, Kafr Qasem and the Elkana ";
           t1 += "block, all in the northwest corner.&nbsp; (Note the way that road ";
           t1 += "access is maintained across borders in such a land-swap.)&nbsp; No other exchanges ";
           t1 += "are allowed on this tile.";
           break;
           case 4: t1 = "This tile involves a large area of no man's land (shown white). ";
           t1 += "Israeli townships in or next to no man's land can exchange, while ";
           t1 += "other parts of the no man's land go to Palestine. ";
           t1 += "(No man's land counts for 50% in exchange, as compared with other ";
           t1 += "territory of the same area.)<br /> The small settlements of Mevo Horon ";
           t1 += "and Har Adar can swap as well as the large block from Modi'in Illit ";
           t1 += "to Maccabim, but the settlements of Nili and Na'ale cannot.";
           break;
           case 5: t1 = "This tile shows Jerusalem and the surrounding area.&nbsp  ";
           t1 += "The new boundary of the city under the Just Peace Agreement is ";
           t1 += "in yellow, with the main residential areas inside the new boundary ";
           t1 += "shown blue for Jewish and green for Arab areas.<br />  ";
           t1 += "Outside the city, only Ramot Allon and Ramat Shlomo can exchange.&nbsp; ";
           t1 += "Inside the city, French Hill, East Talpiyyot and Gillo may be  ";
           t1 += "expected to swap, and the Jewish Quarter of the Old City ";
           t1 += "must certainly do so.&nbsp; Exchange of Har Homa is refused: it will ";
           t1 += "be a Jewish area in the Palestinian half of the city.";
           break;
           case 6: t1 = "On this tile, the town of Betar Illit and the  ";
           t1 += "group of kibbutzim and settlements around Kfar Etzion can exchange.&nbsp; ";
           t1 += "The nearby town of Efrat is included with the Kfar Eztion group.&nbsp; ";
           t1 += "Kiryat Arba, east of Hebron, cannot exchange.";
           break;
           case 7: t1 = "On this tile, only the small settlements Eshkolot and Sansana at ";
           t1 += "the very tip of the West Bank can exchange.<br /> ";
           t1 += "The border of Palestine expands westwards on this tile when territory is ";
           t1 += "owed to Palestine by Israel under the one-to-one land swap.";
           break;
           case 8: t1 = "On this tile, only the small settlements Shani and Mezadot Yehuda ";
           t1 += "can exchange.<br />To the east, ";
           t1 += "the border of Palestine moves north when territory is ";
           t1 += "owed to Israel by Palestine under the one-to-one land swap.";
           break;
       }
       document.getElementById('info').innerHTML = t1;
    }
    else
    {  I.display = 'none';
       I.visibility = 'hidden';
    }
}

