function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function switchAGColour(objTag, strState) {
	if (strState == 'Over') {
		objTag.bgColor='#F6F5EF';
	} else {
		objTag.bgColor='#F0EDDC';
	}
}
function switchBGColour(objTag, strState) {
	if (strState == 'Over') {
		objTag.bgColor='#FFFFFF';
	} else {
		objTag.bgColor='#F6F5EF';
	}
}

function BannerAswitchBGColour(objTag, strState) {
	if (strState == 'Over') {
		objTag.bgColor='#F6F5EF';
	} else {
		objTag.bgColor='#F0EDDC';
	}
}
function BannerBswitchBGColour(objTag, strState) {
	if (strState == 'Over') {
		objTag.bgColor='#FFFFFF';
	} else {
		objTag.bgColor='#F6F5EF';
	}
}

function toggle_secondary_search(search_form_name)
{
	document.getElementById('discipline_search_form').style.display = 'none';
	document.getElementById('usages_search_form').style.display = 'none';
	
	document.getElementById('owner_search_input_form').style.display = 'none';
	document.getElementById('owner_search_info').style.display = 'none';
	
	document.getElementById('horse_search_input_form').style.display = 'none';
	document.getElementById('horse_search_info').style.display = 'none';
	
	if ((search_form_name == 'discipline_search_form') || (search_form_name == 'usages_search_form') || (search_form_name == 'owner_search_input_form') || (search_form_name == 'horse_search_input_form'))
	{
		target_form = document.getElementById(search_form_name);
		target_form.style.display = 'inline';
	}
	
	if (search_form_name == 'owner_search_input_form')
	{
		document.getElementById('owner_search_info').style.display = 'block';		
	}
	
	if (search_form_name == 'horse_search_input_form')
	{
		document.getElementById('horse_search_info').style.display = 'block';
	}
}

function reset_dropdowns()
{
	document.getElementById('discipline_search').value = '';
	document.getElementById('usages_search').value = '';
	document.getElementById('horse_search_input_form').value = '';
	document.getElementById('owner_search_input_form').value = '';
}

function toggle_news_secondary_search(search_form_name)
{
	document.getElementById('discipline_search_form').style.display = 'none';
	
	if (search_form_name != undefined)
	{
		target_form = document.getElementById(search_form_name);
		target_form.style.display = 'inline';
	}
}

function checkUncheckAll(theElement) 
{
    var theForm = theElement.form, z = 0;
	for(z=0; z<theForm.length;z++)
	{
      if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall')
	  	{
			theForm[z].checked = theElement.checked;
		}
	}
}

function submit_form()
{
	document.form1.submit();
}

function add_dropdown_item(text, value, dropdown_name)
{
	// Create an Option object 
	var opt = document.createElement("option");
	// Add an Option object to Drop Down/List Box
	document.getElementById(dropdown_name).options.add(opt);
	// Assign text and value to Option object
	opt.text = text;
	opt.value = value;
}

function show_image_upload_form(page_type)
{
	v = document.getElementById("news_series_news_category_id");
	w = document.getElementById("home_page_hero_checkbox");
	x = document.getElementById("image_upload_form");
	y = document.getElementById("image_upload_form_displayed");
	z = document.getElementById("article_level_id_dropdown");
	
	if (page_type != "News")
	{
		//update the category dropdown with the series options
		v.length = 0;
		
		add_dropdown_item('Please select a group...','0','news_series_news_category_id');
		add_dropdown_item('Ball','7','news_series_news_category_id');
		add_dropdown_item('Dressage','6','news_series_news_category_id');
		add_dropdown_item('Endurance','3','news_series_news_category_id');
		add_dropdown_item('Eventing','4','news_series_news_category_id');
		add_dropdown_item('Show Jumping','5','news_series_news_category_id');
		add_dropdown_item('Other','8','news_series_news_category_id');
		add_dropdown_item('Polo','1','news_series_news_category_id');
		add_dropdown_item('Showing - Retrained Racehorse Championship','10','news_series_news_category_id');
		add_dropdown_item('Showing - ROR/SEIB Racehorse to Riding Horse','12','news_series_news_category_id');
		add_dropdown_item('Showing - The ROR/TARRA in-hand','11','news_series_news_category_id');
		add_dropdown_item('Showing - The ROR/Tattersalls Show Series','9','news_series_news_category_id');
				
		w.style.display = "none";
		x.style.display = "none";		
		y.value = "0";
		z.style.display = "none";		
	}
	else
	{
		//update the category dropdown with the news options
		v.length = 0;
		
		add_dropdown_item('Please select a group...','0','news_series_news_category_id');
		add_dropdown_item('Ball','7','news_series_news_category_id');
		add_dropdown_item('Dressage','6','news_series_news_category_id');
		add_dropdown_item('Endurance','3','news_series_news_category_id');
		add_dropdown_item('Eventing','4','news_series_news_category_id');
		add_dropdown_item('Show Jumping','5','news_series_news_category_id');
		add_dropdown_item('Other','8','news_series_news_category_id');
		add_dropdown_item('Polo','1','news_series_news_category_id');
		add_dropdown_item('Showing','2','news_series_news_category_id');
		
		w.style.display = "block";
		x.style.display = "block";		
		y.value = "1";
		z.style.display = "block";
	}

	return true;
}

function toggle_visibility(div_name)
{
	x = document.getElementById(div_name);
	
	if (x.style.display == "block")
	{
		x.style.display = "none";
	}
	else
	{
		x.style.display = "block";
	}

	return true;
}