﻿var Void=function(){}; //var console = ( console ) ? console : { log: Void };

Element.implement({
	/*
	 *
	 */
	findParent: function( className ) {
		var rollbackEle = this;
		while( rollbackEle != null && rollbackEle != document && ! rollbackEle.hasClass( className ) ) {
			rollbackEle = rollbackEle.getParent();
		};
		return rollbackEle;
	},
	selectIndexFromValue: function( val ) {
		if( this.selectedIndex != null ) {
			for( var i = 0; i < this.options.length; i++ ) {
				if( $(this).options[i].value == val || $(this).options[i].innerHTML == val ) {
					this.selectedIndex = i;
					return i;
				}
			}
		}
	},
	getElementsByTagAndAttribute: function( tagName, attributeName, attributeValue ) {
		if( window.webkit ) {
			var skipArgumentValue = false;
			if( arguments.length == 2 ) {
				skipArgumentValue = true;
			}
			var allTags = this.getElements(tagName);
			var returnEle = [];
			allTags.each( function( ele ) {
				if( ele.getAttribute( attributeName ) ) {
					if( ( ele.getAttribute( attributeName ) == attributeValue ) || skipArgumentValue ) {
						returnEle.include( ele );
					}
				}
			});
			return returnEle ;
		} else {
			if( attributeValue ) {
				return this.getElements( tagName + '[' + attributeName + '="' + attributeValue + '"]');
			} else {
				return this.getElements( tagName + '[' + attributeName + ']');
			}
		}
	},
	IsHidden: function() {
		return this.hasClass('hidden');
	},
	Hide: function() {
		this.addClass('hidden');
		this.setStyle('display', 'none');
	},
	Show: function() {
		this.removeClass('hidden');
		this.setStyle('display', 'block');
	}
});