
// boîte de connexion
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

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;
}

$(document).ready(function() {
//	Smooth scrolling on internal links
$('a[href*=#]').click(function() {
	if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
		var $target = $(this.hash);
		$target = $target.length && $target || $('[id=' + this.hash.slice(1) + ']');
		if ($target.length) {
			var targetOffset = $target.offset().top;
			$('html,body').animate({scrollTop: targetOffset}, 1000);
			return false;
		}
	}
});

}); // fin jquery


// test des urls
	function validateURL(url) {
		if (url.indexOf(' ') > -1) {
			return false;
		} // end if
		var regexp = /^(ftp|http|https|mms|mmst|nntp|pnm|rdf|rss|rtsp)[:]{1}[\/]{2}([.^\w]+[.\.\-\/^\w]+)($|[\?]{1}[.\=\&\%^\w]+)?/
		return regexp.test(url)
	} // end function

	function validateResourceURL(inputElementId,doColorCoding) {
		var urlElement = document.getElementById(inputElementId);
		if (!(urlElement)) {	return;	}
		var isValidURL = validateURL(urlElement.value);
		if (doColorCoding && urlElement.value.length) {
			urlElement.style.color = (isValidURL) ? 'green' : 'red';
		} // end if
	} // end function

var testWindow;

	function testURL(inputElementId) {
		var urlElement = document.getElementById(inputElementId);
		if (!(urlElement)) {	return;	}
		if (testWindow && !testWindow.closed) {
			testWindow.location.replace(urlElement.value);
		} else {
			testWindow = window.open(urlElement.value,'testWindow');
		} // end if
		testWindow.focus();
	} // end function
// test des urls


// permet de vérifier qu'on ne dépasse pas les x caractères dans une textarea
	function CheckLen(Target)
	{
		StrLen = Target.value.length;
		if ( StrLen>300 ) {
			Target.value = Target.value.substring(0,300);
			CharsLeft = 300;
		} else {
			CharsLeft = StrLen;
		};
		var CharsLeft1 = 300 - CharsLeft;
		document.form2submit.reste.value = CharsLeft1;
	};
	
	// permet de vérifier qu'on ne dépasse pas les x caractères dans une textarea
	function CheckLen2(Target)
	{
		StrLen = Target.value.length;
		if ( StrLen>300 ) {
			Target.value = Target.value.substring(0,300);
			CharsLeft0 = 300;
		} else {
			CharsLeft0 = StrLen;
		};
		var CharsLeft2 = 300 - CharsLeft0;
		document.form2submit.reste2.value = CharsLeft2;
	};
// fin 

// pop up
var newWin = null;
function closeWin(){
	if (newWin != null){
		if(!newWin.closed)
			newWin.close();
	}
}

function popUp(strURL,strType,strHeight,strWidth) {
closeWin();
var strOptions="";
if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth;
if (strType=="fixed") strOptions="status,scrollbars,resizable,height="+strHeight+",width="+strWidth;
if (strType=="elastic") strOptions="status,scrollbars,resizable,height="+strHeight+",width="+strWidth;
newWin = window.open(strURL, 'newWin', strOptions);
newWin.focus();
}
