﻿var title = "";
var adridvefir_on = false;

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 toggleImage(pxl, it) {
    it.style.backgroundPosition = "0px " + pxl + "px";
}

function hideAdrirVefir() {
    document.getElementById("divVefirIa").style.display = "none";
    RemoveEvent(document.body, "mouseup", hideAdrirVefir);
    adridvefir_on = true;
}
function adrirVefirClick() {

    document.getElementById("divVefirIa").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 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 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");
}

