(function($){
	var EYE = window.EYE = function() {
		var _registered = {
			init: []
		};
		return {
			init: function() {
				$.each(_registered.init, function(nr, fn){
					fn.call();
				});
			},
			extend: function(prop) {
				for (var i in prop) {
					if (prop[i] != undefined) {
						this[i] = prop[i];
					}
				}
			},
			register: function(fn, type) {
				if (!_registered[type]) {
					_registered[type] = [];
				}
				_registered[type].push(fn);
			}
		};
	}();
	$(EYE.init);
})(jQuery);

(function($){
	var initLayout = function() {
		var hash = window.location.hash.replace('#', '');
		var currentTab = $('ul.navigationTabs a')
							.bind('click', showTab)
							.filter('a[rel=' + hash + ']');
		if (currentTab.size() == 0) {
			currentTab = $('ul.navigationTabs a:first');
		}
		showTab.apply(currentTab.get(0));
		$('#colorpickerHolder').ColorPicker({flat: true});
		$('#colorpickerHolder2').ColorPicker({
			flat: true,
			color: '#00ff00',
			onSubmit: function(hsb, hex, rgb) {
				$('#colorSelector2 div').css('backgroundColor', '#' + hex);
			}
		});
		$('#colorpickerHolder2>div').css('position', 'absolute');
		var widt = false;
		$('#colorSelector2').bind('click', function() {
			$('#colorpickerHolder2').stop().animate({height: widt ? 0 : 173}, 500);
			widt = !widt;
		});
		$('#colorpickerField1, #colorpickerField2, #colorpickerField3').ColorPicker({
			onSubmit: function(hsb, hex, rgb, el) {
				$(el).val(hex);
				$(el).ColorPickerHide();
			},
			onBeforeShow: function () {
				$(this).ColorPickerSetColor(this.value);
			}
		})
		.bind('keyup', function(){
			$(this).ColorPickerSetColor(this.value);
		});
		$('#colorSelector').ColorPicker({
			color: '#88c0dd',
			onShow: function (colpkr) {
				$(colpkr).fadeIn(500);
				return false;
			},
			onHide: function (colpkr) {
				$(colpkr).fadeOut(500);
				return false;
			},
			onChange: function (hsb, hex, rgb) {
				$('#colorSelector div').css('backgroundColor', '#' + hex);
				$('<style type="text/css">#footer{background-color:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">#header{background-color:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">.sf-menu li li:hover{background:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">.header-bottomline span{color:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">h4{color:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">.pagination li.current a {background:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">.dropcap {background:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">.more{color:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">#slides2 .pagination .current a {background:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">#next{background:#' + hex +' url(images/next2.png) no-repeat center;}</style>').appendTo('body');
				$('<style type="text/css">.inner-slogan span{color:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">#header-inner{background-color:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">.blog-title{color:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">.sidebartitle{color:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">.sidebartitle-second{color:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">.sidebar li a:hover{background:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">p.tags span.jg-tags:hover{background:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">p.tags span.jg-tags a:hover{background:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">.blog-pagination ul li a:hover{color:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">.inner-title{color:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">.filter-wrapper li a{color:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">.filter-wrapper li {color:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">.price h1 span{color:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">cufontext{color:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">.error{color:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">.cufon{color:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">cufon canvas{color:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">.portfolio-listing .portfolio-title a{color:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">.respond{color:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">.comments{color:#' + hex +'}</style>').appendTo('body');
				$('<style type="text/css">#commentform small span {color:#' + hex +'}</style>').appendTo('body');
				Cufon.refresh();

				
			
				
				
			}
			
			
		});
	};

	var showTab = function(e) {
		var tabIndex = $('ul.navigationTabs a')
							.removeClass('active')
							.index(this);
		$(this)
			.addClass('active')
			.blur();
		$('div.tab')
			.hide()
				.eq(tabIndex)
				.show();
	};
	
	EYE.register(initLayout, 'init');
})(jQuery)


