var client_url          = "/";
var client_status       = "click to visit scenekunst.no!";
var powered_url         = "http://www.orgdot.com";
var powered_status      = "click to visit orgdot.com!";
var swfit_url           = "http://www.swfit.com";
var swfit_status        = "click for info on swfit!";
window.defaultStatus    = "swfit - powered by orgdot";
var sck_servlet         = "/sck/servlet/sck";

// start (default) servlet
function gotoMenu ()
{
	document.location.href=sck_servlet;
}

// DTS/SCK
function gotoDTS ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='dts';
	swfitSubmit();
}

// production overview

function gotoProdOverview ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='prodoverview';
	swfitSubmit();
}

function getProdOverview(key_)
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='prodoverview';
	document.forms['swfit_form'].p_prod_key.value=key_;
	swfitSubmit();
}

// person overview

function gotoPersonOverview ()
{
        var pidAnchor = "#pa_";
        if (document.forms['swfit_form'].p_pid)
        {
            pidAnchor += document.forms['swfit_form'].p_pid.value; 
        }
        else if (document.forms['swfit_form'].pid)
        {
            pidAnchor += document.forms['swfit_form'].pid.value; 
        }
	document.forms['swfit_form'].action=sck_servlet + pidAnchor;
	document.forms['swfit_form'].todo.value='personoverview';
	swfitSubmit();
}

function getPersonOverview(key_)
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='personoverview';
	document.forms['swfit_form'].p_key.value=key_;
	swfitSubmit();
}

function gotoPerson ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='person';
	swfitSubmit();
}

function openPerson(pid_)
{
	document.forms['swfit_form'].action=sck_servlet + '?p_pid=' + pid_;
	document.forms['swfit_form'].todo.value='person';
	swfitSubmit();
}

// producer

function gotoProducerSel ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='producersel';
	swfitSubmit();
}

function gotoProducer ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='producer';
	swfitSubmit();
}

function openProducer(aid_)
{
	document.forms['swfit_form'].action=sck_servlet + '?p_aid=' + aid_;
	document.forms['swfit_form'].todo.value='producer';
	swfitSubmit();
}

function gotoProducerAccess ()
{
    if (isValid() == false)
    {
        return;
    }
    document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='produceraccess';
    swfitSubmit();
}

// performer

function gotoPerformerSel ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='performersel';
	swfitSubmit();
}

function gotoPerformer ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='performer';
	swfitSubmit();
}

function openPerformer(aid_)
{
	document.forms['swfit_form'].action=sck_servlet + '?p_aid=' + aid_;
	document.forms['swfit_form'].todo.value='performer';
	swfitSubmit();
}

function gotoMemSel ()
{
    if (isValid() == false)
    {
        return;
    }
    document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='memsel';
    swfitSubmit();
}

function openMem(aid_, pid_)
{
	document.forms['swfit_form'].action=sck_servlet + '?p_aid=' + aid_+ '&p_pid=' + pid_;
	document.forms['swfit_form'].todo.value='mem';
	swfitSubmit();
}

function gotoPerformerAccess ()
{
    if (isValid() == false)
    {
        return;
    }
    document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='performeraccess';
    swfitSubmit();
}

// production

function gotoProdSel ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='prodsel';
	swfitSubmit();
}

function gotoProd ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='prod';
	swfitSubmit();
}

function openProd(aid_, prid_)
{
	document.forms['swfit_form'].action=sck_servlet + '?p_aid=' + aid_ + '&p_prid=' + prid_;
	document.forms['swfit_form'].todo.value='prod';
	swfitSubmit();
}

function gotoProdCont ()
{
    if (isValid() == false)
    {
        return;
    }
    else if (document.forms['swfit_form'].p_prid.value == '')
    {
        alert('Du må lagre endringene først!');
        return;
    }
    document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='prodcont';
    swfitSubmit();
}

function openProdCont(aid_, prid_)
{
	document.forms['swfit_form'].action=sck_servlet + '?p_aid=' + aid_ + '&p_prid=' + prid_;
	document.forms['swfit_form'].todo.value='prodcont';
	swfitSubmit();
}

function gotoProdEventSel ()
{
    if (isValid() == false)
    {
        return;
    }
    else if (document.forms['swfit_form'].p_prid.value == '')
    {
        alert('Du må lagre endringene først!');
        return;
    }
    document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='prodeventsel';
    swfitSubmit();
}

function openProdEvent(eid_)
{
	document.forms['swfit_form'].action=sck_servlet + '?p_eid=' + eid_;
	document.forms['swfit_form'].todo.value='prodevent';
	swfitSubmit();
}

function gotoPartSel ()
{
    if (isValid() == false)
    {
        return;
    }
    else if (document.forms['swfit_form'].p_prid.value == '')
    {
        alert('Du må lagre endringene først!');
        return;
    }
    document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='partsel';
    swfitSubmit();
}

function openPart(aid_, prid_, pid_)
{
	document.forms['swfit_form'].action=sck_servlet + '?p_aid=' + aid_+ '&p_prid=' + prid_ + '&p_pid=' + pid_;
	document.forms['swfit_form'].todo.value='part';
	swfitSubmit();
}

function gotoStage ()
{
    if (isValid() == false)
    {
        return;
    }
    else if (document.forms['swfit_form'].p_prid.value == '')
    {
        alert('Du må lagre endringene først!');
        return;
    }
    document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='stage';
    swfitSubmit();
}

function gotoPed ()
{
    if (isValid() == false)
    {
        return;
    }
    else if (document.forms['swfit_form'].p_prid.value == '')
    {
        alert('Du må lagre endringene først!');
        return;
    }
    document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='ped';
    swfitSubmit();
}

// images

function gotoImgSel ()
{
    if (isValid() == false)
    {
        return;
    }
    else if (document.forms['swfit_form'].p_prid.value == '')
    {
        alert('Du må lagre endringene først!');
        return;
    }
    document.forms['swfit_form'].action=sck_servlet;
    document.forms['swfit_form'].todo.value='imgsel';
    swfitSubmit();
}


function gotoImgs (_iscope)
{
    if (isValid() == false)
    {
        return;
    }
    document.forms['swfit_form'].action=sck_servlet + '?p_iscope=' + _iscope;
    document.forms['swfit_form'].todo.value='imgs';
    swfitSubmit();
}



function openUpload()
{
	popWin('/sck/swfit/upload_picture.htm', 270, 400, 50, 50);
}

// videos

function gotoVidSel ()
{
    if (isValid() == false)
    {
        return;
    }
    else if (document.forms['swfit_form'].p_prid.value == '')
    {
        alert('Du må lagre endringene først!');
        return;
    }
    document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='vidsel';
    swfitSubmit();
}

// reviews

function gotoReviewSel ()
{
    if (isValid() == false)
    {
        return;
    }
    else if (document.forms['swfit_form'].p_prid.value == '')
    {
        alert('Du mÃ¥ lagre endringene fÃ¸rst!');
        return;
    }
    document.forms['swfit_form'].action=sck_servlet;
        document.forms['swfit_form'].todo.value='reviewsel';
    swfitSubmit();
}

// KSYS export

function doKsysExport(aid_, prid_)
{
    if (isValid() == false)
    {
        return;
    }
    else if (document.forms['swfit_form'].p_prid.value == '')
    {
        alert('Du må lagre endringene først!');
        return;
    }
    var now = new Date();
    nuWin(sck_servlet + '?todo=ksysexp&p_aid=' + aid_ + '&p_prid=' + prid_ + '&p_ow=1' + '&p_cheat=' + now.getTime());
}

// SCK events

function gotoSckEventSel ()
{
    document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='sckeventsel';
    swfitSubmit();
}

function openSckEvent(eid_)
{
	document.forms['swfit_form'].action=sck_servlet + '?p_eid=' + eid_;
	document.forms['swfit_form'].todo.value='sckevent';
	swfitSubmit();
}

// DTS annual

function gotoAnSel ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='ansel';
	swfitSubmit();
}

function gotoAnSup ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='ansup';
	swfitSubmit();
}

function openAnSup(aid_, year_)
{
	document.forms['swfit_form'].action=sck_servlet + '?p_aid=' + aid_ + '&p_year=' + year_;
	document.forms['swfit_form'].todo.value='ansup';
	swfitSubmit();
}

function gotoAnIn ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='anin';
	swfitSubmit();
}

function gotoAnPed ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='anped';
	swfitSubmit();
}

function gotoAnMemSel ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='anmemsel';
	swfitSubmit();
}

function gotoAnMem ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='anmem';
	swfitSubmit();
}

function openAnMem(aid_, pid_, year_)
{
	document.forms['swfit_form'].action=sck_servlet + '?p_aid=' + aid_ + '&p_pid=' + pid_ + '&p_year=' + year_;
	document.forms['swfit_form'].todo.value='anmem';
	swfitSubmit();
}

function gotoAnProdSel ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='anprodsel';
	swfitSubmit();
}

// county

function gotoCountySel ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='countysel';
	swfitSubmit();
}

function gotoCounty ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='county';
	swfitSubmit();
}

function openCounty(cno_)
{
	document.forms['swfit_form'].action=sck_servlet + '?p_cno=' + cno_;
	document.forms['swfit_form'].todo.value='county';
	swfitSubmit();
}

function gotoMunicip ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='municip';
	swfitSubmit();
}

function gotoAnCouSel ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='ancousel';
	swfitSubmit();
}

function gotoAnCouProdSel ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='ancouprodsel';
	swfitSubmit();
}

function gotoAnCouProd ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='ancouprod';
	swfitSubmit();
}

function openAnCouProd(aid_, prid_, year_, cno_)
{
	document.forms['swfit_form'].action=sck_servlet + '?p_aid=' + aid_ + '&p_prid=' + prid_ + '&p_year=' + year_ + '&p_cno=' + cno_;
	document.forms['swfit_form'].todo.value='ancouprod';
	swfitSubmit();
}

function gotoAnCouStat ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='ancoustat';
	swfitSubmit();
}

// NTO
function gotoNTO ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='nto';
	swfitSubmit();
}

// institution

function gotoInstSel ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='instsel';
	swfitSubmit();
}

function gotoInst ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='inst';
	swfitSubmit();
}

function openInst(aid_)
{
	document.forms['swfit_form'].action=sck_servlet + '?p_aid=' + aid_;
	document.forms['swfit_form'].todo.value='inst';
	swfitSubmit();
}

function gotoInstLocSel ()
{
    if (isValid() == false)
    {
        return;
    }
    document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='instlocsel';
    swfitSubmit();
}

function gotoInstLoc ()
{
    if (isValid() == false)
    {
        return;
    }
    document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='instloc';
    swfitSubmit();
}

function openInstLoc(aid_, lid_)
{
	document.forms['swfit_form'].action=sck_servlet + '?p_aid=' + aid_ + '&p_lid=' + lid_;
	document.forms['swfit_form'].todo.value='instloc';
	swfitSubmit();
}

function gotoEmpSel ()
{
    if (isValid() == false)
    {
        return;
    }
    document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='empsel';
    swfitSubmit();
}

function gotoBoardSel ()
{
    if (isValid() == false)
    {
        return;
    }
    document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='boardsel';
    swfitSubmit();
}

function gotoInstAccess ()
{
    if (isValid() == false)
    {
        return;
    }
    document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='instaccess';
    swfitSubmit();
}

// nto production

function gotoInstProdSel ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='instprodsel';
	swfitSubmit();
}

function gotoInstProd ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='instprod';
	swfitSubmit();
}

function openInstProd(aid_, prid_)
{
	document.forms['swfit_form'].action=sck_servlet + '?p_aid=' + aid_ + '&p_prid=' + prid_;
	document.forms['swfit_form'].todo.value='instprod';
	swfitSubmit();
}

// author

function gotoAuthorSel ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='authorsel';
	swfitSubmit();
}

function gotoAuthor ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='author';
	swfitSubmit();
}

function openAuthor(aid_)
{
	document.forms['swfit_form'].action=sck_servlet + '?p_aid=' + aid_;
	document.forms['swfit_form'].todo.value='author';
	swfitSubmit();
}

// creation

function gotoCreationSel ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='creationsel';
	swfitSubmit();
}

function gotoCreation ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='creation';
	swfitSubmit();
}

function openCreation(cid_)
{
	document.forms['swfit_form'].action=sck_servlet + '?p_cid=' + cid_;
	document.forms['swfit_form'].todo.value='creation';
	swfitSubmit();
}

// NTO requisition

function gotoReqSel ()
{
    document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='reqsel';
    swfitSubmit();
}

function gotoReq ()
{
        document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='req';
        swfitSubmit();
}

function openReq(eid_)
{
	document.forms['swfit_form'].action=sck_servlet + '?p_eid=' + eid_;
	document.forms['swfit_form'].todo.value='req';
	swfitSubmit();
}

// NTO events

function gotoNtoEventSel (_escope)
{
        document.forms['swfit_form'].action=sck_servlet + '?p_escope=' + _escope;
        document.forms['swfit_form'].todo.value='ntoeventsel';
        swfitSubmit();
}


function openNtoEvent(eid_)
{
	document.forms['swfit_form'].action=sck_servlet + '?p_eid=' + eid_;
	document.forms['swfit_form'].todo.value='ntoevent';
	swfitSubmit();
}

// NTO annual

function gotoInstAnSel ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='instansel';
	swfitSubmit();
}

function gotoInstAn ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='instan';
	swfitSubmit();
}

function openInstAn(aid_, year_)
{
	document.forms['swfit_form'].action=sck_servlet + '?p_aid=' + aid_ + '&p_year=' + year_;
	document.forms['swfit_form'].todo.value='instan';
	swfitSubmit();
}

// user access

function gotoUserSel ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='usersel';
	swfitSubmit();
}

function openUser(did_, uid_)
{
	document.forms['swfit_form'].action=sck_servlet + '?p_did=' + did_ + '&p_uid=' + uid_;
	document.forms['swfit_form'].todo.value='user';
	swfitSubmit();
}

// password
function gotoPasswd ()
{
	document.forms['swfit_form'].action=sck_servlet;
	document.forms['swfit_form'].todo.value='passwd';
	swfitSubmit();
}

// logout
function doLogout ()
{
    var _servlet = '/sck/servlet/scklogin';
    if (document.forms['swfit_form'].logout_servlet)
    {
        if (document.forms['swfit_form'].logout_servlet.value != '')
        {
            _servlet = '/sck/servlet/' + document.forms['swfit_form'].logout_servlet.value;
        }
    }

    document.forms['swfit_form'].action= _servlet;
    document.forms['swfit_form'].mission.value = 'do_logout';
    swfitSubmit();
}

// statistics

function getAnStatResult(aid_, year_)
{
    getAnnualArtistStatResult(aid_, year_);
}

function getAnnualArtistStatResult(aid_, year_)
{
    var now = new Date();
    nuWin(sck_servlet + '?todo=dtsreport&p_aid=' + aid_ + '&p_year=' + year_+ '&p_cheat=' + now.getTime());
}

function getAnnualStatResult(repno_, year_)
{
    var now = new Date();
    nuWin('/sck/servlet/dtsstatres?p_repno=' + repno_ + '&p_year=' + year_ + '&p_cheat=' + now.getTime());
}

function getStatResult(repno_, cno_, aid_, year_, shw_)
{
    var now = new Date();
    nuWin('/sck/servlet/sckstat?p_repno=' + repno_ + '&p_cno=' + cno_ + '&p_aid=' + aid_ + '&p_year=' + year_ + '&p_shw=' + shw_ + '&p_cheat=' + now.getTime());
}


// helpers

function goBack ()
{
	self.history.back();
}

function openInfoUrl (url_)
{
	if (url_ != '') document.location.href = url_;
	return false;
}

function nuWin (url_)
{

	specs = "menubar=no,resizable=yes,scrollbars=yes,toolbar=yes,status=yes,titlebar=no,directories=no";
	popper = window.open(url_, "pop1", specs);
	if (window.focus) popper.focus();
}

function nuWin2 (url_)
{

	specs = "menubar=no,resizable=yes,scrollbars=yes,toolbar=yes,status=yes,titlebar=no,directories=no,location=yes";
	popper = window.open(url_, "pop2", specs);
	if (window.focus) popper.focus();
}

function popWin(win_url, win_width, win_height, win_x, win_y)
{
     var specs = "width=" + win_width + ",height=" + win_height + ",";
     specs = specs + "status=no,resizable=no,scrollbars=no,";
     specs = specs + "titlebar=no,directories=no,toolbar=no,";
     specs = specs + "screenX=" + win_x + ",screenY=" + win_y + ",";
     specs = specs + "left=" + win_x + ",top=" + win_y;
     popper = window.open(win_url, "pop", specs);
     if (window.focus) popper.focus();
}

function swfitSubmit ()
{
    if (self.document)
    { 
        if (self.document.swfit_form)
        {
            document.swfit_form.submit();
        }    
        else if (self.document.forms['swfit_form'])
        {
            document.forms['swfit_form'].submit();
        }
    }
}

function isValid()
{
    if (document.forms['swfit_form'].p_is_valid.value == 'false' 
        || document.forms['swfit_form'].p_is_ready.value == 'false')
    {
        if (hasError())
        {
            alert(document.forms['swfit_form'].p_error_msg.value);
        }
        return false;
    }
    return true;
}

function hasError()
{
    if (document.forms['swfit_form'].p_error_msg.value != '')
    {
        return true;
    }
    return false;
}

