function $E(user_pars)
{
	//Define Defaults
	pars = {type : 'div', attr : {}, inner : null, style : {},  styleE : {}, parent : $(document.body), insert : 'bottom'}
	//Extend parameters
	Object.extend(pars, user_pars);
	//create DOM element
	var E = new Element(pars.type, pars.attr);
	//update content
	if(pars.inner != null){E.update(pars.inner)}
	//extend and styles
	var style = Object.clone(pars.style);
	Object.extend(style, pars.styleE);	
	E.setStyle(style);
	//specify insert type and insert
	var I = new Object;
	I[pars.insert] = E;
	pars.parent.insert(I);
	//return element
	return E;
}

var DOMObject=Class.create({initialize:function(parent,default_props,instance_props,overwrite_props,addition_props){this.parent=parent||$(document.body);this.default_props=default_props||{};this.structure=new Hash();this.build();this.set(instance_props||{},overwrite_props||false,addition_props||{})},set:function(props,overwrite,additions){if((this.props==null)||(overwrite)){this.props=Object.clone(this.default_props);this.props=Object.extend(this.props,additions||{})}else{this.props=this.props.toObject()}this.props=Object.extend(this.props,props||{});this.props=$H(this.props);this.flush()},S:function(key,value){if(value==null){return this.structure.get(key)}else{this.structure.set(key,value)}},P:function(key,value){if(value==null){return this.props.get(key)}else{this.props.set(key,value)}},hide:function(){this.structure.get('root').hide()},show:function(){this.structure.get('root').show()},getRoot:function(){return this.structure.get('root')},flush:function(){},build:function(){var root=new Element('div');this.parent.insert({bottom:root});this.structure.set('root',root)},destroy:function(complete){this.S('root').remove();if(complete){delete this}}});
Element.prototype.round = function(props)
{
	if(Prototype.Browser.IE){return}
	
	if(Object.isNumber(props.r))
	{
		this.style.setProperty("-moz-border-radius", props.r + "px", "");
		this.style.setProperty("-webkit-border-radius", props.r + "px", "");
	}
	else
	{
		var p = {tr : 0, tl : 0, br : 0, bl : 0}
		Object.extend(p, props);	
		
		this.style.setProperty("-moz-border-radius-topright", p.tr + "px", "");
		this.style.setProperty("-moz-border-radius-topleft", p.tl + "px", "");
		this.style.setProperty("-moz-border-radius-bottomright", p.br + "px", "");
		this.style.setProperty("-moz-border-radius-bottomleft", p.bl + "px", "");		
		
		this.style.setProperty("-webkit-border-top-right-radius", p.tr + "px", "");
		this.style.setProperty("-webkit-border-top-left-radius", p.tl + "px", "");
		this.style.setProperty("-webkit-border-bottom-right-radius", p.br + "px", "");
		this.style.setProperty("-webkit-border-bottom-left-radius", p.bl + "px", "");
	}
}

Element.prototype.shadow = function(props)
{
	if(Prototype.Browser.IE){return}
	
	var p = {x : 0, y : 0, s : '3px', c : 'rgba(0,0,0,.5)'}
	Object.extend(p, props);
	
	this.style.setProperty("-moz-box-shadow", p.x + 'px ' + p.y + 'px ' + p.s + ' ' + p.c, "");
	this.style.setProperty("-webkit-box-shadow", p.x + 'px ' + p.y + 'px ' + p.s + ' ' + p.c, "");	
}

var post = Class.create(DOMObject,
{
	initialize:function($super, parent, instance_props)
	{
		default_props = 
		{
			//display props
			sunImgSrc : 'img/core/sun.png',
			earthImgSrc : 'img/core/earth.jpg',
			info : true,
			//data props
			title : 'Title Here',
			author : 'author',
			date : '00-00-0000',
			styles : [],
			post : '',
			homeURL : 'http://www.gotproject.com',
			blogURL : 'http://www.gotproject.com/blog/',
			twitterURL : 'http://twitter.com/gotproject',			
			//callback props
			//inner props
			homeHref : 'http://www.gotproject.com',
			twitterHref : 'http://www.twitter.com/gotproject',
			blogHref : 'http://www.gotproject.com/blog/'
		}
		this.load = true;
		$super(parent, default_props, instance_props);
	},
	
	build:function($super)
	{
		button_style = {float : 'left', fontSize : '10px', marginLeft : '10px', lineHeight: '30px', textDecoration : 'none', color : '#333333'};
		
		$super();
		var root = this.S('root');
			root.setStyle({position : 'relative', zIndex : '2'})
			var header = $E({parent : root, style : {position : 'fixed', top : '0px', left : '0px', height : '30px', width : '100%', zIndex : '3'}});
				header.setStyle({backgroundColor : '#F2F2F2', backgroundImage : 'url(http://www.gotproject.com/img/tool/noise.png)', borderBottom : '1px solid #AAAAAA'});
			var homeURL = $E({parent : header, inner : 'gotproject', type : 'a', style : button_style});
			var blogURL = $E({parent : header, inner : 'blog', type : 'a', style : button_style});
			var twitterURL = $E({parent : header, inner : 'twitter', type : 'a', style : button_style});
						
		this.S('header', header);
		this.S('homeURL', homeURL);
		this.S('blogURL', blogURL);
		this.S('twitterURL', twitterURL);
		
		var content = $E({parent : root, style : {position : 'relative', width : '800px', margin : '0px auto', paddingTop : '90px'}});
			var title = $E({parent : content, style : {textAlign : 'right', color : '#AAAAAA', fontSize : '25px'}});
			var subTitle = $E({parent : content, style : {textAlign : 'right', color : '#AAAAAA', fontSize : '10px', marginTop : '5px'}});
			var post = $E({parent : content, style : {background : '#F2F2F2', border : '1px solid #FFFFFF', marginTop : '16px', padding: '30px', minHeight : '100px'}});
				if(!Prototype.Browser.IE)
				{
					post.round({r : 5});
					post.shadow({c : '#AAAAAA', s : '10px'})
				}
			
		this.S('title', title);
		this.S('subTitle', subTitle);
		this.S('post', post);
		
		
		var sun = $E({type : 'img', style : {position : 'fixed', top : '50px', left : '30px'}});	
		var earth = $E({type : 'img', style : {position : 'fixed', bottom : '20px', right : '20px', width : '200px'}});
		
		this.S('earth', earth);
		this.S('sun', sun);	
	},

	flush:function()
	{
		this.S('title').update(this.P('title'));
		this.S('subTitle').update('by ' + this.P('author') + ', ' + this.P('date'));
		this.S('post').update($(this.P('post')).innerHTML)
		
		if(this.P('info') == false)
		{
			this.S('title').setOpacity(0);
			this.S('subTitle').setOpacity(0);
		}
		
		if(this.load)
		{
			this.load = false;
			this.insertStyles();
			this.insertRetweet();
			$(this.P('post')).remove();
		}		
		
		this.S('homeURL').href = this.P('homeHref');
		this.S('blogURL').href = this.P('blogHref');
		this.S('twitterURL').href = this.P('twitterHref');
		
		this.S('earth').src = this.P('earthImgSrc');
		this.S('sun').src = this.P('sunImgSrc');
	},
	
	insertRetweet:function()
	{
		$('retweet').setStyle({position : '', opacity : '', float : 'right', padding : '7px'})
		$('retweet').getElementsByTagName('iframe')[0].setAttribute('width', '74');
		this.S('header').insert($('retweet'));
		
		$('retweet').getElementsByTagName('iframe')[0].setAttribute("allowTransparency", "true");
		$('retweet').getElementsByTagName('iframe')[0].style.background = 'transparent';
	},
	
	insertStyles:function()
	{
		var styles = this.P('styles');
		var l = styles.length;
		var head = document.getElementsByTagName('head')[0];
		
		for(var i = 0; i<l; i ++)
		{
			var style = document.createElement('link');
				style.setAttribute('rel', 'stylesheet');
				style.setAttribute('type', 'text/css');
				style.setAttribute('href', styles[i]);
			head.appendChild(style);
		}
	}

});
