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" || inputs[a].className == "nolabel 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]);
				if (inputs[a].id == "Form_BookingCalloutForm_residence" || inputs[a].id == "Form_ContactForm_form_attention") {
					inputs[a].onchange = Custom.choose;
				} else if (inputs[a].id == "top_dropDown") {
					inputs[a].onchange = Custom.redirectSite;
				} else inputs[a].onchange = Custom.redirect;
			}
		}
	},
	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;
			}
		}
	},
	redirectSite: function() {
		window.location = this[this.selectedIndex].value;
	},
	redirect: function() {
		window.location = document.getElementsByTagName("base")[0].href+this[this.selectedIndex].value;
	}
}

window.onload = Custom.init;

/* bottom fading  below */
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}
function blendimage(imageTitle, imageLink, imagefile) { 
	var millisec = 200;
    var speed = Math.round(millisec / 50); 
    var timer = 0;      
    //set the current image as background 
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";      
    //make image transparent 
    changeOpac(0, imageid);     
    //make new image 
    document.getElementById(imageid).src = imagefile; 
    document.getElementById(imageid).alt = imageTitle; 
    document.getElementById(imageid).title = imageTitle; 
    document.getElementById(Linkid).href = imageLink; 
    //fade in image 
    for(i = 0; i <= 100; i++) { 
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed)); 
        timer++; 
    } 
}