function validpart(){
	var f_artist_antibot = document.getElementById("f_artist_antibot").value;
	if(f_artist_antibot == "rouge"){

		if(nameok && emailok && accrocheok && texteok && keyok && botok){
			var url = 'http://www.artconek.com/partners/process_update.php';
			var f_artist_name = document.getElementById("f_artist_name").value;
			var f_artist_accroche = document.getElementById("f_artist_accroche").value;
			var f_artist_texte = document.getElementById("f_artist_texte").value;
			var f_artist_keyword = document.getElementById("f_artist_keyword").value;
			var f_artist_url = document.getElementById("f_artist_url").value;
			var f_artist_email = document.getElementById("f_artist_email").value;
			var f_artist_choixoptmail = "";
			var f_artist_password = document.getElementById("f_artist_password").value;
			var partner = document.getElementById("partner").value;
			var myAjax = new Ajax.Request( url, {method: 'post', postBody: 'f_artist_name='+f_artist_name+'&f_artist_accroche='+f_artist_accroche+'&f_artist_texte='+f_artist_texte+'&f_artist_keyword='+f_artist_keyword+'&f_artist_url='+f_artist_url+'&f_artist_email='+f_artist_email+'&f_artist_choixoptmail='+f_artist_choixoptmail+'&f_artist_password='+f_artist_password+'&partner='+partner, onLoading: showLoad_update, onComplete: showResponse_update} );
		}
	}
	return false;
}

var nametemp = "";
var urltemp = "";
var emailtemp = "";
var accrochetemp = "";
var textetemp = "";
var keytemp = "";
var bottemp = "";

var nameok = 0;
var emailok = 0;
var accrocheok = 0;
var texteok = 0;
var keyok = 0;
var botok = 0;

function trim(s) {
    return s.replace(/^\s+/, '').replace(/\s+$/, '');
}


function kpHandler(e) {




	var code;
	if(window.event) {
		code = e.keyCode;
	} else {
		code = e.which;
	}
	if(code == 13) { // Enter
		checkdata();
	}
}

function checkdata(){
	var elm = document.getElementById("gp_art");
	var node;
	if (elm) {
		var subnodes = elm.getElementsByTagName("*");			
		for (var i=0; i<subnodes.length; i++) {
			var lib = "res";
			node = subnodes[i];
			if (node.nodeName == "DIV" && node.className == "edit") {
				var o1 = search(node.parentNode.id,"DIV","ttl");
					
					var subsubnodes = node.getElementsByTagName("*");
					if(subsubnodes[0]){
						var vv = subsubnodes[0].value;
						
						if((subsubnodes[0].id == "f_artist_password")||(subsubnodes[0].id == "f_artist_password2")){
							vv= vv.replace(/./gi,"*");  
							if(subsubnodes[0].value.length < 6){
								lib = "reserre";
								vv += " minimum 6 caract&egrave;res";
							}else {
								if(subsubnodes[0].id == "f_artist_password2"){
									 if(subsubnodes[0].value != document.getElementById("f_artist_password").value){
										lib = "reserre";
										vv += " confirmation incorrect";
									 }
								}
							}							
						}
						
						if((subsubnodes[0].id == "f_artist_name")||(subsubnodes[0].id == "f_artist_url")||(subsubnodes[0].id == "f_artist_email")){
								
								if(subsubnodes[0].id == "f_artist_name"){ 
									if(subsubnodes[0].value != nametemp){
										checkform(subsubnodes[0].id);
										
									}
								}
								if(subsubnodes[0].id == "f_artist_url"){ 
									if(subsubnodes[0].value != urltemp){
										checkform(subsubnodes[0].id);
									}
								}
								if(subsubnodes[0].id == "f_artist_email"){ 
									if(subsubnodes[0].value != emailtemp){
										checkform(subsubnodes[0].id);
									}
								}
								var o_lib = document.getElementById("lib_"+subsubnodes[0].id);
								if(o_lib){if(o_lib.className == "reserre"){ lib = "reserre";}}
								if(subsubnodes[0].id == "f_artist_name"){nametemp = subsubnodes[0].value;}
								if(subsubnodes[0].id == "f_artist_url"){urltemp = subsubnodes[0].value;}
								if(subsubnodes[0].id == "f_artist_email"){emailtemp = subsubnodes[0].value;}
						}
						if(subsubnodes.length > 0){
					
							if(subsubnodes[0].value != ""){
							     var splt = new Array(2);
								splt[0]= "" ;splt[1]="" ;
								var div = ((o1.innerHTML.indexOf("</DIV>") > 0) ? "</DIV>" : ((o1.innerHTML.indexOf("</div>") > 0) ? "</div>" : "</DIV>"));
								splt = o1.innerHTML.split(div);
								if((subsubnodes[0].id == "f_artist_name")||(subsubnodes[0].id == "f_artist_url")||(subsubnodes[0].id == "f_artist_email")){
									var o_lib = document.getElementById("lib_"+subsubnodes[0].id);
									if(o_lib){if(o_lib.className == "reserre"){ lib = "reserre";}}
								}
								if(vv ==""){lib="resbuild";}
									if(typeof splt[1]== "undefined"){
										o1.innerHTML = '<DIV class="'+ lib +'" id="lib_'+subsubnodes[0].id+'">&nbsp;</DIV>' + splt[0]; 
									}else{				
										o1.innerHTML = '<DIV class="'+ lib +'" id="lib_'+subsubnodes[0].id+'">&nbsp;</DIV>' + splt[1];
									}
								
							}
							
						}
							//node.style.display = "none";
					}	
						
					}		
				}	
		}
		//affbt();
}




function initformart (){
	var elm = document.getElementById("gp_art");
	var node;
	

	if (elm) {
		var subnodes = elm.getElementsByTagName("*");			
			for (var i=0; i<subnodes.length; i++) {
				var lib = "res";
				node = subnodes[i];
				if (node.nodeName == "DIV" && node.className == "edit") {
					var o1 = search(node.parentNode.id,"DIV","ttl");
					var subsubnodes = node.getElementsByTagName("*");
					
					if(subsubnodes[0]){
						var vv = subsubnodes[0].value;
						
						if((subsubnodes[0].id == "f_artist_password")||(subsubnodes[0].id == "f_artist_password2")){
							vv= vv.replace(/./gi,"*");  			
							if(subsubnodes[0].value.length < 6){
								lib = "reserre";
								vv += " minimum 6 caract&egrave;res";
							}else {
								if(subsubnodes[0].id == "f_artist_password2"){
									 if(subsubnodes[0].value != document.getElementById("f_artist_password").value){
										lib = "reserre";
										vv += " confirmation incorrect";
									 }
								}
							}		
						}
						
					}
				}
				if (node.nodeName == "DIV" && node.className == "ttl") {
					node.onclick = function (event){
						act_e_a(this.parentNode.id);
					}	
				}
				if((node.nodeName == "TEXTAREA")||(node.nodeName == "INPUT")){
					if(node.name != "f_artist_options_email"){
						node.onblur = function (event){
							valid_e_a(this.id,this.parentNode.parentNode.id);
						}	
					}else{
						node.onblur = function (event){
							valid_e_a_opt(this.id,this.parentNode.parentNode.id);
						}
					}
				}
				
			}
	}
	//affbt();
	//initcc2();
	//valid_e_a("art_edit_name_ttl","art_edit_name","0");
}

function mniclose(){
	
	var elm = document.getElementById("gp_art");
		var node;
		
		if (elm) {
			var subnodes = elm.getElementsByTagName("*");			
				for (var i=0; i<subnodes.length; i++) {
					var lib = "res";
					node = subnodes[i];
					if (node.nodeName == "DIV" && node.className == "edit") {
					var o1 = search(node.parentNode.id,"DIV","ttl");
					
					var subsubnodes = node.getElementsByTagName("*");
					if(subsubnodes[0]){
						var vv = subsubnodes[0].value;
						
						if((subsubnodes[0].id == "f_artist_password")||(subsubnodes[0].id == "f_artist_password2")){
							vv= vv.replace(/./gi,"*");  
							if(subsubnodes[0].value.length < 6){
								lib = "reserre";
								vv += " minimum 6 caract&egrave;res";
							}else {
								if(subsubnodes[0].id == "f_artist_password2"){
									 if(subsubnodes[0].value != document.getElementById("f_artist_password").value){
										lib = "reserre";
										vv += " confirmation incorrect";
									 }
								}
							}							
						}
						if((subsubnodes[0].id == "f_artist_name")||(subsubnodes[0].id == "f_artist_url")||(subsubnodes[0].id == "f_artist_email")){
								
								if(subsubnodes[0].id == "f_artist_name"){ 
									if(subsubnodes[0].value != nametemp){
										checkform(subsubnodes[0].id);
									}
								}
								if(subsubnodes[0].id == "f_artist_url"){ 
									if(subsubnodes[0].value != urltemp){
										checkform(subsubnodes[0].id);
									}
								}
								if(subsubnodes[0].id == "f_artist_email"){ 
									if(subsubnodes[0].value != emailtemp){
										checkform(subsubnodes[0].id);
									}
								}
								var o_lib = document.getElementById("lib_"+subsubnodes[0].id);
								if(o_lib){if(o_lib.className == "reserre"){ lib = "reserre";}}
								if(subsubnodes[0].id == "f_artist_name"){nametemp = subsubnodes[0].value;}
								if(subsubnodes[0].id == "f_artist_url"){urltemp = subsubnodes[0].value;}
								if(subsubnodes[0].id == "f_artist_email"){emailtemp = subsubnodes[0].value;}
						}
						if(subsubnodes.length > 0){
					
							if(subsubnodes[0].value != ""){
							     var splt = new Array(2);
								splt[0]= "" ;splt[1]="" ;
			var div = ((o1.innerHTML.indexOf("</DIV>") > 0) ? "</DIV>" : ((o1.innerHTML.indexOf("</div>") > 0) ? "</div>" : "</DIV>"));
								splt = o1.innerHTML.split(div);
								if((subsubnodes[0].id == "f_artist_name")||(subsubnodes[0].id == "f_artist_url")||(subsubnodes[0].id == "f_artist_email")){
									var o_lib = document.getElementById("lib_"+subsubnodes[0].id);
									if(o_lib){if(o_lib.className == "reserre"){ lib = "reserre";}}
								}
								if(vv ==""){lib="resbuild";}
									if(typeof splt[1]== "undefined"){
										o1.innerHTML = '<DIV class="'+ lib +'" id="lib_'+subsubnodes[0].id+'">&nbsp;</DIV>' + splt[0]; 
									}else{				
										o1.innerHTML = '<DIV class="'+ lib +'" id="lib_'+subsubnodes[0].id+'">&nbsp;</DIV>' + splt[1];
									}
								
							}
							
						}
							//node.style.display = "none";
					}	
						
					}		
				}	
		}
		//affbt();
}


function search (pid,clss,name){
	var elm = document.getElementById(pid);
	var node;
	if (elm) {
		var subnodes = elm.getElementsByTagName("DIV");			
			for (var i=0; i<subnodes.length; i++) {
				node = subnodes[i];
				if (node.nodeName == clss && node.className == name) {	
					return node;
				}
			}
	}
	return false;
}


function retardevent (iid){
	var elm = document.getElementById(iid);
	elm.onclick = function (event){act_e_a(this.parentNode.id,0);}
	//affbt();
}

function act_e_a (pid,mod){
	var o = search(pid,"DIV","edit");
	if (o.style.display != "block"){
		//mniclose();
		o.style.display = "block";
		//initcc2();
	}
	else {
		//o.style.display = "none";
			//initcc2();
	}
}



function valid_e_a (iid,pid,act) {
	var o = document.getElementById(iid);
	
	var o1 = search(pid,"DIV","ttl");
	var tt;
	if(act != 0){
		var lib = "res";
	}

	if (iid != ""){
	
			var splt = new Array(2);
			splt[0]= "" ;splt[1]="" ;
			var div = ((o1.innerHTML.indexOf("</DIV>") > 0) ? "</DIV>" : ((o1.innerHTML.indexOf("</div>") > 0) ? "</div>" : "</DIV>"));
			splt = o1.innerHTML.split(div);
			o1.onclick = function (event){}
			var vv = o.value;
			if((o.id == "f_artist_password")||(o.id == "f_artist_password2")){
				vv= vv.replace(/./gi,"*"); 
				if(o.value.length < 6){
					lib = "reserre";
					keyok = 0;
					vv = " minimum 6 caract&egrave;res";
				}else {
					if(o.id == "f_artist_password2"){
						if(o.value != document.getElementById("f_artist_password").value){
							lib = "reserre";
							keyok = 0;
							vv = " confirmation incorrect";
						}else {
							keyok = 1;
						}
					}else {
						if(document.getElementById("f_artist_password2").value != ""){
							if(o.value != document.getElementById("f_artist_password2").value){
								lib = "reserre";
								keyok = 0;
								vv = " confirmation incorrect";
							}else {
								keyok = 1;
							}
						}
					}
				}		
				
			}
			
		    if(vv === undefined){
				vv = "";
			}
			if((o.id == "f_artist_antibot")||(o.id == "f_artist_name")||(o.id == "f_artist_url")||(o.id == "f_artist_email")||(o.id == "f_artist_accroche")||(o.id == "f_artist_texte")){


				//alert(vv + o.value);
				if(o.id == "f_artist_antibot"){ 
					if(o.value != bottemp){
						if(o.value != "rouge"){
							lib = "reserre";
							vv = " r&eacute;ponse n&eacute;cessaire";
							botok = 0;
						}else {
							botok = 1;
						}
					}
				}			
				if(o.id == "f_artist_name"){ 
					if(o.value != nametemp){
						if(o.value != ""){
							checkform(o.id);
						}else {
							lib = "reserre";
							vv = " nom obligatoire";
						}
					}
				}
				if(o.id == "f_artist_email"){ 
					if(o.value != emailtemp){
						if(o.value != ""){
							checkform(o.id);
						}else {
							lib = "reserre";
							vv = " email obligatoire";
						}
					}
				}
				if(o.id == "f_artist_accroche"){ 
					if(o.value != accrochetemp){
						if(o.value != ""){
							accrocheok = 1;
						}else {
							accrocheok = 0;
							lib = "reserre";
							vv = " titre obligatoire";
						}
					}
				}
				if(o.id == "f_artist_texte"){ 
					if(o.value != textetemp){
						if(o.value != ""){
							texteok = 1;
						}else {
							texteok = 0;
							lib = "reserre";
							vv = " description obligatoire";
						}
					}
				}
				if(o.id == "f_artist_url"){ 
					if(o.value != urltemp){
						checkform(o.id);
					}
				}		
				
				var o_lib = document.getElementById("lib_"+o.id);
				//if(o_lib){if(o_lib.className == "reserre"){ lib = "reserre";}}
				if(o.id == "f_artist_name"){nametemp = o.value;}
				if(o.id == "f_artist_url"){urltemp = o.value;}
				if(o.id == "f_artist_email"){emailtemp = o.value;}
				if(o.id == "f_artist_accroche"){accrochetemp = o.value;}
				if(o.id == "f_artist_texte"){textetemp = o.value;}
				if(o.id == "f_artist_keyword"){keytemp = o.value;}
				if(o.id == "f_artist_antibot"){bottemp = o.value;}
			}
				if(vv ==""){lib="resbuild";}
				if(lib != "reserre"){vv ="&nbsp;";}
				if(typeof splt[1]== "undefined"){

					o1.innerHTML = '<DIV class="'+ lib +'" id="lib_'+o.id+'">'+vv+'</DIV>' + splt[0]; 
				}else{
					o1.innerHTML = '<DIV class="'+ lib +'" id="lib_'+o.id+'">'+vv+'</DIV>' + splt[1];
				}
			
			
			act_e_a(pid,1);
			setTimeout("retardevent('"+o1.id+"')",1000);
			
		
	}
	//affbt();
	
}


function valid_e_a_opt (iid,pid) {
	var o = document.getElementById(iid);
	var otemp = document.getElementById("f_artist_choixoptmail");
	//var ogp = document.edit_part.f_artist_options_email;
	//var ogp = document.getElementById("f_artist_options_email");
	//var o1 = search(pid,"DIV","ttl");
	var o1 = document.getElementById("art_edit_optemail_ttl");
	
	//alert(iid + "_" +pid);
	var tt;
	var lib = "res";
	
	oForm = document.forms["edit_part"];
	oElement = oForm.elements["f_artist_options_email"];
	if(oElement.length) {
		for(var i = 0; i < oElement.length; i++) {
			if(oElement[i].checked == true){
				vv = oElement[i].title;
		  		otemp.value = vv;
			}	
		}
	}

	/* for (var i=0; i<ogp.length;i++) {
         if (ogp[i].checked) {
            vv = ogp[i].title;
			otemp.value = vv;
         }
      }*/
	
	
			var splt = new Array(2);
			splt[0]= "" ;splt[1]="" ;
			var div = ((o1.innerHTML.indexOf("</DIV>") > 0) ? "</DIV>" : ((o1.innerHTML.indexOf("</div>") > 0) ? "</div>" : "</DIV>"));
			splt = o1.innerHTML.split(div);
			o1.onclick = function (event){}
			if(vv ==""){lib="resbuild";}
			if(typeof splt[1]== "undefined"){
				o1.innerHTML = '<DIV class="'+ lib +'" id="lib_'+o1.id+'">&nbsp;</DIV>' + splt[0]; 
			}else{
				o1.innerHTML = '<DIV class="'+ lib +'" id="lib_'+o1.id+'">&nbsp;</DIV>' + splt[1];
			}
			
			act_e_a("art_edit_optemail",1);
			setTimeout("retardevent('"+o1.id+"')",1000);
	

}




function checkform(what) {
	var url = 'http://www.artconek.com/partners/process_edition.php';
	var o = document.getElementById(what);
	var partner = document.getElementById('partner');
	if(what == "f_artist_name"){
		if(partner == ""){
			var myAjax = new Ajax.Request( url, {method: 'get', parameters: what + "=" +o.value, onLoading: showLoad, onComplete: showResponse_checkform_f_artist_name} );
		}else {
			var myAjax = new Ajax.Request( url, {method: 'get', parameters: what + "=" +o.value + "&partner="+partner.value, onLoading: showLoad, onComplete: showResponse_checkform_f_artist_name} );
		}
	}
	if(what == "f_artist_url"){
		var myAjax = new Ajax.Request( url, {method: 'get', parameters: what + "=" +o.value, onLoading: showLoad, onComplete: showResponse_checkform_f_artist_url} );
	}
	if(what == "f_artist_email"){
		var myAjax = new Ajax.Request( url, {method: 'get', parameters: what + "=" +o.value, onLoading: showLoad, onComplete: showResponse_checkform_f_artist_email} );
	}		
}
		
function showResponse_checkform_f_artist_name (originalRequest) {
	var newData = originalRequest.responseText;
	$('load').style.display = "none";
	if(newData != ""){
		nameok = 0;
		$('lib_f_artist_name').innerHTML = newData;
		$('lib_f_artist_name').className = "reserre";
	}else {
		$('lib_f_artist_name').className = "res";
		nameok = 1;
	}
}

function showResponse_checkform_f_artist_email (originalRequest) {
	var newData = originalRequest.responseText;
	$('load').style.display = "none";
	if(newData != ""){
		emailok = 0;
		$('lib_f_artist_email').innerHTML = newData;
		$('lib_f_artist_email').className = "reserre";
	}else {
		$('lib_f_artist_email').className = "res";
		emailok = 1;
	}
}

function showResponse_checkform_f_artist_url (originalRequest) {
	var newData = originalRequest.responseText;
	$('load').style.display = "none";
	if(newData != ""){
		$('lib_f_artist_url').innerHTML = newData;
		$('lib_f_artist_url').className = "reserre";
	}else {
		$('lib_f_artist_url').className = "res";
	}
}

function showResponse_update (originalRequest) {
	var newData = originalRequest.responseText;
	$('formpartner').style.display = 'none';
	$('load').style.display = "none";
	$('status').innerHTML = newData;
	initcc2();
}
		
function showLoad () {
	$('load').style.display = 'block';
}

function showLoad_update () {
	$('load').style.display = 'block';
}



