<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
	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_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 OpenCalendar(nom,Left,Top){  
	  var nom,lien,Left,Top
	  lien="../global/calendar.php?nom="+nom;
	  if(!Left){Left=window.screen.width/2+60;}
	  if(!Top){Top=window.screen.height/2-100;}
	  var Configuration="'toolbar=no, menubar=no, location=no, directories=no, status=no, resizeable=no, width=162, height=165, left=" + Left + ", top=" + Top;
	 
	 window.open(lien,"calendar",Configuration);
	}
	
	function Open(lien,Left,Top,width,height){  
	  var lien,Left,Top
	  if(!Left){Left=60;}
	  if(!Top){Top=100;}
	  if(!width){width=800;}
	  if(!height){height=600;}
	  var Configuration="'toolbar=no, menubar=no, location=no, directories=no, status=no, resizeable=no, width=" + width + ", height=" + height + ", left=" + Left + ", top=" + Top;
	 
	 window.open(lien,"",Configuration);
	}
	
	function Open_historique(lien,Left,Top,width,height){  
	  var lien,Left,Top
	  if(!Left){Left=60;}
	  if(!Top){Top=100;}
	  if(!width){width=800;}
	  if(!height){height=600;}
	 
	 window.open(lien,"","resizable=yes,scrollbars=yes,status=yes, width=800,height=600,top=60,left=60");
	}
	
	function checknumber(num) {
	var ok = "yes";
	var valid = "0123456789"
	var temp;
		for (var i=0; i<num.length; i++) {
			temp = "" + num.substring(i, i+1);
			if (valid.indexOf(temp) == "-1") {ok = "no";}
		}
		return ok;
	}
   function remplace(expr,a,b) {
      var i=0
      while (i!=-1) {
         i=expr.indexOf(a,i);
         if (i>=0) {
            expr=expr.substring(0,i)+b+expr.substring(i+a.length);
            i+=b.length;
         }
      }
      return expr;
      }	
	function Majuscule(m){
		
		m=remplace(m,'é','e');
		m=remplace(m,'è','e');
		m=remplace(m,'à','a');
		m=remplace(m,'â','a');
		m=remplace(m,'ä','a');
		m=remplace(m,'ç','c');
		m=remplace(m,'ù','u');
		m=remplace(m,'ü','u');
		m=remplace(m,'û','u');
		m=remplace(m,'ô','o');
		m=remplace(m,'ö','o');
		m=remplace(m,'ï','i');
		m=remplace(m,'î','i');
		m=m.toUpperCase();
		
		return m;
	}
	function Miniscule(n){
		n=n.toLowerCase();
		return n;
	}
	
	function format_prenom(n){
		var n
		var prenom_array1 = n.split("-");

		var prenom_new1;
		prenom_new1=Majuscule(prenom_array1[0].substring(0,1))+Miniscule(prenom_array1[0].substring(1,prenom_array1[0].length));
		if(prenom_array1.length>1){
		
			for (var loop=1; loop < prenom_array1.length; loop++)
			{
					prenom_new1=prenom_new1+"-"+Majuscule(prenom_array1[loop].substring(0,1))+Miniscule(prenom_array1[loop].substring(1,prenom_array1[loop].length));
			}
		}

		var prenom_array2 = prenom_new1.split(" ");
		var prenom_new2;
		prenom_new2=Majuscule(prenom_array2[0].substring(0,1))+prenom_array2[0].substring(1,prenom_array2[0].length);
		if(prenom_array2.length>1){
		
			for (var loop=1; loop < prenom_array2.length; loop++)
			{
					prenom_new2=prenom_new2+" "+Majuscule(prenom_array2[loop].substring(0,1))+prenom_array2[loop].substring(1,prenom_array2[loop].length);
			}
		}	
		
		var prenom_array3 = prenom_new2.split("'");
		var prenom_new3;
		prenom_new3=Majuscule(prenom_array3[0].substring(0,1))+prenom_array3[0].substring(1,prenom_array3[0].length);
		if(prenom_array3.length>1){
		
			for (var loop=1; loop < prenom_array3.length; loop++)
			{
					prenom_new3=prenom_new3+"'"+Majuscule(prenom_array3[loop].substring(0,1))+prenom_array3[loop].substring(1,prenom_array3[loop].length);
			}
		}	

		return prenom_new3;
	}
	function date_change_focus(x,y){
		var x,y;
			if(document.alice.elements[x].value.length==2){document.alice.elements[y].focus();}
	}
	
		function check_date(date_choix){
		var amin=1900; 
		var amax=2020; 
		var j1=document.alice.elements(date_choix+'_d').value;
		var m1=document.alice.elements(date_choix+'_m').value;
		var a1=document.alice.elements(date_choix+'_y').value;
		var fev=28;
		if ( (checknumber(j1) == "no") || (j1<1) || (j1>31) ) { 		
			alert(msg_date); 
			document.alice.elements(date_choix+'_d').value="";
			document.alice.elements(date_choix+'_d').focus();
			return false;
		} 
		
		if ( (checknumber(m1) == "no") || (m1<1) || (m1>12) ) {  
			alert(msg_date);
			document.alice.elements(date_choix+'_m').value="";
			document.alice.elements(date_choix+'_m').focus();
			return false;
		} 
		
		if ( (checknumber(a1) == "no") || (a1<amin) || (a1>amax) ) { 
			
			alert(msg_date);
			document.alice.elements(date_choix+'_y').value="";
			document.alice.elements(date_choix+'_y').focus();
			return false;
		} 
	
		if (a1%4 == 0 && a1%100 !=0 || a1%400 == 0) {fev = 29;}
		if (m1=='02'&&j1>fev){
			alert(msg_date);
			document.alice.elements(date_choix+'_d').value="";
			document.alice.elements(date_choix+'_d').focus();
			return false;
		}
	}

	function emailCheck (emailStr) {
		var emailPat=/^(.+)@(.+)$/
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
		var validChars="\[^\\s" + specialChars + "\]"
		var quotedUser="(\"[^\"]*\")"
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
		var atom=validChars + '+'
		var word="(" + atom + "|" + quotedUser + ")"
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
		var matchArray=emailStr.match(emailPat)
		if (matchArray==null) {
			alert(msg_mail);
			return false
		}
		var user=matchArray[1]
		var domain=matchArray[2]
		if (user.match(userPat)==null) {
			alert(msg_mail);
			return false
		}
		var IPArray=domain.match(ipDomainPat)
		if (IPArray!=null) {
			  for (var i=1;i<=4;i++) {
				if (IPArray[i]>255) {
					alert(msg_mail);
				return false
				}
			}
			return true
		}
		var domainArray=domain.match(domainPat)
		if (domainArray==null) {
			alert(msg_mail);
			return false
		}
		var atomPat=new RegExp(atom,"g")
		var domArr=domain.match(atomPat)
		var len=domArr.length
		if (domArr[domArr.length-1].length<2 || 
			domArr[domArr.length-1].length>3) {
		   alert(msg_mail)
		   return false
		}
		if (len<2) {
		   alert(msg_mail);
		   return false
		}
		return true;
	}

		function printpr(OLECMDID,PROMPT)
			{
			//var OLECMDID;
			/* OLECMDID values:
			* 6 - print
			* 7 - print preview
			* 1 - open window
			* 4 - Save As
			*/
			var PROMPT = 1; // 2 DONTPROMPTUSER 
			var WebBrowser = "<OBJECT ID='WebBrowser1' WIDTH=0 HEIGHT=0 CLASSID='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></OBJECT>";
			document.body.insertAdjacentHTML("beforeEnd", WebBrowser); 
			WebBrowser1.ExecWB(OLECMDID, PROMPT);
			WebBrowser1.outerHTML = "";
			}

			function setPrint()
			{
			printpr(8,1);
			}
			function previewPrint()
			{
			printpr(7,1)
			}
			function print_page()
			{
			printpr(6,1)
			}


function LTrim(str)

{

    var whitespace = new String(" \t\n\r");

    var s = new String(str);

    

    if (whitespace.indexOf(s.charAt(0)) != -1)

    {

        var j=0, i = s.length;

        while (j < i && whitespace.indexOf(s.charAt(j)) != -1)

        {

            j++;

        }

        s = s.substring(j, i);

    }

    return s;

}

 


function RTrim(str)

{

    var whitespace = new String(" \t\n\r");

    var s = new String(str);

 

    if (whitespace.indexOf(s.charAt(s.length-1)) != -1)

    {

        var i = s.length - 1;

        while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)

        {

            i--;

        }

        s = s.substring(0, i+1);

    }

    return s;

}

 

function LRtrim(str)

{

    return RTrim(LTrim(str));

}

 
function check_trim(s) {
        var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
        return (m == null) ? "" : m[1];
} 

function setKWequal(){// set ths keyword to equal
	document.getElementById('kw_op_switch').firstChild.firstChild.nodeValue = "(equals)";
	document.form1.KW_OP.value = "1";
}

function setKWcontains(){
document.getElementById('kw_op_switch').firstChild.firstChild.nodeValue = "(contains)";
		document.form1.KW_OP.value = "";
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

/*
From FScommand
*/
var vID = -1;
//var rep = -1;
function stopme(pID) {
//pID is the primary Id sent from flash
	if (pID != vID){// check to see if this a different player if so Stop player vID
		if (vID >-1){
		MM_controlShockwave(vID,'','GotoFrame','1');
		}
		vID = pID;
	}
}

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);}
  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_controlShockwave(objStr,x,cmdName,frameNum) { //v3.0
  var obj=MM_findObj(objStr);
  if (obj) eval('obj.'+cmdName+'('+((cmdName=='GotoFrame')?frameNum:'')+')');
} 

function AddEscapeChar(strValue_1){
var strValue_1;
var strValue_2;
strValue_2 = '';
strCharsToEsape ='\'';

for(i=0; i <=strValue_1.length-1; i++){
	vchar = strValue_1.substr(i,1);//go through each char checking it against strCharsToEscape
	if (strCharsToEsape.indexOf(vchar,0)!=-1){
		strValue_2 += '\\';// add in escape char
	}
	strValue_2 += vchar;
	}
	return(strValue_2);
}

function exactKW(txt){
//takes the keyword clicked and poulates the keyword field;
ttext = document.form1.keyword.value;
document.form1.keyword.value = txt;
// need this because of extra space added when inserting ttext into a bank value
ttext = document.form1.keyword.value;
if(ttext.substring(0,1) == ' '){
document.form1.keyword.value = ttext.substring(1,ttext.lenght);

}

}


function changetext(){ //changes the keyword Search type
	if (document.getElementById('kw_op_switch').firstChild.firstChild.nodeValue != "(equals)"){
		setKWequal();
	}else{
		setKWcontains();
	}
}

function resetform(){
document.getElementById('keyword').setAttribute('value',"");
document.getElementById('tracktitle').setAttribute('value',"");
document.getElementById('genre').selectedIndex = 0;
document.getElementById('Library').selectedIndex = 0;
document.form1.tempo.value = "";
clearme('tab2');
}

function clearme(id){// remove the second row of the table (composer and instrumentation)
 var tbody = document.getElementById(id).getElementsByTagName("TBODY")[0];
 if (tbody.childNodes.length > 1){// if there a is a row to delete
	tbody.removeChild(tbody.childNodes[1]); 
	document.form1.composer_text.value ="";
	document.getElementById('tab2hidden').setAttribute('value',"");
	}
}


  function addRow(id,msg){
    var tbody = document.getElementById(id).getElementsByTagName("TBODY")[0];
    var row = document.createElement("TR");
    var td1 = document.createElement("TD");
	  var td2 = document.createElement("TD");//new
	  // creat a link to clear the table element
	var clearLink = document.createElement("A")// create s link to call the delete function
	clearLink.setAttribute('href','javascript:clearme(\''+id+'\')');
	  var clearBut = document.createTextNode('Clear');//new
	  clearLink.appendChild(clearBut);
	  
	  td2.appendChild(clearLink);//new
    td1.appendChild(document.createTextNode(msg));
	if (tbody.childNodes.length < 3){ // add a row if there is only one left
    row.appendChild(td1);
	row.appendChild(td2);//new
    tbody.appendChild(row);
	}else{
	tbody.childNodes[1].childNodes[0].childNodes[0].nodeValue = msg;// changes the text
	}
	document.form1.composer_text.value = msg;
  }


function GP_AdvOpenWindow(theURL,winName,features,popWidth,popHeight,winAlign,ignorelink,alwaysOnTop,autoCloseTime,borderless) { //v2.0
  var leftPos=0,topPos=0,autoCloseTimeoutHandle, ontopIntervalHandle, w = 480, h = 340;  
  if (popWidth > 0) features += (features.length > 0 ? ',' : '') + 'width=' + popWidth;
  if (popHeight > 0) features += (features.length > 0 ? ',' : '') + 'height=' + popHeight;
  if (winAlign && winAlign != "" && popWidth > 0 && popHeight > 0) {
    if (document.all || document.layers || document.getElementById) {w = screen.availWidth; h = screen.availHeight;}
		if (winAlign.indexOf("center") != -1) {topPos = (h-popHeight)/2;leftPos = (w-popWidth)/2;}
		if (winAlign.indexOf("bottom") != -1) topPos = h-popHeight; if (winAlign.indexOf("right") != -1) leftPos = w-popWidth; 
		if (winAlign.indexOf("left") != -1) leftPos = 0; if (winAlign.indexOf("top") != -1) topPos = 0; 						
    features += (features.length > 0 ? ',' : '') + 'top=' + topPos+',left='+leftPos;}
  if (document.all && borderless && borderless != "" && features.indexOf("fullscreen") != -1) features+=",fullscreen=1";
  if (window["popupWindow"] == null) window["popupWindow"] = new Array();
  var wp = popupWindow.length;
  popupWindow[wp] = window.open(theURL,winName,features);
  if (popupWindow[wp].opener == null) popupWindow[wp].opener = self;  
  if (document.all || document.layers || document.getElementById) {
    if (borderless && borderless != "") {popupWindow[wp].resizeTo(popWidth,popHeight); popupWindow[wp].moveTo(leftPos, topPos);}
    if (alwaysOnTop && alwaysOnTop != "") {
    	ontopIntervalHandle = popupWindow[wp].setInterval("window.focus();", 50);
    	popupWindow[wp].document.body.onload = function() {window.setInterval("window.focus();", 50);}; }
    if (autoCloseTime && autoCloseTime > 0) {
    	popupWindow[wp].document.body.onbeforeunload = function() {
  			if (autoCloseTimeoutHandle) window.clearInterval(autoCloseTimeoutHandle);
    		window.onbeforeunload = null;	}  
   		autoCloseTimeoutHandle = window.setTimeout("popupWindow["+wp+"].close()", autoCloseTime * 1000); }
  	window.onbeforeunload = function() {for (var i=0;i<popupWindow.length;i++) popupWindow[i].close();}; }   
  document.MM_returnValue = (ignorelink && ignorelink != "") ? false : true;
}
