var lang = {
	"le_champs" : "Field ",
	"est_obligatoire" : "is compulsory",
	"characteres" : "characters",
	"doit_contenir" : "must contain",
	"doit_etre_numerique" : "must bu numeric",
	"merci_de_joindre_un_fichier_pour" : "you must select a fil for",
	"doit_etre_un_email" : "must be a valid email"
};







/* fonction relatives au rollover d'images etc. */
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

/* fonctions relatives à l'AJAX utilisé dans les pages */ 
function createXMLHttpRequest() {
	try { return new ActiveXObject("Msxml2.XMLHTTP");    } 
	catch(e) {}                
	try { return new ActiveXObject("Microsoft.XMLHTTP"); } 
	catch(e) {}                
	try { return new XMLHttpRequest();                   } 
	catch(e) {}                
	alert("XMLHttpRequest not supported");               
	return null;
}             
function file(fichier, data)     { 
	fichier = fichier
	xhr_object = createXMLHttpRequest();
	
	xhr_object.open("POST", fichier, false);
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 

	xhr_object.send(data + "&is_ajax=1");
	if(xhr_object.readyState == 4) return(xhr_object.responseText);
	else return(false);    
}   





























function swap_faq(theme_id,t, nb_theme){
	
	for(var i=0; i <nb_theme ; i++){
		document.getElementById('bt_theme_'+i).className = '';
	}
	document.getElementById('bt_theme_'+t).className = 'selected';
	
	
	
	
	retour = file('js/ajax.php','action=swap_faq&theme_id=' + theme_id);
	if(retour){
		document.getElementById('faq_questions').innerHTML = retour;
	}
}















/*** APRIL77 RECORDS ***/
function artist_sheet_picture(picture, id, nb_picture, nb_video){
	document.getElementById('artists_picture').innerHTML = '<img src="'+picture+'" />';
	
	for(var i=0; i <nb_picture ; i++){
		document.getElementById('picture_'+i).className = 'thumb_out';
	}
	for(var i=0; i <nb_video ; i++){
		document.getElementById('video_'+i).className = 'thumb_out';
	}
	document.getElementById('picture_'+id).className = 'thumb_selected';
}








function artist_sheet_video(video, id,nb_picture, nb_video){
	for(var i=0; i <nb_picture ; i++){
		document.getElementById('picture_'+i).className = 'thumb_out';
	}
	for(var i=0; i <nb_video ; i++){
		document.getElementById('video_'+i).className = 'thumb_out';
	}
	document.getElementById('video_'+id).className = 'thumb_selected';
	
	document.getElementById('artists_picture').innerHTML = '<object width="600" height="450"><param name="movie" value="http://www.youtube.com/v/'+video+'&hl=en&rel=0&color1=0x111111&color2=0x000000"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/'+video+'&hl=en&rel=0&color1=0x111111&color2=0x000000" type="application/x-shockwave-flash" wmode="transparent" width="600" height="450"></embed></object>';
}


function check_code(){
	var code=document.getElementById("download_code").value;
	retour = file('js/ajax.php', 'action=check_code&code=' + code);
	if(retour == 'error'){
		document.getElementById('download_error').innerHTML = 'An error occured, please check your code';
	}else{
		index = document.getElementById('INDEX').value
		document.location.replace(index+'?pge=artists_download&artist_id='+retour+'&code=' + code);
	}
}


function press_login(){
	var press_login=document.getElementById("press_login").value;
	var press_password=document.getElementById("press_password").value;
	if ((press_login != '') && (press_password != '')){
		
	retour = file('js/ajax.php', 'action=press_login&login=' + press_login + '&password=' + press_password );
	}else{
		retour = 'error';
	}
	if(retour == 'error'){
		document.getElementById('press_login_error').innerHTML = 'An error occured, please check your login and password';
	}else{
		index = document.getElementById('INDEX').value
		document.location.replace(index+'?pge=press_private_space');
	}
}


function download(url){
	if(document.getElementById('accept_terms').checked == true){
		document.location.replace(url);
		document.getElementById('content_download_error').innerHTML = 'Your code has officially been registered and your download will follow.<br />Please do not try to reuse this code.  It is now invalid.';
	}else{
		document.getElementById('content_download_error').innerHTML = 'Please accept the terms and conditions below.';
	}
		
}


function leave_comment(table, post_id){
	var poster = valeur_input(document.forms['leave_comment_'+post_id].poster);
	var comment = valeur_input(document.forms['leave_comment_'+post_id]['comment']);
	if (comment != '' && poster != ""){
		retour = file('js/ajax.php', 'action=leave_comment&table=' + table + '&post_id=' + post_id + '&poster=' + poster + '&comment=' + comment );
		if (retour){
			document.location.reload();
		}
	}else{
		document.getElementById('strerr_leave_comment_'+post_id).innerHTML = 'To leave a comment, you have to fill both fields.';	
	}
}













/*** COMMON ***/



function ajax(page, action, element_retour, id_name, id_value){
	retour = file(''+page+'', '&action='+action+'&'+id_name+'=' + id_value);
	if(retour){
		document.getElementById(element_retour).innerHTML = retour;
	}

}




var crlf = "<br />";
function valide_formulaire(formulaire){
	var existe_erreur = 0;
	erreur_div = document.getElementById("erreur");
	erreur_div.innerHTML = '';
	
	for(key in tableau){
		if (tableau[key] != "") {

			message="";
			existe_erreur = 0;
			test_array = tableau[key].split(';');
			
			champ_libelle = key;
			nom_champ = test_array[0];
			champ_type = test_array[1];
			champ_minchar = test_array[2];
			
			
			if(document.forms[formulaire][nom_champ]){
			champ_value = valeur_input(document.forms[formulaire][nom_champ]);
			}else{
				champ_value ='';
			}
			if(champ_value == ''){
				existe_erreur = 1;
				if (champ_type == 'file'){
					existe_erreur = 1;
					message = lang["merci_de_joindre_un_fichier_pour"] + ' ' + champ_libelle ;
				}else{
				message = lang["le_champs"] + ' ' + champ_libelle + ' ' + lang["est_obligatoire"];
				if (champ_minchar > 2){
					message +=" (" + champ_minchar + ' '  + lang['characteres'] + ")";
				}
				}
			}else{
				if ((champ_type == 'email') && (!valid_email(champ_value))){
					existe_erreur = 1;
					message = lang["le_champs"] + ' ' + champ_libelle + ' '  + lang['doit_etre_un_email'];
				}else if ((champ_type == 'numeric') && (!is_numeric(champ_value))){
					existe_erreur = 1;
					message = lang["le_champs"] + ' ' + champ_libelle + ' '  + lang['doit_etre_numerique'];
					if (champ_minchar > 2){
					message +=" (" + champ_minchar + ' '  + lang['characteres'] + ")";
					}
				}
				
				
				if (champ_value.length < champ_minchar){
					existe_erreur = 1;
					message = lang["le_champs"] + ' ' + champ_libelle + ' '  + lang['doit_contenir'] + ' '  + champ_minchar + ' '  + lang['characteres'];
				}
				
			}
			
			if (existe_erreur == 1){
				document.getElementById('label_'+nom_champ).style.color = '#FF0000';
				erreur_div.innerHTML += message;
				erreur_div.innerHTML += crlf;
			}else{
				document.getElementById('label_'+nom_champ).style.color = '#4e153c';
			}			
		}
	}
	
	
	if(erreur_div.innerHTML  == ''){
		document.forms[formulaire].submit();
	}
}



function valid_email(mail){
	if (mail.length < 1){
		return false;
	}else{
		if ((mail.indexOf("@")>=0)&&(mail.indexOf(".")>=0)) {
			return true;
		}else{
			return false;
		}
	}
}

function is_numeric(valeur) {
numChars = "0123456789";
var isNum = true;
var index = 0;
while ((index < valeur.length) && (isNum))
     {
     isNum = (numChars.indexOf(valeur.charAt(index)) != -1);
     index ++;
     }
return isNum;
}

function valeur_input(objet){
	col_name = objet.name;
	col_value = escape(objet.value);
	
	
	if (objet.type == 'checkbox' ) {
		col_value = (objet.checked == true ) ? 1 : 0 ;
	}else if (objet.type == 'file' ) {
		col_value = objet.value;
	}else{
		Nom = navigator.appName;
		Version = navigator.appVersion;
			ns = (Nom == 'Netscape') ? 1:0
			ie = (Nom == 'Microsoft Internet Explorer') ? 1:0
			if ((ie)&&(objet.type == 'textarea') ) {col_value = escape(objet.firstChild.data);}
		}

	return col_value;	
}






document.write('');
document.write('');


