// rollover
$(document).ready(function(){
	$('img.rollover').hover(
		function() {
			var newImage = $(this).attr('src').replace(/^(.*?)(\.(?:gif|jpg|png))$/, "$1-over$2");
			$(this).attr('src', newImage);
		},
		function() {
			var newImage = $(this).attr('src').replace('-over', '');
			$(this).attr('src', newImage);
		}
	);
});

// shadow
$(document).ready(function(){
	$(".dropshadow").wrap('<div class="wrap1"><div class="wrap2"><div class="wrap3"></div></div></div>');
});

function imeisearch(imei, message) {
	if (imei == undefined || imei == '' || imei.length != 8 || imei == message) {
		alert('Veuillez saisir les 8 premiers chiffres du code IMEI SVP.');
		$('input[@name=imei]').attr('value', message);
		return(false);
	}
	else {
		if (imeilist[imei] === undefined) {
			alert('Aucun mobile documenté ne correspond au code IMEI ' + imei);
			$('input[@name=imei]').attr('value', message);
			return(false);
		}
		else {
			parent.location.href = imeilist[imei] + '/index.html';
		}
	}
}

function select_mobile(sel) {
	ind = sel.selectedIndex;
	if (ind == 0) {
		return false;
	}
	else {
		if (ind == 1) {
			sel.selectedIndex = 0;
			location.href = sel.options[ind].value;
		}
		else {
			sel.selectedIndex = 0;
			parent.location.href = sel.options[ind].value + '/index.html';
		}
	}
}

function select_manip(sel) {
	ind = sel.selectedIndex;
	if (ind == 0) {
		return false;
	}
	else {
		sel.selectedIndex = 0;
		parent.page.location.href = sel.options[ind].value + '.html';
	}
}

function select_carac(sel) {
	if (sel.selectedIndex == 0) {
		return false;
	}
	else {
		parent.page.location.href = 'pages/carac/' + sel.options[sel.selectedIndex].value + '.html';
		sel.selectedIndex = 0;
	}
}

/*
	var rotator_current = 0;
	var rotator_max = 11;
*/
function rotator_prev() {
	if (rotator_current == 0) {
		rotator_current = rotator_max;
	}
	else {
		rotator_current--;
	}
	$('img#rotator_img').attr('src', "photos/photo" + rotator_current + ".jpg");
}
function rotator_next() {
	if (rotator_current == rotator_max) {
		rotator_current = 0;
	}
	else {
		rotator_current++;
	}
	$('img#rotator_img').attr('src', "photos/photo" + rotator_current + ".jpg");
}
function rotator_home() {
	rotator_current = 0;
	$('img#rotator_img').attr('src', "photos/photo" + rotator_current + ".jpg");
}


function show_etape(num) {
	$('#etape' + etape_cur).hide();
	etape_cur = num;
	$('#etape' + etape_cur).show();

//	$('a#prev').style.color = '#d3002b';
//	$('a#next').style.color = '#d3002b';
	if (etape_cur == 1) {
		$('a#prev').addClass('disabled');
	}
	else {
		$('a#prev').removeClass('disabled');
	}
	if (etape_cur == etape_nb) {
		$('a#next').addClass('disabled');
	}
	else {
		$('a#next').removeClass('disabled');
	}

	return false;
}

function show_etape_prev() {
	if (etape_cur > 1) {
		show_etape(etape_cur-1);
	}
	return false;
}
function show_etape_next() {
	if (etape_cur < etape_nb) {
		show_etape(etape_cur+1);
	}
	return false;
}

function toggle_etape() {
	$('div.etape').each(
		function () {
			$(this).toggle();

if ($(this).children(".num").html().indexOf('/', 0) == -1) {
	if (etape_nb < 10) {
		$(this).children(".num").html($(this).children(".num").html() + " / 0" + etape_nb);
	}
	else {
		$(this).children(".num").html($(this).children(".num").html() + " / " + etape_nb);
	}
}
else {
	$(this).children(".num").html($(this).children(".num").html().replace(/^([0-9]*)( \/ )([0-9]*)$/, "$1"));
}
		}
	);
	$('#etape' + etape_cur).toggle();
	$('div.paginator').toggle();
}

