//////
/////
/////I suck at Javascript. Don't judge me :D
/////
/////

//Get Random Color Set
function getRandomColorSet() {
	new Ajax.Request('random.php',
	  {
	  	onCreate: $('loader').style.display = "",
	    onSuccess: function(transport){
	      var colors = transport.responseText || "fail";
	      onComplete: $('loader').fade();
	      if(colors != "fail"){
	     	 var c1 = colors.slice(0,6);
	     	 var c2 = colors.slice(6,12);
	     	 var c3 = colors.slice(12,18);
	     	 var c4 = colors.slice(18,24);
	     	 var c5 = colors.slice(24,30);
	     	 $('b1b').style.background = "#"+c1;
	     	 $('b2b').style.background = "#"+c2;
	     	 $('b3b').style.background = "#"+c3;
	     	 $('b4b').style.background = "#"+c4;
	     	 $('b5b').style.background = "#"+c5;
	     	 $('b1').value = c1;
	     	 $('b2').value = c2;
	     	 $('b3').value = c3;
	     	 $('b4').value = c4;
	     	 $('b5').value = c5;
	      }else{
	      	 alert('Something went wrong and we couldn\'t get a random color set.');
	      }
	    },
	    onFailure: function(){ alert('Something went wrong and we couldn\'t get a random color set.') }
	  });
}

////////
function change(color,input){
	if (color.match(/([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/) == null){
			var isHex=false;
			document.getElementById(input).setAttribute("style", "color: red;");
		}
	if(color.length == 6 && isHex != false){
		document.getElementById(""+input+"b").setAttribute("style", "background: #"+color+";");
		document.getElementById(input).setAttribute("style", "color:;");
	}
}


//check submit
function checkSubmit(){
	if($('select').value == 0){
		alert('Please Select A Resolution');
		return false;
	}else{
		return true;
	}
}

//Get random values for FireFox -- so you can set the computer background more than once.
function randomValues() {
	new Ajax.Request('random_values.php',
	  {
	    onSuccess: function(transport){
	      var string = transport.responseText || "fail";
	      if(string != "fail"){
	      	 $('submit_form').action = "create"+string+".png";
	      }
	    }
	  });
}












