// THEsearch.js

/* Search Checkboxes */
chk_reson = new Image();    
chk_reson.src = "images/0000_but_chk1_on.gif"; 
chk_resoff = new Image();      
chk_resoff.src = "images/0000_but_chk1_off.gif";    

chk_offon = new Image();    
chk_offon.src = "images/0000_but_chk2_on.gif"; 
chk_offoff = new Image();      
chk_offoff.src = "images/0000_but_chk2_off.gif";  

chk_comon = new Image();    
chk_comon.src = "images/0000_but_chk1_on.gif"; 
chk_comoff = new Image();      
chk_comoff.src = "images/0000_but_chk1_off.gif";    

chk_ageon = new Image();    
chk_ageon.src = "images/0000_but_chk2_on.gif"; 
chk_ageoff = new Image();      
chk_ageoff.src = "images/0000_but_chk2_off.gif";  

chk_agron = new Image();    
chk_agron.src = "images/0000_but_chk1_on.gif"; 
chk_agroff = new Image();      
chk_agroff.src = "images/0000_but_chk1_off.gif";    


/********************************************************************/
/* Functionality */
function allOffBut(imgName){

	if(imgName != "chk_res"){
		document['chk_res'].src = chk_resoff.src;
		document.forms['THEsearch'].chk_pty.value = '';
	}

	if(imgName != "chk_com"){
		document['chk_com'].src = chk_comoff.src;
		document.forms['THEsearch'].chk_pty.value = '';
	}

	if(imgName != "chk_agr"){
		document['chk_agr'].src = chk_agroff.src;
		document.forms['THEsearch'].chk_pty.value = '';
	}

	if(imgName != "chk_off"){
		document['chk_off'].src = chk_offoff.src;
		document.forms['THEsearch'].chk_rem.value = '';
	}

	if(imgName != "chk_age"){
		document['chk_age'].src = chk_ageoff.src;
		document.forms['THEsearch'].chk_rem.value = '';
	}
}

/********************************************************************/

function THEtoggle(imgName){

	var strSelect = "";
	var txt = /off/;
	var pat = document[imgName].src;

	if(pat.match(txt)){
		imgOn = eval(imgName + "on.src");
		document[imgName].src = imgOn;

		allOffBut(imgName);

		if(imgName == "chk_res"){
			document.forms['THEsearch'].chk_pty.value = 'res';
			document.forms['THEsearch'].chk_rem.value = '';
			document.getElementsByTagName("SELECT")[0].style.backgroundColor = "#EFDBDC";
			document.getElementsByTagName("SELECT")[1].style.backgroundColor = "#EFDBDC";
			document.getElementById("opt").style.display = 'block';
			document.getElementById("dropdown1").style.display = 'block';
			document.getElementById("dropdown2").style.display = 'none';
			document.getElementById("dropdown3").style.display = 'none';
		}

		if(imgName == "chk_com"){
			document.forms['THEsearch'].chk_pty.value = 'com';
			document.forms['THEsearch'].chk_rem.value = '';
			document.getElementsByTagName("SELECT")[0].style.backgroundColor = "#EFDBDC";
			document.getElementsByTagName("SELECT")[1].style.backgroundColor = "#EFDBDC";
			document.getElementById("opt").style.display = 'none';
		}

		if(imgName == "chk_agr"){
			document.forms['THEsearch'].chk_pty.value = 'agr';
			document.forms['THEsearch'].chk_rem.value = '';
			document.getElementsByTagName("SELECT")[0].style.backgroundColor = "#EFDBDC";
			document.getElementsByTagName("SELECT")[1].style.backgroundColor = "#EFDBDC";
			document.getElementById("opt").style.display = 'none';
		}

		if(imgName == "chk_off"){
			document.forms['THEsearch'].chk_rem.value = 'off';
			document.forms['THEsearch'].chk_pty.value = '';
			document.getElementsByTagName("SELECT")[0].style.backgroundColor = "#DCE9F1";
			document.getElementsByTagName("SELECT")[1].style.backgroundColor = "#DCE9F1";
			document.getElementById("opt").style.display = 'block';
			document.getElementById("dropdown1").style.display = 'none';
			document.getElementById("dropdown2").style.display = 'block';
			document.getElementById("dropdown3").style.display = 'none';
		}

		if(imgName == "chk_age"){
			document.forms['THEsearch'].chk_rem.value = 'age';
			document.forms['THEsearch'].chk_pty.value = '';
			document.getElementsByTagName("SELECT")[0].style.backgroundColor = "#DCE9F1";
			document.getElementsByTagName("SELECT")[1].style.backgroundColor = "#DCE9F1";
			document.getElementById("opt").style.display = 'block';
			document.getElementById("dropdown1").style.display = 'none';
			document.getElementById("dropdown2").style.display = 'none';
			document.getElementById("dropdown3").style.display = 'block';
		}

	}else{

		imgOff = eval(imgName + "off.src");
		document[imgName].src = imgOff;

	}
}

/********************************************************************/

function process(){

	var pty = document.forms['THEsearch'].chk_pty.value;
	var rem = document.forms['THEsearch'].chk_rem.value;
	var pro = document.forms['THEsearch'].combo0.value;

	var subres = document.forms['THEsearch'].subopt1.selectedIndex; 
	var suboff = document.forms['THEsearch'].subopt2.selectedIndex; 
	var subage = document.forms['THEsearch'].subopt3.selectedIndex; 

	if(pty == "res" || pty == "com" || pty == "agr"){
		if(pty == "res"){
			if(document.forms['THEsearch'].subopt1.selectedIndex == "0"){
				document.forms['THEsearch'].chk_value.value = "resrem";
			}else{
				document.forms['THEsearch'].chk_value.value = "resmls";
			}
		}
		if(pty == "com"){
			document.forms['THEsearch'].chk_value.value = "com";
		}
		if(pty == "agr"){
			document.forms['THEsearch'].chk_value.value = "agr";
		}
	}

	if(rem == "off"){
		if(document.forms['THEsearch'].subopt2.selectedIndex == "0"){
			document.forms['THEsearch'].chk_value.value = "offres";
		}else{
			document.forms['THEsearch'].chk_value.value = "offcom";
		}
	}

	if(rem == "age"){
		if(document.forms['THEsearch'].subopt3.selectedIndex == "0"){
			document.forms['THEsearch'].chk_value.value = "ageres";
		}else{
			document.forms['THEsearch'].chk_value.value = "agecom";
		}
	}

	document.forms['THEsearch'].submit();

}
