// fix IE...
document.createElement('abbr');

if (typeof(jQuery) == 'undefined')
{
	jQuery = $ = {}; // global vars to prevent tinyMCE alert (editor doesn't appear though)
}

/**
 * Deal with Firebug not being present
 */
if (!window.console || !console.firebug)
{
	(function(w) { var fn, i = 0;
		if (!w.console) w.console = {};
		fn = ['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'getFirebugElement', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'notifyFirebug', 'profile', 'profileEnd', 'time', 'timeEnd', 'trace', 'warn'];
		for (i = 0; i < fn.length; ++i) if (!w.console[fn[i]]) w.console[fn[i]] = function() {};
	})(window);
}
jQuery.noConflict();
jQuery(document).ready(function($){
	var secondarymycolors = "html,#ipbwrapper,body,.topic_buttons li.non_button a,.ipsSideMenu ul li.active a,.popupInner";
	var colormycolors = "#secondary_nav a,.tab_bar.no_title.mini,.forums_block a,.category_row a ,table.ipb_table a,.forums_cont_css a,.altbar,.header,body .ipb_table .header a, 	body .topic_options a,.post_block h3,#member_wrap h3,.input_submit.alt:hover,.topic_options, .generic_bar, .tab_filters,table.ipb_table ol.subforums li,table.ipb_table ol.subforums li.newposts ,ul.post_controls a,.user_controls li a ,#latest_news,p.rep_highlight,#user_navigation ul#user_link_menucontent a";
	var bordermycolors = ".tab_bar.no_title.mini";

$('.ipboard_body').ColorPicker({
	color: '#0000ff',
	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);
	}
});	


$('#colorpickerField1').ColorPicker({
	onSubmit: function(hsb, hex, rgb, el) {
		$(el).val(hex);
		$(el).ColorPickerHide();
		$(el).css("backgroundColor", "#" + hex);
		$(el).css("borderColor", "#" + hex);
		$(secondarymycolors).css("background-color", "#" + hex);
         $(colormycolors).css("color", "#" + hex);
         $(bordermycolors).css("border-color", "#" + hex);
		$.cookie('cookiescolor1',hex,{ expires: 365, path: '/'});
		$.cookie('cookiescolor2',hex,{ expires: 365, path: '/'});
		$.cookie('cookiescolor3',hex,{ expires: 365, path: '/'});
	},
	onBeforeShow: function () {
		$(this).ColorPickerSetColor(this.value);
	} ,
	onChange: function (hsb, hex, rgb, el) {
$(secondarymycolors).css("background-color", "#" + hex);
$(colormycolors).css("color", "#" + hex);
$(bordermycolors).css("border-color", "#" + hex);
	}

	
})
.bind('keyup', function(){
	$(this).ColorPickerSetColor(this.value);
});	



	if ( ($.cookie('cookiescolor1') != null))	{
		$(secondarymycolors).css("background-color", "#" + $.cookie('cookiescolor1'));
		$("#colorpickerField1").val($.cookie('cookiescolor1'));
	}

	if ( ($.cookie('cookiescolor2') != null))	{
		$(colormycolors).css("color", "#" + $.cookie('cookiescolor2'));
		$("#colorpickerField1").val($.cookie('cookiescolor2'));
	}
		if ( ($.cookie('cookiescolor3') != null))	{
		$(secondarymycolors).css("border-color", "#" + $.cookie('cookiescolor3'));
		$("#colorpickerField1").val($.cookie('cookiescolor3'));
	}


});


$('#colorSelector').ColorPicker({
	color: '#0000ff',
	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);
	}
});


