/*
Use in <HEAD> with DEFER keyword wrapped in conditional comments:
<!--[if lt IE 7]>
<script defer type="text/javascript" src="scripts/pngfix.js"

></script>
<![endif]-->
*/
/*
var arVersion = navigator.appVersion.split("MSIE");
var version = parseFloat(arVersion[1]);




if ((version >= 5.5) && (document.body.filters)) 
{
   for(var i=0; i<document.images.length; i++)
   {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
      {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText 
         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
         img.outerHTML = strNewHTML
         i = i-1
      }
   }
}
*/
function open_lang()
{
	if(document.getElementById('divup').style.display == 'none')
	{
		Effect.BlindDown('divup');
		divposresize('divup');
		window.onresize = function(event) {divposresize('divup');};
	}
	else
	{
		close_lang();
	}
	
}

function close_lang()
{
	Effect.BlindUp('divup');
	window.onresize = function(event) {};
}

function divposresize(my_box)
{
	if (document.body)
	{
		var larg = (document.body.clientWidth);
	}
	else
	{
		var larg = (window.innerWidth);
	}
	var xx = ( (larg - 900) / 2) + 762;
	document.getElementById(my_box).style.left = xx + 'px';
}

function hideall(alistdiv)
{
	for (i=0; i < alistdiv.length; ++i)
	{
		document.getElementById(alistdiv[i]).style.display = 'none';
	}
}

function is_valid(email)
{
	var verif_email = /^[a-zA-Z0-9_\.-]+@[a-zA-Z0-9-]{2,}[\.][a-zA-Z]{2,3}$/;

	if (verif_email.exec(email) == null)
		return false;
	return true;
}

function my_check(titi, toto)
{
	if (titi != '')
	{
		toto.style.backgroundColor = '#FFFFFF';
		return true;
	}
	else
	{
		toto.style.backgroundColor = '#EE6E6D';
		return false;
	}
}

function update_form()
{
	document.getElementById('form_work').style.display='none';
	document.getElementById('good_send').style.display='block';
}

function send_form(formu)
{
	if (formu.r1.checked)
	{
		var civil = formu.r1.value
	}
	else if (formu.r2.checked)
	{
		var civil = formu.r2.value
	}
	else
	{
		var civil = formu.r3.value
	}

	var lname	= formu.form_lname.value;
	var fname	= formu.form_fname.value;
	var date	= formu.form_date.value;
	var add		= formu.form_add.value;
	var zip		= formu.form_zip.value;
	var city	= formu.form_city.value;
	var country	= formu.form_country.value;
	var tel		= formu.form_tel.value;
	var cell	= formu.form_cell.value;
	var email	= formu.form_email.value;
	var edu		= formu.form_edu.value;
	var skill	= formu.form_skill.value;
	var xp		= formu.form_xp.value;
	var lang	= formu.form_lang.value;
	var check	= true;

	if (my_check(lname, formu.form_lname) == false)
	{
		check = false;
	}
	if (my_check(fname, formu.form_fname) == false)
	{
		check = false;
	}
	if (my_check(date, formu.form_date) == false)
	{
		check = false;
	}
	if (my_check(add, formu.form_add) == false)
	{
		check = false;
	}
	if (my_check(zip, formu.form_zip) == false)
	{
		check = false;
	}
	if (my_check(city, formu.form_city) == false)
	{
		check = false;
	}
	if (my_check(country, formu.form_country) == false)
	{
		check = false;
	}
	if (my_check(edu, formu.form_edu) == false)
	{
		check = false;
	}
	if (my_check(skill, formu.form_skill) == false)
	{
		check = false;
	}
	if (my_check(xp, formu.form_xp) == false)
	{
		check = false;
	}
	if (my_check(lang, formu.form_lang) == false)
	{
		check = false;
	}

	if (tel != '' || cell != '')
	{
		formu.form_tel.style.backgroundColor = '#FFFFFF';
		formu.form_cell.style.backgroundColor = '#FFFFFF';
	}
	else
	{
		check = false;
		formu.form_tel.style.backgroundColor = '#EE6E6D';
		formu.form_cell.style.backgroundColor = '#EE6E6D';
	}

	if (is_valid(email) == true)
	{
		formu.form_email.style.backgroundColor = '#FFFFFF';
	}
	else
	{
		check = false;
		formu.form_email.style.backgroundColor = '#EE6E6D';
	}

	if (check == true)
	{
		var url		= "../../_script/send_mail.ajax.php";
		var pars	= 'civil='+civil+'&nom='+lname+'&prenom='+fname+'&date='+date+'&adresse='+add+'&zip='+zip+'&city='+city+'&country='+country+'&phone='+tel+'&por='+cell+'&email='+email+'&formation='+edu+'&etude='+skill+'&xp='+xp+'&lang='+lang;
		var myAjax = new Ajax.Request(
			url,
			{
				method			: 'post', 
				parameters		: pars,
				onComplete		: 
					function ajax_pchange_success(toto)
					{
						if (toto.responseText == 1)
							update_form();
					}
			}
		);
	}
}


function ajax_organi( company, city)
{
		var url		= "../../_script/organi.ajax.php";
		var pars	= 'company='+company+'&city='+city;
		var myAjax = new Ajax.Updater(
			'organivar',
			url,
			{
				method			: 'post', 
				parameters		: pars,
				onComplete		: 
					function ajax_organi_success(toto)
					{
						window.location="#top-orga";
					}
			}
		);

}
