<!--
function cachehpimages()
{
	mapimages = new Array(); 
	mapimages[1] = new Image();
	mapimages[1].src = "/images/map_non.jpg";  
	mapimages[2] = new Image();
	mapimages[2].src = "/images/map_eu.jpg"; 
	mapimages[3] = new Image();
	mapimages[3].src = "/images/map_uk.jpg"; 
	mapimages[4] = new Image();
	mapimages[4].src = "/images/map_us.jpg"; 
	mapimages[5] = new Image();
	mapimages[5].src = "/images/map_ww.jpg";
}

function imagechanger(to)
{
	document.worldmap.src = mapimages[to].src;
}

function wipemhfield(objField)
{
	if ((objField.value == "e-mail address") || (objField.value == "Password"))
	{
		objField.value = "";
	}
}

function ChangeConfirmation(Field,SelectedValue)
{
	input_box=confirm("Are you sure you wish to change all instances of this " + document.getElementById(Field.name).name + " to '" + document.getElementById(Field.name).options[SelectedValue].text + "' ?");
	if (input_box==true)
	{ 
	// Output when OK is clicked
	return true; 
	}
	else
	{
	// Output when Cancel is clicked
	return false;
	}
}

function ConfirmAddition(Field, DropdownName)
{

	var boolConfirmation = confirm("Are you sure you wish to add '" + document.getElementById(Field.name).value + "' to the '" + DropdownName + "' dropdown? ");
	if (boolConfirmation == true)
	{
		return true;
	}
	else
	{
	return false;
	}
}

//form validation
function ValidateForm(form, lang, email) 
{
	var validate_email = email; // This fieldname is for email format validation
	var form = document[form];
	var lang = lang.toLowerCase();
	var error = text = fieldnames = langfieldnames = validemail = strIntro = "";
	var required = form.required_fields.value;
	var fieldarray = required.split("|");
	for (i=0; i<fieldarray.length; i++)
	{
		req_field_value = fieldarray[i].split("^");
		fieldnames = (fieldnames + "|" + req_field_value[0]);
		langfieldnames = (langfieldnames + "|" + req_field_value[1]);
	}
	langfieldnames = langfieldnames.substring(1,langfieldnames.length); 
	langarray = langfieldnames.split("|");
	fieldnames = fieldnames.substring(1,fieldnames.length);
	array = fieldnames.split("|");
	
	for (i=0; i<array.length; i++)
	{
		if (form[array[i]].type == "radio" || form[array[i]].type == "checkbox" || typeof(form[array[i]].type) == "undefined")
		{
			//Radio field
			var bolSelected;
			if (typeof(form[array[i]].type) != "undefined")
			{
				// Single field radio/checkbox
				//alert(array[i] + ", " + form[array[i]].type + ", " + typeof(form[array[i]].type) + ", " + "single");
				intLength = 0;
				//A single named field
				if (form[array[i]].checked == true)
				{
					//alert("Checked");
					bolSelected = true;
				}
			}
			else
			{
				//multiple field radio/checkbox
				intLength = form[array[i]].length;
				for (j = 0; j < intLength; j++)
				{
					//alert(intLength + typeof(intLength) + form[array[i]].name + "=" + j + ", " + form[array[i]][j].checked);
					//alert(form[array[i]][j].checked);
					if (form[array[i]][j].checked == true)
					{
						bolSelected = true;
					}			
				}				
			}
			if (bolSelected != true)
			{
				//alert("create error");
				error++;
				if (error < 2)
				{
					if (intLength == 0)
					{
						form[array[i]].focus();
					}
					else
					{
						form[array[i]][0].focus();
					}
				}
				text += " - " + replace(langarray[i],  "_",  " ") + "\n";
				
			}
			bolSelected = false;			
		}
		else if (form[array[i]].type == "select-one")
		{
			//select-one field
			if (form[array[i]].options[form[array[i]].selectedIndex].value != "")
			{
				bolSelected = true;
			}
			if (bolSelected != true)
			{
				error++;
				if (error < 2)
				{
					form[array[i]].focus();
				}
				text += " - " + replace(langarray[i],  "_",  " ") + "\n";
			}
			bolSelected = false;
		}
		else if (form[array[i]].type == "select-multiple")
		{
			//select-multiple field
			intLength = form[array[i]].length;
			for (j = 0; j < intLength; j++)
			{
				if (form[array[i]][j].selected == true)
				{
					if(form[array[i]][j].value != "")
					{
						bolSelected = true;
					}
				}		
			}
			if (bolSelected != true)
			{
				error++;
				if (error < 2)
				{
					form[array[i]].focus();
				}
				text += " - " + replace(langarray[i],  "_",  " ") + "\n";
			}
			bolSelected = false;
		}
		else
		{
			//Text or hidden field
			if (array[i] == validate_email)
			{
				/*emailfieldvalue = form[array[i]].value;
				atloc = emailfieldvalue.indexOf('@');
				dotloc = emailfieldvalue.indexOf('.',atloc);
				emaillength = emailfieldvalue.length;
				
				if ((atloc < 1) || (dotloc < (atloc + 2)) || ((emaillength - 3) < dotloc))
				{
					error++;
					if (error < 2)
					{
						form[array[i]].focus();
					}
					text += " - ##validemail## \n"; 
				}*/
				var emailfieldvalue=new String(form[array[i]].value);
				var filter=/^[a-z0-9]([a-z0-9_]|\-|\.)+@(([a-z0-9_]|\-)+\.)+[a-z]{2,4}$/i;
				if (!filter.test(emailfieldvalue))
				{
					error++;
					if (error < 2)
					{
						form[array[i]].focus();
					}
					text += " - ##validemail## \n";
				}
			}
			else if (form[array[i]].value == "")
			{
				error++;
				if (error < 2)
				{
					form[array[i]].focus();
				}
				text += " - " + replace(langarray[i],  "_",  " ") + "\n";
			}
		} 
	}
	if (error) 
	{
		switch (lang)
		{
			//resolve languages
			case "fr":
				validemail = "adresse e-mail valide";
				text = replace(text, "##validemail##", validemail); //Do Not edit this line
				if (error > 1)
				{
					//plural error
					strIntro = "Veuillez remplir les champs suivants:\n";
				}
				else
				{
					//single error
					strIntro = "Veuillez remplir le champ suivant:\n";
				}				
				//alert ("Veuillez remplir le (ou les) champ(s) suivant(s):\n" + text);
			break;
			case "de":
				validemail = "Gültige E-Mail-Adresse";
				text = replace(text, "##validemail##", validemail); //Do Not edit this line
				if (error > 1)
				{
					//plural error
					strIntro = "Bitte füllen Sie folgendes Felder aus:\n";
				}
				else
				{
					//single error
					strIntro = "Bitte füllen Sie folgende Feld aus:\n";
				}				
				//alert ("Bitte füllen Sie folgende(s) Feld(er) aus:\n" + text);
			break;
			case "il":
				validemail = "ëúåáú îééì îìàä";
				text = replace(text, "##validemail##", validemail); //Do Not edit this line
				if (error > 1)
				{
					//plural error
					strIntro = "àðà îìà àú äùãåú äáàéí:\n";
				}
				else
				{
					//single error
					strIntro = "àðà îìà àú äùãä äáà:\n";
				}
				text = replace(text, "- ", "");
				text = replace(text, "\n", " -\n");
				//alert ("You must fill in the following field(s):\n" + text);
			break;
			case "it":
				validemail = "Indirizzo email valido";
				text = replace(text, "##validemail##", validemail); //Do Not edit this line
				if (error > 1)
				{
					//plural error
					strIntro = "Compila i seguenti campi:\n";
				}
				else
				{
					//single error
					strIntro = "Compila il seguente campo:\n";
				}
			break;
			case "es":
				validemail = "Dirección de e-mail válida";
				text = replace(text, "##validemail##", validemail); //Do Not edit this line
				if (error > 1)
				{
					//plural error
					strIntro = "Debe rellenar el los campos siguientes:\n";
				}
				else
				{
					//single error
					strIntro = "Debe rellenar el campo siguiente:\n";
				}				
				//alert ("Debe rellenar el (los) campo(s) siguiente(s):\n" + text);
			break;
			case "nl":
				validemail = "Geldig email adres";
				text = replace(text, "##validemail##", validemail); //Do Not edit this line
				if (error > 1)
				{
					//plural error
					strIntro = "Kunt u de volgende velden invullen a.u.b.:\n";
				}
				else
				{
					//single error
					strIntro = "Kunt u het volgende veld invullen a.u.b.:\n";
				}				
				//alert ("Kunt u de volgende veld(en) invullen a.u.b.:\n" + text);
			break;
			case "at":
				validemail = "Gültige E-Mail Adresse";
				text = replace(text, "##validemail##", validemail); //Do Not edit this line
				if (error > 1)
				{
					//plural error
					strIntro = "Bitte füllen Sie folgendes Felder aus:\n";
				}
				else
				{
					//single error
					strIntro = "Bitte füllen Sie folgende Feld aus:\n";
				}
				//alert ("Bitte füllen Sie folgende(s) Feld(er) aus:\n" + text);
			break;
			default : 
				validemail = "Valid Email Address";
				text = replace(text, "##validemail##", validemail); //Do Not edit this line
				if (error > 1)
				{
					//plural error
					strIntro = "You must fill in the following fields:\n";
				}
				else
				{
					//single error
					strIntro = "You must fill in the following field:\n";
				}
				//alert ("You must fill in the following field(s):\n" + text);
		}
		alert (strIntro + text);
		return false; 
	}
	else 
	{
		return true;
	}
}

function replace(string, substring1, substring2)
{
	stringparts = string.split(substring1);
	string = stringparts.join(substring2);	
	return string;	
}

function addDownload(NewDownloadCount)
{
	if (NewDownloadCount < 10)
	{
		var strInnerHTML;
		var intThisDownloadId;
		intThisDownloadId = NewDownloadCount + 1;
		var ni = document.getElementById('Downloads');
		var newdiv = document.createElement('div');
		var divIdName = 'download_' + intThisDownloadId;
		newdiv.setAttribute('id',divIdName);
		strInnerHTML = '<strong>Download ' + intThisDownloadId + ':</strong> <span id="download' + intThisDownloadId + '_preview"></span><input type="hidden" name="download' + intThisDownloadId + '" id="download' + intThisDownloadId + '" value="" /><br />';
		strInnerHTML = strInnerHTML + '<a href="#" onclick="window.open(\'list_productassets.asp?downloadid=' + intThisDownloadId + '\', \'selectdownload\', \'width=420,height=390\'); return false;"><strong>Select/change Download</strong></a> - <a href="#" onclick="removeDownload(' + intThisDownloadId + '); return false;"><strong>Remove download</strong></a>';
		strInnerHTML = strInnerHTML + '<hr />';
		newdiv.innerHTML = strInnerHTML;
		ni.appendChild(newdiv);
		intDownloadCount = intDownloadCount + 1;
	}
	else
	{
		alert("Maximum of 10 downloads can be added");
	}
	return false;
}

function removeDownload(divNum)
{
	ReorderDownloads(divNum, intDownloadCount)

	var d = document.getElementById('downloads');
	//var olddiv = document.getElementById('download_' + divNum);
	var olddiv = document.getElementById('download_' + intDownloadCount);
	d.removeChild(olddiv);
	intDownloadCount = intDownloadCount - 1;
	return false;
}

function ReorderDownloads(divNum, DownloadCountTotal)
{
	var strInnerHTML;
	if (divNum != DownloadCountTotal)
	{
		for (i=divNum; i<DownloadCountTotal; i++)
		{
			var divIdName = document.getElementById('download' + i + '_preview');
			strInnerHTML = document.getElementById('download' + (i+1) + '_preview').innerHTML;
			divIdName.innerHTML = strInnerHTML;
			document.getElementById('download' + i).value = document.getElementById('download' + (i + 1)).value;
		}
	}
}

function RefreshImage(valImageId) {
	var objImage = document.images[valImageId];
	if (objImage == undefined) {
		return;
	}
	var now = new Date();
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}

//-->
