/*
Declaration 
===========
Button: 
<a href="#" class="roundedbutton">Text</a>
Button with icon: 
<a href="#" class="roundedbutton" rel="add">Text</a>
Disabled button with icon:
<a href="#" class="roundedbutton disabled" rel="application_form_delete">Text</a>
*/

var Buttons = {

	Create: function(strTree) {
		// If there is no tree specified, we will check the whole DOM
		if (typeof(strTree) == 'undefined') {
			strTree	= '';
		}
		$(strTree+' .roundedbutton').each (function() {
			icon		= $(this).attr('rel');
			textContent	= $(this).html();
			disabled	= this.className.search("disabled");
			
			setIcon = '';
			if (icon) {
				setIcon = '<img class="'+icon+'_png" src="../../img/iconset_silk/'+icon+'.png" alt="'+icon+'.png" />';
			}
			if(disabled != -1) {
				attrDisable	= document.createAttribute("disabled");
				attrDisable.value	= 'disabled';
				this.attributes.setNamedItem(attrDisable);
			}
			this.innerHTML = '<span title="'+textContent+'">'+setIcon+textContent+'</span>';
			
			if (icon && $.browser.msie && $.browser.version<7 ) {
				this.firstChild.firstChild.src="../../img/bg/trans_1px.gif";
				this.firstChild.firstChild.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../img/iconset_silk/"+icon+".png', sizingMethod='crop')";
			}
		});
		
		$(strTree+' .iconize').each (function() {
			iconize		= $(this).attr('rel');
			textContent	= $(this).html();
			
			setIcon = '';
			if (iconize) {
				setIcon = '<img class="'+iconize+'_png" src="../../img/iconset_silk/'+iconize+'.png" alt="'+iconize+'.png" />';
			}
			this.innerHTML = '<span title="'+textContent+'">'+setIcon+textContent+'</span>';
			
			if (iconize && $.browser.msie && $.browser.version<7 ) {
				this.firstChild.firstChild.src="../../img/bg/trans_1px.gif";
				this.firstChild.firstChild.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../img/iconset_silk/"+iconize+".png', sizingMethod='crop')";
			}
	
		});
	}
	
}

$(function() {
	$('.roundedbutton').each (function() {
		icon		= $(this).attr('rel');
		textContent	= $(this).html();
		disabled	= this.className.search("disabled");
		
		setIcon = '';
		if (icon) {
			setIcon = '<img class="'+icon+'_png" src="../../img/iconset_silk/'+icon+'.png" alt="'+icon+'.png" />';
		}
		if(disabled != -1) {
			attrDisable	= document.createAttribute("disabled");
			attrDisable.value	= 'disabled';
			this.attributes.setNamedItem(attrDisable);
		}
		this.innerHTML = '<span title="'+textContent+'">'+setIcon+textContent+'</span>';
		
		if (icon && $.browser.msie && $.browser.version<7 ) {
			this.firstChild.firstChild.src="../../img/bg/trans_1px.gif";
			this.firstChild.firstChild.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../img/iconset_silk/"+icon+".png', sizingMethod='crop')";
			//this.firstChild.firstChild.style.filter="";
			//alert(this.firstChild.firstChild.style.filter);
		}

	})
});

/*
Declaration 
===========
Icon link: 
<a href="#" class="iconize" rel="add">Text</a>
*/

$(function() {
	$('.iconize').each (function() {
		iconize		= $(this).attr('rel');
		textContent	= $(this).html();
		
		setIcon = '';
		if (iconize) {
			setIcon = '<img class="'+iconize+'_png" src="../../img/iconset_silk/'+iconize+'.png" alt="'+iconize+'.png" />';
		}
		this.innerHTML = '<span title="'+textContent+'">'+setIcon+textContent+'</span>';
		
		if (iconize && $.browser.msie && $.browser.version<7 ) {
			this.firstChild.firstChild.src="../../img/bg/trans_1px.gif";
			this.firstChild.firstChild.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../img/iconset_silk/"+iconize+".png', sizingMethod='crop')";
		}

	})
});

