function gotoGayvox(val) {
	var cible = val.options[val.selectedIndex].value;
	if (cible=='3') { location.href = 'http://www.gayvox.com/inscript/'; }
	if (cible=='4') { location.href = 'http://www.gayvox.com/inscript/'; }
}

function check_prop1(){
  for (i=0;i<window.document.formulaire.prop1.length;i++){
   if (window.document.formulaire.prop1[i].checked){
     return true;
   }
  }
  return false;
}

function check_prop2(){
  for (i=0;i<document.formulaire.elements['prop2[]'].length;i++){
   if (window.document.formulaire.elements['prop2[]'][i].checked){
     return true;
   }
  }
  return false;
}

function validation() {
  if (!check_prop1()){
    alert("Veuillez sélectionner garçon, fille ou couple.\n\nMerci.");
    document.formulaire.prop1[0].focus();
    return false;
  }
  if (!check_prop2()){
    alert("Veuillez sélectionner l'orientation sexuelle\n\nMerci.");
    //document.formulaire.prop2[0].focus();
    return false;
  }
}

function changePhoto(SourceImage, NewImage) { 
  top.document.images[SourceImage].src = NewImage;
}
function get_path(f_path) {
  l_result = "";
  if (f_path == "") {
    l_result = "/";
  } else if (f_path.charAt(f_path.length - 1) == "/") {
    l_result = f_path;
  } else if ((f_path.indexOf(".php") <= 0) && (f_path.indexOf(".htm") <= 0)) {
    l_result = f_path + "/";
  } else {
    l_result = f_path.substring(0, f_path.lastIndexOf("/") + 1);
  }
  return(l_result);
}
function check_url(url) {
  if (url.substring(0, 7) != "http://") {
    if (url.substring(0, 1) != "/") {
      url = "http://" + location.hostname + tmp_path + url;
    } else {
      url = "http://" + location.hostname + url;
    }
  }
  return(url);
}
function get_url_no_domain(f_url) {
	l_url    = check_url(f_url);
	l_result = l_url.substr(l_url.indexOf('/', 7));
	return(l_result);
}
var tmp_path = get_path(location.pathname);
function SPop(url,nom,attributs){
  l_url = check_url(url);
  if (l_url.indexOf('#') == -1) {
    l_url_start = l_url;
    l_url_end   = '';
  } else {
    l_url_start = l_url.substring(0, l_url.indexOf('#'));
    l_url_end   = l_url.substring(l_url.indexOf('#'));
  }
  if (l_url.indexOf('?') == -1) {
    l_url_start = l_url_start + '?'
  } else {
    l_url_start = l_url_start + '&'
  }
  l_url_start = l_url_start + 'disp_pop=1'
  pass = window.open(l_url_start+l_url_end,nom,attributs);
  return(false);
}
function SPopAndClose(url,nom,attributs){
  pass = window.open(check_url(url),nom,attributs);
  top.close();
}

function frameSelectPays() { 
  var dest ;
  
  selInd = document.formulaire.pays.selectedIndex; 
  pays = document.formulaire.pays.options[selInd].value;
  dest = "http://" + location.hostname + "/data.php?page=compte&spage=inscription&pays="+pays+"";
  self.location.href = dest; 
}
function SelectPays() { 
  var dest ;
   selInd = document.formulaire.pays.selectedIndex; 
  pays = document.formulaire.pays.options[selInd].value;
  dest = "http://" + location.hostname + "/inscription.php?pays="+pays+"";
  self.location.href = dest; 
}

function choixPaysRechAv2(page,genre,idsearch,orientation,formulaire_name) {
  selInd = document.forms[formulaire_name].prop3e.selectedIndex;
  idPays = document.forms[formulaire_name].prop3e.options[selInd].value;
  window.location="?page="+page+"&idrecherche="+idsearch+"&prop1="+genre+"&prop2="+orientation+"&prop3e="+idPays+"";
}

function choixPaysRechAv3(page,spage,genre,idsearch,orientation,formulaire_name) {
  selInd = document.forms[formulaire_name].prop3e.selectedIndex;
  idPays = document.forms[formulaire_name].prop3e.options[selInd].value;
  window.location="?page="+page+"&spage="+spage+"&idrecherche="+idsearch+"&prop1="+genre+"&prop2="+orientation+"&prop3e="+idPays+"";
}
function choixPaysRechAv4(page,spage,genre,idsearch,orientation,formulaire_name) {
  selInd = document.forms[formulaire_name].prop3e.selectedIndex;
  idPays = document.forms[formulaire_name].prop3e.options[selInd].value;
  loadWait('#data');
  $('#data').load("data.php?page="+page+"&spage="+spage+"&idrecherche="+idsearch+"&prop1="+genre+"&prop2="+orientation+"&prop3e="+idPays+"", addClickHandlers_data);
}


var max_car = 90;
function set_compteur() {
	document.getElementById("compteur").innerHTML = max_car - document.formulaire.message.value.length;
}
function trim_message(f_textarea) {
	if (f_textarea) {
		if (check_length(f_textarea, true)) {
			l_result = true;
		} else {
			l_result = false;
			f_textarea.value = f_textarea.value.substr(0, max_car)
		}
		set_compteur();
		return(l_result);
	} else {
		return(true);
	}
}
function can_input(f_textarea) {
	if (typeof(f_textarea.onkeypress.arguments[0]) != 'undefined') {
		key_code = f_textarea.onkeypress.arguments[0].keyCode;
		evt = f_textarea.onkeypress.arguments[0];
		key_code = evt.keyCode ? evt.keyCode : evt.charCode ? evt.charCode : evt.which ? evt.which : void 0;
	} else {
		if (document.selection.createRange().text.length != 0) {
			set_compteur();
			return true;
		}
		key_code = event.keyCode;
	}
	allowed_car = new Array(8, 18, 33, 34, 35, 36, 37, 38, 39, 40, 46, 99, 120);
	for (x = 0; x < allowed_car.length; x++) {
		if (allowed_car[x] == key_code) {
			set_compteur();
			return true;
		}
	}
	if (check_length(f_textarea, false)) {
		set_compteur();
		return true;
	} else {
		return false;
	}
}
function check_length(f_textarea, f_equal) {
	if ((!f_equal && f_textarea.value.length < max_car) || (f_equal && f_textarea.value.length <= max_car)) {
		return true;
	} else {
		alert('Texte trop long.');
		return false;
	}
}
function openAbo(f_p, f_audio, f_pl, f_pp, f_else) {
	return(openAbo2(f_p, f_audio, f_pl, f_pp, f_else));
	////if (top.loggedin) {
		////l_url = 'extra/pop_abonnement.php?f=mb';
	////} else {
		//l_url = '/profile/pop_abonnement.php?a=1';
	////}
	//if (f_p > 0) {
		//l_url = l_url + '&p=' + f_p;
	//}
	//if (f_audio > 0) {
		//l_url = l_url + '&audio=oui';
	//}
	//if (f_pl > 0) {
		//l_url = l_url + '&pl=' + f_pl;
	//}
	//if (f_pp) {
		//l_url = l_url + '&pp=' + f_pp;
	//}
	//if (f_else) {
		//l_url = l_url + '&' + f_else;
	//}
	//pass = window.open(l_url, 'Abonnement', 'width=680,height=620,scrollbars,top=0,left=0,status=no,resizable=1');
	//return(false);
}
function openAlbum(f_url) {
	return(SPop(f_url, 'PopupAlbum', 'width=525,height=780,scrollbars,top=0,left=0,status=no,resizable=yes'));
}
