function cda_getCategoryID() {
    var e = document.getElementById( "adsk91-el-id-cat" );
    if( e == null ) {
        return null;
    }
    return e.value;
}

function cda_getContentID() {
    var e = document.getElementById( "adsk91-el-id-cont" );
    if( e == null ) {
        return null;
    }
    return e.value;
}

function cda_getLinkCategoryID() {
    var e = document.getElementById( "adsk91-el-id-lc" );
    if( e == null ) {
        return null;
    }
    return e.value;
}

function cda_getSiteID() {
    var e = document.getElementById( "adsk91-el-id-site" );
    if( e == null ) {
        return null;
    }
    return e.value;
}

function cda_isPreview() {
    var e = document.getElementById( "adsk91-el-is-preview" );
    if( e == null ) {
        return false;
    }
    return e.value == "1";
}

/**
 * Animate an element. For jQuery, the use of params and options are specified here: http://docs.jquery.com/Effects
 * @param element dom element that needs to be animated
 * @param action toggle and slideToggle
 * @param speed the value could be slow, normal, fast, or number in milliseconds
 */

function cda_animateElement( element, action, speed, callback ) {
    var j = jQuery(element);
    switch( action ) {
        case "toggle": 	j.toggle(speed, callback);
            		break;
        case "slideToggle": j.slideToggle(speed, callback);
                	break;
        case "slideUp": j.slideUp(speed, callback);
                	break;
        case "slideDown": j.slideDown(speed, callback);
                	break;
    	default:	break;
    }
}

/**
 * Animate an accordion.
 * @param toShowHeader the header whose section is to be opened
 * @param toHideHeader the header whose section is to be closed
 * @param options optional. Define accordion speed, autoHeight and on complete function. By default speed 300 miliseconds, autoHeight true, and on complete function empty
 */

function cda_animateAccordion(toShowHeader, toHideHeader, options) {
	var toShow = jQuery(toShowHeader).next(),
	    toHide = jQuery(toHideHeader).next();

	options = jQuery.extend({duration: 300, autoHeight: true, complete: function() {} }, options);
	if ( !toHideHeader ) {
        	toShow.animate({height: "show"}, options.duration, options.complete);
		return;
	}
	// fix width before calculating height of hidden element. otherwise there could be a discrepency b/w manual height and autoheight.
	var s = toShow;
	originalWidth = s[0].style.width;
	s.width( parseInt(s.parent().width(),10) - parseInt(s.css("paddingLeft"),10) - parseInt(s.css("paddingRight"),10) - (parseInt(s.css("borderLeftWidth"),10) || 0) - (parseInt(s.css("borderRightWidth"),10) || 0) );

    // IE fix for 0px height. Manually set height to 11px which is what Firefox set for empty accordion
    var hideHeight = ( toHide.height() == 0 ) ? "11" : toHide.height(),
	showHeight = toShow.height(),
	difference = showHeight / hideHeight,
	padding = toShow.outerHeight() - toShow.height(),
	margin = toShow.css('marginBottom'),
	overflow = toShow.css('overflow'),
	tmargin = toShow.css('marginTop');
	toShow.css({ height: 0, overflow: 'hidden', marginTop: 0, marginBottom: -padding }).show();
	toHide.animate({height:"hide"},{
		step: function(now) {
			var current = (hideHeight - now) * difference;
			if (jQuery.browser.msie || jQuery.browser.opera) {
				current = Math.ceil(current);
			}
			toShow.height( current );
		},
		duration: options.duration,
		complete: function() {
			toShow.css({marginTop: tmargin, marginBottom: margin, overflow: overflow});
			if ( !options.autoHeight ) {
				toShow.css("height", "auto");
			}
			options.complete;
		}
	});

}
