// JavaScript Functions by Bevisions

function set_image(current_image)
{
	document.images["main_image"].src = current_image.src;
}

//on change of combobox change province combobox options.
var province 	= new Array(3);
province[0]  	= new Array(10);

province[0][0]  = "Antwerpen";
province[0][1]  = "West-Vlaanderen";
province[0][2]  = "Oost-Vlaanderen";
province[0][3]  = "Brabant-Wallon";
province[0][4]  = "Hainaut";
province[0][5]  = "Luxembourg";
province[0][6]  = "Vlaams Brabant";
province[0][7]  = "Liege";
province[0][8]  = "Namur";
province[0][9]  = "Limburg (B)";

province[1]  = new Array(12);

province[1][10]   = "Friesland";
province[1][11]   = "Flevoland";
province[1][12]   = "Noord-Holland";
province[1][13]   = "Utrecht";
province[1][14]   = "Zuid-Holland";
province[1][15]   = "Noord-Brabant";
province[1][16]   = "Zeeland";
province[1][17]   = "Groningen";
province[1][18]   = "Drenthe";
province[1][19]   = "Overijssel";
province[1][20]  = "Gelderland";
province[1][21]  = "Limburg";

province[2]  = "";

function change_provinces(combobox, formName, selectName)
{
	document.forms[formName].province_id.options.length = 1;
	var mindex = combobox.value-1;
	
	if(combobox.value == 2)
	{
		ivalue = 10;
		do_loops = 12;
	}
	else
	{
		ivalue = 0;
		do_loops = province[mindex].length;
	}
	
	if(province[mindex].length == 0)
	{
		document.forms[formName].province_id.options[0] = new Option('-- No Province --','');
	}
	else
	{
		document.forms[formName].province_id.options[0] = new Option('-- Any Province --','');
		for(i=0;i< do_loops;i++)
		{
			option_value = ivalue+i+1;
			option_index = i+1;
			document.forms[formName].province_id.options[option_index] = new Option(province[mindex][(ivalue+i)],option_value);
		}
	}
}

function open_page(element, path, tab_month)
{
	document.location.href= path+element.value+"/"+tab_month+"/";
}

function set_bgcolor(element_id, color)
{
	var content = document.getElementById(element_id);
	content.style.background = color;
}

/* javascript function to update form field
 *  field		form field that is being counted
 *  count		form field that will show characters left
 *  maxchars 	maximum number of characters	
*/
function characterCount(field, count, maxchars) {
	if (field.value.length > maxchars) {
		field.value = field.value.substring(0, maxchars);
		alert("Error:\n\n- You are only allowed to enter up to "+maxchars+" characters.");
	} else {
		count.value = maxchars - field.value.length;
	}
}
