/* To open popup windows */
function popup(mylink, windowname, width, height, scrollbar){
	if (! window.focus)return true;
	var href;
	if (typeof(mylink) == 'string')
		href=mylink;
	else
		href=mylink.href;
		prop = "width="+ width +",height="+ height +",scrollbars="+ scrollbar;
		window.open(href, windowname, prop);
	return false;
}

/* To close popup windows */
function close_window(){
	window.close();
	return false;
}

/* Dollar prototype function used instead of getElementById() */
function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

/* Clear contents from an input form item */
function clear_contents(input_id, input_initial){
	if ($(input_id).value == input_initial) {
		$(input_id).value = "";		
	}
}

/* Show hide divs depending on which select box is selected */
function show_hide_boxes (option) {
	document.contactus_form.child_name_1.value = '';
	document.contactus_form.child_name_2.value = '';

	switch(option)
	{
		case "registration":
			$('registration').style.display='block';
			$('change_address').style.display='none';
			break;
		case "change_of_details":
			$('change_address').style.display='block';
			$('registration').style.display='none';
			break;
		case "other_enquiry":
			clear_contents('other_subject','If other subject please enter here');
			$('other_subject').focus();
			break;
		case "not_chosen":
		case "support_materials":
		case "general_queries":
		default:
			$('registration').style.display='none';
			$('change_address').style.display='none';
	}
	
}

var form_submitted = false;

function submit_form()
{
  if (form_submitted)
  {
    alert ( "Your form has already been submitted. Please wait..." );
    return false;
  }
  else
  {
    form_submitted = true;
    return true;
  }
}

