﻿var title = "";

function toggleImage(pxl, it) {
    it.style.backgroundPosition = "0px " + pxl + "px";
}

function changeFrettaAr(ar) {
    var arin = document.getElementById("div_Arin").childNodes;
    for (i = 0; i < arin.length; i++) {
        if (arin[i].tagName == "DIV") {
            arin[i].style.display = "none";
        }
    }
    document.getElementById("div_Ar_" + ar).style.display = "block";
}
function hideAdrirVefir() {
    document.getElementById("divVefirAkraness").style.display = "none";
    RemoveEvent(document.body, "mouseup", hideAdrirVefir);
}
function adrirVefirClick() {
    document.getElementById("divVefirAkraness").style.display = "block";
    AddEvent(document.body, "mouseup", hideAdrirVefir);
}


function AddEvent(tObject, tEvent, tFunc) {
    if (document.attachEvent) {
        tObject.attachEvent("on" + tEvent, tFunc);
    }
    else {
        tObject.addEventListener(tEvent, tFunc, false);
    }
}

function RemoveEvent(tObject, tEvent, tFunc) {
    if (document.detachEvent) {
        tObject.detachEvent(tEvent, tFunc);
    }
    else {
        tObject.removeEventListener(tEvent, tFunc, false);
    }
}

function whatToTo(where) {
    if (where != "") {
        document.location.href = where;
    }
}



function showMap() {
    document.getElementById("divCollapse").style.display = "none";
    document.getElementById("divFlash").style.display = "block";
    document.getElementById("ifrKort").src = "/vefsja/index.html";
}












function setActiveStyleSheet(tTitle) {
    var i, a, main;
    for (i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
        if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
            a.disabled = true;
            if (a.getAttribute("title") == tTitle) {
                a.disabled = false;
            }
        }
    }
    title = tTitle;
    //setButtons(tTitle);
}

function window_load() {
    var cookie = readCookie("style");
    title = cookie ? cookie : getPreferredStyleSheet();
    setActiveStyleSheet(title);
}

function setButtons(tTitle) {
    var a = document.getElementById("imgA");
    var aa = document.getElementById("imgAA");
    switch (tTitle) {
        case "Size2":
            a.style.backgroundPosition = "0px 0px";
            a.style.cursor = "pointer";
            aa.style.backgroundPosition = "0px 0px";
            aa.style.cursor = "pointer";
            break;
        case "Size3":
            a.style.backgroundPosition = "0px 0px";
            a.style.cursor = "pointer";
            aa.style.backgroundPosition = "0px -28px";
            aa.style.cursor = "default";
            break;
        default:
            //          a.style.backgroundPosition="0px -28px";
            //          a.style.cursor="default";
            //          aa.style.backgroundPosition="0px 0px";
            //          aa.style.cursor="pointer";
    }
}

function fontLarger() {
    if (title == "Size1" || title == "") {
        setActiveStyleSheet("Size2");
    } else {
        if (title == "Size2") {
            setActiveStyleSheet("Size3");
        }
    }
}
function fontSmaller() {
    if (title == "Size3") {
        setActiveStyleSheet("Size2");
    } else {
        if (title == "Size2") {
            setActiveStyleSheet("Size1");
        }
    }
}

function window_unload() {
    var title = getActiveStyleSheet();
    createCookie("style", title, 7);
}
function getPreferredStyleSheet() {
    var i, a;
    for (i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
        if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("rel").indexOf("alt") == -1 && a.getAttribute("title"))
            return a.getAttribute("title");
    }
    return null;
}
function getActiveStyleSheet() {
    var i, a;
    for (i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
        if (a.getAttribute("rel").indexOf("style") != -1
			&& a.getAttribute("title")
			&& !a.disabled) return a.getAttribute("title");
    }
    return null;
}
function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}
function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}
function askrift(SID_ID, VEF_ID) {
    gluggi_askrift = window.open('http://nepal.vefurinn.is/fastar/postlistaskraning_1.asp?ASK_SID_ID=' + SID_ID + '&VEF_ID=' + VEF_ID, 'image', "toolbar=0,scrollbars=0,location=0,status=0,menubar=0,width=350,height=300");
}

