﻿// called on the mivzakim combo select event 
// recieves the sender combo
// calls the webservice to get the selected mivzak and show it the mivzak body section
function MivzakSelected(mivzakimCombo )
{
    ajaxHelper.ShowProgress("MivzakSelected", "ctl00_mivzakBody_mivzakBodyDiv");
    var mivzakId = mivzakimCombo.value;
    
    SearchEngineService.GetMivzakBySelectedID(mivzakId, 'ctl00_mivzakBody_mivzakBodyDiv', GetMivzakByID_Complete);
}

// the "complete" event for the webmethod called in MivzakSelected
// if args.Result contains data, it is put in the args.Target innerHtml.
// otherwise, the mivzak body is hidden
function GetMivzakByID_Complete(args)
{
    if (args.Result != "")
    {
        document.getElementById(args.Target).innerHTML = args.Result;
    }
    else
    {
        document.getElementById(args.Target).className = 'hide'; 
    }
}

// Calls the webservice to load the page
//  this method is called on page load and loads both the combo and the default mivzak.
function  LoadMizakimDiv()
{
       ajaxHelper.ShowProgress("LoadMizakimDiv", "mainMivzakimDiv");
       
       var mivzakID = GetQueryStringItem("mivzakId");
       if (mivzakID == null)
            mivzakID = -1;
            
       SearchEngineService.GetMivzakimPage("mainMivzakimDiv",mivzakID,LoadMizakimDiv_Complete);
}

// the "complete" event for the webmethod called in LoadMizakimDiv
// if args.Result contains data, it is put in the args.Target innerHtml.
// otherwise, the mivzak body is hidden
function LoadMizakimDiv_Complete(args)
{
    if (args.Result != "")
    {
        document.getElementById(args.Target).innerHTML = args.Result;
        if(document.getElementById("ctl00_mainContentPlaceHolder_showContents").value == "false")
        {
            $j("#ctl00_contentsBoxTitle").parents("div:first").css("display", "none");
        }
    }
    else
    {
        document.getElementById(args.Target).className = 'hide';
    }
}


//underline a text item
function UnderlineItem(itemId)
{
    var item =document.getElementById(itemId);
    if (item != null)
    {
        item.style.textDecoration = "underline";
    }
}

//remove underline from a text item
function RemoveItemUnderline(itemId)
{
    var item =document.getElementById(itemId);
    if (item != null)
    {
        item.style.textDecoration = "none";
    }
}
