// JavaScript Document


var urlAddress = "http://www.ecpartners.es/"; 
var pageName = "Euroconsulting Partners"; 
function addToFavorites(anchor) 
{ 
if (window.external) 
{ 
window.external.AddFavorite(anchor.getAttribute('href'), anchor.getAttribute('title')); 
} 
} 


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


/******** popup virtuel ********/
function getScrollY() {
	var scrOfY = 0;
	if(typeof(window.pageYOffset)=='number') { // Netscape compliant
		scrOfY = window.pageYOffset;
	}
	else if(document.body&&(document.body.scrollTop)) {// DOM compliant
		scrOfY = document.body.scrollTop;
	}
	else if(document.documentElement&&(document.documentElement.scrollTop)) {//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
	}
	return scrOfY;
}
win=false;
function popup_virtuel(page,titre,largeur,hauteur) {
	try {
	haut = getScrollY()+50;
	if (win) {
		win.setTitle(titre);
		win.setURL(page);
		win.show();
		win.setSize(largeur, hauteur);
		win.setLocation(haut, 500);
	}
	else {
		win = new Window ("modification", {
			className: "mac_os_x",
			title: titre, 
			top:haut, left:500, width:largeur, height:hauteur, 
			showEffect: Element.show,
			hideEffect: Element.hide,
			url: page
		});
		win.show();
	}
	} catch(e) { alert(e) }
}

function limit_to(tab, n){
	var cpt = 0;
	for(i=0; i<tab.length;i++){
		if (tab[i].selected){
			cpt++;
		}
	}
	if (cpt > n){
		alert("Pas plus de "+n+" choix possibles!");
		for(i=0; i<tab.length;i++){
			tab[i].selected = false;
		}
	}
}

/******** uploader flash ********/
win_up=false;
_id=false;
_type=false;
_cpt=1;
ajout=false;
function changerMedia(type,id,nom_fichier) {
	haut = getScrollY()+50;
	_id = id;
	if (type[0]=='+') {
		ajout=true;
		type=type.substring(1);
	}
	_type = type;
	if (! nom_fichier) nom_fichier = '';
	if (win_up) {
		win_up.setURL('/uploader.php?type='+type+'&nom_fichier='+nom_fichier);
		win_up.show(true);
		win_up.setLocation(haut, 50);
	}
	else {
		win_up = new Window ("upload", {
			className: "mac_os_x",
			title: 'upload', 
			top:haut, left:50, width:317, height:80, 
			showEffect: Element.show,
			hideEffect: Element.hide,
			minimizable:false,
			maximizable:false,
			closable:false,
			url: '/uploader.php?type='+type+'&nom_fichier='+nom_fichier
		});
		win_up.show(true);
	}
}
function flashUploaded(nouveauNom){
	parent.uploaded(nouveauNom);
}
function flashAnnuler(){
	parent.win_up.hide();
}
function uploaded(nouveauNom){
	win_up.hide();
	if (nouveauNom.length > 30){
		nouveauNom_short = nouveauNom.substr(0,27)+'...';
	}
	else {
		nouveauNom_short = nouveauNom;
	}
	switch (_type){
		case 'vignette' :
			$(_id).src = '/images/vignettes/'+nouveauNom;
			$('hidden_'+_id).value = nouveauNom;
			element = '<input type="hidden" name="truc"></input>';
			$('form_buzz').insert(element, {position:top});
		break;
		case 'image' :
			nouveauNom = nouveauNom.strip();
//			$(_id).value = nouveauNom;
			//$('photos_form').submit();
		break;
		case 'gif' :
			$(_id).src = '/upload/'+nouveauNom;
		break;
		case 'pdf' :
		case 'document' :
			if (ajout){
				nouveauNom = nouveauNom.strip();
				element = '\
					<div id="etude_'+_cpt+'">\
						<input type="hidden" name="hidden_'+_cpt+'" id="hidden_{$etude.id_etude}" value="'+nouveauNom+'" />\
						<a href="/upload/'+nouveauNom+'">'+nouveauNom_short+'</a><br />\
						<span class="faux_lien" onclick="supprimerMedia(\''+nouveauNom+'\','+_cpt+');">supprimer</span>\
					</div><br />';
				_cpt++;
				$('etudes').insert(element, {position:'top'});
			}
			else {
				$(_id).value = nouveauNom;
				$('lien_'+_id).innerHTML = '<a href="/upload/'+nouveauNom+'">'+nouveauNom_short+'</a>';
			}
		break;
	}
}


function valide(formulaire){
	if ($('nom').value.length < 1) {
		alert('Veuillez entrer un nom');
		$('nom').focus();
		return false;
	}
	if ($('prenom').value.length < 1) {
		alert('Veuillez entrer un prenom');
		$('prenom').focus();
		return false;
	}
	if ($('adresse').value.length < 1) {
		alert('Veuillez entrer une adresse');
		$('adresse').focus();
		return false;
	}
	if ($('ville').value.length < 1) {
		alert('Veuillez entrer une ville');
		$('ville').focus();
		return false;
	}
	if ($('code_postal').value.length < 1) {
		alert('Veuillez entrer un code postal');
		$('code_postal').focus();
		return false;
	}
	if ($('nationalite').value.length < 1) {
		alert('Veuillez entrer une nationalite');
		$('nationalite').focus();
		return false;
	}
	if ($('date_naissance').value.length < 1) {
		alert('Veuillez entrer une date de naissance');
		$('date_naissance').focus();
		return false;
	}
	if ($('password').value.length < 1) {
		alert('Veuillez entrer un mot de passe');
		$('password').focus();
		return false;
	}
	if ($('password').value != $('password_confirm').value){
		alert('password doesn\'t match');
		$('password').focus();
		return false;
	}
	if ($('email').value.length < 1) {
		alert('Veuillez entrer une adresse électronique');
		$('email').focus();
		return false;
	}
	if(!($('email').value.match(/^.+@.+\..{2,4}$/))) {
		alert('L\'adresse e-mail saisie ne semble pas valide');
		$('email').focus();
		return false;
	}
	return true;
}

function supprimer() {
	if (window.confirm('Êtes-vous sûr de vouloir supprimer cet élément?')) {
		return true;
	}
	else {
		return false;
	}
}

function limit_to(tab, n){
	var cpt = 0;
	for(i=0; i<tab.length;i++){
		if (tab[i].selected){
			cpt++;
		}
	}
	if (cpt > n){
		alert("Pas plus de "+n+" choix possibles!");
		for(i=0; i<tab.length;i++)
			tab[i].selected = false;
	}
}




/*
*
* Copyright (c) 2007 Andrew Tetlaw
* 
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* * 
*
*
* FastInit
* http://tetlaw.id.au/view/javascript/fastinit
* Andrew Tetlaw
* Version 1.4.1 (2007-03-15)
* Based on:
* http://dean.edwards.name/weblog/2006/03/faster
* http://dean.edwards.name/weblog/2006/06/again/
* Help from:
* http://www.cherny.com/webdev/26/domloaded-object-literal-updated
* 
*/
var FastInit = {
	onload : function() {
		if (FastInit.done) { return; }
		FastInit.done = true;
		for(var x = 0, al = FastInit.f.length; x < al; x++) {
			FastInit.f[x]();
		}
	},
	addOnLoad : function() {
		var a = arguments;
		for(var x = 0, al = a.length; x < al; x++) {
			if(typeof a[x] === 'function') {
				if (FastInit.done ) {
					a[x]();
				} else {
					FastInit.f.push(a[x]);
				}
			}
		}
	},
	listen : function() {
		if (/WebKit|khtml/i.test(navigator.userAgent)) {
			FastInit.timer = setInterval(function() {
				if (/loaded|complete/.test(document.readyState)) {
					clearInterval(FastInit.timer);
					delete FastInit.timer;
					FastInit.onload();
				}}, 10);
		} else if (document.addEventListener) {
			document.addEventListener('DOMContentLoaded', FastInit.onload, false);
		} else if(!FastInit.iew32) {
			if(window.addEventListener) {
				window.addEventListener('load', FastInit.onload, false);
			} else if (window.attachEvent) {
				return window.attachEvent('onload', FastInit.onload);
			}
		}
	},
	f:[],done:false,timer:null,iew32:false
};
/*@cc_on @*/
/*@if (@_win32)
FastInit.iew32 = true;
document.write('<script id="__ie_onload" defer src="' + ((location.protocol == 'https:') ? '//0' : 'javascript:void(0)') + '"><\/script>');
document.getElementById('__ie_onload').onreadystatechange = function(){if (this.readyState == 'complete') { FastInit.onload(); }};
/*@end @*/
FastInit.listen();

function my$$(expr,e){
		return (Object.isUndefined($(e))) ? $$(expr) : $(e).select(expr);
}

function general_style(e){
	// Les marges
	my$$('img[align="right"]',e).each(function(elt){
		elt.style.marginLeft='20px';
		elt.style.marginRight='0';
		elt.style.styleFloat='right';
	});
	my$$('img[align="left"]',e).each(function(elt){
		elt.style.marginLeft='0';
		elt.style.marginRight='20px';
		elt.style.styleFloat='left';
	});
}

FastInit.addOnLoad(general_style);



