var loaded_all_sponsors = false;

function doSelect() {
	try {
		imageform.plantid.value = imageform.elements['plant_select'].options[imageform.elements['plant_select'].selectedIndex].value;
	} catch (e) {
		imageform.newid.value = imageform.elements['plant_select'].options[imageform.elements['plant_select'].selectedIndex].value;
	}
}

function parseGet() {
	if ((xGet.readyState == 4)) { 
		if (xGet.status == 200) {
			success = xGet.responseText;
			document.getElementById('plant_select').style.backgroundColor = "#FFFFFF";			
			if (success.length > 0) {
				document.getElementById('plant_select_container').innerHTML = success;
			}
		}
	}
}

function doGet(key) {
	
	document.getElementById('plant_select').style.backgroundColor = "#CCCCCC";
	
	try {
		xGet = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch (e) {
		alert("This page requirse an AJAX enabled Browser");
	}
	
	xGet.onreadystatechange = parseGet;

	xGet.open("GET", 'admin.php?todo=plantselect&key=' + key);
 
	xGet.send(null);

}

function parse_search_sponsors() {
	if ((x_search_sponsors.readyState == 4)) { 
		if (x_search_sponsors.status == 200) {
			success = x_search_sponsors.responseText;			
			if (success.length > 0) {
				document.getElementById('search_sponsors_container').innerHTML = success;
				document.forms['entryform']['SEARCH_SPONSORS[]'].style.backgroundColor = "#FFFFFF";
			}
		}
	}
}

function get_search_sponsors() {
	loaded_search_sponsors = true;
	
	document.forms['entryform']['SEARCH_SPONSORS[]'].style.backgroundColor = "#CCCCCC";
	
	try {
		x_search_sponsors = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch (e) {
		alert("This page requirse an AJAX enabled Browser");
	}
	
	x_search_sponsors.onreadystatechange = parse_search_sponsors;

	x_search_sponsors.open("GET", 'admin.php?todo=searchsponsors&search=' + 	document.forms['entryform']['sponsor_search_text'].value);
 
	x_search_sponsors.send(null);
	
}

function parse_all_sponsors() {
	if ((x_all_sponsors.readyState == 4)) { 
		if (x_all_sponsors.status == 200) {
			success = x_all_sponsors.responseText;			
			if (success.length > 0) {
				document.getElementById('all_sponsors').innerHTML = success;
				document.forms['entryform']['ALL_SPONSORS[]'].style.backgroundColor = "#FFFFFF";
			}
		}
	}
}

function get_all_sponsors() {
	if (loaded_all_sponsors == false) {
	
		loaded_all_sponsors = true;
		
		document.forms['entryform']['ALL_SPONSORS[]'].style.backgroundColor = "#CCCCCC";
		
		try {
			x_all_sponsors = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e) {
			alert("This page requirse an AJAX enabled Browser");
		}
		
		x_all_sponsors.onreadystatechange = parse_all_sponsors;
	
		x_all_sponsors.open("GET", 'admin.php?todo=allsponsors');
	 
		x_all_sponsors.send(null);
	}

}


function remove_options(selectbox) {
	var i;
	for(i=selectbox.options.length-1;i>=0;i--) {
		if(selectbox.options[i].selected) {
			selectbox.remove(i);
		}
	}
}


function add_options(from_selectbox, to_selectbox) {
	var i;
	var j;
	for(i=from_selectbox.options.length-1;i>=0;i--) {
		if(from_selectbox.options[i].selected) {
			var unique=-1;
			for(j=to_selectbox.options.length-1;j>=0;j--) {
				if(to_selectbox.options[j].value == from_selectbox.options[i].value) {
					unique = j;
				}
			}
			if (unique == -1) {
				var optn = document.createElement("OPTION");
				optn.text = from_selectbox.options[i].text;
				optn.value = from_selectbox.options[i].value;
				to_selectbox.options.add(optn);
			} else {
				for(j=to_selectbox.options.length-1;j>=0;j--) {
					to_selectbox.options[j].selected = false;
				}
				to_selectbox.options[unique].selected = true;
			}
		}
	}
}

function select_all(selectbox) {
   for(var i=0; i < selectbox.length; i++) {
   	selectbox[i].selected = true;
   }
}

function show_my_sponsors() {
	document.getElementById("my_sponsors_tab").className = "active";
	document.getElementById("all_sponsors_tab").className = "inactive";
	document.getElementById("search_sponsors_tab").className = "inactive";
	//document.getElementById("my_sponsors_header").style.display = "block";
	document.getElementById("my_sponsors").style.display = "inline";
	//document.getElementById("all_sponsors_header").style.display = "none";
	document.getElementById("all_sponsors").style.display = "none";
	//document.getElementById("search_sponsors_header").style.display = "none";
	document.getElementById("search_sponsors").style.display = "none";
	document.forms['entryform']['MY_SPONSORS[]'].focus();	
}

function show_all_sponsors() {
	document.getElementById("my_sponsors_tab").className = "inactive";
	document.getElementById("all_sponsors_tab").className = "active";
	document.getElementById("search_sponsors_tab").className = "inactive";
	//document.getElementById("my_sponsors_header").style.display = "none";
	document.getElementById("my_sponsors").style.display = "none";
	//document.getElementById("all_sponsors_header").style.display = "block";
	document.getElementById("all_sponsors").style.display = "inline";
	//document.getElementById("search_sponsors_header").style.display = "none";
	document.getElementById("search_sponsors").style.display = "none";
	document.forms['entryform']['ALL_SPONSORS[]'].focus();		
}

function show_search_sponsors() {
	document.getElementById("my_sponsors_tab").className = "inactive";
	document.getElementById("all_sponsors_tab").className = "inactive";
	document.getElementById("search_sponsors_tab").className = "active";
	//document.getElementById("my_sponsors_header").style.display = "none";
	document.getElementById("my_sponsors").style.display = "none";
	//document.getElementById("all_sponsors_header").style.display = "none";
	document.getElementById("all_sponsors").style.display = "none";
	//document.getElementById("search_sponsors_header").style.display = "block";
	document.getElementById("search_sponsors").style.display = "inline";		
	document.forms['entryform']['sponsor_search_text'].focus();
}

function show_basic_event() {
	showsubmenu("basic_tab");
	showsubmenu("advanced_tab");
	showsubmenu("adv_short_title");
	showsubmenu("adv_short_desc");
	//showsubmenu("SHORT_DESCRIPTION___Frame");
	showsubmenu("SHORT_DESCRIPTION_container");
	showsubmenu("adv_span");
	showsubmenu("adv_fee");
	//showsubmenu("adv_room");
	showsubmenu("adv_contact_name");
	showsubmenu("adv_contact_number");
	showsubmenu("adv_contact_email");
	showsubmenu("adv_website");
	showsubmenu("adv_info");
	showsubmenu("adv_on_home");
}

function show_basic_news() {
	showsubmenu("basic_tab");
	showsubmenu("advanced_tab");
	showsubmenu("adv_short_title");
	showsubmenu("adv_short_desc");
	//showsubmenu("SHORT_DESCRIPTION___Frame");
	showsubmenu("SHORT_DESCRIPTION_container");
	showsubmenu("adv_contact_name");
	showsubmenu("adv_contact_number");
	showsubmenu("adv_contact_email");
	showsubmenu("adv_website");
	showsubmenu("adv_info");
}
