// JavaScript Document
var Displayed;
var Home = false;
var ISIE6 = false;

function ReplaceSelects(){
	if(typeof document.body.style.maxHeight == "undefined")
		ISIE6 = true;
	var Selects = document.getElementsByTagName("select");
	
	
	for(var i = 0;i<Selects.length;i++){
		if(Selects[i].className.indexOf('NoStyle') < 0){
		var SelectSpot = document.createElement('div');
		SelectSpot.style.zIndex = Selects.length - i + 1;
		var Cont = document.createElement('div');
		Cont.id = "SSpan" + i;
		Cont.className = "SelectArea";
		var ResSpot = document.createElement('div');
		ResSpot.id = "SRes" + i;
		
		Selects[i].id = "Select" + i;
		ResSpot.className = "ResSpot";
		//ResSpot.style.width = parseInt(Selects[i].style.width.replace("px","")) + 4 + "px";
		
		for(var n = 0;n<Selects[i].options.length;n++){
			var Opt = document.createElement('a');
			Opt.href="javascript:SelectItem(" + i + "," + n + ");";
			Opt.innerHTML = Selects[i].options[n].text;
			ResSpot.appendChild(Opt);
		}
		
		ResSpot.style.display = "none";	
		if (typeof ResSpot.onselectstart!="undefined") //IE route
		ResSpot.onselectstart=function(){return false}
		else if (typeof ResSpot.style.MozUserSelect!="undefined") //Firefox route
		ResSpot.style.MozUserSelect="none"
		else //All other route (ie: Opera)
		ResSpot.onmousedown=function(){return false}
		ResSpot.style.cursor = "default"
		
		SelectSpot.className = "SelectSpot";
		if(Selects[i].options.length > 5){
			ResSpot.className += " Scroll";
		}
		
		var SelImg = document.createElement('img');
		SelImg.src="../images/darrow.png";
		SelImg.alt="";
		
		var SelImgA = document.createElement('a');
		SelImgA.href="javascript:ShowRes(" + i + ");";
		SelImgA.appendChild(SelImg);
		
		var PreImg = document.createElement('img');
		PreImg.alt = "";
		PreImg.src ="../images/selects.png";
		
		SelectSpot.appendChild(PreImg);
		SelectSpot.appendChild(Cont);
		SelectSpot.appendChild(SelImgA);
		
		//SelectSpot.style.top = Selects[i].offsetTop + "px";
		//SelectSpot.style.left = Selects[i].offsetLeft + "px";
		SelectSpot.style.width = Selects[i].style.width;
		Selects[i].style.display = "none";
		SelectSpot.appendChild(ResSpot);
		Selects[i].parentNode.insertBefore(SelectSpot,Selects[i]);
		SelectItem(i,Selects[i].selectedIndex);
		}
	}
	document.body.onclick = function() {HideBox();}
	
}
function SelectItem(Select,Index){
	var SelectBox = document.getElementById('Select' + Select);
	SelectBox.selectedIndex = Index;
	var Span = document.getElementById('SSpan' + Select);
	Span.innerHTML = SelectBox.options[Index].text != "" ? SelectBox.options[Index].text : "&nbsp;";
}
function ShowRes(Index){
	var ResBox = document.getElementById('SRes' + Index);
	ResBox.style.display = "block";
	Displayed = Index;
}
function HideBox(){
	if(Displayed != null){
		var ResBox = document.getElementById('SRes' + Displayed);
		ResBox.style.display = "none";
		Displayed = null;
	}
}

function ClearFirst(txtBox){
	if(txtBox.value == txtBox.defaultValue)
		txtBox.value = "";
}
function ReplaceEmpty(txtBox){
	if(txtBox.value == "") txtBox.value = txtBox.defaultValue;
}