function search_input(text){
	if (text.value == 'rechercher')
		text.value = '';
}

function check_email_newsletters(text){
	if (text.value == 'E-mail')
		text.value = '';
}

function add_favoris() {
if (navigator.appName != 'Microsoft Internet Explorer')
 window.sidebar.addPanel('Osez chez Arroganss !','http://www.arroganss.com','Osez chez Arroganss !');
else
 window.external.AddFavorite('http://www.arroganss.com','Osez chez Arroganss !');
}

function restart_var_defil(elem){
	elem.start();
}

function pause_start(elem) {
	setTimeout("restart_var_defil(elem)",500);
}

function getElementsByClass(searchClass,node,tag) {
  var classElements = new Array();
  if (node == null)
    node = document;
  if (tag == null)
    tag = '*';
  var els = node.getElementsByTagName(tag);
  var elsLen = els.length;
  var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
  for (i = 0, j = 0; i < elsLen; i++) {
    if (pattern.test(els[i].className) ) {
      classElements[j] = els[i];
      j++;
    }
  }
  return classElements;
}

function setmouse(id, value){
	id.SetVariable('statefl',value);
}

function start(){
	
	row = $("table.specialBox").length;
	var k = Math.floor(Math.random() * row) % row;  //make random starting special //http://www.shawnolson.net/a/789/make-javascript-mathrandom-useful.html
	var i ;
	if (k == 0)
		k = 1;
	for(i = 1; i < row + 1; i++){    //echo total # of special's
		if(i == k) {
			
			document.getElementById('special'+i).style.display="";
		}
		else{
			document.getElementById('special'+i).style.display="none";  //hide all
		}
	}

	// need to randomize beginnning value
	setTimeout("slideshow("+ k +")",4000);  //change 3000 to custom time if desired
	//setTimeout("slideshow(1)",3000);  //static if starting at 1
}

/***Put in a new array all the heights***/
function tri_nombres(a,b)
{ return b - a; }
		


function start_defil(id_defil, class_link, time){
	var k = Math.floor(Math.random()* $(id_defil+" .link_defil").length - 1)  //make random starting special //http://www.shawnolson.net/a/789/make-javascript-mathrandom-useful.html
	var arr = new Array();
	$.each($(id_defil+" .link_defil"), function(i,j) { arr[i] = $(j).height();});
	/***Take the highest and set that height to the container***/
	arr = arr.sort(tri_nombres);
	$(id_defil).height(arr[0]+"px");
	$(id_defil+" .link_defil").hide();
	$(id_defil+" .link_defil."+class_link+k).show();
	// need to randomize beginnning value
	setTimeout("slideshow_defil('"+ id_defil+"','"+ class_link+"',"+ k + 1 +","+ time +")",time);  //change 3000 to custom time if desired
	//setTimeout("slideshow(1)",3000);  //static if starting at 1
}

function slideshow(i){
	row = $("table.specialBox").length;

	Effect.Appear(document.getElementById('special'+i),{ duration: 1.0 });
	//document.getElementById('special'+i).style.display="";

	
	if (i > 1) {
		var j = i - 1;
		
		//Effect.Fade(document.getElementById('special'+j),{ duration: 1.0 , queue: 'front' });
		document.getElementById('special'+j).style.display="none";
	}else {
		//Effect.Fade(document.getElementById('special'+ row),{ duration: 1.0 , queue: 'front'});
		document.getElementById('special'+ row).style.display="none";
	}
	++i;

	if (i > row ){
		i = 1;
	}
	setTimeout("slideshow("+i+")",4000);
}

function slideshow_defil(id_defil, class_link, i, time){
	$(id_defil+" .link_defil").hide();
	$(id_defil+" .link_defil."+class_link+i).fadeIn("slow");
	i++;
	if (i >= $(id_defil+" .link_defil").length){
		i = 0;
	}
	setTimeout("slideshow_defil('"+ id_defil+"','"+ class_link+"',"+ i +","+time+")",time);  //change 3000 to custom time if desired
}

$(document).ready(function() {
//	start();
	start_defil("#manufacturers_index", "manu_", 2000);
	start_defil("#new_products", "new_products_", 3000);
});

// Function d'ouverture de Popup avec scroll
function PopupScroll(sUrl,sNom,iWidth,iHeight,sMessageNoPopup) {
	var oPopup = null;
	oPopup = window.open(sUrl, sNom,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=" + iWidth + ",height=" + iHeight);
	if (sMessageNoPopup == "") sMessageNoPopup = "Les Popups sont bloquées sur votre navigateur !";
	if (oPopup == null) alert("Les Popups sont bloquées sur votre navigateur !");
	else oPopup.focus();
}
