var images_container = "";

function prechargimg() {
   var doc=document;
   if(doc.images){ if(!doc.precharg) doc.precharg=new Array();
   var i,j=doc.precharg.length,x=prechargimg.arguments; for(i=0; i<x.length; i++)
   if (x[i].indexOf("#")!=0){ doc.precharg[j]=new Image; doc.precharg[j++].src=x[i];}}
}

function detail_grise(objname)
{
  obj = document.getElementById(objname);
  obj.style.filter="alpha(opacity=100)";
  obj.style.opacity= (1);
}

function detail_degrise(objname)
{
  obj = document.getElementById(objname);
  obj.style.filter="alpha(opacity=30)";
  obj.style.opacity= (.3);
}

function detail_make_white(obj) {
  var reg = new RegExp("^detail_menu_link_[0-9]+$");
  if (reg.test(obj.id))
  {
    obj.parentNode.style.background='#FFFFFF';
    obj.className='detailLink';
  }
  for (var i=0;i < obj.childNodes.length;i++)
  {
    if (obj.childNodes[i].nodeType==1)
       detail_make_white(obj.childNodes[i]);
  }
}

function detail_menu_categorie(categ)
{
  for (var i = 1; i < 4; i++)
    if (document.getElementById('detail_categ_'+i))
      document.getElementById('detail_categ_'+i).className = "detailBlocOpacity";
  document.getElementById('detail_categ_'+categ).className = "detailBlocNoOpacity";
  var f = document.getElementById('detail_menu_general');
  detail_make_white(f);
}

function detail_menu_red(objname)
{
  if (!document.getElementById('detail_menu_'+objname))
	return(false);

  for (var i = 1; i < 4; i++)
    if (document.getElementById('detail_categ_'+i))
	{
	   document.getElementById('detail_categ_'+i).className = "detailBlocOpacity";
	   document.getElementById('motioncontainer'+i).className = "detailMotionContainerOpacity";
	}

  var f = document.getElementById('detail_menu_general');
  detail_make_white(f);

  document.getElementById('detail_menu_'+objname).style.background='#E2001A';
  document.getElementById('detail_menu_link_'+objname).className='detailLinkSelected';
  document.getElementById('detail_menu_'+objname).parentNode.parentNode.parentNode.parentNode.className = "detailBlocNoOpacity";
  document.getElementById('detail_menu_'+objname).parentNode.parentNode.className = "detailMotionContainerNoOpacity";
}


function detail_load_video(img, width, height)
{
  var str = "<div style='text-align:center;'>";
  str += "<object type='application/x-shockwave-flash' data='class/player_flv.swf' width='"+width+"' height='"+height+"'>";
  str += "<param name='movie' value='class/player_flv.swf' />";
  str += "<param name='FlashVars' value='flv="+img+"&showvolume=1&showtime=1&showstop=1&buttonovercolor=FF0000&autoplay=1&margin=0&loadingcolor=FF0000&sliderovercolor=990000&width="+width+"&height="+height+"&buffer=10' />";
  str += "<param name='wmode' value='transparent' /></object>";
  str += "</div>";

  str += "<div style='padding-right:4px; padding-top:5px; margin-bottom:10px;'>";
  str += "<a href=\"javascript:list_hide_map()\" class='detailLinkClose'>";
  str += "<div style=\"background:#CECFCC url(http://www.athem.fr/im/btn-hidemap.jpg) no-repeat top right; padding-right:25px; font-size:11px; height:18px; padding-left:4px; padding-top:1px; display:inline;\">";
  str += "Revenir aux photos</div></a></div>";

  images_container = document.getElementById('detailContainer_1').innerHTML;  
  document.getElementById('detailContainer_1').innerHTML = str;
}

function detail_degrise_img(div)
{
  for (var i = 1; i <= 4; i++)
  {
    if (div2 = document.getElementById('detail_img_min_'+i))
    {
      div2.style.filter="alpha(opacity=30)";
      div2.style.opacity= (.3);
    }
  }

  div2 = document.getElementById('detail_img_min_'+div);
  div2.style.filter="alpha(opacity=100)";
  div2.style.opacity=(1);
  document.getElementById('detail_main_img').setAttribute('main', 'false');
  if (document.getElementById('detail_main_img').innerHTML != document.getElementById('detail_img_'+div).innerHTML)
  {
    start_div_fondu('detail_main_img', 'detail_img_'+div);
  }
}

function detail_grise_img()
{
  for (var div = 1; div <= 4; div++)
  {
    if (div2 = document.getElementById('detail_img_min_'+div))
    {
      div2.style.filter="alpha(opacity=30)";
      div2.style.opacity= (.3);
    }
  }
  //if (document.getElementById('detail_main_img').innerHTML != document.getElementById('detail_main_img_save').innerHTML)
  if (document.getElementById('detail_main_img').getAttribute('main') == 'false')
  {
     document.getElementById('detail_main_img').setAttribute('main', 'true');
     start_div_fondu('detail_main_img', 'detail_main_img_save')
  }
}

function detail_print(to)
{
  var date = new Date();

  window.open(to, 'Athem'+date.getTime(), 'size=landscape,resizable=yes,scrollbars=yes,status=yes,dependent=no,menubar=yes');
/*
  var img = document.getElementById('under_detail_main_img').firstChild;
  var date = new Date();
  while (img!=null && img.nodeName!="IMG")
        img = img.nextSibling;
  window.open(to+"&img="+escape(img.src), 'Athem'+date.getTime(), 'width=800px;');
*/
}

/***********/
/** affichage googlemap ***/
/***********/

function detail_aff_map(long, lat)
{
  	document.getElementById('detail_button_hide_map').style.display = "";
  	document.getElementById('detail_button_show_map').style.display = "none";
        var map_container = '<div id="map" style="margin-right:auto; margin-left:auto; margin-top:0px; margin-bottom:0px; border:1px solid #222222; width: 404px; height: 403px"></div>';
       	if (GBrowserIsCompatible()) {
       	document.getElementById('images_container').innerHTML = map_container;
	insideInitMap('true', long, lat);
	}
}

function detail_aff_images_container()
{
  document.getElementById('images_container').innerHTML = images_container;
}

function detail_hide_map()
{
  document.getElementById('detail_button_hide_map').style.display = "none";
  document.getElementById('detail_button_show_map').style.display = "";
  detail_aff_images_container();
}


function list_aff_map(long, lat)
{
       	images_container = document.getElementById('detailContainer_1').innerHTML;
  	document.getElementById('list_button_hide_map').style.display = "";
  	document.getElementById('list_button_show_map').style.display = "none";
        var map_container = '<div id="map" style="margin-right:auto; margin-left:auto; margin-top:0px; margin-bottom:0px; border:1px solid #222222; width: 404px; height: 403px"></div>';
       	if (GBrowserIsCompatible()) {
       	document.getElementById('detailContainer_1').innerHTML = map_container;
	insideInitMap('true', long, lat);
	}
}

function list_hide_map()
{
  document.getElementById('list_button_hide_map').style.display = "none";
  document.getElementById('list_button_show_map').style.display = "";
  document.getElementById('detailContainer_1').innerHTML = images_container;
}
