var agt    = navigator.userAgent.toLowerCase();
var appVer = navigator.appVersion.toLowerCase();
var osys;
if (appVer.toLowerCase().indexOf("win")!=-1) {
  osys = "win";
}

if (appVer.toLowerCase().indexOf("mac")!=-1) {
  osys = "mac";
}

var verInt = parseInt(appVer);
var ie     = (appVer.indexOf('msie') != -1);
var opera  = (agt.indexOf("opera") != -1);
var mozilla = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('opera')==-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));	
var netscape =(agt.indexOf('netscape')!=-1)
    
var ie = (document.all)? true:false;
var ns4 = (document.layers)? true:false;
var ns6 = (document.getElementById)? true:false;





     
// Correcteur Gama pour IE
// function IE_CorrectAlpha_PNG(){ 
//   for(i=0; i<document.images.length; i++){ 
//     img    = document.images[i]; 
//     imgExt  = img.src.substring(img.src.length-3, img.src.length); 
//     imgExt  = imgExt.toUpperCase(); 
//     if (imgExt == "PNG"){ 
//       imgID    = (img.id) ? "id='" + img.id + "' " : ""; 
//       imgClass= (img.className) ? "class='" + img.className + "' " : ""; 
//       imgTitle= (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "; 
//       imgStyle= "display:inline-block;" + img.style.cssText; 
//       if (img.align == "left") { imgStyle = "float:left;"  + imgStyle; } else if (img.align == "right"){ imgStyle = "float:right;" + imgStyle; } 
//       if (img.parentElement.href)   { imgStyle = "cursor:hand;" + imgStyle; }        
//       strNewHTML    = '<span '+imgID+imgClass+imgTitle+' style="width:'+img.width+'px; height:'+img.height+'px;'+imgStyle+';'+'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+img.src+'\', sizingMethod=\'scale\');"></span>'; 
//       img.outerHTML = strNewHTML; 
//       i = i-1; 
//     }}}
// if (ie)
// {
//   window.attachEvent("onload", IE_CorrectAlpha_PNG);
// }


function GetElementsWithClassName(elementName,className) {
  for (i=0; i<document.getElementsByTagName("*").length; i++) {
    if (document.getElementsByTagName("*").item(i).className == "element"){
      document.getElementsByTagName("*").item(i).style.display="block";
    }
  }
}


function popup(url,height,width)
{
  popup=window.open(url,'popup',config='height='+height+', width='+width+', toolbar=no, menubar=no, scrollbars=true, resizable=no, location=no, directories=no, status=no');
  popup.focus();

}



function gotourl(value)
{
  document.location=value;
}

function change(element,valeur)
{
  alert(element);
  alert(valeur);
  var val=element.value;
  alert(val);
  if (element.checked)
    {
      val='';
    }
  else val=valeur;
  alert(val);
}

function altern_check(element)
{
  if (element.checked==true)
    {
      element.checked=false;
    }
  else
    {
      element.checked=true;
    }
}


function all_check(form,bool)
{

  for(i=0;i<document.forms[form].length;i++)
    {
      document.forms[form].elements[i].checked=bool;
    }
}


function calque_position(name,left,top)
{
  document.getElementById(name).style.visibility='visible';
  
  if (mozilla)
    {
      document.getElementById(name).style.top=top +"px;";
      document.getElementById(name).style.left=left +"px;";
    }
  else if (ie)
    {
      document.getElementById(name).style.pixelTop=top;
      document.getElementById(name).style.pixelLeft=left;
    } 
}



function calque_affiche(name,e)
{
  if (mozilla) // mozilla
    {
     var x = e.clientX + window.scrollX;
     var y = e.clientY + window.scrollY;      
    }  
  else if (ie) {
    var x=window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft; 
    var y=window.event.clientY + document.documentElement.scrollTop  + document.body.scrollTop;
  }
  calque_position(name,x,y);
}


function calque_masque(name)
{
  document.getElementById(name).style.visibility='hidden';
}



function sendData(data,page,div)
{
  
  if(document.all)
    {
      var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ;
    }
  else
    {
      var XhrObj = new XMLHttpRequest();
    }
		
  var content = document.getElementById(div);
		
  XhrObj.open("POST", page);

  XhrObj.onreadystatechange = function() 
    {
      if (XhrObj.readyState == 4 && XhrObj.status == 200)
      content.innerHTML = XhrObj.responseText ;
      else content.innerHTML = "<img src='../theme/mini-images/chargement.gif' alt='chargement' /><span>Chargement en cours...</span>";
    }	
  XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  XhrObj.send(data);
  
}




function init_sendData(nom_form){
  var elements = document.forms[nom_form].elements;
  var valeurs="";
  var first=true;
  var tag="";
  for(var i=0; i< elements.length; i++){
    if (first){
      tag="";
      first = false;
    }else{
      tag="&";
    }
    if (elements.item(i).type=="checkbox" || elements.item(i).type=="radio"){
      if (elements.item(i).checked){
	valeurs=valeurs+tag+elements.item(i).name+"="+elements.item(i).value;
      }
    }else{
      if (elements.item(i).value!="" && elements.item(i).name!=""){
	valeurs=valeurs+tag+elements.item(i).name+"="+elements.item(i).value;
      }
    }
  }
  return valeurs;
}



function montre(id) {
  var d = document.getElementById(id);
  for (var i = 1; i<=10; i++) {
    if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
  }
  if (d) {d.style.display='block';}
}


function hn(sire) {
  window.open('http://cookie.haras-nationaux.fr/harasire_e3/consultation/chevaux/info_generales/contenu_info_generales.jsp?CheNucheval='+sire+'&SrcPage=liste');

}


function altern_color (element) {
  var color = element.style.backgroundColor;
  if(color==site_hover || color==site_hover_rgb) {
    element.style.backgroundColor='';
  }
  else {
    element.style.backgroundColor=site_hover;
  }
}

function survol_color(element,bool) {
   var color = element.style.backgroundColor;
   if(color!=site_hover && color!=site_hover_rgb) {
    if(bool==0) element.style.backgroundColor='';
    else element.style.backgroundColor=site_grey;
   }
}


function gebi(element) {
  return document.getElementById(element);
}