﻿
function chkVer(imagename, objectsrc) {
    var n = navigator.appName
    var v = parseInt(navigator.appVersion)
    var browsok = ((n == "Netscape") && (v >= 3))
    var browsok2 = ((n == "Microsoft Internet Explorer") && (v >= 4))
    if ((browsok) || (browsok2))
        document.images[imagename].src = eval(objectsrc + ".src")
}
//-->

//if (document.images) {
//    //On & Off-->

//    contacton = new Image;
//    contacton.src = "images/Contact_on.gif";
//    contactoff = new Image;
//    contactoff.src = "images/Contact_off.gif";

//    resultson = new Image;
//    resultson.src = "images/Results_on.gif";
//    resultsoff = new Image;
//    resultsoff.src = "images/Results_off.gif";

//    homeon = new Image;
//    homeon.src = "images/home_on.gif";
//    homeoff = new Image;
//    homeoff.src = "images/home_off.gif";

//    specialson = new Image;
//    specialson.src = "images/specials_on.gif";
//    specialsoff = new Image;
//    specialsoff.src = "images/specials_off.gif";

//    advon = new Image;
//    advon.src = "images/adv_search_on.gif";
//    advoff = new Image;
//    advoff.src = "images/adv_search_off.gif";

//    carton = new Image;
//    carton.src = "images/omdesign/Shopping Cart_green.png";
//    cartoff = new Image;
//    cartoff.src = "images/omdesign/Shopping Cart.png";

//    checkouton = new Image;
//    checkouton.src = "images/omdesign/ok_green.png";
//    checkoutoff = new Image;
//    checkoutoff.src = "images/omdesign/ok.png";

//    loginon = new Image;
//    loginon.src = "images/login_on.gif";
//    loginoff = new Image;
//    loginoff.src = "images/login_off.gif";

//    logouton = new Image;
//    logouton.src = "images/logout_on.gif";
//    logoutoff = new Image;
//    logoutoff.src = "images/logout_off.gif";

//    searchon = new Image;
//    searchon.src = "images/omdesign/search_green.png";
//    searchoff = new Image;
//    searchoff.src = "images/omdesign/search.png";
//}



function searchCheck() {
    if (document.forms[0].searchbox.value.length < 2) {
        alert("Du måste ha minst 3 tecken i din sökning!");
        document.forms[0].searchbox.select();
        document.forms[0].searchbox.focus();
        return false;
    } else {
        return true;
    }
}

function koll() {
    if (document.Form1.fornamn.value == "") {
        alert("Du måste fylla i ditt förnamn!");
        document.Form1.fornamn.focus();
        return false;
    }
    if (document.Form1.efternamn.value == "") {
        alert("Du måste fylla i ditt efternamn!");
        document.Form1.efternamn.focus();
        return false;
    }
    if (document.Form1.adress.value == "") {
        alert("Du måste fylla i din adress!");
        document.Form1.adress.focus();
        return false;
    }
    if (document.Form1.postnr.value == "") {
        alert("Du måste fylla i ditt postnummer!");
        document.Form1.postnr.focus();
        return false;
    }
    if (document.Form1.ort.value == "") {
        alert("Du måste fylla i din ort!");
        document.Form1.ort.focus();
        return false;
    }
    if (document.Form1.telefon.value == "") {
        alert("Du måste fylla i din telefon!");
        document.Form1.telefon.focus();
        return false;
    }
    if (document.Form1.mobil.value == "") {
        alert("Du måste fylla i ditt mobiltelefon!");
        document.Form1.ort.focus();
        return false;
    }
    if (document.Form1.email.value == "") {
        alert("Du måste fylla i din emailadress!");
        document.Form1.email.focus();
        return false;
    }
    if (document.Form1.email.value.length < 6) {
        alert("Du har en ogiltig emailadress!");
        document.Form1.email.focus();
        document.Form1.email.select();
        return false;
    }
    if (document.Form1.email.value.indexOf('@') == -1) {
        alert("Du har en ogiltig emailadress!");
        document.Form1.email.focus();
        document.Form1.email.select();
        return false;
    }
    if (document.Form1.email.value.indexOf('.') == -1) {
        alert("Du har en ogiltig emailadress!");
        document.Form1.email.focus();
        document.Form1.email.select();
        return false;
    }
}


function chkFrm() {

    if ((document.frm.name.value.length) < 3) {
        window.alert(" Ditt namn måste innehålla minst 3 tecken! ");
        document.frm.name.focus();
        return false;
    }

    var strEmail = document.frm.email.value;

    if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(strEmail))) {
        window.alert("Var snäll och fyll i en giltig emailadress!");
        document.frm.email.select();
        return false;
    }

    else {
        document.frm.submit();

    }
}

function chkFrmSend() {

    var strEmail = document.frmSend.email.value;

    if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(strEmail))) {
        window.alert("Var snäll och fyll i en giltig emailadress!");
        document.frmSend.email.select();
        return false;
    }

    else {
        document.frmSend.submit();

    }
}

function validateLength(oSrc, args) {
    args.IsValid = (args.Value.length >= 3);
}

function validateEmail(oSrc, args) {

    if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(args.Value))) {
        args.IsValid = false;
    }
}

function delClient(msg, clientId) {
    if (confirm(msg)) {
        document.location.href = ("editProfile2.asp?expand=delClient&clientId=" + clientId);
        return true;
    }
    else {
        return false;
    }
}


function newWindow_itempg_blem(artno) {
    window.open("itm_img/big_" + artno + ".jpg", "kalle", "HEIGHT=520, WIDTH=520")
}


function newPayopt_itempg_blem() {
    window.open("payopt.aspx", "test", "HEIGHT=380, WIDTH=520")
}

function openwindow_search_help_manufacture_section() {
    h = 400;
    w = 450;
    l = (screen.availWidth - 10 - w) / 2;
    t = (screen.availHeight - 20 - h) / 2;
    window.open("search_help.aspx?desc=manufacturer_section", "my_new_window", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=yes, width=" + w + ", height=" + h + ", left=" + l + ", top=" + t)
}

function notSupported() { alert('your browser is not supported.'); }
function siv(nm, top) {
    if (document.getElementById) {
        var element = document.getElementById(nm);
        if (element.scrollIntoView) {
            element.scrollIntoView(top);
        }
        else { notSupported(); }
    }

}

function openwindow_used() {
    window.open("search_help.aspx?desc=used", "my_new_window", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=yes, width=600, height=600")
}

function newWindow_shops(value) {
    if (value == "karta_taby.gif")
        window.open("../images/maps/" + value, "kalle", "HEIGHT=486, WIDTH=571")
    else if (value == "karta_eriksgatan.gif")
        window.open("../images/maps/" + value, "kalle", "HEIGHT=354, WIDTH=467")
    else if (value == "Karta_opmusikk.gif")
        window.open("../images/maps/" + value, "kalle", "HEIGHT=367, WIDTH=600")
    else if (value == "karta_gjovik.jpg")
        window.open("../images/maps/" + value, "kalle", "HEIGHT=360, WIDTH=515")
    else
        window.open("../images/maps/" + value, "kalle", "HEIGHT=330, WIDTH=370")
}

function lordag() {
    window.open("lordagsstangt.htm", "Lördagsöppet", "HEIGHT=200, WIDTH=370")
}

function openwindow_section() {
    h = 400;
    w = 500;
    l = (screen.availWidth - 10 - w) / 2;
    t = (screen.availHeight - 20 - h) / 2;
    window.open("search_help.aspx?desc=section", "my_new_window", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=yes, width=" + w + ", height=" + h + ", left=" + l + ", top=" + t)
}

function newWindowCVV2() {
    window.open("CVV2CVC2.htm", "popup", "HEIGHT=520, WIDTH=520")
}
function CCInfo() {
    window.open("creditCardInfo.htm", "popup", "HEIGHT=520, WIDTH=520")
}
function MCInfo() {
    window.open("http://www.mastercardbusiness.com/mcbiz/index.jsp?template=/orphans&content=securecodepopup", "popup", "HEIGHT=520, WIDTH=550")
}

function openwindowHyllvarmare() {
    window.open("search_help.aspx?desc=used", "my_new_window", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=yes, width=600, height=600")
}

function itemconfirm(artno) {
    if (confirm("OBS! Du kan inte beställa Outletvaror till Outletpriser via webshopen. Ring den säljande butiken i stället.")) {
        window.location = 'itempg.aspx?artno=' + artno
    }
}
function confirmDelete(delUrl) {
    if (confirm("OBS! Du kan inte beställa Outletvaror till Outletpriser via webshopen. Ring den säljande butiken i stället.")) {
        document.location = delUrl;
    }
}

function newWindowItempg(artno){
	window.open("popup_image.aspx?artno=" + artno + "", "popup", "HEIGHT=520, WIDTH=520")
}

function newBigWindowItempg(artno, shtWidth,shtHeight){
	window.open("popup_image.aspx?artno=" + artno + "", "popup", "HEIGHT=" + shtHeight + ", WIDTH=" + shtWidth  )
}

function newPayoptItempg(){
	window.open("finance_appl_pre.aspx", "popup_2", "HEIGHT=580, WIDTH=520")
}

function openwindowSearch_res() {
    h = 400;
    w = 450;
    l = (screen.availWidth - 10 - w) / 2;
    t = (screen.availHeight - 20 - h) / 2;
    window.open("search_help.aspx?desc=search_res", "my_new_window", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=yes, width=" + w + ", height=" + h + ", left=" + l + ", top=" + t)
}





function StartRotator(rotator, direction) {
    if (!rotator.autoIntervalID) {
        rotator.autoIntervalID = window.setInterval(function() { rotator.showNext(direction); }, rotator.get_frameDuration());
    }
}

function StopRotator(rotator) {
    if (rotator.autoIntervalID) {
        window.clearInterval(rotator.autoIntervalID);
        rotator.autoIntervalID = null;
    }
}

function openWinRegNewsLetter(url) {
    var setWidth = 450;
    var setHeight = 550;
    var setScroll = 1;
    var setStatus = 0;
    var setMenu = 0;
    var setResiz = 0;
    var setLeft = (screen.width / 2) - (setWidth / 2);
    var setTop = (screen.height / 2) - (setHeight / 2);

    window.open(url, 'help', 'height=' + setHeight + ',width=' + setWidth + ',left=' + setLeft + ',top=' + setTop + ',scrollbars=' + setScroll + ',status= ' + setStatus + ',menubar=' + setMenu + ',resizable=' + setResiz);
}

function doClick(buttonName,e)
    {
//the purpose of this function is to allow the enter key to 
//point to the correct button to click.
        var key;

         if(window.event)
              key = window.event.keyCode;     //IE
         else
              key = e.which;     //firefox
    
        if (key == 13)
        {
            //Get the button the user wants to have clicked
            var btn = document.getElementById(buttonName);
            if (btn != null)
            { //If we find the button click it
                btn.click();
                event.keyCode = 0
            }
        }
    }


    function ClientNodeClicked(sender, eventArgs) {
        var node = eventArgs.get_node();
        node.toggle();
    }