  
	$(document).ready(function() {
			
		initApplicationForm();
		
	});
	
	function initApplicationForm()	{
	
	update_DiscvoveryThru();
	update_schoolyear();
	var actionURI = window.location.pathname + "/?action=sendbroorder";
	document.sendbroorder.action = actionURI.replace(/\/\//g, "/");
	
  }// end function initApplicationForm
  
  function update_DiscvoveryThru()	{
  
	var tmp_discs = $("#discvoveryThruValues").val().split(",");
	var discs = new Array();
	
	for(var i=0;i<tmp_discs.length;i++)	{
		var disc = jQuery.trim(tmp_discs[i]);
		if (disc.length > 0)
			discs[disc] = disc;
	}	
	$("#discvoveryThru").removeOption(/./);
	$("#discvoveryThru").addOption("NULL",$("#discvoveryThruValuesCTA").val());
	$("#discvoveryThru").addOption(discs, false);
  }  
  
  function update_schoolyear()	{
  
	var d = new Date();
	var curr_year = d.getFullYear();
	$("#schoolyear").removeOption(/./);
	$("#schoolyear").addOption(curr_year + " - " + (curr_year + 1),curr_year + " - " + (curr_year + 1),true);
	$("#schoolyear").addOption((curr_year + 1) + " - " + (curr_year + 2),(curr_year + 1) + " - " + (curr_year + 2),false);
	
  }
  
  function validate_entries()	{
	
	var mandatory_fields = new Array("lastname","firstname","str_no","zip","city","country");
	// check mandatory fields
	for(var i=0;i<mandatory_fields.length;i++)	{
		
		if(document.sendbroorder[mandatory_fields[i]].value == "" || document.sendbroorder[mandatory_fields[i]].value == "NULL")	{
			alert($("#errormsg").val());
			document.sendbroorder[mandatory_fields[i]].focus();
			return false;
		}
		
	}
	
	return true;
	
  }