/* 	Colopicker Script
	Copyright 2011 DataSub.com
*/		
	$(document).ready( function() {
			$('#color_primary li a').hover( function() {
				$('#primary_label').css('color', $(this).css('background-color')).html( $(this).attr('title') );
				if( $(this).attr('title') == 'White' ) {
				    $('#primary_label').css('color', 'black' );				    
				}
			}, function() {
				$('#primary_label').html('');
			} ).click( function() {
				changeColor( 'primary', $(this).attr('data-color') );
			} );
			
			$('#color_accent li a').hover( function() {
				$('#accent_label').css('color', $(this).css('background-color')).html( $(this).attr('title') );
				if( $(this).attr('title') == 'White' ) {
				    $('#accent_label').css('color', 'black' );				    
				}

			}, function() {
				$('#accent_label').html('');
			} ).click( function() {
				changeColor( 'accent', $(this).attr('data-color') );
			} );
			
			$('#color_caption li a').hover( function() {
				$('#caption_label').css('color', $(this).css('background-color')).html( $(this).attr('title') );
				if( $(this).attr('title') == 'White' ) {
				    $('#caption_label').css('color', 'black' );				    
				}

			}, function() {
				$('#caption_label').html('');
			} ).click( function() {
				changeColor( 'caption', $(this).attr('data-color') );
			} );
			
			$('#color_led li a').hover( function() {
				$('#led_label').css('color', $(this).css('background-color')).html( $(this).attr('title') );
			}, function() {
				$('#led_label').html('');
			} ).click( function() {
				changeColor( 'leds', $(this).attr('data-color') );
			} );
			
			$("#boardimg img:eq(0)").load( function() {
				$('#loadnotif').hide();
			} );
	});
		
	function changeColor( strColorType, strColor ) {
		$('#loadnotif').css( 'height', $("#boardimg img:eq(0)").height() ).fadeIn('slow');
			
		currSrc = $("#boardimg img:eq(0)").attr('src');
		colRE = new RegExp( strColorType + '=\\w+&?', 'g' );
		$("#boardimg img:eq(0)").attr('src', currSrc.replace( colRE, strColorType + '='+ strColor +'&' ));
	}
