$.fn.onecolorchanger = function(options) {

	var animtime = 1000;
	var actual = "#fff";
	

	var actualtext1 = "#605e5c";
	var actualtext2 = "#858585";
	var actualtext3 = "#b8b8b8";

	$(".bg", this).each(function(i) {

		var node = $(this);
		node.bind("click", function() {

			var newcolor = node.attr("data-color");

			//find all old bgs and animate
			var others = $('a, p, input, div, span, h1, h2, h3, h4').filter(function() {
				return ( jQuery.Color(this, 'background-color').toHexString() == jQuery.Color( actual ).toHexString()  );
			});
			others.add("body").add(".onedetailimgzoomDiv").animate( { backgroundColor: newcolor }, animtime);

			//borders:
			//$("#mainMenu div").animate( { borderColor: newcolor }, animtime);


			actual = newcolor;

			var text1 = node.attr("data-textcolor1");
			var text2 = node.attr("data-textcolor2");
			var text3 = node.attr("data-textcolor3");


			switchTextColors(actualtext1, text1);
			switchTextColors(actualtext2, text2);
			switchTextColors(actualtext3, text3);


			actualtext1 = text1;
			actualtext2 = text2;
			actualtext3 = text3;


		});

	});


	function switchTextColors(from, to) {
		if (from != to) {
			var nodes = $('a, p, input, div, span, h1, h2, h3, h4').filter(function() {
				return ( jQuery.Color(this, 'color').toHexString() == jQuery.Color( from ).toHexString()  );
			});

			//nodes.animate( { color: to }, animtime);
			nodes.css( "color", jQuery.Color(to) );

			/* ----- borders also ---- */

			var nodes = $('a, p, input, div, span, h1, h2, h3, h4').filter(function() {
				return ( jQuery.Color(this, 'border-color').toHexString() == jQuery.Color( from ).toHexString()  );
			});

			//nodes.animate( { color: to }, animtime);
			nodes.css( "border-color", jQuery.Color(to) );

		}
	}

}


