﻿// optimize IE for images
if( Browser.Engine.trident ) try {document.execCommand("BackgroundImageCache", false, true);} catch( e ) { };

var Void=function(){};if(!console){var console={log:Void}};

window.addEvent('load', MKQ.Load );
window.addEvent('domready', MKQ.Init );

var exhibitViewer = { 
    writeExhibitById: function() {
        console.log( 'warning!!! old exhibit viewer');
    }
}

Array.implement({
	// returns the element(s) where this.checked is true, returns an item if its 1, or an array if multiple
	getChecked: function() {
		var ele = null;
		
		this.each(function(item){
			if( item.checked ) {
				if( ele == null ) {
					ele = item; 
				} else {
					if( $type(ele) == "array" ) {
						ele.push( item );
					} else {
						ele = [ ele, item ];
					}
				}
			}
		});

		return ele;
	}
});

Element.implement({
	findParent: function( className ) {
		var rollbackEle = this;
		while( rollbackEle != null && rollbackEle != document && ! rollbackEle.hasClass( className ) ) {
			rollbackEle = rollbackEle.getParent();
		};
		return rollbackEle;
	},
    'VoidLink': function() {
        this.setAttribute('href', Settings.VOID_LINK);
        return this;
    },
	Hide: function() {
		this.addClass('hidden');
		return this;
	},
	Show: function() {
		this.removeClass('hidden');
		return this;
	},
	IsHidden: function() {
		return this.hasClass('hidden');
	},
	getRealSize: function(flag) {
		var theSize = this.getSize();
		if( theSize.x == 0 || theSize.y == 0 && this.IsHidden() ){
			if( flag ) {
				this.getParent().Show();
				theSize = this.getSize();
				this.getParent().Hide();
			} else {
				this.Show();
				theSize = this.getSize();
				this.Hide();
			}
		}
		return theSize;
	}
});
       
     
