function ChangeFA()
{
var arg;
arg = ChangeFA.arguments;

if (arg[1] == "") 
	{ document.forms.my_form.action = arg[0]}
else
	{ document.forms.my_form.action = arg[0] + "?" + arg[1]; }

document.forms.my_form.submit();
}
function checkYear(my_day, my_month, my_year)
{
	day_obj = eval("document.my_form." + my_day)
	month_obj = eval("document.my_form." + my_month)
	year_obj = eval("document.my_form." + my_year)

	day_length = day_obj.length
	month_selected = month_obj.options[month_obj.selectedIndex].value
	year = year_obj.options[year_obj.selectedIndex].value

	old_day = day_obj.selectedIndex
	old_month =	month_obj.selectedIndex
	month_selected = parseInt(month_selected)

	if (month_selected == 2)
	{
		if (year%4 == 0 && day_length == 29)
			day_obj.options[day_length] = new Option("29","29");		
		if (year%4 != 0 && day_length == 30)
		{
			day_obj.options[day_length - 1] = null;
			if (old_day == 29)
				old_day = 0;
		}
	}
	day_obj.options[old_day].selected = true
	month_obj.options[old_month].selected = true
}

function checkMonth(my_day, my_month, my_year)
{
	day_obj = eval("document.my_form." + my_day)
	month_obj = eval("document.my_form." + my_month)
	year_obj = eval("document.my_form." + my_year)

	day_length = day_obj.length
	month_selected = month_obj.options[month_obj.selectedIndex].value
	month_selected = parseInt(month_selected)
	
	old_day = day_obj.selectedIndex
	old_month =	month_obj.selectedIndex
	
	if (month_selected == 1 || month_selected == 3 || month_selected == 5 || month_selected == 7 || month_selected == 8 || month_selected == 10 || month_selected == 12)
	{
		if (day_length == 31)
			day_obj.options[day_length] = new Option("31","31");
		if (day_length == 30)
		{
			day_obj.options[day_length] = new Option("30","30");
			day_length = day_obj.length
			day_obj.options[day_length] = new Option("31","31");
		}
		if (day_length == 29)
		{
			day_obj.options[day_length] = new Option("29","29");
			day_length = day_obj.length
			day_obj.options[day_length] = new Option("30","30");
			day_length = day_obj.length
			day_obj.options[day_length] = new Option("31","31");
		}
	}
	if (month_selected == 4 || month_selected == 6 || month_selected == 9 || month_selected == 11)
	{
		if (day_length == 30)
			day_obj.options[day_length] = new Option("30","30");
		if (day_length == 29)
		{
			day_obj.options[day_length] = new Option("29","29");
			day_length = day_obj.length
			day_obj.options[day_length] = new Option("30","30");
		}
		if (day_length == 32)
			day_obj.options[day_length-1] = null;
	}
	if (month_selected == 2)
	{
		year = year_obj.options[year_obj.selectedIndex].value
		if (year%4 == 0)
		{
			if (day_length == 32)
			{
				day_obj.options[day_length-1] = null;
				day_length = day_obj.length
				day_obj.options[day_length-1] = null;
			}
			if (day_length == 31)
				day_obj.options[day_length-1] = null;
		}
		if (year%4 != 0)
		{
			if (day_length == 32)
			{
				day_obj.options[day_length-1] = null;
				day_length = day_obj.length
				day_obj.options[day_length-1] = null;
				day_length = day_obj.length
				day_obj.options[day_length-1] = null;
			}
			if (day_length == 31)
			{
				day_obj.options[day_length-1] = null;
				day_length = day_obj.length
				day_obj.options[day_length-1] = null;
			}
			if (day_length == 30)
				day_obj.options[day_length-1] = null;
		}
	}
}

function checkWeek(my_week, my_year) 
{
	week_obj = eval("document.MainForm." + my_week)
	year_obj = eval("document.MainForm." + my_year)
	
	week_length = week_obj.length
	old_week = week_obj.selectedIndex
	year = year_obj.options[year_obj.selectedIndex].value
	
	if (year != "")
	{
		sDateYear = "01/01/" + year
		dayNum = new Date(sDateYear).getDay()
		
		if (dayNum == 5)	// First day of the year is a Friday
		{
			if (year%4 == 0 && week_length == 54)
				{	week_obj.options[week_length] = new Option("54","54"); }
		}
		else
		{
			if (week_length == 55)
			{
				week_obj.options[week_length - 1] = null;
				if (old_week == 54)
					old_week = 0;
			}
		}
	}
	week_obj.options[old_week].selected = true
}

function update(my_day, my_month, my_year)
{
	day_obj = eval("document.MainForm." + my_day)
	month_obj = eval("document.MainForm." + my_month)
	year_obj = eval("document.MainForm." + my_year)

	day_length = day_obj.length
	month_selected = month_obj.options[month_obj.selectedIndex].value
	month_selected = parseInt(month_selected)
	
	old_day = day_obj.selectedIndex
	old_month =	month_obj.selectedIndex
	
	if (month_selected == 1 || month_selected == 3 || month_selected == 5 || month_selected == 7 || month_selected == 8 || month_selected == 10 || month_selected == 12)
	{
		if (day_length == 31)
			day_obj.options[day_length] = new Option("31","31");
		if (day_length == 30)
		{
			day_obj.options[day_length] = new Option("30","30");
			day_length = day_obj.length
			day_obj.options[day_length] = new Option("31","31");
		}
		if (day_length == 29)
		{
			day_obj.options[day_length] = new Option("29","29");
			day_length = day_obj.length
			day_obj.options[day_length] = new Option("30","30");
			day_length = day_obj.length
			day_obj.options[day_length] = new Option("31","31");
		}
	}
	if (month_selected == 4 || month_selected == 6 || month_selected == 9 || month_selected == 11)
	{
		if (day_length == 30)
			day_obj.options[day_length] = new Option("30","30");
		if (day_length == 29)
		{
			day_obj.options[day_length] = new Option("29","29");
			day_length = day_obj.length
			day_obj.options[day_length] = new Option("30","30");
		}
		if (day_length == 32)
			day_obj.options[day_length-1] = null;
	}
	if (month_selected == 2)
	{
		year = year_obj.options[year_obj.selectedIndex].value
		if (year%4 == 0)
		{
			if (day_length == 32)
			{
				day_obj.options[day_length-1] = null;
				day_length = day_obj.length
				day_obj.options[day_length-1] = null;
			}
			if (day_length == 31)
				day_obj.options[day_length-1] = null;
		}
		if (year%4 != 0)
		{
			if (day_length == 32)
			{
				day_obj.options[day_length-1] = null;
				day_length = day_obj.length
				day_obj.options[day_length-1] = null;
				day_length = day_obj.length
				day_obj.options[day_length-1] = null;
			}
			if (day_length == 31)
			{
				day_obj.options[day_length-1] = null;
				day_length = day_obj.length
				day_obj.options[day_length-1] = null;
			}
			if (day_length == 30)
				day_obj.options[day_length-1] = null;
		}
	}
}
function check_date(ctrl, form) {
	obj = eval("document." + form + "." + ctrl)
	if (!obj)
	{
		alert (ctrl + " is not an object!")
		return 0
	}
	
	var err = 0
	string = obj.value
	var valid = "0123456789/"
	var ok = "yes";
	var temp;
	
	for (var i=0; i< string.length; i++) {
		temp = "" + string.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") err = 1;
	}
	if (string.length != 10) err=1
	// Date has changed to mm/dd/yyyy
	b = string.substring(0, 2) // month
	c = string.substring(2, 3)// '/'
	d = string.substring(3, 5) // day
	e = string.substring(5, 6)// '/'
	f = string.substring(6, 10) // year
	if (b<1 || b>12) err = 1
	if (c != '/') err = 1
	if (d<1 || d>31) err = 1
	if (e != '/') err = 1
	if (f<1900 || f>3000) err = 1
	if (b==4 || b==6 || b==9 || b==11) {
		if (d==31) err=1
	}
	if (b==2) {
		var g=parseInt(f/4)
		if (isNaN(g)) {
			err=1
		}
		if (d>29) err=1
		if (d==29 && ((f/4)!=parseInt(f/4))) err=1
	}
	if (err==1) {
		alert ("La date est invalide!")
		obj.select();
		return 1;
	}	
	else {
		return 0;
	}
}

function check_date1(ctrl, form) {
	obj = eval("document." + form + "." + ctrl)
	if (!obj)
	{
		alert (ctrl + " is not an object!")
	}
	
	var err = 0
	string = obj.value
	var valid = "0123456789/"
	var ok = "yes";
	var temp;
	
	for (var i=0; i< string.length; i++) {
		temp = "" + string.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") err = 1;
	}
	if (string.length != 10) err=1
	// Date has changed to dd/mm/yyyy
	b = string.substring(3, 5) // month
	c = string.substring(2, 3)// '/'
	d = string.substring(0, 2) // day
	e = string.substring(5, 6)// '/'
	f = string.substring(6, 10) // year
	if (b<1 || b>12) err = 1
	if (c != '/') err = 1
	if (d<1 || d>31) err = 1
	if (e != '/') err = 1
	if (f<1900 || f>3000) err = 1
	if (b==4 || b==6 || b==9 || b==11) {
		if (d==31) err=1
	}
	if (b==2) {
		var g=parseInt(f/4)
		if (isNaN(g)) {
			err=1
		}
		if (d>29) err=1
		if (d==29 && ((f/4)!=parseInt(f/4))) err=1
	}
	if (err==1) {
		alert ("La date est invalide!")
		obj.select();
	}	
}
function check_date_dd(my_day, my_month, my_year)
{
	day_obj = eval("document.MainForm." + my_day)
	month_obj = eval("document.MainForm." + my_month)
	year_obj = eval("document.MainForm." + my_year)
	
	if (day_obj.selectedIndex == 0 || month_obj.selectedIndex == 0 || year_obj.selectedIndex == 0)
	{
		alert ("La date est invalide!")
		day_obj.focus();
		return 1
	}
	return 0
}	

function check_empty(ctrl, form)
{
	obj = eval("document." + form + "." + ctrl)
	if (!obj)
	{
		alert (ctrl + " is not an object!")
		return 0
	}
	if (obj.value.length == 0)
	{
		alert ("Veuillez remplir les informations requises!")
		obj.focus();
		return 1
	}
	return 0
}

function check_list(ctrl, form)
{
	obj = eval("document." + form + "." + ctrl)
	if (!obj)
	{
		alert (ctrl + " is not an object!")
		return 0
	}
	my_index = obj.selectedIndex;
	//my_value = obj.options[my_index].value
	//if (my_value == "")
	if (my_index == 0)
	{
		alert ("Remplissez les informations obligatoires!")
		obj.focus();
		return 1
	}
	return 0
}

function check_combo(ctrl, form)
{
	obj = eval("document." + form + "." + ctrl)
	if (!obj)
	{
		alert (ctrl + " is not an object!")
		return 0
	}
	my_index = obj.selectedIndex;

	if (my_index == "-1")
	{
		alert ("Remplissez les informations obligatoires!")
		obj.focus();
		return 1
	}
	return 0
}

function check_int(ctrl, form)
{
	//err = check_empty(ctrl, form); if (err == 1) return 1;
	
	allowed = "0123456789"
	obj = eval("document." + form + "." + ctrl)
	
	for (counter = 0; counter < obj.value.length; counter++)
	{
		my_char = obj.value.charAt(counter)
		if (allowed.indexOf(my_char) == -1)
		{
			alert("Forme invalide. Remplissez par un nombre entier");
			obj.focus();
			return 1
		}
	}
	return 0
}	
function check_float(ctrl, form)
{
	err = check_empty(ctrl, form); if (err == 1) return 1;
	
	allowed = "0123456789."
	obj = eval("document." + form + "." + ctrl)
	
	for (counter = 0; counter < obj.value.length; counter++)
	{
		my_char = obj.value.charAt(counter)
		if (allowed.indexOf(my_char) == -1)
		{
			alert("Forme invalide. Remplissez par un nombre");
			obj.select();
			return 1
		}
	}
	return 0
}	
function validEmail(field, form)
{
	url = document[form][field].value;
	a = url.lastIndexOf("@");
	b = url.lastIndexOf(".");
	c = url.indexOf(":");
	d = url.indexOf("/");
	e = url.substring(0,a);
	f = e.indexOf("@");
	g = url.substring(a+1,url.length);
	h = g.indexOf("[");
	i = g.indexOf("]");
	j = g.indexOf("<");
	k = g.indexOf(">");
	l = url.substring(a+1,b);
	m = url.substring(b+1,url.length);
	n = url.substring(0,a);
	o = 0;
	
		if (a > b) {o++};
		 if (c != -1) {o++};
		  if (d != -1) {o++};
			 if (f != -1) {o++};
			  if (h != -1) {o++};
				 if (i != -1) {o++};
				  if (j != -1) {o++};
					 if (k != -1) {o++};
					  if (l.length < 3) {o++};
						 if (m.length < 2) {o++};
						  if (n.length < 1) {o++};
							 if (o != 0) 
							 {
							 	alert("Le format de l'adresse email n'est pas valable!");
								document[form][field].select();
								return 1
							 }
	return 0
}
function check_email(ctrl, form) {
	obj = eval("document." + form + "." + ctrl)
	if (!obj)
	{
		alert (ctrl + " is not an object!")
		return 0
	}
	
	// Return false if the E-Mail field is blank.
	err = check_empty(ctrl, form); if (err == 1) return 1;
   
	 // Return false if e-mail field does not contain a '@' and '.' .
   if (obj.value.indexOf ('@',0) == -1 || 
       obj.value.indexOf ('.',0) == -1)
      {
      alert("La forme de l'addresse email n'est pas acceptée.");
			obj.focus();
      return 1
      }
  return 0
}

function check_area(ctrl, form)
{
	obj = eval("document." + form + "." + ctrl)
	if (!obj)
	{
		alert (ctrl + " is not an object!")
		return 0
	}
	if (obj.value.length == 0)
	{
		alert ("Remplissez les informations obligatoires!")
		obj.focus();
		return 1
	}
	if (obj.value.length > 10000)
	{
		alert ("Field size is too large! Please limit your text to 10000 letters.")
		obj.focus();
		return 1
	}
	return 0
}

function check_radio(ctrl, form) 
{
	obj = eval("document." + form + "." + ctrl)
	if (!obj)
	{
		alert (ctrl + " is not an object!")
		return 0
	}
	for (var i = 0; i < obj.length; i++)
	{
		if (obj[i].checked)
		{
			i = obj.length + 1;
			return 0
		}
	}
	alert("Remplissez les informations obligatoires!");
	obj[0].focus();
	return 1;
}

function check_box(ctrl, form) 
{
	obj = eval("document." + form + "." + ctrl)
	if (!obj)
	{
		alert (ctrl + " is not an object!")
		return 0
	}
	for (var i = 0; i < obj.length; i++)
	{
		if (obj[i].checked)
		{
			i = obj.length + 1;
			return 0
		}
	}
	alert("Remplissez les informations obligatoires!");
	obj[0].focus();
	return 1;
}

function check_time(ctrl1, ctrl2, form)
{
	obj1 = eval("document." + form + "." + ctrl1)
	obj2 = eval("document." + form + "." + ctrl2)
	
	if ((!obj1) || (!obj2))
	{
		alert (ctrl1 + " or " + ctrl2 + " is not an object!")
		return 0
	}
	my_index1 = obj1.selectedIndex;
	my_value1 = obj1.options[my_index1].value
	my_index2 = obj2.selectedIndex;
	my_value2 = obj2.options[my_index2].value
	if (parseInt(my_value1) >= parseInt(my_value2))
	{
		alert ("La forme du temps est incorrecte!")
		obj2.focus();
		return 1
	}
	return 0
}

function check_password(ctrl, form, field, len)
{
	obj = eval("document." + form + "." + ctrl)
	if (!obj)
	{
		alert (ctrl + " is not an object!")
		return 0
	}
	if (obj.value.length == 0)
	{
		alert ("Remplissez les informations obligatoires!")
		obj.focus();
		return 1
	}
	if (obj.value.length < len)
	{
		alert (field + " doit être d'au moins " + len + " charactèrs!")
		obj.focus();
		return 1
	}
	return 0
}
function check_confpass(ctrl1, ctrl2, form)
{
	obj1 = eval("document." + form + "." + ctrl1)
	obj2 = eval("document." + form + "." + ctrl2)
	
	if (obj2.value.length == 0)
	{
		alert ("Remplissez les informations obligatoires!")
		obj2.focus();
		return 1
	}
	if (obj1.value != obj2.value)
	{
		alert ("Le mot de passe n'a pas été confirmé correctement.");
		obj1.value = "";
		obj2.value = "";
		obj1.focus();
		return 1
	}
	return 0
}
function check_del(temp) {
	if (confirm ("Vous êtes sures d'effacer ce " + temp + "?"))
		return true;
	return false;
}

function confirm_msg(temp) {
	if (confirm (temp))
		return true;
	return false;
}

function addBookmark() {
	if (window.external)
    external.AddFavorite("http://www.sogecapliban.com", "SOGECAP LIBAN")
  else
    alert("Your browser doesn't support this feature.");
}

function fnSet(){
        oHomePage.setHomePage(oHomeHref.value);
        event.returnValue = false;
}

function prt() {
	print();
	window.opener.focus();
	self.close();
	return true
}
function prt1() {
	window.print();
	return true
}
function popupBanner(pic) {
	window.open("viewpic.asp?photo=" + pic,"Banner","width=600,height=200,top=50,left=100,scrollbars=1");
	return true;
}
function popupPrint(url, id) {
	if (id == "") {
		prt1();
		return true
	}
	else {
		window.open(url + "?id=" + id,"Print","width=600,height=300,top=50,left=100,scrollbars=1,resizable=1");
		return true;
	}
}

