// JavaScript Document
var Globals = {
	initialize: function() {
		Custom.init();
	}
}
window.onload = Globals.initialize;

var selectWidth = "145";

document.write('<style type="text/css">input.styled { display: none; } select.styled { position: relative; width: ' + selectWidth + 'px; opacity: 0; filter: alpha(opacity=0); z-index: 5; }</style>');

var Custom = {
	init: function() {
		var inputs = document.getElementsByTagName("input"), span = Array(), textnode, option, active;
		
		inputs = document.getElementsByTagName("select");
		for(a = 0; a < inputs.length; a++) {
			if(inputs[a].className == "styled") {
				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 = "select";
				span[a].id = "select" + inputs[a].name;
				span[a].appendChild(textnode);
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				//inputs[a].onchange = Custom.choose;
			}
		}
	},
	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;
			}
		}
	}
}


function cambiaMoll(id) {

	object=document.getElementById(id);
	moll=object.value;
	
	location.href='http://www.bodaclick.com/index.htm?moll='+moll;
}

function cambiaProvinciaBuscadorIframe(seleccion) {

	option = seleccion.getElementsByTagName("option");
	for(d = 0; d < option.length; d++) {
		if(option[d].selected == true) {
			document.getElementById("select" + seleccion.name).childNodes[0].nodeValue = option[d].childNodes[0].nodeValue;
		}
	}
	if (seleccion.value=='') return;
	
	$("#capaBdBuscadorEmpresaPlanta").html(plantas[seleccion.value]);
	Custom.init();
}

function vePlanta(moll) {

	planta=document.getElementById('bdBuscadorEmpresaPlanta').value;
	
	top.location.href='http://www.bodaclick.com/index.htm?moll='+moll+'&planta='+planta+'&hola=1';
}
