// JavaScript Document

/*

CUSTOM FORM ELEMENTS

Created by Ryan Fait
www.ryanfait.com

The only thing you need to change in this file is the following
variables: checkboxHeight, radioHeight and selectWidth.

Replace the first two numbers with the height of the checkbox and
radio button. The actual height of both the checkbox and radio
images should be 4 times the height of these two variables. The
selectWidth value should be the width of your select list image.

You may need to adjust your images a bit if there is a slight
vertical movement during the different stages of the button
activation.

Visit http://ryanfait.com/ for more information.

TM
- trimmed code from original 
- this is just for select image change
- multiple sizes can be created by adding code (SEE flags //SET SELECT STYLE A B etc)
- You must call "SelectClass init()" function  from the document you wish to change select dropdown



*/



var select65_Width = "65";
document.write('<style type="text/css">select.select65 { position: relative; width: '+ select65_Width + 'px; opacity: 0; filter: alpha(opacity=0); z-index: 5;}</style>');

var select135_Width = "135";
document.write('<style type="text/css">select.select135 { position: relative; width: '+ select135_Width + 'px; opacity: 0; filter: alpha(opacity=0); z-index: 5;}</style>');


var select175_Width = "175";
document.write('<style type="text/css">select.select175 { position: relative; width: '+ select175_Width + 'px; opacity: 0; filter: alpha(opacity=0); z-index: 5;}</style>');


var select300_Width = "300";
document.write('<style type="text/css">select.select300 { position: relative; width: '+ select300_Width + 'px; opacity: 0; filter: alpha(opacity=0); z-index: 5;}</style>');

var select315_Width = "315";
document.write('<style type="text/css">select.select315 { position: relative; width: '+ select315_Width + 'px; opacity: 0; filter: alpha(opacity=0); z-index: 5;}</style>');

var select325_Width = "325";
document.write('<style type="text/css">select.select325 { position: relative; width: '+ select325_Width + 'px; opacity: 0; filter: alpha(opacity=0); z-index: 5;}</style>');



var SelectClass = {
	
	init: function() {

		var inputs = document.getElementsByTagName("select"), span = Array(), textnode, option, active;

		for(a = 0; a < inputs.length; a++) {


			///////////// SET SELECT 65 ///////////
			if(inputs[a].className == "select65") {
				option = inputs[a].getElementsByTagName("option");
				active = option[0].childNodes[0].nodeValue;
				textnode = document.createTextNode(active);
				for(b = 0; b < option.length; b++) {
					if(option[b].selected == true) {
						textnode = document.createTextNode(option[b].childNodes[0].nodeValue);
					}
				}
				span[a] = document.createElement("span");
				span[a].className = "class65";//was select SEE css doc
				span[a].id = "select" + inputs[a].name;
				span[a].appendChild(textnode);
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = SelectClass.choose;
			}//////////////////




			///////////// SET SELECT 135 ///////////
			if(inputs[a].className == "select135") {
				option = inputs[a].getElementsByTagName("option");
				active = option[0].childNodes[0].nodeValue;
				textnode = document.createTextNode(active);
				for(b = 0; b < option.length; b++) {
					if(option[b].selected == true) {
						textnode = document.createTextNode(option[b].childNodes[0].nodeValue);
					}
				}
				span[a] = document.createElement("span");
				span[a].className = "class135";//was select SEE css doc
				span[a].id = "select" + inputs[a].name;
				span[a].appendChild(textnode);
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = SelectClass.choose;
			}//////////////////




			///////////// SET SELECT 175 ///////////
			if(inputs[a].className == "select175") {
				option = inputs[a].getElementsByTagName("option");
				active = option[0].childNodes[0].nodeValue;
				textnode = document.createTextNode(active);
				for(b = 0; b < option.length; b++) {
					if(option[b].selected == true) {
						textnode = document.createTextNode(option[b].childNodes[0].nodeValue);
					}
				}
				span[a] = document.createElement("span");
				span[a].className = "class175";//was select SEE css doc
				span[a].id = "select" + inputs[a].name;
				span[a].appendChild(textnode);
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = SelectClass.choose;
			}//////////////////




			///////////// SET SELECT 300 ///////////
			if(inputs[a].className == "select300") 
			{
				option = inputs[a].getElementsByTagName("option");
				active = option[0].childNodes[0].nodeValue;
				textnode = document.createTextNode(active);
				for(b = 0; b < option.length; b++) {
					if(option[b].selected == true) 
					{
						textnode = document.createTextNode(option[b].childNodes[0].nodeValue);
					}
				}//END for loop
				span[a] = document.createElement("span");
				span[a].className = "class300";//was select SEE css doc
				span[a].id = "select" + inputs[a].name;
				span[a].appendChild(textnode);
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = SelectClass.choose;
			}///////////////////





			////////////// SET SELECT 315 ////////////
			if(inputs[a].className == "select315") 
			{
				option = inputs[a].getElementsByTagName("option");
				active = option[0].childNodes[0].nodeValue;
				textnode = document.createTextNode(active);
				for(b = 0; b < option.length; b++) {
					if(option[b].selected == true) 
					{
						textnode = document.createTextNode(option[b].childNodes[0].nodeValue);
					}
				}//END for loop
				span[a] = document.createElement("span");
				span[a].className = "class315";//was select SEE css doc
				span[a].id = "select" + inputs[a].name;
				span[a].appendChild(textnode);
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = SelectClass.choose;
			}///////////////////




			////////////// SET SELECT 325 ////////////
			if(inputs[a].className == "select325") 
			{
				option = inputs[a].getElementsByTagName("option");
				active = option[0].childNodes[0].nodeValue;
				textnode = document.createTextNode(active);
				for(b = 0; b < option.length; b++) {
					if(option[b].selected == true) 
					{
						textnode = document.createTextNode(option[b].childNodes[0].nodeValue);
					}
				}//END for loop
				span[a] = document.createElement("span");
				span[a].className = "class325";//was select SEE css doc
				span[a].id = "select" + inputs[a].name;
				span[a].appendChild(textnode);
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = SelectClass.choose;
			}///////////////////



		}//END for loop

	},//////////////

	choose: function() {
		option = this.getElementsByTagName("option");
		for(d = 0; d < option.length; d++) {
			if(option[d].selected == true) {
				document.getElementById("select" + this.name).childNodes[0].nodeValue = option[d].childNodes[0].nodeValue;
			}
		}
	}/////////////
	
}//END Custom 


//window.onload = SelectClass.init;



