﻿function FbtDeleteConfirmation(sMessage) {
	if (CheckBoxIDs != null)
    {
		var bConfirm = false;
		for (var i = 0; i < CheckBoxIDs.length; i++) 
		{
			var cb = document.getElementById(CheckBoxIDs[i]);
            if (cb != null)
            {
				if (cb.checked) 
				{
					bConfirm = true;
					break;
				}
            }
		}
		
		if (bConfirm) 
		{
			return confirm(sMessage);
		}
		else 
			return true;
	}
	else {
		return true;
	}
}

function ChangeCheckBoxState(id, checkState)
{
    var cb = document.getElementById(id);
    if (cb != null)
        cb.checked = checkState;
}
    
function ChangeAllCheckBoxStates(checkState)
{
    if (CheckBoxIDs != null)
    {
        for (var i = 0; i < CheckBoxIDs.length; i++)
           ChangeCheckBoxState(CheckBoxIDs[i], checkState);
    }
}

function ChangeHeaderAsNeeded()
{
    if (CheckBoxIDs != null)
    {
        for (var i = 1; i < CheckBoxIDs.length; i++)
        {
            var cb = document.getElementById(CheckBoxIDs[i]);
            if (cb != null)
            {
                if  (!cb.checked)
                {
                    ChangeCheckBoxState(CheckBoxIDs[0], false);
                    return;
                }
            }
        }
        ChangeCheckBoxState(CheckBoxIDs[0], true);
    }
}

function ChangeChecked(thisis) 
{
    for (var i = 0; i < CheckBoxIDs.length; i++)
        ChangeCheckBoxState(CheckBoxIDs[i], false);
       
    thisis.checked = true;        
}

function SelectOneRadioButton(rdo,gridName)
{   
    all=document.getElementsByTagName("input");
    for(i=0;i<all.length;i++)
    {
        if(all[i].type=="radio")
        {
            var count=all[i].id.indexOf(gridName+'__ctl'); 
            if(count!=-1)
            {
                all[i].checked=false;
            }
        }
    }
    
    rdo.checked=true;/* Finally making the clicked radio button CHECKED */
}





function Scripts_GetObject(obj) 
{
    var theObj;
    if(document.all) 
    {
        if(typeof obj=="string") 
        {
            return document.all(obj);
        } 
        else 
        {
            return obj.style;
        }
  }
  
  if(document.getElementById) 
  {
        if(typeof obj=="string") 
        {
            return document.getElementById(obj);
        } 
        else 
        {
            return obj.style;
        }
  }
  return null;
}



$(document).ready(
function()
{
    $("img#arrCloseIt").click(
        function () 
        {
            $("div#leftmenu").toggle('slow');
            $("img#arrOpenIt").toggle('slow');
        }
    );
    
    $("img#arrOpenIt").click(
        function () 
        {
            $("div#leftmenu").toggle('slow');
            $("img#arrOpenIt").toggle('slow');
        }
    );
 
    var selectedItem;
 
    function toggleMenu(id)
    {
        if(selectedItem==id)
        {
            $("#m_"+selectedItem).attr("class","menuitem");
            $("#arr_o_"+selectedItem).attr("class","hidden");
            $("#arr_"+selectedItem).attr("class","block");
            $("#s_"+selectedItem).slideUp("slow");
            selectedItem=0;
            return;
        }
        if(selectedItem!=0)
        {
            $("#m_"+selectedItem).attr("class","menuitem");
            $("#arr_o_"+selectedItem).attr("class","hidden");
            $("#arr_"+selectedItem).attr("class","block");
            $("#s_"+selectedItem).slideUp("slow");
        }
		$("#m_"+id).attr("class","menuitem openmenuitem");
		$("#arr_o_"+id).attr("class","block");
        $("#arr_"+id).attr("class","hidden");
        $("#s_"+id).slideToggle("slow");
        
        selectedItem=id;
		
    }
    
    $("#m_1").click(
        function () 
        {
            toggleMenu(1);
        }
    );
    
    $("#m_2").click(
        function () 
        { 
            toggleMenu(2);
        }
    );
    
    $("#m_3").click(
        function () 
        { 
            toggleMenu(3);
        }
    );
    
    $("#m_4").click(
        function () 
        { 
            toggleMenu(4);
        }
    );
    $("#m_5").click(
        function () 
        { 
            toggleMenu(5);
        }
    );
    $("#m_6").click(
        function () 
        { 
            toggleMenu(6);
        }
    );
    
    var url = document.URL;
    $('.submenuholder > ul > li > a').each(
        function () 
        {
            if (url.indexOf($(this).attr("href")) != -1)
            {
                $(this).attr("class","selected");
                var parent = $(this).parents().get(2);
                var mItem = $(parent).prev();
                toggleMenu(parent.id.charAt(2));
            }
        }
    );
}
);
