﻿function popup(mylink, windowname, popwidth, popheight) {
	if (!window.focus) return true;
	var href;

	if (typeof (mylink) == 'string')
		href = mylink;
	else
		href = mylink.href;

	var haut = (screen.height - popheight) / 2;
	var Gauche = (screen.width - popwidth) / 2;

	retVal = window.open(href, windowname, 'top=' + haut + ',left=' + Gauche + ',height=' + popheight + ',width=' + popwidth + ',scrollbars=no');
}

function GetDepartementFromZipCode(pZipCode)
{
	var zipcode = new String(pZipCode)
	var dept = new String();

	if ((zipcode > '20000' && zipcode < '20190') || zipcode == '20223' || zipcode == '20700' || zipcode == '20900' || zipcode == '20502' || zipcode == '20503' || zipcode == '20504')
		dept = '2A';
	else
	    if (zipcode >= '20200' && zipcode <= '20620' && zipcode != '20223' && zipcode != '20502' && zipcode != '20503' && zipcode != '20504')
			dept = '2B';
		else
		    if (zipcode.substring(0, 2) == '97' || zipcode.substring(0, 2) == '98')
				if (zipcode.substring(0, 3) == '978')
					dept = '974';
				else
					dept = zipcode.substring(0, 3);
			else
				dept = zipcode.substring(0, 2);
				
	return dept;
}


function SelectOptionInList(ddl, value) {
    var i = 0;
    if (value != "") {
        for (i = 0; i < ddl.options.length; i++)
            if (ddl.options[i].value == value) {
            ddl.selectedIndex = i;
            break;
        }
    }
}

function ddlMentionSelectchanged(txtResh1, txtResh2, txtResh3, value) {
    var i = 0;
    txtResh1.value = "";
    txtResh2.value = "";
    txtResh3.value = "";
    if (value != "") {
        var s = value.split('-');
        if (s.length > 2) {
            txtResh3.value = s[2];
        }
        if (s.length > 1) {
            txtResh2.value = s[1];
        }
        if (s.length > 0) {
            txtResh1.value = s[0];
        }
    }
}
