﻿/*********************
Egenskaper för PopUps.
*********************/
function imagePopUp(strUrl) {
    window.open('archive_preview.aspx?Url='+ strUrl, 'PopUp', 'width=900, height=800, top=150, left=150, toolbar=no, resizable=yes, scrollbars=yes');
}

function regularPopUp(strUrl) {
    window.open(strUrl, 'PopUp', ' top=600, left=600, toolbar=no, resizable=yes, scrollbars=yes');
}

function regularPopUp(strUrl, strName) {
    window.open(strUrl, strName, ' top=150, left=150, toolbar=no, resizable=yes, scrollbars=yes');
}

function regularPopUp(strUrl, strWidth, strHeight) {
    window.open(strUrl, "PopUp", 'width=' + strWidth + ', height=' + strHeight + ', top=150, left=150, toolbar=no, resizable=yes, scrollbars=yes');
}

function openEditor(strUrl, strName) {
    window.open(strUrl, strName, 'width=700, height=800, top=150, left=150, toolbar=no, resizable=yes, scrollbars=yes');
}

function OpenArchive() {
    window.open('/emitools/filearchive/archive_seperate.aspx?from=seperate', 'Archive', 'width=800, height=800, top=150, left=150, toolbar=no, resizable=yes, scrollbars=yes');
}

function openHelp(strHelpPage)
{
    window.open('http://www.stockholmdof.se/how_to_emi/default.aspx?page='+ strHelpPage, 'PopUp', 'width=900, height=800, top=150, left=150, toolbar=no, resizable=yes, scrollbars=yes');
}

function openCalendar(strId, booMultipeInput, strDate)
{
    window.open('/emitools/editor/calendar.aspx?id=' + strId + '&multi=' + booMultipeInput + '&date=' + strDate, 'Calendar', 'width=500, height=450, top=150, left=150, toolbar=no, resizable=yes, scrollbars=yes');  
}

/**********************************
Olika funktioner för input element.
**********************************/
function enableDisable(strId)
{
    booDisabled = document.getElementById(strId).disabled
    if (booDisabled) document.getElementById(strId).disabled = false;
    else document.getElementById(strId).disabled = true;
}

var strValue = null;
function removeValue(strId)
{
    if (strValue == null)
        strValue = document.getElementById(strId).value;
    if (document.getElementById(strId).value == strValue)
        document.getElementById(strId).value = "";
}

function restoreValue(strId)
{
    if (document.getElementById(strId).value == "")
        document.getElementById(strId).value = strValue;
}


/*********************
Lite olika funktioner.
*********************/
function fillCheckBox(value) 
{
    CheckBox = document.getElementById(value);
    if (CheckBox.checked) { CheckBox.checked = false; }
    else { CheckBox.checked = true; }
}

function WindowClick(strID)
{
    document.getElementById(strID).click();
}

function selectAndCopyIt(strID)
{
    var tempval = eval(document.getElementById(strID));
    tempval.focus();
    tempval.select();
    therange = tempval.createTextRange();
    therange.execCommand("Copy");
}

function pasteIt(strID)
{
    var tempval = eval(document.getElementById(strID));
    tempval.focus();
    tempval.select();
    therange = tempval.createTextRange();
    therange.execCommand("Paste");
}



/*******************************************
Funktioner för att markera många checkboxes.
*******************************************/
function ChangeAllCheckBoxStates(checkState)
{
    if (CheckBoxIDs != null)
    {
        for (var i = 0; i < CheckBoxIDs.length; i++)
        {
            ChangeCheckBoxState(CheckBoxIDs[i], checkState);
        }
    }
}
function ChangeCheckBoxState(id, checkState)
{
    var cb = document.getElementById(id);
    if (cb != null)
    {
        cb.checked = checkState;
    }
}


/*
Ajax Funktion
*/

function ajaxFunction()
{  
    var myXmlHttpRequest;
    
    // Firefox, Opera 8.0+, Safari
    try { myXmlHttpRequest = new XMLHttpRequest(); }
    catch (e)
    {
        // Internet Explorer
        try { myXmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
        catch (e)
        {
            try { myXmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");}
            catch (e)
            {
                alert("Your browser does not support AJAX!");
                return false;
            }
        }
    }
    
    myXmlHttpRequest.onreadystatechange = function()
    {
        if (xmlHttp.readyState == 4)
        {
            document.myForm.time.value = myXmlHttpRequest.responseText;
        }
    }
    
    myXmlHttpRequest.open("GET", "time.asp", true);
    myXmlHttpRequest.send(null);
}
