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 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);
}

// 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 = "sherbrookeAmi"; //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);
}

function printPage() {
	var param ="?";
	var txt ="print=1";
	var lien = (window.location+"").split("#")[0];
	//alert("lien:"+lien);

	if(lien.indexOf("?") > 0) {
		param="&";
	}

	if(lien.indexOf("print") < 0) {
	  window.location.href=lien + param + txt;
	}
}

function sendLink() {
	var link = "/webconcepteur/web/villedesherbrooke/"+ document.getElementById("user-language").value +"/sendlink.prt?link="+ escape(document.getElementById("full-path").value);
	link_popup(link,'false',375,420, 'location=0,statusbar=0,menubar=0,scrollbars=0,resizable=0');
}

function navigDropDownMenu(mySelect) {
	if (mySelect.options[mySelect.selectedIndex].value != 0) {
		var myIndex = mySelect.selectedIndex;
		mySelect.selectedIndex=0;
		location.href = mySelect.options[myIndex].value;
	}
}