function uvfWindowCenter(nWidth, nHeight) 
{
	var nAvailWidth = window.top.screen.availWidth;
	var nAvailHeight = window.top.screen.availHeight;
	var nWindowLeft = Math.round((nAvailWidth - nWidth) / 2);
	var nWindowTop = Math.round((nAvailHeight - nHeight) / 2);
	return "left="+nWindowLeft+",top="+nWindowTop+",width="+nWidth+",height="+nHeight
}
function WindowFixedOpen(Href, Name, Params, nWidth, nHeight)
{
var windowParams = uvfWindowCenter(nWidth, nHeight)
window.open(Href, Name,windowParams + ',' + Params);
}
function RestartApplication(Url,Contexte)
{
try {
	window.opener.document.location.href = Url + Contexte;
	}
catch (ex)
	{window.open ("Fedala.aspx?code=Fedala&code=&Item=&" + Contexte, "Fedala")}
	window.close();
}
function ConfirmDesabonnement(TextConfirm)
{
if (confirm(TextConfirm))
{
	document.getElementById('ihDesabonner').value = "O";
}
return true
}

function ConvertCodeCleV9(codeDico, codeCle) 
{
	return codeDico + '~' + codeCle.replace(/\t/ig,'~')
}

function ConvertUrl2V9(url, codeDico, codeCle) 
{
	return url + ConvertCodeCleV9(codeDico, codeCle)
}
function AddUrlContexte(url)
{
	var sParams = document.location.search
	if (sParams.length > 0) sParams = sParams.slice(1)
	var rgParams = sParams.split("&")
	for (var iParam in rgParams) {
		if (rgParams[iParam].substring(0,3).toUpperCase() == "ID=") {
			if (url.length > 0) {
				return url + "&" + rgParams[iParam];
			} else {
				return rgParams[iParam];
			}
		}
	}
	return url;
}
function SetFocusSubmit(sIdBouton)
{
	if (event.keyCode && event.keyCode == 13)
            {
                document.getElementById(sIdBouton).click();
                return false
            }
            return true
}
function RefreshBackgroundPage()
{
try {
	window.opener.document.location.replace("Fedala.aspx");
	}
catch (ex)
	{window.open("Fedala.aspx", "Fedala")}
}
// Function retrieved from: http://cass- hacks.com/articles/code/js_url_encode_decode/  
function URLEncode(clearString) {
    var output = '';
    var x = 0;
    clearString = clearString.toString();
    var regex = /(^[a-zA-Z0-9_.]*)/;
    while (x < clearString.length) {
        var match = regex.exec(clearString.substr(x));
        if (match != null && match.length > 1 && match[1] != '') {
            output += match[1];
            x += match[1].length;
        } else {
            if (clearString[x] == ' ')
                output += '+';
            else {
                var charCode = clearString.charCodeAt(x);
                var hexVal = charCode.toString(16);
                output += '%' + (hexVal.length < 2 ? '0' : '') + hexVal.toUpperCase();
            }
            x++;
        }
    }
    return output;
}

// Retrieved from: http://www.htmlcodetutorial.com/forms/index_famsupp_157.html  
function SubmitOnEnter(myfield, e) {
    var keycode;
    if (window.event)
        keycode = window.event.keyCode;
    else if (e)
        keycode = e.which;
    else
        return true;
    if (keycode == 13) {
        SearchSite();
        return false;
    }
    else
        return true;
}
function SearchSite() {
    document.location.href = 'http://www.unevieafedala.com/ancienseleves/search.aspx?cx=partner-pub-0813597321509367%3Avbge3fzki56&cof=FORID%3A10&ie=UTF-8&q=' + URLEncode(document.getElementById('q').value) + '&sa=Search';
}