function defaultValueInput(focus, inputValue) {
	if (focus) {
	  if (document.search.query.value == inputValue) {
		  document.search.query.value = "";
		}
	}
	else {
	  if (document.search.query.value == "") {
		  document.search.query.value = inputValue;
		}
	}
}

function flipVisibility(strIdVisible, strIdHidden) {
	document.getElementById(strIdHidden).style.display = "none";
	document.getElementById(strIdVisible).style.display = "block";	
}

/* Function that validate the email address against a specific email regular expression */
function validateEmail(strCourriel) {
	
	var reg = /^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$/;
	
	return reg.test(strCourriel);
}

function valideFormAdrenaline(strLanguage) {
	var strMesgEmptyEmail;
	var strMesgEmailError;
	if (strLanguage == "fr") {
		strMesgEmptyEmail = "Vous devez saisir votre adresse de courriel.";
		strMesgEmailError = "Vous devez saisir une adresse de courriel valide.";
	}
	else {
		strMesgEmptyEmail = "You must fill in your email address";
		strMesgEmailError = "You must fill in a valid email address";
	}
	
	if (document.getElementById("A001_posteur").value == "") {
		alert(strMesgEmptyEmail);
		return false;
	}
	else {
		if (!validateEmail(document.getElementById("A001_posteur").value)) {
			alert(strMesgEmailError);
			return false;
		}
		else {
			return true;
		}
	}
}

// POPUP STUFF

function isUndefined(v) {
    var undef;
    return v===undef;
}

function raw_popup(url, target, w, h, features, framed) {
	// pops up a window containing url optionally named target, optionally having features
	if (isUndefined(w)) w = _POPUP_W;
	if (isUndefined(h)) h = _POPUP_H;
	if (isUndefined(features)) features = _POPUP_FEATURES;
	if (isUndefined(target  )) target   = '_blank';
	if (isUndefined(framed  )) framed   = true;
	var wleft = (screen.availWidth-w-10)/2;
	var wtop = (screen.availHeight-h-90)/2;
	if (eval(framed)) {
		var theWindow = window.open('', target, 'width='+w+',height='+h+',left='+wleft+',top='+wtop+','+features);
		// var frameset et frameheader definies dans var_fr.js
		theWindow.document.open();
		theWindow.document.write(frameset);
		theWindow.document.close();
		theWindow.frames[0].location = frameheader+"?"+url;
		theWindow.frames[1].location = url;
	}else{
		var theWindow = window.open(url, target, 'width='+w+',height='+h+',left='+wleft+',top='+wtop+','+features);
	}
	theWindow.focus();
	return theWindow;
}
function link_popup(src, inframe, w, h, features) {
	// to be used in an html event handler as in: <a href="..." onclick="link_popup(this,...)" ...
	// pops up a window grabbing the url from the event source's href
	//var href = src.getAttribute('href');
	var target = "ami"; //src.getAttribute('target');
	var href = src;
	if (isUndefined(inframe)) {
		inframe = true;
		// var urlvalide definie a la fin de la lib.
		var n = urlvalide.length;
		for (var i=0; i<n; i++) {
			if (href.indexOf(urlvalide[i]) != -1) {
				inframe = false;
				break;
			}
		}
	}
	return raw_popup(href, target || '_blank', w, h, features, inframe);
}