/*
======================================================================
ddcolorposter.js: By Dynamic Drive (http://www.dynamicdrive.com)
Communicates between Yahoo Color Picker and form fields on your page
Created: Feb 20th, 06'
======================================================================
*/

function executeonload(functionref){
	if (window.addEventListener)
		window.addEventListener("load", functionref, false)
	else if (window.attachEvent)
		window.attachEvent("onload", functionref)
	else if (document.getElementById)
		window.onload=functionref
}

var ddcolorposter={

initialize:function(r,g,b, hexvalue){
	this.rvalue=r //store red value
	this.gvalue=g //store green value
	this.bvalue=b //store blue value
	this.hexvalue=hexvalue //store combined hex value
	if (typeof this.targetobj!="undefined"){
		this.targetobj.value=this.hexvalue //set field to selected hex color value
		if (typeof this.divobj!="undefined"){ //set adjacent div to selected hex color value
			this.divobj.style.backgroundColor="#"+this.hexvalue;
			if (this.welk == "colorbox2"){
				document.getElementById("mainwldiv").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("bottommenu").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("topmenu").style.backgroundColor="#"+this.hexvalue;
			}
			else if (this.welk == "colorbox5"){
				document.getElementById("xb12a").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("xb13a").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("xb14a").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("xb12b").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("xb13b").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("xb14b").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("xb12c").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("xb13c").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("xb14c").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("xb12d").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("xb13d").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("xb14d").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("aiboxcontent2a").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("aiboxcontent2b").style.backgroundColor="#"+this.hexvalue;
			}
			else if (this.welk == "colorbox20"){
				document.getElementById("xb12a").style.borderLeftColor="#"+this.hexvalue;
				document.getElementById("xb13a").style.borderLeftColor="#"+this.hexvalue;
				document.getElementById("xb14a").style.borderLeftColor="#"+this.hexvalue;
				document.getElementById("xb12b").style.borderLeftColor="#"+this.hexvalue;
				document.getElementById("xb13b").style.borderLeftColor="#"+this.hexvalue;
				document.getElementById("xb14b").style.borderLeftColor="#"+this.hexvalue;
				document.getElementById("xb12c").style.borderLeftColor="#"+this.hexvalue;
				document.getElementById("xb13c").style.borderLeftColor="#"+this.hexvalue;
				document.getElementById("xb14c").style.borderLeftColor="#"+this.hexvalue;
				document.getElementById("xb12d").style.borderLeftColor="#"+this.hexvalue;
				document.getElementById("xb13d").style.borderLeftColor="#"+this.hexvalue;
				document.getElementById("xb14d").style.borderLeftColor="#"+this.hexvalue;

				document.getElementById("xb12a").style.borderRightColor="#"+this.hexvalue;
				document.getElementById("xb13a").style.borderRightColor="#"+this.hexvalue;
				document.getElementById("xb14a").style.borderRightColor="#"+this.hexvalue;
				document.getElementById("xb12b").style.borderRightColor="#"+this.hexvalue;
				document.getElementById("xb13b").style.borderRightColor="#"+this.hexvalue;
				document.getElementById("xb14b").style.borderRightColor="#"+this.hexvalue;
				document.getElementById("xb12c").style.borderRightColor="#"+this.hexvalue;
				document.getElementById("xb13c").style.borderRightColor="#"+this.hexvalue;
				document.getElementById("xb14c").style.borderRightColor="#"+this.hexvalue;
				document.getElementById("xb12d").style.borderRightColor="#"+this.hexvalue;
				document.getElementById("xb13d").style.borderRightColor="#"+this.hexvalue;
				document.getElementById("xb14d").style.borderRightColor="#"+this.hexvalue;

				document.getElementById("xb11a").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("xb11b").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("xb11c").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("xb11d").style.backgroundColor="#"+this.hexvalue;

				document.getElementById("aiboxcontent2a").style.borderColor="#"+this.hexvalue;
				document.getElementById("aiboxcontent2b").style.borderColor="#"+this.hexvalue;
			}
			else if (this.welk == "colorbox21"){
				document.getElementById("aiboxcontent2b").style.color="#"+this.hexvalue;
			}
			else if (this.welk == "colorbox8"){
				document.getElementById("xb2a").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("xb3a").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("xb4a").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("xb2b").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("xb3b").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("xb4b").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("aiboxcontent1").style.backgroundColor="#"+this.hexvalue;
			}
			else if (this.welk == "colorbox22"){
				document.getElementById("xb2a").style.borderLeftColor="#"+this.hexvalue;
				document.getElementById("xb3a").style.borderLeftColor="#"+this.hexvalue;
				document.getElementById("xb4a").style.borderLeftColor="#"+this.hexvalue;
				document.getElementById("xb2b").style.borderLeftColor="#"+this.hexvalue;
				document.getElementById("xb3b").style.borderLeftColor="#"+this.hexvalue;
				document.getElementById("xb4b").style.borderLeftColor="#"+this.hexvalue;

				document.getElementById("xb2a").style.borderRightColor="#"+this.hexvalue;
				document.getElementById("xb3a").style.borderRightColor="#"+this.hexvalue;
				document.getElementById("xb4a").style.borderRightColor="#"+this.hexvalue;
				document.getElementById("xb2b").style.borderRightColor="#"+this.hexvalue;
				document.getElementById("xb3b").style.borderRightColor="#"+this.hexvalue;
				document.getElementById("xb4b").style.borderRightColor="#"+this.hexvalue;

				document.getElementById("xb1a").style.backgroundColor="#"+this.hexvalue;
				document.getElementById("xb1b").style.backgroundColor="#"+this.hexvalue;

				document.getElementById("aiboxcontent1").style.borderColor="#"+this.hexvalue;
			}
			else if (this.welk == "colorbox23"){
				document.getElementById("aiboxcontent1").style.color="#"+this.hexvalue;
			}
			else if (this.welk == "colorbox6" || this.welk == "colorbox3" || this.welk == "colorbox9"){
				if (document.getElementById(this.welk+"a")){
				document.getElementById(this.welk+"a").style.color="#"+this.hexvalue;
				}
				if (document.getElementById(this.welk+"b")){
				document.getElementById(this.welk+"b").style.color="#"+this.hexvalue;
				}
				if (document.getElementById(this.welk+"c")){
				document.getElementById(this.welk+"c").style.color="#"+this.hexvalue;
				}
				if (document.getElementById(this.welk+"d")){
				document.getElementById(this.welk+"d").style.color="#"+this.hexvalue;
				}
				if (document.getElementById(this.welk+"e")){
				document.getElementById(this.welk+"e").style.color="#"+this.hexvalue;
				}
				if (document.getElementById(this.welk+"f")){
				document.getElementById(this.welk+"f").style.color="#"+this.hexvalue;
				}
			}
			else if (this.welk == "colorbox19"){
				document.getElementById("logodiv").style.backgroundColor="#"+this.hexvalue;	
			}
			else if (this.welk == "colorbox192"){
				document.getElementById("logodiv2").style.backgroundColor="#"+this.hexvalue;	
			}
			else if (this.welk == "colorbox1"){
				document.getElementById("topmenu").style.color="#"+this.hexvalue;
				document.getElementById("bottommenu").style.color="#"+this.hexvalue;
				document.getElementById("hr1").style.color="#"+this.hexvalue;
				document.getElementById("hr2").style.color="#"+this.hexvalue;
			}
			else {
			}

		}
	}
},
echocolor:function(inputobj, divID){
	this.targetobj=inputobj
	this.divobj=document.getElementById(divID)
	this.welk=divID
	this.targetobj.onblur=function(){
	if (inputobj.value.search(/^[a-zA-Z0-9]{6}$/)!=-1){ //if field contains valid hex value
		document.getElementById(divID).style.backgroundColor= "#"+inputobj.value;
	}
}
},
fillcolorbox:function(inputID, divID){
	var inputobj=document.getElementById(inputID)
	if (inputobj.value.search(/^[a-zA-Z0-9]{6}$/)!=-1); //if field contains valid hex value
		document.getElementById(divID).style.backgroundColor="#"+inputobj.value;
}
}
