//------------------------
// random color - requires jquery
//
// apply a random color to class randomcolor, randombgcolor 
// version 1.2    
// date    2009.04.21
// author  erational <http://www.erational.org>
// url     http://www.erational.org/randomColor.html
//------------------------

// -----------------
// parameters
// -----------------
var rndc_speed = 300;     // refresh time  (ms)
var rndc_step = 1;       //  step (1 progressive, 50 quick) 
var linkCol = true;

r = new Array(125, 093, 110, 088, 088, 088, 081);
g = new Array(125, 103, 151, 101, 147, 129, 175);
b = new Array(125, 168, 149, 149, 192, 156, 197);


$(document).ready(function(){
    
    // color start
    var randInt = Math.floor(Math.random() * r.length-1);
    var rndc_red   = r[randInt];
    var rndc_green = g[randInt];
    var rndc_blue  = b[randInt];  
     
    // color target
    randInt = Math.floor(Math.random() * r.length);
    var rndc_red2   = r[randInt];
    var rndc_green2 = g[randInt];
    var rndc_blue2  = b[randInt];
    
    randomColor(); 
    var t = setTimeout(randomColor,0);
    //$("#title").append('<span>'+rndc_red+'_'+rndc_green+'_'+rndc_blue+'</span>');
    $(".holder").mousemove(function(e){
    	var t = setTimeout(randomColor,rndc_speed);  
    })
            
    function randomColor() {
     	if(linkCol){
        // R
        if (Math.abs(rndc_red2-rndc_red)>rndc_step) rndc_red += ((rndc_red2-rndc_red)/Math.abs(rndc_red2-rndc_red)) * rndc_step;
        else rndc_red = rndc_red2;
        // G 
        if (Math.abs(rndc_green2-rndc_green)>rndc_step) rndc_green += ((rndc_green2-rndc_green)/Math.abs(rndc_green2-rndc_green)) * rndc_step;
        else rndc_green = rndc_green2;       
        // B 
        if (Math.abs(rndc_blue2-rndc_blue)>rndc_step) rndc_blue += ((rndc_blue2-rndc_blue)/Math.abs(rndc_blue2-rndc_blue)) * rndc_step;
        else rndc_blue = rndc_blue2; 
        
        if (rndc_red==rndc_red2  && rndc_green==rndc_green2 && rndc_blue==rndc_blue2) {
                // new color        
                randInt = Math.floor(Math.random() * r.length);         
                rndc_red2   = r[randInt];
                rndc_green2 = g[randInt];
                rndc_blue2  = b[randInt];            
        }
        
        // apply color                
        
        //border
        $('.borderColor').css("border-color","rgb("+rndc_red+","+rndc_green+","+rndc_blue+")");

        //background
        $('#background').css("background-color","rgb("+rndc_red+","+rndc_green+","+rndc_blue+")");
                
        //color
        $('.changeColor').css("color","rgb("+rndc_red+","+rndc_green+","+rndc_blue+")");
        $('.colLink').css("color","rgb("+rndc_red+","+rndc_green+","+rndc_blue+")");
        $('.kickdialog').css("background-color","rgb("+rndc_red+","+rndc_green+","+rndc_blue+")");
        $('#orderlink').css("background-color","rgb("+rndc_red+","+rndc_green+","+rndc_blue+")");
    			
		}
		$('.colLink').mouseout(function(){
      		$(this).css("background","none");
      		$(this).css("color","rgb("+rndc_red+","+rndc_green+","+rndc_blue+")");
      		linkCol= true;
    	}).mouseover(function(){
           	$(this).css("background","rgb("+rndc_red+","+rndc_green+","+rndc_blue+")");
     		$(this).css("color","#fff");
     		linkCol= false;
      	});      
    }
});


