// JavaScript Document
/*
//this function will show hidden menu items
//found in menu.php
function show_menu(show_main,total_main,show_sub,total_sub)
{
	//show all sub menu's under the main menu required
	var curr_style = "";
	var curr_span = "";
	var curr_sub=1;
	while (curr_sub <= total_main)
	{
		curr_span = "m"+show_main+"s"+curr_sub;
		curr_style = document.getElementById(curr_span).style;
		curr_style.visibility = "visible";
		curr_style.display = "block";
		curr_sub++;
	}
	
	//if required, show sub sub menus
	if (total_sub > 0)
	{
		curr_style = "";
		curr_span = "";
		curr_sub=1;
		while (curr_sub <= total_sub)
		{
			curr_span = "m"+show_main+"s"+show_sub+"ss"+curr_sub;
			curr_style = document.getElementById(curr_span).style;
			curr_style.visibility = "visible";
			curr_style.display = "block";
			curr_sub++;
		}
	}
}

//this function will hide menu items
//found in menu.php
function hide_menu(show_main,total_main,show_sub,total_sub,selected_page,selected_sub)
{
	//alert(selected_page);
	window.setTimeout("timed_hide_menu("+show_main+","+total_main+","+show_sub+","+total_sub+","+selected_page+","+selected_sub+")", 1000);
}
	
function timed_hide_menu(show_main,total_main,show_sub,total_sub,selected_page,selected_sub)
{
	//hide all sub menu's under the main menu required
	var curr_style = "";
	var curr_span = "";
	var curr_sub=1;
	while (curr_sub <= total_main)
	{
		if (selected_page != show_main)
		{
			curr_span = "m"+show_main+"s"+curr_sub;
			curr_style = document.getElementById(curr_span).style;
			curr_style.visibility = "collapse";
			curr_style.display = "none";
		}
		curr_sub++;
	}
	
	//if required, show sub sub menus
	if (total_sub > 0)
	{
		curr_style = "";
		curr_span = "";
		curr_sub=1;
		while (curr_sub <= total_sub)
		{
			if (selected_page != show_main && selected_sub != show_sub)
			{
				curr_span = "m"+show_main+"s"+show_sub+"ss"+curr_sub;
				curr_style = document.getElementById(curr_span).style;
				curr_style.visibility = "collapse";
				curr_style.display = "none";
			}
			curr_sub++;
		}
	}
}

*/

//this function is to go forwards or backwards in multi-part forms
//found in quote.php and orders.php
function submit_form(which_way)
{
	document.input_form.form_part.value = which_way;
	document.input_form.submit();
}

//this function hides and shows answers in the FAQ
//found in faq.php subpages
function show_hide_answer(answer_id, total_qus)
{
	curr_style = document.getElementById(answer_id).style;
	if (curr_style.display == "none")
	{
		//loop through other questions and close them
		i=1;
		while (i <= total_qus)
		{
			close_style = document.getElementById("answer_"+i).style;
			close_style.display = "none";
			i++;
		}
		curr_style.display = "block";
	} else
	{
		curr_style.display = "none";
	}
}

//this function checks that there is a method of contact used in the quote and order forms
//found in part_1.php of quote_form and order_form
function check_contact_details()
{
	//make sure that there is a value in the field corresponding the preference of contact
	if (document.step1.contact_method[0].checked)
	{
		if (document.step1.email.value == "")
		{
			alert ("Your preferred contact method is email, please enter your email address.");
		} else
		{
			document.step1.submit();
		}
	} else if (document.step1.contact_method[1].checked)
	{
		if (document.step1.phone.value == "")
		{
			alert ("Your preferred contact method is phone, please enter your phone number.");
		} else
		{
			document.step1.submit();
		}
	} else if (document.step1.contact_method[2].checked)
	{
		if (document.step1.fax.value == "")
		{
			alert ("Your preferred contact method is fax, please enter your fax number.");
		} else
		{
			document.step1.submit();
		}
	} else
	{
		alert ("You have not selected a preferred contact method.");
	}
}

//this function is to load any popup windows in the site
//found in FAQ section
function popwin(linkName,winWidth,winHeight)
{
	testwindow= window.open (linkName, "newwindow", "location=1,status=0,scrollbars=1,menubar=0,toolbar=0,width="+winWidth+",height="+winHeight);
}
