
if(document.getElementById){
 	if(navigator.appName.substring(0,3) == "Net")
 	document.captureEvents(Event.MOUSEMOVE);
 	document.onmousemove = acces_get_mouse;
}
function acces_get_mouse(e)
{
 	access_X = (navigator.appName.substring(0,3) == "Net") ? e.pageX : event.x+document.body.scrollLeft;
 	access_Y = (navigator.appName.substring(0,3) == "Net") ? e.pageY : event.y+document.body.scrollTop;
}

function ajaxSendData(data, page, method, id){
		if (window.ActiveXObject)
		{
		//Internet Explorer
		var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ;
		}
		else
		{
		var XhrObj = new XMLHttpRequest();
		}
		
		//définition de l'endroit d'affichage:
		var content = document.getElementById(id);
		
		//Ouverture du fichier en methode POST
		XhrObj.open(method, page);
		
		//Ok pour la page cible
		XhrObj.onreadystatechange = function()
		{
		if (XhrObj.readyState == 4 && XhrObj.status == 200)
		content.innerHTML = XhrObj.responseText;
		}
		
		XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		XhrObj.send(data);
	}
function ajaxBlankData(id){
	document.getElementById(id).innerHTML = "";
}

function getCookieVal(offset) {
	var endstr=document.cookie.indexOf (";", offset);
	if (endstr==-1)
      		endstr=document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
	var arg=name+"=";
	var alen=arg.length;
	var clen=document.cookie.length;
	var i=0;
	while (i<clen) {
		var j=i+alen;
		if (document.cookie.substring(i, j)==arg)
                        return getCookieVal (j);
                i=document.cookie.indexOf(" ",i)+1;
                        if (i==0) break;
   }
	return null;
}
function erreurChgtImage(ErreurImage){
	if(zoom=$(ErreurImage).attr('zoom')){
		switch(zoom){
			case 'original':
			case 'HIGH':
				zoom='_200';
				break;
			case 'MEDIUM':
				zoom='_200';
				break;
			case 'MINI':
				zoom='_100';
				break;
			case 'SMALL':
				zoom='_50';
				break;
			default:
				zoom='_50';
				break;
		}
	}else{
		zoom='_50';
	}
	
	if(extension=$(ErreurImage).attr('ext')){
		if(extension==""){
			ErreurImage.src="images/pictos/fiche"+zoom+".jpg";
		}else{
			ErreurImage.src="images/pictos/"+extension.substr(1)+zoom+".jpg";
		}
		/*switch(extension){
			case '.doc':
				ErreurImage.src="images/pictos/doc_50.jpg";
			break;
			case '.eps':
				ErreurImage.src="images/pictos/eps_50.jpg";
			break;
			case '.pdf':
				ErreurImage.src="images/pictos/pdf_50.jpg";
			break;
			case '.jpg':
				ErreurImage.src="images/pictos/jpg_50.jpg";
			break;
			default :
				ErreurImage.src="images/NonDispo50.jpg";
			break;
		}*/
	}else{
		ErreurImage.src="images/NonDispo50.jpg";
	}
	//ErreurImage.src="images/NonDispo50.jpg";
	
}
function strrchr(haystack, needle) {
    var pos = 0;
 
    if (typeof needle !== 'string') {
        needle = String.fromCharCode(parseInt(needle, 10));
    }
    needle = needle[0];
    pos = haystack.lastIndexOf(needle);
    if (pos === -1) {
        return false;
    }
 
    return haystack.substr(pos);
}
function setTypeCanaux(obj_form){
		document.getElementById("idTypeCanaux").innerHTML = obj_form.label;
}

//set_docs_affect_value('0', document.form_add_role.create_action, 35 , '',4790, '', 'list_define')
function affectAssetToFiche(usage, obj_form, id_role, id_attach, id_asset, obj_type, link_action){

	if(usage==1){
		var a = confirm("Êtes vous sur de vouloir remplacer la valeur active ?");
		if(a == true){
			v_execute=true;
			obj_form.value="linkAssetToFiche";
		} else {
			exit;
		}

	}else{
		v_execute=true;
		obj_form.value="linkAssetToFiche";
		//
	}
	if(v_execute==true) action_charact(obj_form,id_role,id_attach,id_asset,obj_type,link_action);
}




function affectValueToFiche(assetcl, version, champ, formname, valeur){
	/*
	alert(assetcl);
	alert(version);
	alert(champ);
	*/
	valchamp = eval("document."+formname+"."+valeur+".value");

	lien = TJS_ExtractURL("create_action=affectValueToFiche,version="+version+",champ="+champ+",valchamp="+valchamp, 1);
	alert(lien)
	//view_pop(1,lien);return(false);
	//view_pop(2,'monUrl');
}

function pause(Amount) {
	d = new Date() //today's date
	while (1){
		mill=new Date() // Date Now
		diff = mill-d //difference in milliseconds
		if( diff > Amount ) {break;}
	}
}
function update_asset_docs(obj_form,id_asset){
	//asset_name_value = eval(document"id_asset+'asset_name'" );
	
	asset_name_value	=	eval("document." + obj_form.form.name + "." + id_asset + "_assetname.value");
	asset_descript_value	=	eval("document." + obj_form.form.name + "." + id_asset + "_descript.value");
	asset_key_words_value	=	eval("document." + obj_form.form.name + "." + id_asset + "_key_words.value");
	
	/*
	alert(asset_name_value)
	alert(asset_descript_value)
	alert(asset_key_words_value)
	*/
	
	//asset_key_words_value	=	eval("document." + obj_form.form.name + "." + edit_asset_doc + "_key_words.value");
	content ="toto";
	menu ='edit_asset_doc';
	document.getElementById(menu).innerHTML=content; 
	//left:368px; top:61px; 
	
	getMouseXY()	
		
	alert(tempX);	
	//alert(tempY);
	document.getElementById(menu).style.left=(tempX+50)+"px";
	document.getElementById(menu).style.top= (tempY-50)+"px";
	document.getElementById(menu).style.visibility= 'visible';


	//asset_name_value	=	eval("document.write('toto')");
	//field_#".$row[id_asset]
}
/*global use variables*/
var ns4,ie4,ie5;

ns4 = (document.layers) ? true:false
ie4 = (document.all) ? true:false
ie5 = (document.getElementById) ? true:false
var allIDs;
var tempX = 0;
var tempY = 0;
/////////////////////////////////////////////
//TIGRA 
/////////////////////////////////////////////
function expand_all (n_index, n_depth) {
	var o_tree = TREES[n_index ? n_index : 0];
	if (!o_tree)
		alert("Tree is not initialized yet");
	var a_nodes = o_tree.a_nodes;
	for (var i = 0; i< a_nodes.length; i++)
		if (n_depth == null || a_nodes[i].n_depth <= n_depth)
			a_nodes[i].open(0, 1);
	o_tree.ndom_refresh();
}
function collapse_all (n_index, n_depth) {
	var o_tree = TREES[n_index ? n_index : 0];
	if (!n_depth) n_depth = 1;
	if (!o_tree)
		alert("Tree is not initialized yet");
	var a_nodes = o_tree.a_nodes;
	for (var i = a_nodes.length - 1; i >= 0; i--)
		if (a_nodes[i].n_depth >= n_depth && a_nodes[i].open)
			a_nodes[i].open(1, 1);
	o_tree.ndom_refresh();
}
function deselect_all (n_index, n_depth) {
	var o_tree = TREES[n_index ? n_index : 0];
	if (!n_depth) n_depth = 1;
	if (!o_tree)
		alert("Tree is not initialized yet");
	var a_nodes = o_tree.a_nodes;
	for (var i = a_nodes.length - 1; i >= 0; i--)
			a_nodes[i].select(1); 
	o_tree.ndom_refresh();
}

function openArbo(mytree, idkey){
var a_found = TREES[mytree].find_item_by_key('idkey', idkey); 
			for (var i=0; i<a_found.length; i++){  
								a_found[i].select(0); 
								a_found[i].open(0); 
								}
	}
	var colorlien = "#000000"; //couleur du texte
	var taillebg = 150 //largeur du menu


function position(p){
	position_x = (navigator.appName.substring(0,3) == "Net") ? p.pageX : window.event.clientX+document.body.scrollLeft;
	position_y = (navigator.appName.substring(0,3) == "Net") ? p.pageY : parent.event.clientY+parent.document.body.scrollTop;
}
var position_arbo;

function ouvrir_menu(myurl){
	//closeAllWin();
	send_data('', myurl, 'get', 'menu_context');
	document.getElementById("menu_context").style.visibility = "visible";
	document.getElementById("menu_context").style.top = access_Y-10;
	document.getElementById("menu_context").style.left = access_X-10;
	menuVisible=0;
	menuOpen=1;
	return false;
}

function fermer_menu(menuid){
	/**/
	//alert(document.getElementById("menu_context").style.visibility )
	if ((document.getElementById) && menuVisible==1){
		document.getElementById("menu_context").style.visibility = "hidden";
		document.getElementById("menu_context").innerHTML='';
	}else{
		if(menuOpen==1){
			menuOpen=0;
			menuVisible=1;
		}
	}
}
function fermer_winActions(){
	if (document.getElementById)
	document.getElementById("winactionspanel").style.visibility = "hidden";
	document.getElementById("winactions").innerHTML='';
	
	
}
function closeAllWin(){
	//alert('click')
	fermer_winActions();
	fermer_menu();
}
var timeout = 1000;
function timeoutHide(id){
//alert(id);
    // start the timeout
    eval( "timeout" + id + " = window.setTimeout('hideUlUnder( \"" + id + "\" )', " + timeout + " );");
}
// hide the ul elements under the element identified by id
function hideUlUnder( id )
{
    document.getElementById(id).style['visibility'] = 'hidden';
		document.getElementById(id).innerHTML='';
}
function ouvrir_winActions(myurl,larg){
	//alert(myurl)
	closeAllWin();
	send_data('', myurl, 'get', 'winactions');
	document.getElementById("winactionspanel").style.top = access_Y;
	document.getElementById("winactionspanel").style.left = access_X;
	
	//dd.elements.pop_options.moveTo(access_X, access_Y);
	document.getElementById("winactionspanel").style.width = larg+'px';
	document.getElementById("winactionspanel").style.visibility = "visible";
	//document.getElementById("winactionspanel").innerHTML='';	
	
	//return(false);
}


if(navigator.appName.substring(0,3) == "Net")
document.captureEvents(Event.MOUSEMOVE);

function ask_paste_node(dest){
	copysource = GetCookie ('move_arbo');
	//alert(dest)
	copysource = copysource.split('#');
	dest = dest.split('#');
	//alert(copysource[1]+'/'+dest[0]);
	//alert(copysource[0]);
	if(copysource[0]=='COPY')
		if (confirm('Copier \'' + copysource[2] + '\' dans \''+dest[1]+'\'')) {
		    	//mon_url = pageadmin+"op=menu_arbo&act=copy&source="+copysource[1]+"&dest="+dest[0];
		    	mon_url = TJS_ExtractURL("module=Workspace,act=copy,source="+copysource[1]+",dest="+dest[0], 2);

		    	SetCookie ('move_arbo','');
		    	view_pop(2,"bw_menufunctions.php?"+mon_url);
		}
	if(copysource[0]=='ALLCOPY')
		if (confirm('Copier \'' + copysource[2] + '\' dans \''+dest[1]+'\'')) {
		    	//mon_url = pageadmin+"op=menu_arbo&act=allcopy&source="+copysource[1]+"&dest="+dest[0];
		    	mon_url = TJS_ExtractURL("module=Workspace,&act=allcopy,source="+copysource[1]+",dest="+dest[0], 2);
		    	SetCookie ('move_arbo','');
		    	view_pop(2,"bw_menufunctions.php?"+mon_url);
		    	
		}		
	if(copysource[0]=='CUT')
		if (confirm('Déplacer \'' + copysource[2] + '\' dans \''+dest[1]+'\'')) {
		    	SetCookie ('move_arbo','');
		    	//set_copy_node (copysource[1],dest[1]);
		}			
	
}


function delete_node(node){
	var temp = "Vous désirez vraiment detacher ? \n(Tous les sous dossiers seront détachés en même temps !)";
	if (confirm(temp)) {		
		    	mon_url = TJS_ExtractURL("module=Workspace,create_action=menu_arbo,act=delete,node_pos="+node, 2);

		    	view_pop(2,"bw_menufunctions.php?"+mon_url);
	}	
}


function duplicate_node(node){
	var temp = "Dupliquer cette fiche ? ";
	if (confirm(temp)) {		
		    	mon_url = TJS_ExtractURL("module=Workspace,create_action=menu_arbo,act=duplicate,node_pos="+node, 2);
		    	view_pop(2,"bw_menufunctions.php?"+mon_url);
	}	
}
/////////////////////////////////////////////
function getMouseXY() {
  if (ie4) { // grab the <B style="color:black;background-color:#99ff99">x-y</B> pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {
  	   
    tempX = e.pageX;
    tempY = e.pageY;
  }
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0;}
  if (tempY < 0){tempY = 0;}

  return true
}
function setCookieAndReload(cookname, val){
	SetCookie (cookname, val);
	//document.location.reload();
	TJS_ExtractAllUrl();
}
function modifieNBRpages(val){
	SetCookie('RESULTPERLINE',val );
	TJS_ExtractAllUrl('min=');
}
function setEmptyRole(){
	if(document.getElementById("hideEmptyRole").checked==true){
		setCookieAndReload('hideEmptyRole', 1);	
	}else{
		setCookieAndReload('hideEmptyRole', '');
	}
	//document.location.reload();
}
function setViewMiniatures(){
	if(document.getElementById("ViewMiniatures").checked==true){
		setCookieAndReload('ViewMiniatures', 1);	
	}else{
		setCookieAndReload('ViewMiniatures', '');
	}
	//document.location.reload();
}	


function SetCookie (name, value) {

	var argv=SetCookie.arguments;
	var argc=SetCookie.arguments.length;
	var expires=(argc > 2) ? argv[2] : null;
	var path=(argc > 3) ? argv[3] : null;
	var domain=(argc > 4) ? argv[4] : null;
	var secure=(argc > 5) ? argv[5] : false;
	document.cookie=name+"="+escape(value)+
		((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
		((path==null) ? "" : ("; path="+path))+
		((domain==null) ? "" : ("; domain="+domain))+
		((secure==true) ? "; secure" : "");
}


function send_data(data, page, method, id){
				if (window.ActiveXObject)
				{
				//Internet Explorer
				var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ;
				}
				else
				{
				var XhrObj = new XMLHttpRequest();
				}
				
				//définition de l'endroit d'affichage:
				var content = document.getElementById(id);
				
				//Ouverture du fichier en methode POST
				XhrObj.open(method, page);
				
				//Ok pour la page cible
				XhrObj.onreadystatechange = function()
				{
				if (XhrObj.readyState == 4 && XhrObj.status == 200)
				content.innerHTML = XhrObj.responseText;
				}
				
				XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				XhrObj.send(data);
}

function search_documents(recherche, id_role, id_asset_cat){

	if(recherche==""){recherche='%';}

	var tmp_url="id_role="+id_role+",find="+recherche+",action=searchAsset";

	(id_asset_cat!=0) ? tmp_url+=",id_asset_cat="+ id_asset_cat : "";
	TJS_ExtractURL(tmp_url);
}



var show_tab_function = null;
var hide_tab_function = null;

function show_tab(i)
{
	hide_tabs();
	if (show_tab_function) {
		show_tab_function(i);
		return;
	}
	var tab = document.getElementById('tab_' + i);
	tab.style.display = 'block';
	tab = document.getElementById('toptab_' + i);
	tab.className = 'tabon';
	tab = document.getElementById('lefttab_' + i);
	tab.className = 'tabon_l';
	tab = document.getElementById('righttab_' + i);
	tab.className = 'tabon_r';
}

function hide_tabs()
{
	if (hide_tab_function) {
		hide_tab_function();
		return;
	}
	var tabs = document.getElementsByTagName('td');
	var i;
	
	for(i = 0; i < tabs.length; i++){
		if (tabs[i].className == 'tabon')
			tabs[i].className = 'taboff';
			
		if (tabs[i].className == 'tabon_l')
			tabs[i].className = 'taboff_l';
			
		if (tabs[i].className == 'tabon_r')
			tabs[i].className = 'taboff_r';
	}		
			

	tabs = document.getElementsByTagName('div');
	for(i = 0; i < tabs.length; i++)
		if (tabs[i].className == 'tab')
			tabs[i].style.display = 'none';
} 


function change_version(asset,obj_form){
	for (var i=1; i <= count_version; ++i){
		eval("document.getElementById('version_"+i+"').innerHTML = ''");
	}	
	for (var i=1; i <= (data_asset[asset].length -1); ++i){
		if(data_asset[asset][i]==undefined){
			new_data_asset="";
			} else {
			new_data_asset=data_asset[asset][i];
		}
		eval("document.getElementById('version_"+i+"').innerHTML = new_data_asset");
	}
}
function form_action_submit(t_action){
	document.form_action.create_action.value=t_action;
	document.form_action.submit();
}
function verif_folder(){
 
	if(document.form_canaux_upload.list_canaux.value!=0) document.form_canaux_upload.submit();
    		
    		
}
function navig(myurl){
	//alert(myurl)
	parent.document.location.href = myurl;
}

//       action_charact(this,'75','99340','117044','input',this.form.return_action.value)
function action_charact(obj_form,id_role,id_attach,id_asset,obj_type,link_action,visiblepop){
	if(visiblepop==undefined)visiblepop=2;
	

	
	if (obj_type=="input"){
		liste_type	=	obj_form.name;
	}else{
		//alert("verification de l\'utilisation d'une fonction : \"action_charac\" efectuée");
		liste_type	=	obj_form.value;
	}

//alert(liste_type)
	if((id_role!=0) && (liste_type!=0)){
		
			//AFFICHE LISTE PREDEFINIE
			if (liste_type=="define"){
				TJS_ExtractURL(",id_role="+id_role+",id_attach="+id_attach+",id_asset="+id_asset+",action=list_"+liste_type);
			
			//EDITE l'ASSET
			} else if (liste_type=="edit"){
				TJS_ExtractURL("id_role="+id_role+",id_attach="+id_attach+",id_asset="+id_asset+",action=edit");
				
			//DETACHE UN ASSET d'UN ATTRIBUT
			} else if ((liste_type=="getFormDeleteAttachement") && (id_attach!="")){
				if(link_action!=""){link_action="list_define";}
				lien_direct = TJS_ExtractURL(",id_role="+id_role+",id_attach="+id_attach+",id_asset="+id_asset+",create_action="+liste_type+",action="+link_action, 1);
				view_pop(1,lien_direct);return(false);
				
			//ATTACHEMENT D'UN ASSET A UNE FICHE OU AUTRE (DIVERS ACTIONS)
			} else {
				lien_direct = TJS_ExtractURL("module=Workspace,id_role="+id_role+",id_attach="+id_attach+",id_asset="+id_asset+",create_action="+liste_type+",action="+link_action, 1);
				//alert(lien_direct);
				view_pop(visiblepop,lien_direct);return(false);
			}
	}
}

function TJS_ExtractAllUrl(champ){
	  mon_url=parent.document.location.href;
	  var id_position;
	  var regexp=new RegExp("[?&]");
	  var param_url = mon_url.split(regexp);
	  tabparams = new Array;
	  
	  ////////////////////////////////////////
		

	  	  
	  //je construit mon tableau a partir de mon url
	  for (var i=1;i<param_url.length;i++){ 
	     	tabparams[param_url[i].substring(0,param_url[i].indexOf("="))] = param_url[i].substring(param_url[i].indexOf("=")+1);
	  }

	  var param_champ = new Array();
		//je split ma var champ qui contient tous les champs avec valeur
	  if (champ!=undefined){
	  	var param_champ = champ.split(',');	  
	  }
	  newtabparam = new Array;
	  //je construit mon new tableau
	  for (var i=0;i<param_champ.length;i++){
	    newtabparam[param_champ[i].substring(0,param_champ[i].indexOf("="))]=param_champ[i].substring(param_champ[i].indexOf("=")+1);
	  }
	 //je modifie l'ancien avec le nouveau
	  for (var clef in newtabparam){
	  	tabparams[clef] = newtabparam[clef];
	  }
	  //alert(texte);
		myurl="";
		for (var clef in tabparams){
			if (typeof(tabparams[clef]) != 'function') {
				
				if((tabparams[clef]!=""))  {
						myurl += "&"+clef +"="+tabparams[clef];
				}
			}
		}
		
		if((myurl.slice(0, 1)=='&')) myurl = myurl.slice(1, myurl.length);
		myurl = myurl.replace("#", "");
	  //alert(myurl)
	
		document.location.href="index.php?"+myurl;
}

function TJS_ExtractURL(champ, retour) {
	//sert a reloader la page globale et change l'id position et/ou l'onglet
		//alert(champ);
		//if ((champ==undefined)|| (champ='')) champ = "id_position";
	  mon_url=parent.document.location.href;
	  var id_position;
	  var regexp=new RegExp("[?&]");
	  var param_url = mon_url.split(regexp);
	  tabparams = new Array;
	  
	  //SERT A AUTORISER LA REUTILISATION DES LIENS
	  tab_ok = new Array;
	  tab_ok['module'] = 1;
	  tab_ok['id_form'] = 1;
	  tab_ok['id_position'] = 1;
	  tab_ok['id_fiche'] = 1;
	  tab_ok['assetcl'] = 1;
	  tab_ok['objcl'] = 1;
	  ////////////////////////////////////////
		

	  	  
	  //je construit mon tableau a partir de mon url
	  for (var i=1;i<param_url.length;i++){ 
	  	
	    if(tab_ok[param_url[i].substring(0,param_url[i].indexOf("="))] == 1) {
	    // alert(param_url[i].substring(0,param_url[i].indexOf("=")) +":::::"+param_url[i].substring(param_url[i].indexOf("=")+1))
	    

	     	if(param_url[i].substring(0,param_url[i].indexOf("="))=='id_position') id_position = tabparams[clef];
	     	tabparams[param_url[i].substring(0,param_url[i].indexOf("="))] = param_url[i].substring(param_url[i].indexOf("=")+1);

	    	
	    	
	    }
	  }
	 	//alert(tabparams['each'])
		/*
		texte="";	  
		
		for (var clef in tabparams){
			//if (typeof(tabparams[clef]) != 'function')  
			texte += clef+' : '+ tabparams[clef]+"\n";
		 	//texte += "tabparams[" + clef + "] = " + tabparams[clef] + "\n";
		}		  
	  alert(texte)
	  */
	  
		//je split ma var champ qui contient tous les champs avec valeur
	  var param_champ = champ.split(',');	  
	  newtabparam = new Array;
	  //je construit mon new tableau
	  for (var i=0;i<param_champ.length;i++){
	    newtabparam[param_champ[i].substring(0,param_champ[i].indexOf("="))]=param_champ[i].substring(param_champ[i].indexOf("=")+1);
	  }
	 //je modifie l'ancien avec le nouveau
	  for (var clef in newtabparam){
	  	tabparams[clef] = newtabparam[clef];
	  }
	  //alert(texte);
		myurl="";
		for (var clef in tabparams){
			if (typeof(tabparams[clef]) != 'function') {
				
				if((tabparams[clef]!=""))  {
						myurl += "&"+clef +"="+tabparams[clef];
				}
			}
		}
		
		if((myurl.slice(0, 1)=='&')) myurl = myurl.slice(1, myurl.length);
		myurl = myurl.replace("#", "");
	  //alert(myurl)
	  
		if(retour==undefined){ 
			myurl = pageadminform+'?' + myurl;
			document.location.href = myurl;
			
		} else if(retour==2){
			return myurl;
			
		} else {
			myurl = pageadminform+'?' + myurl;
			return myurl;
		}
}














//script pour le resume principalement
function view_resume(d){
        var pathname=location.pathname;
        var myDomain=pathname.substring(0,pathname.lastIndexOf('/')) +'/';
        var date_exp = new Date();
        date_exp.setTime(date_exp.getTime()+(365*24*3600*1000));

        if (document.getElementById("resume").style.display =='') {
                document.getElementById("resume").style.display = 'none';
                document.getElementById("iresume").src=old;
                SetCookie("resum","none",date_exp,myDomain);
        } else {
                document.getElementById("resume").style.display='';
                old=document.getElementById("iresume").src;
                document.getElementById("iresume").src='images/icons/rminus.gif';
                SetCookie("resum","",date_exp,myDomain);
        }
}



function change_iframe_src(op,id_position,id_fiche,id_module,find_search){
	//ne change juste que le src de l'iframe
	//alert(parent.document.getElementById("iframe_test").src)
	mon_link=pageadmin+"op="+op;
	//alert(id_position)
	if(id_position != ""){
		mon_link+="&id_position=" + id_position; 
	}
	
	if(id_fiche != ""){
		mon_link+="&id_fiche=" + id_fiche; 
	}
	
	if(id_module != ""){
		mon_link+="&id_module=" + id_module; 
	}	
	/*
	if(find_search != ""){ //alert(id_fiche)
		mon_link+="&find=" + id_fiche; 
	}
	*/
	//alert(mon_link)
  //ed = parent.document.getElementById("iframe_test");
  //ed.setAttribute("src", mon_link)	;
  document.location.href=mon_link;
  //alert();
}

function heritage(d){
        if (document.getElementById(d).style.height =='') {
                document.getElementById(d).style.height = '18px';
                document.getElementById("i"+d).src='/kbx_conf/images/system/plus.gif';
        } else {
                document.getElementById(d).style.height='';
                document.getElementById("i"+d).src='/kbx_conf/images/system/minus.gif';
        }
}
function show_admin_old(d){
        var pathname=location.pathname;
        var myDomain=pathname.substring(0,pathname.lastIndexOf('/')) +'/';
        var date_exp = new Date();
        date_exp.setTime(date_exp.getTime()+(365*24*3600*1000));	
        if (document.getElementById(d).style.height =='') {
                document.getElementById(d).style.height = '28px';
                document.getElementById("i"+d).src='/kbx_conf/images/system/plus.gif';
                SetCookie(d,'none',date_exp,myDomain);                
        } else {
                document.getElementById(d).style.height='';
                document.getElementById("i"+d).src='/kbx_conf/images/system/minus.gif';
                SetCookie(d,'',date_exp,myDomain);    
        }
}
function displaydiv(d){
	
				var content = document.getElementById(''+d);
				var header = document.getElementById('Header'+d);

		  if(d){
        if (content.style.display=='none') { //
        	//alert(content.style.display)
              header.className = 'TabTitleBar_on';
              content.className = 'TabContentBox_on';
              content.style.display='block';
        			SetCookie (d, '');
        } else {
              header.className = 'TabTitleBar';
              content.className = 'TabContentBox';
              content.style.display = 'none';
              SetCookie (d, 'none');
        }
			}
}
/*
function SetEncodeTabCookie(val){
	cook = GetCookie ('TabTypeView');
	tab = cook.split(",");
}
function GetEncodeTabCookie(val){
	
}*/
function loadtabs(){
				tabs = document.getElementsByTagName('div');
				for(i = 0; i < tabs.length; i++){
					if (tabs[i].className == 'TabContentBox_on'){
						cook = GetCookie (tabs[i].id);
						//alert('toto'+cook);
						if(cook=='none')
							displaydiv(tabs[i].id);
					}
				}		
}
function loadtabs2(nom){
	var champs='';
				tabs = document.getElementsByTagName('tr');
				for(i = 0; i < tabs.length; i++){

					if (tabs[i].className == nom){
						champs += '' + tabs[i].id + ' : ';
						//alert(tabs[i].id)
					}
				}
				alert(champs);		
}

function delete_charact(tmp_url){
	//document.location.href="admin.php?op=navigation_charact_list_delete"+tmp_url;
	
}
function restoreAssets(){
	
	var liste = select_checked_liste();
	var fiches = "";
	for (var clef in liste){
		fiches+= "&fiches[]=" + liste[clef];
	}
	myurl = TJS_ExtractURL("module=Workspace,objcl=,create_action=setRestoreDeletedFiche"+fiches, 1);
	view_pop(2,myurl);return false;
}


//renvoi un tableau de cases selectionnées
function select_checked_liste(){

	var countElements = document.getElementById('select_all_bouton').value;
	var tab = new Array();
	var count = 0;
	for (var idx = 1; idx <= countElements; idx++) {
		
			if(document.getElementById('check_list_' +idx).checked==true){
				//alert(document.getElementById('check_list_' +idx).value)
				tab[count] = document.getElementById('check_list_' +idx).value;
			}
			count++;
		}			
		return tab;
}

//est apelée a partir de liste des sous fiches pour grouper une liste de fiches et modifier leur LCA
function setManageLca(from){
	var liste = select_checked_liste();
	var fiches = "";
	for (var clef in liste){
		fiches+= "&fiches[]=" + liste[clef];
	}
	if(from=='search') tmp_url= "id_position=,"; else tmp_url="";
	myurl = TJS_ExtractURL(tmp_url+"module=Workspace,objcl=,create_action=getFormLcaArbo"+fiches, 1);
	view_pop(1,myurl);return false;
}
/*
//est apelée a partir de liste des sous fiches pour grouper une liste de fiches et modifier leur LCA
function setManageLcaFromSearch(){
	var liste = select_checked_liste();
	var fiches = "";
	for (var clef in liste){
		fiches+= "&fiches[]=" + liste[clef];
	}
	myurl = TJS_ExtractURL("id_position=,module=Workspace,objcl=,create_action=getFormLcaArbo"+fiches, 1);
	view_pop(1,myurl);return false;
}
*/
//est apelée a partir de liste des sous fiches pour grouper une liste de fiches et modifier leur LCA
function setManageType(from){
	var liste = select_checked_liste();
	var fiches = "";
	for (var clef in liste){
		fiches+= "&fiches[]=" + liste[clef];
	}
	if(from=='search') tmp_url= "id_position=,"; else tmp_url="";
	myurl = TJS_ExtractURL(tmp_url+"module=Workspace,objcl=,create_action=getFormTypesArbo"+fiches, 1);
	view_pop(1,myurl);return false;
}
/*
//est apelée a partir de liste des sous fiches pour grouper une liste de fiches et modifier leur LCA
function setManageTypeFromSearch(from){
	var liste = select_checked_liste();
	var fiches = "";
	for (var clef in liste){
		fiches+= "&fiches[]=" + liste[clef];
	}
	myurl = TJS_ExtractURL("id_position=,module=Workspace,objcl=,create_action=getFormTypesArbo"+fiches, 1);
	view_pop(1,myurl);return false;
}
*/
function select_all(etat, countElements, objlistname, maclass){

	//si le bouton select all est coché

	if (etat==true){
		for (var idx = 1; idx <= countElements; idx++) {
			idstyle = ((idx%2)) ? "2" : "1";
			document.getElementById(objlistname +idx).checked=true;
			document.getElementById(objlistname +idx).disabled=false;
			if(maclass) document.getElementById("t_"+objlistname + idx).className = maclass+idstyle + "_on";
		}			
	} else {
		for (var idx = 1; idx <= countElements; idx++) {
			idstyle = ((idx%2)) ? "2" : "1";
			document.getElementById(objlistname +idx).checked=false;
			if(maclass) document.getElementById("t_"+objlistname + idx).className = maclass+idstyle;
		}		
	}
}


///////////////////////////////////////
//Arbo gauche
//////////////////////////////////////

	//CHANGE LE NOM DE LA CLASS AVEC _ON SI SELECTIONNÉ ET REMET A L'ORIGINAL SINON
	function changeStyle(obj, checkinput){
		
		if(obj.className.substr(obj.className.length - 3, 3)=='_on'){
				obj.className = obj.className.substr(0, obj.className.length - 3);
				if(checkinput) document.getElementById(checkinput).checked = false;
				if($(obj).parent().parent().parent().parent().attr('id')=='displayAssetBloc2'){
					$(obj).parent().parent().parent().parent().removeClass('selected');
				}
		}else{
				obj.className = obj.className + '_on';
				if(checkinput) document.getElementById(checkinput).checked = true;
				if($(obj).parent().parent().parent().parent().attr('id')=='displayAssetBloc2'){
					$(obj).parent().parent().parent().parent().addClass('selected');
				}
		}
	}
	var newwindow;	
	function open_win(url,l,h,nom){
	        if(l==null) l=500;
	        if(h==null) h=500;
	        var optionss="toolbar=no,location=no,status=no,"
	        + "menubar=no,scrollbars=yes,resizable=no,"
	        + "width="+l+","
	        + "height="+h
	        newwindow = window.open(url,nom,optionss);
	        
	//newwindow=window.open(url,'name','height=400,width=200');
	if (window.focus) {newwindow.focus()}
	}
	
	
	
	function Change_formulaire(id_fiche,id_module,id_position,op){
		//alert(id_position);
		id_form=document.options_fiche.formulaire.value;
		if (id_form!=0){
			if (id_position!=""){
				document.location.href=pageadmin+'op='+op+'&id_form='+id_form+'&id_position='+id_position;
			}else{
				document.location.href=pageadmin+'op='+op+'&id_fiche='+ id_fiche +'&id_form='+id_form;
				//'&id_module='+ id_module +
			}
		}
		
		//if (document.options_fiche.formulaire.value!=0){}		
		
		
	}
	
function getMsgDeleteFicheConfirm(){
			var temp = "Vous désirez vraiment detacher ? \n(Toutes les sous fiches ne seront plus visibles !)";
			if (confirm(temp)) {		
				TJS_ExtractURL('create_action=deleteFicheNode')
				//alert(myurl);
			}
}
	
function getMsgDeleteAssetConfirm(id_asset, myurl){
			var temp = "Vous désirez vraiment supprimer cet élément ? \n";
			document.getElementById(id_asset).className = "assetHighlight";
			if (confirm(temp)) {		
				view_pop(2,myurl);
				//TJS_ExtractURL('create_action=deleteFicheNode')
				//alert(myurl);
			}else{
				document.getElementById(id_asset).className = "";
			}
}

function Change_Arbo_Content(obj_form,formulaire,id_role){
	
	//value_pop	=	eval("document." + obj_form.form.name + ".move_fiche.value");
	value_pop = obj_form;	
	//alert(formulaire)
	form_to_send = eval("document."+formulaire);

	if (value_pop!=0){
		
		//SUPRESSION EN LOTS=>LISTE SOUS FICHES
		if (value_pop=="delete"){
			var temp = "Vous désirez vraiment detacher ? \n(Toutes les sous fiches ne seront plus visibles !)";
			if (confirm(temp)) {		
				form_to_send.action_temp.value = value_pop;
				form_to_send.create_action.value='SupprimeNoeud';
				form_to_send.submit();
			}
			
		//SUPRESSION A PARTIR DE LA RECHERCHE	
		}else if (value_pop=="del_fiche") {
			var temp = "Vous désirez vraiment supprimer définitivement ?";
			if (confirm(temp)) {		
				//alert('fonction a revoir');
				form_to_send.action_temp.value = value_pop;
				form_to_send.create_action.value=value_pop;
				form_to_send.submit();
			}
			
		} else if (value_pop=="fiche_associe"){

			open_win('about:blank','800','600','openArbo');
			form_to_send.action_temp.value = value_pop;
			form_to_send.id_role.value=id_role;
			form_to_send.create_action.value=value_pop;
			form_to_send.target='openArbo';
			form_to_send.submit();
		} else {
			open_win('about:blank','800','600','openArbo');
			form_to_send.action_temp.value = value_pop;
			form_to_send.create_action.value='openArbo';
			form_to_send.target='openArbo';
			form_to_send.submit();
			//alert(value_pop)
		}
	}
		
		
}




function Ordonner_arbo(id_position){
	link = TJS_ExtractURL("create_action=ordonner&pop=1&id_position=" + id_position,1);
	open_win(link ,'500','600','action');
}

function Arbo_actionjs(arbo_action) {
	document.form_action.action_temp.value=arbo_action;
	document.form_action.submit();
}

function searchAsset(){

	//module_name=document.getElementById("searchModuleList").value;
	module_name="";
	key_search=document.getElementById("searchValue").value;
	//module_name=document.form_search.module_list.value;
	//key_search=document.form_search.find.value;
	var tab_categ= new Array();
	$('#rapidSearch input.categorie:checked').each(function(){
		tab_categ.push($(this).attr('value'));
	});
	
	//if(module_name!="") 
	TJS_ExtractURL("id_fiche=,objcl=,id_position=,module=SearchAsset,idAssetType="+ module_name +",find=" + key_search + ",categories=" + tab_categ.join(':') + ",search=new");

	
	
}
function submit_formulaire(submit_value, obj_form, validform){
	//alert(submit_value)
	eval("document."+ obj_form.form.name + ".create_action.value=submit_value");
	//alert(validform);
	if(validform==true) {
		//myform = eval("v" + obj_form.form.name+"exec()");
		//alert(myform);
		if (eval("v_" + obj_form.form.name+".exec()")) eval("document."+ obj_form.form.name + ".submit()");
	}else{
		 eval("document."+ obj_form.form.name + ".submit()");
	}
}
function submit_formulaire_name(submit_value, form_name, validform){
	
	//eval("document."+ form_name + ".create_action.value=submit_value");
	//eval("document."+ form_name + ".create_action.value='"+submit_value+"'");
	var frm = document.getElementById(form_name);
	frm.create_action.value = submit_value;

	if(validform==true) {
	    if (v.exec())  frm.submit();
		//if (v.exec()) 	eval("document."+ form_name + ".submit()");
	}else{
		 	//eval("document."+ form_name + ".submit()");
		 	frm.submit();
	}	
}
//////////////////////////////////////


	





/////////////////////////////////////////////
/*ANCIEN BOUTON POP EMPLACEMENT 
	function pop() 
	{	
		
		var bak = '#f1f1f1';
		var content ="<div class=box>"
		            +"<table border=0 cellspacing=0 cellpadding=2 width=600><TR bgcolor='#0099FF' nowrap align=left>"
			            +"<td bgcolor='#0099FF'' width='550'><b><FONT FACE='verdana,ARIAL' COLOR=#FFFFFF SIZE=1>Classement</FONT></b></TD>"
			            +"<td bgcolor='#0099FF' width='50' align=right><a href='javascript:kill()'><FONT FACE='verdana,ARIAL' COLOR=#FFFFFF SIZE=1>Fermer</FONT></td></TR>"
		            +"<TR BGCOLOR=#C9D0D6>"
		            	+"<TD colspan=2><table border=1 cellspacing=0 cellpadding=4 width=100% style=\"border-collapse: collapse\">"+msg+"</table></TD></TR>"
		            +"</TABLE></div>";
		monLayer = "topdeck";
		document.write ("<DIV class=popper id=\"topdeck\" name=\"topdeck\"></DIV>");
		document.getElementById(monLayer).innerHTML=content; 
		document.getElementById(monLayer).style.visibility= 'visible';

	}
	
	function kill() 
	{
		document.getElementById(monLayer).style.visibility= 'hidden';
	} 
	//////////////////////////////////////////
*/	
	
	
	function send_image_to_uploader(obj_form, msg){
		canal = eval("document."+obj_form+".list_canaux.value");
		
		if(canal!=0){
			getImageUploader('ImageUploader').Send();
			}else{
			alert(msg);
		}
	//
	
	}




	function excel_export(file_name, id_export){
		mon_url=parent.document.location.href;
		var regexp=new RegExp("[?&]");
		var tab=mon_url.split(regexp);
		param=new Array;
		//split l'url iframe
		for (var i=1;i<tab.length;i++){ 
			param[tab[i].substring(0,tab[i].indexOf("="))]=tab[i].substring(tab[i].indexOf("=")+1)
		}
		//alert(document.options_fiche.formulaire.value);
		id_form = document.options_fiche.formulaire.value;
		link_url = pageadmin+"op="
			+param["op"]
			+"&id_position="
			+param["id_position"]
			+"&action="+file_name
			+"&id_form="+id_form;
		//if(param["id_form"] != undefined) link_url+="&id_form="+param["id_form"]
		//if(id_export != undefined) link_url+="&exp="+id_export
		
		//TJS_ExtractURL('action=Tablefamille')
		
		
		//alert(file_name);
		if(file_name=='attach_product'){
			var x=window.confirm("Enregistrer liste dans bdd ?")
			if (x) link_url+="&expdb=1";
			//alert(link_url);
		}
		if(file_name=='export_docs'){
			var reponse = prompt("Quel est le nom du dossier ? ", "sans_titre");
			link_url+="&label="+reponse;
		}
		
		
		
		if((file_name != undefined) || (file_name != "")){
			//alert("admin.php?op="+param['op']+"&action=wait");
			//view_pop(1, "admin.php?op="+param['op']+"&action=wait");
			document.location.href = link_url;
		}
		
	}


































































	
	
// Aurigma Image Uploader Embedding Script 
// Version 1.0.0.3 July 1, 2005
// Copyright(c) Aurigma Inc. 2002-2005
var __agt=navigator.userAgent.toLowerCase();
var _isWinIE=(__agt.indexOf("msie")!=-1)&&(__agt.indexOf("win")!=-1);
var _isSafari=(__agt.indexOf("safari")!=-1);

function ImageUploaderWriter(id,width,height){
	//Private
	this._params=new Array();
	this._events=new Array();    

	this._writeObjectParam=function(name,value){
		document.writeln("<param name=\""+name+"\" value=\""+value+"\" />");
	}

	this._writeObjectParams=function(){
		var p=this._params;
		var i;
		for (i=0;i<p.length;i++){
			this._writeObjectParam(p[i].name,p[i].value);
		}
	}
	
	this._writeObjectEvents=function(){	
		var e=this._events;
		for (i=0;i<e.length;i++){
			this._writeObjectParam(e[i].name+"Listener",e[i].listener);
		}
	}

	this._writeEmbedParam=function(name,value){
		document.write(" "+name+"=\""+value+"\"");	
	}

	this._writeEmbedParams=function(){
		var p=this._params;
		var i;
		for (i=0;i<p.length;i++){
			this._writeEmbedParam(p[i].name,p[i].value);
		}
	}

	this._writeEmbedEvents=function(){	
		var e=this._events;
		for (i=0;i<e.length;i++){
			this._writeEmbedParam(e[i].name+"Listener",e[i].listener);
		}
	}

	//Public

	//Properties
	this.id=id;
	this.width=width;
	this.height=height;

	this.activeXControlEnabled=true;
	this.activeXControlCodeBase="ImageUploader3.cab";
	this.activeXControlVersion="";

	this.javaAppletEnabled=true;
	this.javaAppletCodeBase="./";
	this.javaAppletCached=true;
	this.javaAppletVersion="";

	this.fullPageLoadListenerName=null;

	//Methods
	this.addParam=function(paramName,paramValue){		
		var p=new Object();
		p.name=paramName;
		p.value=paramValue;
		this._params.push(p);
	}

	this.addEventListener=function(eventName,eventListener){
		var p=new Object();
		p.name=eventName;
		p.listener=eventListener;
		this._events.push(p);		
	}

	this.writeHtml=function(){
		var a=navigator.userAgent.toLowerCase();
		var isOpera=(a.indexOf("opera")!=-1);
		var isWinIE=(a.indexOf("msie")!=-1)&&(a.indexOf("win")!=-1)&&!isOpera;
		var isSafari=(a.indexOf("safari")!=-1);
		//ActiveX control
		if(isWinIE&&this.activeXControlEnabled){
			this.controlType="ActiveX";
			var v=this.activeXControlVersion.replace(/\./g,",")
			var cb=this.activeXControlCodeBase+(v==""?"":"#version="+v);
			
			document.writeln("<object id=\""+this.id+"\" name=\""+this.id+"\" classid=\"clsid:A18962F6-E6ED-40B1-97C9-1FB36F38BFA8\" codebase=\""+cb+"\" width=\""+this.width+"\" height=\""+this.height+"\">");

			this._writeObjectParams();

			document.writeln("</object>");
			
			//Event handlers
			var e=this._events;
			var eventParams;
			for (i=0;i<e.length;i++){
				if (e[i].name=="Progress"){
					eventParams="Status, Progress, ValueMax, Value, StatusText";
				}
				else if (e[i].name=="ViewChange"){
					eventParams="Pane";
				}
				else{
					eventParams="";
				}
				document.writeln("<" + "script for=\""+this.id+"\" event=\""+e[i].name+"("+eventParams+")\">");
				if (e[i].name=="BeforeUpload"){
					document.write("return ");
				}
				document.writeln(e[i].listener+"("+eventParams+");");
				document.writeln("<"+"/script>");
			}

			//Set/get expando methods
			var props=new Array("Action","AdditionalFolderNavigator","AdditionalFormName","AllowMultipleSelection","AllowTreePaneWidthChanging","AutoRecoverMaxTriesCount","AutoRecoverTimeOut","BackgroundColor","ButtonAddAllToUploadListText","ButtonAddFilesText","ButtonAddFoldersText","ButtonAddToUploadListText","ButtonDeleteFilesText","ButtonDeselectAllText","ButtonFontName","ButtonFontSize","ButtonPasteText","ButtonRemoveAllFromUploadListText","ButtonRemoveFromUploadListText","ButtonSelectAllText","ButtonSendText","ButtonStopText","CheckFilesBySelectAllButton","CodePage","DeniedFileMask","DescriptionEditorButtonOkText","DescriptionEditorButtonCancelText","DescriptionsReadOnly","DimensionsAreTooLargeText","DimensionsAreTooSmallText","DisplayNameActiveSelectedTextColor","DisplayNameActiveUnselectedTextColor","DisplayNameInactiveSelectedTextColor","DisplayNameInactiveUnselectedTextColor","DropFilesHereText","EditDescriptionText","EditDescriptionTextColor","EnableFileViewer","EnableRotate","ExtractExif","FileMask","FileIsTooLargeText","FilesPerOnePackageCount","FolderPaneHeight","FolderView","HashAlgorithm","HoursText","IncludeSubfoldersText","IncorrectFileActiveSelectedTextColor","IncorrectFileActiveUnselectedTextColor","IncorrectFileInactiveSelectedTextColor","IncorrectFileInactiveUnselectedTextColor","KilobytesText","Layout","LicenseKey","ListColumnFileNameText","ListColumnFileSizeText","ListColumnFileTypeText","ListColumnLastModifiedText","LoadingFilesText","MaxDescriptionTextLength","MaxFileCount","MaxFileSize","MaxImageHeight","MaxImageWidth","MaxTotalFileSize","MegabytesText","MenuAddAllToUploadListText","MenuAddToUploadListText","MenuDeselectAllText","MenuDetailsText","MenuIconsText","MenuInvertSelectionText","MenuListText","MenuRefreshText","MenuRemoveAllFromUploadListText","MenuRemoveFromUploadListText","MenuSelectAllText","MenuThumbnailsText","MessageBoxTitleText","MessageCannotConnectToInternetText","MessageDimensionsAreTooLargeText","MessageDimensionsAreTooSmallText","MessageMaxFileCountExceededText","MessageUserSpecifiedTimeoutHasExpiredText","MessageMaxFileSizeExceededText","MessageMaxTotalFileSizeExceededText","MessageNoFilesToSendText","MessageNoInternetSessionText","MessageNoResponseFromServerText","MessageRedirectText","MessageServerNotFoundText","MessageSwitchAnotherFolderWarningText","MessageUnexpectedErrorText","MessageUploadCancelledText","MessageUploadCompleteText","MessageUploadFailedText","MinImageHeight","MinImageWidth","MinutesText","Padding","PaneBackgroundColor","PreviewThumbnailActiveColor","PreviewThumbnailInactiveColor","PreviewThumbnailSize","ProgressDialogSentText","ProgressDialogCancelButtonText","ProgressDialogCloseButtonText","ProgressDialogCloseWhenUploadCompletesText","ProgressDialogEstimatedTimeText","ProgressDialogPreparingDataText","ProgressDialogTitleText","ProgressDialogWaitingForResponseFromServerText","ProgressDialogWidth","QualityMeterAcceptableQualityColor","QualityMeterBackgroundColor","QualityMeterBorderColor","QualityMeterFormats","QualityMeterHighQualityColor","QualityMeterLowQualityColor","RedirectUrl","RememberLastVisitedFolder","SecondsText","ShowButtons","ShowContextMenu","ShowDebugWindow","ShowDeleteButton","ShowDescriptions","ShowFileNames","ShowPasteButton","ShowStatusPane","ShowSubfolders","ShowUploadCompleteMessage","ShowUploadListButtons","SignatureFilter","SilentMode","StatusFilesInFolderText","StatusSelectedFilesText","TimeOut","TotalFileSize","TreePaneWidth","ThumbnailHorizontalSpacing","ThumbnailVerticalSpacing","UncheckUploadedFiles","UnixFileSystemRootText","UnixHomeDirectoryText","UploadItems","UploadFileCount","UploadMode","UploadSourceFile","UploadThumbnail1CopyExif","UploadThumbnail1FitMode","UploadThumbnail1Height","UploadThumbnail1JpegQuality","UploadThumbnail1Width","UploadThumbnail2CopyExif","UploadThumbnail2FitMode","UploadThumbnail2Height","UploadThumbnail2JpegQuality","UploadThumbnail2Width","UploadThumbnail3CopyExif","UploadThumbnail3FitMode","UploadThumbnail3Height","UploadThumbnail3JpegQuality","UploadThumbnail3Width","UploadView","UseSystemColors","Version");

			var o=document.getElementById(this.id);
			for (i=0;i<props.length;i++){
				eval("o.set"+props[i]+"=function(v){this."+props[i]+"=v};");
				eval("o.get"+props[i]+"=function(){return this."+props[i]+"};");
			}
			
			if (this.fullPageLoadListenerName!=null){
				document.writeln("<" + "script>");
				document.writeln("window.attachEvent(\"onload\",new Function(\""+this.fullPageLoadListenerName+"();\"));");
				document.writeln("<"+"/script>");
			}
		}
		else 
		//Java appplet
		if(this.javaAppletEnabled){
			this.controlType="Java";
			if (this.fullPageLoadListenerName!=null){
				document.writeln("<" + "script language=\"javascript\">");
				document.writeln("var __"+this.id+"_pageLoaded=false;");
				document.writeln("var __"+this.id+"_appletLoaded=false;");
				document.writeln("function __"+this.id+"_InitComplete(){");
				document.writeln("	__"+this.id+"_appletLoaded=true;");
				document.writeln("	__fire_"+this.id+"_fullPageLoad();");
				document.writeln("}");
				document.writeln("function __fire_"+this.id+"_fullPageLoad(){");
				document.writeln("		if (__"+this.id+"_pageLoaded&&__"+this.id+"_appletLoaded){");
				document.writeln("		"+this.fullPageLoadListenerName+"();");
				document.writeln("	}");
				document.writeln("}");
				var pageLoadCode="new Function(\"__"+this.id+"_pageLoaded=true;__fire_"+this.id+"_fullPageLoad();\")"
				if (isWinIE){
					document.writeln("window.attachEvent(\"onload\","+pageLoadCode+");");
				}
				else{
					document.writeln("var r=window.addEventListener?window:document.addEventListener?document:null;");
					document.writeln("if (r){r.addEventListener(\"load\","+pageLoadCode+",false);}");
				}
				document.writeln("<"+"/script>");
			}

			//<object> for IE and <applet> for Safari
			if (isWinIE||isSafari){
				if (isWinIE){
					document.writeln("<object id=\""+this.id+"\" classid=\"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93\" codebase=\"http://java.sun.com/update/1.4.2/jinstall-1_4-windows-i586.cab#Version=1,4,0,0\" width=\""+this.width+"\" height=\""+this.height+"\">");
				}
				else{
					document.writeln("<applet id=\""+this.id+"\" code=\"com.aurigma.imageuploader.ImageUploader.class\" java_codebase=\"../\" align=\"baseline\" archive=\"kbx_temp/ImageUploader.jar\" mayscript=\"true\" scriptable=\"true\" width=\""+this.width+"\" height=\""+this.height+"\">");
				}

				if (this.javaAppletCached&&this.javaAppletVersion!=""){
					this._writeObjectParam("cache_archive","kbx_temp/ImageUploader.jar");
					var v=this.javaAppletVersion.replace(/\,/g,".");
					this._writeObjectParam("cache_version",v+","+v);
				}

				this._writeObjectParam("type","application/x-java-applet;version=1.4");
				this._writeObjectParam("codebase",this.javaAppletCodeBase);
				this._writeObjectParam("archive","kbx_temp/ImageUploader.jar");
				this._writeObjectParam("code","com.aurigma.imageuploader.ImageUploader.class");
				this._writeObjectParam("scriptable","true");
				this._writeObjectParam("mayscript","true");

				this._writeObjectParams();

				this._writeObjectEvents();

				if (this.fullPageLoadListenerName!=null){
					this._writeObjectParam("InitCompleteListener","__"+this.id+"_InitComplete");
				}
				if (isWinIE){
					document.writeln("</object>");
				}
				else{
					document.writeln("</applet>");
				}
			}
			//<embed> for all other browsers
			else{
				document.write("<embed id=\""+this.id+"\" type=\"application/x-java-applet;version=1.4\" codebase=\""+this.javaAppletCodeBase+"\" code=\"com.aurigma.imageuploader.ImageUploader.class\" archive=\"kbx_temp/ImageUploader.jar\" width=\""+this.width+"\" height=\""+this.height+"\" scriptable=\"true\" mayscript=\"true\" pluginspage=\"http://java.sun.com/products/plugin/index.html#download\"");

				if (this.javaAppletCached&&this.javaAppletVersion!=""){
					this._writeEmbedParam("cache_archive","kbx_temp/ImageUploader.jar");
					var v=this.javaAppletVersion.replace(/\,/g,".");
					this._writeEmbedParam("cache_version",v+","+v);
				}

				this._writeEmbedParams();

				this._writeEmbedEvents();

				if (this.fullPageLoadListenerName!=null){
					this._writeEmbedParam("InitCompleteListener","__"+this.id+"_InitComplete");
				}
				document.writeln(">");
				document.writeln("</embed>");
			}
		}
		else
		{
			this.controlType="None";		
			document.writeln("Your browser is not supported.");
		}
	}
}

function getImageUploader(id){
	if (_isSafari){
		return document[id];
	}
	else{
		return document.getElementById(id);
	}
}


function redimImage(inImg, inMW, inMH)
{
  // Cette function recoit 3 parametres
  // inImg : Chemin relatif de l'image
  // inMW  : Largeur maximale
  // inMH   : Hauteur maximale
  var maxWidth = inMW;
  var maxHeight = inMH;
  // Declarations des variables "Nouvelle Taille"
  var dW = 0;
  var dH = 0;
  // Declaration d'un objet Image
  var oImg = new Image();
  // Affectation du chemin de l'image a l'objet
  oImg.src = inImg;
  // On recupere les tailles reelles
  var h = dH = oImg.height;
  var w = dW = oImg.width;
  // Si la largeur ou la hauteur depasse la taille maximale
  if ((h >= maxHeight) || (w >= maxWidth)) {
    // Si la largeur et la hauteur depasse la taille maximale
    if ((h >= maxHeight) && (w >= maxWidth)) {
      // On cherche la plus grande valeur
      if (h > w) {
        dH = maxHeight;
        // On recalcule la taille proportionnellement
        dW = parseInt((w * dH) / h, 10);
      } else {
        dW = maxWidth;
        // On recalcule la taille proportionnellement
        dH = parseInt((h * dW) / w, 10);
      }
    } else if ((h > maxHeight) && (w < maxWidth)) {
      // Si la hauteur depasse la taille maximale
      dH = maxHeight;
        // On recalcule la taille proportionnellement
      dW = parseInt((w * dH) / h, 10);
    } else if ((h < maxHeight) && (w > maxWidth)) {
      // Si la largeur depasse la taille maximale
      dW = maxWidth;
        // On recalcule la taille proportionnellement
      dH = parseInt((h * dW) / w, 10);
    }
  }
  // On ecrit l'image dans le document
  document.writeln("<img src=\"" + inImg + "\" width=\"" + dW + "\" height=\"" + dH + "\" border=\"0\">");
}

function testerRadio(radio) {
      for (var i=0; i<radio.length;i++) {
         if (radio[i].checked) {
            return radio[i].value;
         }
      }
   }
   
   
   
   
   
   
   
   