function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function check_input_focus(welches_input, bezeichnung) {
  if (welches_input.value==bezeichnung) {welches_input.value="";}
}

function check_input_blur(welches_input, bezeichnung) {
  if (welches_input.value=="" || welches_input.value==" " || welches_input.value=="  " || welches_input.value=="   ") {welches_input.value=bezeichnung;}
}

function geturl(url, target) {
  window.open(url,target);
}

function openCountryInfo(link) {
  window.open("http://www.msf.org/msfinternational/countries"+link);
}

function check_hr_form() {
	var errortext = 'Prosím, vyplntě hvězdičkou označena políčka';
	if (false == selectFieldNotEmpty('f_salutation', errortext )) {
		return false;
	}
	if (false == formFieldNotEmpty('f_first_name', errortext )) {
		return false;
	}
	if (false == formFieldNotEmpty('f_last_name', errortext )) {
		return false;
	}
	if (false == selectFieldNotEmpty('f_profession', errortext )) {
		return false;
	}
	if (false == formFieldNotEmpty('f_diploma', errortext )) {
		return false;
	}
	if (false == formFieldNotEmpty('f_year_of_degree', errortext )) {
		return false;
	}
	if (false == selectFieldNotEmpty('f_good_english', errortext )) {
		return false;
	}
	if (false == formFieldNotEmail('f_email', errortext )) {
		return false;
	}
	if (false == formFieldNotEmpty('f_street', errortext )) {
		return false;
	}
	if (false == formFieldNotEmpty('f_street_number', errortext )) {
		return false;
	}
	if (false == formFieldNotEmpty('f_zip', errortext )) {
		return false;
	}
	if (false == formFieldNotEmpty('f_city', errortext )) {
		return false;
	}
	if (false == selectFieldNotEmpty('f_country', errortext )) {
		return false;
	}
	if (false == formFieldNotEmpty('code', errortext )) {
		return false;
	}
	return true;
}

function check_hr_form_en () {
	var errortext = 'Please fill in all fields marked with *';
	if (false == selectFieldNotEmpty('f_salutation', errortext )) {
		return false;
	}
	if (false == formFieldNotEmpty('f_first_name', errortext )) {
		return false;
	}
	if (false == formFieldNotEmpty('f_last_name', errortext )) {
		return false;
	}
	if (false == selectFieldNotEmpty('f_profession', errortext )) {
		return false;
	}
	if (false == formFieldNotEmpty('f_diploma', errortext )) {
		return false;
	}
	if (false == formFieldNotEmpty('f_year_of_degree', errortext )) {
		return false;
	}
	if (false == selectFieldNotEmpty('f_good_english', errortext )) {
		return false;
	}
	if (false == formFieldNotEmail('f_email', errortext )) {
		return false;
	}
	if (false == formFieldNotEmpty('f_street', errortext )) {
		return false;
	}
	if (false == formFieldNotEmpty('f_street_number', errortext )) {
		return false;
	}
	if (false == formFieldNotEmpty('f_zip', errortext )) {
		return false;
	}
	if (false == formFieldNotEmpty('f_city', errortext )) {
		return false;
	}
	if (false == selectFieldNotEmpty('f_country', errortext )) {
		return false;
	}
	if (false == formFieldNotEmpty('code', errortext )) {
		return false;
	}
	return true;
}

function check_donation_form() {
	var errortext = 'Prosím, vyplntě hvězdičkou označena políčkaka';
	if (false == formFieldNotEmail('f_email', errortext)) {
		return false;
	}
	return true;
}

function check_contact_form() {
	var errortext = 'Prosím, vyplntě hvězdičkou označena políčkaka';
	if (false == selectFieldNotEmpty('f_salutation', errortext)) {
		return false;
	}
	if (false == formFieldNotEmpty('f_first_name', errortext)) {
		return false;
	}
	if (false == formFieldNotEmpty('f_last_name', errortext)) {
		return false;
	}
	if (false == formFieldNotEmail('f_email', errortext)) {
		return false;
	}
	if (false == formFieldNotEmpty('f_message', errortext)) {
		return false;
	}
	return true;
}

function check_contact_form_en() {
	var errortext = 'Please fill in all fields marked with *';
	if (false == selectFieldNotEmpty('f_salutation', errortext )) {
		return false;
	}
	if (false == formFieldNotEmpty('f_first_name', errortext )) {
		return false;
	}
	if (false == formFieldNotEmpty('f_last_name', errortext )) {
		return false;
	}
	if (false == formFieldNotEmail('f_email', errortext )) {
		return false;
	}
	if (false == formFieldNotEmpty('f_message', errortext )) {
		return false;
	}
	return true;
}

function check_nl_form() {
	var errortext = 'Prosím, vyplntě hvězdičkou označena políčka';
	if (false == selectFieldNotEmpty('f_salutation', errortext )) {
		return false;
	}
	if (false == formFieldNotEmpty('f_first_name', errortext )) {
		return false;
	}
	if (false == formFieldNotEmpty('f_last_name', errortext )) {
		return false;
	}
	if (false == formFieldNotEmail('f_email', errortext )) {
		return false;
	}
	return true;
}

function check_flager_form() {
	var errortext = 'Prosím, vyplntě hvězdičkou označena políčkaka';
	if (false == selectFieldNotEmpty('f_salutation', errortext)) {
		return false;
	}
	if (false == formFieldNotEmpty('f_first_name', errortext)) {
		return false;
	}
	if (false == formFieldNotEmpty('f_last_name', errortext)) {
		return false;
	}
	if (false == formFieldNotEmail('f_email', errortext)) {
		return false;
	}
	return true;
}

function formFieldNotEmpty(elementId, messageIfEmpty) {
	var obj;
	obj = document.getElementById(elementId);
	if (obj) {
		if (obj.value.length == 0) {
			alert(messageIfEmpty);
			obj.focus();
			return false;
		}
		return true;
	}
	throw "Element with id '" + elementId + "' not found";
}

function selectFieldNotEmpty(elementId, messageIfEmpty) {
	var obj;
	obj = document.getElementById(elementId);
	if (obj) {
		if ( (obj.options[obj.selectedIndex].text == "Vyberte") || (obj.options[obj.selectedIndex].text == "Please select") || (obj.options[obj.selectedIndex].text == "") ) {
			alert(messageIfEmpty);
			obj.focus();
			return false;
		}
		return true;
	}
	throw "Element with id '" + elementId + "' not found";
}



function formFieldNotEmail(elementId, messageIfEmpty) {
	var obj;
	obj = document.getElementById(elementId);
	if (obj) {
		if (!validEmail(obj.value)) {
			alert(messageIfEmpty);
			obj.focus();
			return false;
		}
		return true;
	}
	throw "Element with id '" + elementId + "' not found";
}

function validEmail (emailStr) {
	/* The following is the list of known TLDs that an e-mail address must end with. */
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

	/* The following pattern is used to check if the entered e-mail address
	fits the user@domain format.  It also is used to separate the username
	from the domain. */
	var emailPat=/^(.+)@(.+)$/;

	/* The following string represents the pattern for matching all special
	characters.  We don't want to allow special characters in the address. 
	These characters include ( ) < > @ , ; : \ " . [ ] */
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

	/* The following string represents the range of characters allowed in a 
	username or domainname.  It really states which chars aren't allowed.*/
	var validChars="\[^\\s" + specialChars + "\]";

	/* The following pattern applies if the "user" is a quoted string (in
	which case, there are no rules about which characters are allowed
	and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
	is a legal e-mail address. */
	var quotedUser="(\"[^\"]*\")";

	/* The following pattern applies for domains that are IP addresses,
	rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
	e-mail address. NOTE: The square brackets are required. */
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

	/* The following string represents an atom (basically a series of non-special characters.) */
	var atom=validChars + '+';

	/* The following string represents one word in the typical username.
	For example, in john.doe@somewhere.com, john and doe are words.
	Basically, a word is either an atom or quoted string. */
	var word="(" + atom + "|" + quotedUser + ")";

	// The following pattern describes the structure of the user
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

	/* The following pattern describes the structure of a normal symbolic
	domain, as opposed to ipDomainPat, shown above. */

	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

	/* Finally, let's start trying to figure out if the supplied address is valid. */
	/* Begin with the coarse pattern to simply break up user@domain into
	different pieces that are easy to analyze. */

	var matchArray=emailStr.match(emailPat);

	if (matchArray==null) {
		/* Too many/few @'s or something; basically, this address doesn't
		even fit the general mould of a valid e-mail address. */
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];

	// Start by checking that only basic ASCII characters are in the strings (0-127).
	for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
			return false;
		}
	}
	for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
			return false;
	  }
	}
	// See if "user" is valid 
	if (user.match(userPat)==null) {
		// user is not valid
		return false;
	}

	// Domain is symbolic name.  Check if it's valid.
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
			return false;
	  }
	}

	// Make sure there's a host name preceding the domain.
	if (len<2) {
		return false;
	}

	// If we've gotten this far, everything's valid!
	return true;
}

String.prototype.ncr2c = function( ) {
	return this
		.replace( /&#x([\da-f]{2,4});/gi,
		function( $0, $1 ) { return String.fromCharCode( "0x" + $1 ) } )
}
String.prototype.c2ncr = function( ) {
	return this	.ncr2c( ).replace( /./g,
		function( $0 ) { return "&#x" + $0.charCodeAt( ).toString( 16 ).toUpperCase( ) + ";" } )
}