function SwapImageRealisations(vID, vImage, vNomClient) {
	document.getElementById(vID).innerHTML = '<img src="../../images/portfolio/'+vImage+'" width="100%" alt="'+vNomClient+'" title="'+vNomClient+'">';
}

function OpenNewWin(tmpPath,tmpFichier,width,height,scrollbars,statusbar,menubar) {
	if (tmpFichier == '') { alert('Valeur incorrecte pour l\'ouverture de la page.'); }
	else {
		if (!width) { width=700 }
		if (!height) { height=500 }

		if (!scrollbars) { scrollbars='yes' }
		if (!statusbar) { statusbar='yes' }
		if (!menubar) { menubar='yes' }
		popupNouvelleFenetre = open(tmpPath+tmpFichier, 'popupNouvelleFenetre', 'scrollbars='+scrollbars+',statusbar='+statusbar+',menubar='+menubar+',' + StringGrandeur(width,height));
		popupNouvelleFenetre.focus();
	}
}

function CheckURL(url) {
    var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/; 
    if(RegExp.test(url) && Left(url,7) == 'http://') { return true;	} else { return false; }
}

function CheckEmail(email){ 
	email = email.toLowerCase();
    var RegExp = /^((([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|\/|=|\?|\^|_|`|\{|\||\}|~)+(\.([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|\/|=|\?|\^|_|`|\{|\||\}|~)+)*)@((((([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.))*([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.)[\w]{2,4}|(((([0-9]){1,3}\.){3}([0-9]){1,3}))|(\[((([0-9]){1,3}\.){3}([0-9]){1,3})\])))$/ 
    if(RegExp.test(email)){ return true; } else { return false; } 
} 

function trim(str, charlist) {
    var whitespace, l = 0;
	if (!charlist) {whitespace = ' \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000';}
	else {whitespace = charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1');}
    l = str.length;
    for (var i = 0; i < l; i++) {if (whitespace.indexOf(str.charAt(i)) === -1) {str = str.substring(i); break;}}
    l = str.length;
    for (i = l - 1; i >= 0; i--) {if (whitespace.indexOf(str.charAt(i)) === -1) {str = str.substring(0, i + 1);break;}}
	return whitespace.indexOf(str.charAt(0)) === -1 ? str : '';
}

function CheckText(fieldName) {
	if (trim(document.getElementsByName(fieldName).item(0).value)=='') {
		document.getElementById("tag_"+fieldName).setAttribute("class", "required_wrong"); 
		return false;
	}
	return true;
}

function StringGrandeur (width, height) {
	var string = 'width=' + width + ',height=' + height + ',left=' + ((screen.width - width) / 2) + ',top=' + ((screen.height - height) / 2) + ',screenX=' + ((screen.width - width) / 2) + ',screenY=' + ((screen.height - height) / 2);
	return string;
}

function Left(str, n){
	if (n <= 0) return "";
	else if (n > String(str).length) return str;
	else return String(str).substring(0,n);
}

function Right(str, n){
    if (n <= 0) return "";
    else if (n > String(str).length) return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}