function mouseOver(obj, hightlight) {
    obj.style.cursor = 'hand';
    if (hightlight) {
        /*obj.style.backgroundColor='#e6f2fa';*/
        obj.style.borderColor='#c3c3c3';
    }
}

function mouseOut(obj, hightlight) {
    obj.style.cursor = 'auto';
    if (hightlight) { 
        /*obj.style.backgroundColor='#ffffff';*/
        obj.style.borderColor='#ffffff';
    }
}

function zoomImage(url, title, width, height) {
    var dialogUrl = '/storbild.aspx?imageTitle=' + title + '&imageUrl=' + url;
    //alert('dialogUrl:\n' + dialogUrl);
    openWindow(dialogUrl, 'Bild', width + 'px', height + 'px');
}

function linkClick(url) {
    location.href=url;
}

function textBoxClick(obj,defaultText) {
    var val = obj.value;
    if (val == defaultText) {
        obj.value = '';
    }
}

function textBoxChange(obj,defaultText) {
    var val = obj.value;
    if (val == '') {
        obj.value = defaultText;
    }
}

function checkBoxClick(checkBoxID, siblings) {
    var hidObj = document.getElementById('hid-' + checkBoxID);
    var imgObj = document.getElementById('img-' + checkBoxID);
    
    hidObj.value = '1';
    imgObj.src = '/resurser/bilder/form/chetrue.png';
    
    if (siblings.length > 0) {
        siblings += ',';
        
        var sibList = siblings.split(',');
        for (i=0;i<sibList.length;i++) {

            var sibID = sibList[i];

            if (sibID.length > 0) {
                var hidObjSib = document.getElementById('hid-' + sibID);
                var imgObjSib = document.getElementById('img-' + sibID);
                
                hidObjSib.value = '0';
                imgObjSib.src = '/resurser/bilder/form/chefalse.png';
            }
        }
    }
}

function openWindow(dialogUrl, dialogName, dialogWidth, dialogHeight) {
    //window.open(dialogUrl,dialogName,'height=' + dialogHeight +',width=' + dialogWidth);
    //alert('dialogUrl:\n' + dialogUrl + '\ndialogName:\n' + dialogName + '\ndialogWidth:\n' + dialogWidth + '\ndialogHeight:\n' + dialogHeight);
    window.open(dialogUrl, dialogName, 'height=' + dialogHeight +',width=' + dialogWidth + ',scrollbars=1,resizable=0,location=0,toolbar=0,status=0');
}

function downloadFileTimer(filUrl, source) {
    setTimeout("downloadFile('" + filUrl + "','" + source + "')",3000);
}

function downloadFile(filUrl, source) {
    window.open(filUrl);
    if (source.length > 0) {
        setTimeout("downloadFileNavigate('" + source + "')", 3000);
    }
}

function downloadFileNavigate(source) {
    if (source.length > 0) {
        location.href=source;
    }
}

function newsletterAction(emailObj, nameObj, actionStartObj, actionEndObj) {

    if (nameObj.value.length == 0 || nameObj.value == '[Namn]') {
        alert('Du måste fylla i ditt namn.');
        return false;
    }

    if (emailObj.value.length == 0 || emailObj.value == '[E-post adress]') {
        alert('Du måste fylla i din e-postadress.');
        return false;
    }
        
    var emailValue = emailObj.value;
    var nameValue = nameObj.value;
    var actionValue = (actionEndObj.value=='1') ? 'unsubscribe' : 'subscribe';
    
    var url = '/omwlan/nyhetsbrev.aspx?email=' + emailValue + '&action=' + actionValue + '&name=' + nameValue;
    //alert('Url:' + url);
    location.href=url;
}
