
var condText;


// ------------------------------------------------------------
function clearTextBoxOnCondition(textBox,conditionText){
  if(textBox.value == conditionText) {
    textBox.value="";
    condText=conditionText;
  }
}


// ------------------------------------------------------------
function fillTextBoxOnCondition(textBox){
  if(textBox.value == "") {
    textBox.value=condText;
  }
}


// ------------------------------------------------------------
function open_help() {
  help_window = window.open('/help/Recherche.html','help','scrollbars=no, menubar=no,height=580,width=400,resizable=yes,toolbar=no, location=no,status=no');
  help_window.focus();
}


// ------------------------------------------------------------
function open_in( target, url ) {
  target.location = url ;
  target.focus() ;
}


// ------------------------------------------------------------
function pricerange()
{
  pr = document.prform.prselect.options[document.prform.prselect.selectedIndex].value;
  if( pr )
    {
      tmp = pr.split("-") ;
      if (tmp[0] > 0) document.prform.pmin.value = tmp[0] ;
      if (tmp[1] > 0) document.prform.pmax.value = tmp[1] ;
      document.prform.prselect.selectedIndex = -1 ;
    }	

  document.prform.submit() ;
}


// ------------------------------------------------------------
function bookmark()
{
  if ( (navigator.appName.indexOf("Microsoft", 0) >= 0) &&
       (parseInt(navigator.appVersion) >= 4) )
    window.external.AddFavorite( window.document.URL, window.document.title ) ;
  else
    alert( "Pressez CTRL+D pour ajouter cette page à vos favoris." ) ;
}


// ------------------------------------------------------------
function check_email_address ( email )
{
  var email_pattern =  /^[^\.@]+(\.[^\.@]+)*@[^\.@]+(\.[^\.@]+)+$/ ;
  return email_pattern.test( email ) ;
}


// ------------------------------------------------------------
function check_sendemail_form( f )
{
  if( f.body.value.length == 0 )
    {
      alert( "Vous devez saisir un message !" ) ;
      return false ;
    }

  if( ! check_email_address( f.from.value ) )
    {
      alert( "La syntaxe de votre adresse email n'est pas valide !" ) ;
      return false ;
    }

  return true ;
}


// ------------------------------------------------------------
function check_news_form( f )
{
  if( ! check_email_address( f.email.value ) )
    {
      alert( "La syntaxe de votre adresse email n'est pas valide !" ) ;
      return false ;
    }

  return true ;
}


// ------------------------------------------------------------
function open_press() {
  help_window = window.open('/misc/Presse.html','presse','scrollbars=no, menubar=no,height=200,width=400,resizable=no,toolbar=no, location=no, status=no');
  help_window.focus();
}



var once_per_session = 0 ;

// ------------------------------------------------------------
function get_cookie( name )
{
  if( document.cookie.length == 0 ) return null ;

  begin = document.cookie.indexOf( name + "=" )
    if( begin != -1 )
      {
	begin += name.length + 1 ;
	end = document.cookie.indexOf(";", begin) ;
	if (end == -1) end = document.cookie.length ;
	return unescape( document.cookie.substring(begin, end ) )
      }
}

// ------------------------------------------------------------
function load_popunder()
{
  popunder_window = window.open('/','popunder','scrollbars=yes, menubar=yes,height=600,width=800,resizable=yes,toolbar=yes, location=yes, status=yes');
  popunder_window.blur();
  window.focus() ;
}


// ------------------------------------------------------------
function get_referrer()
{
  if( ! document.referrer ) return null ;
  var i = document.referrer.indexOf( "/", 7 ) ;
  if( i < 7 ) return null ;
  return document.referrer.substring( 7, i ) ;
}


// ------------------------------------------------------------
if( window.name != 'popunder' && get_referrer() == '192.168.30.14' ) //&& (once_per_session == 0 || get_cookie( 'VP_popunder' )) == null )
  {
    load_popunder() ;
    loaded = 1 ;
    document.cookie="VP_popunder=1" ;
  }

