/*
Script: kap_dhtmlFunctions.js
    KickApps DHTML Functions (dynamic HTML)

General Information:
    Company - <http://www.kickapps.com>
    Created - Wednesday, April 04, 2007 | 5:24 PM

Author:
    Oliver Nassar - onassar@kickapps.com

Editing:
    onassar - Wednesday, April 04, 2007 | 5:24 PM
    onassar - Wednesday, April 05, 2007 | 8:57 AM
    onassar - Wednesday, May 30, 2007 	| 5:36 PM
    onassar - Friday, June 08, 2007 	| 11:42 AM
    onassar - Sunday, June 10, 2007 	| 8:54 PM

Notes:
    - Responsible for most non-mootools dynamic action
    - kap_mootools.js *independent*
*/

/*
Function: kap_showHideToggle
    Toggles DOM elements based on their current status

Arguments:
    toggleOptions - an object containing all the properties of the toggling action (see toggleOptions Object Properties below)

toggleOptions Object Properties:
    hideId - the id of what ought to be hidden
    hideClass - the class of what ought to be hidden
    showId - the id of what ought to be shown
    showClass - the class of what ought to be shown
    hideStartFunction - the function that should execute before anything is hidden
    hideEndFunction - the function that should execute after anything has hidden
    showStartFunction - the function that should execute before anything is shown
    showEndFunction - the function that should execute after anything has been shown

Notes:
    - This function is used (or at least will be :P) throughout the platform. Be *careful* when making changes to it.
    - kap_cssFunctions.js *dependent*
*/

    // function to handle show and hide of elements
    function kap_showHideToggle(toggleOptions)
    {
        // if an id should be toggled
        if(toggleOptions.toggleIds)
		{
			// loop through the elements
			for(var x=0;x<toggleOptions.toggleIds.length;x++)
			{
				// if it ought to be shown
				if(kap_getCSSValue(toggleOptions.toggleIds[x],'display')=='none')
				{
					// show it
		            document.getElementById(toggleOptions.toggleIds[x]).style.display	=	'block';
		            // mark what the display value is
		            var displayValue													=	'block';
				}
				// otherwise if it ought to be hidden
				else if(kap_getCSSValue(toggleOptions.toggleIds[x],'display')=='block')
				{
					// hide it
		            document.getElementById(toggleOptions.toggleIds[x]).style.display	=	'none';
		            // mark what the display value is
		            var displayValue													=	'none';
				}
		        // if there are callbacks
		        if(toggleOptions.callbacks)
		        {
		        	// loop through them
		        	for(var q=0;q<toggleOptions.callbacks.length;q++)
		        	{
			            // if there is a callback matching the id and display value
			            if(toggleOptions.callbacks[q].id==toggleOptions.toggleIds[x] && toggleOptions.callbacks[q].displayValue==displayValue)
			            {
			            	// run the callback (which sent in as a function should be created as a new object)
			            	eval(new toggleOptions.callbacks[q].callback);
			            }
		        	}
		        }
			}
        }
    }

	// 
	function kap_bubbleShow(toggleId)
	{
		// if the affiliate control is not defined
		if(typeof KA_AFFCONTROL_KP_USE_BUBBLES=='undefined')
		{
			// use kap function to toggle it
			kap_showHideToggle ( { toggleIds: new Array ( toggleId ) } );
		}
	}

	// 
	function kap_bubbleHide(toggleId)
	{
		// if the affiliate control is not defined
		if(typeof KA_AFFCONTROL_KP_USE_BUBBLES=='undefined')
		{
			// use kap function to toggle it
			kap_showHideToggle ( { toggleIds: new Array ( toggleId ) } );
		}
	}