function play_music() {
	$("img.img_sound").attr('src','../_img/general/sound.png');
	$("span.img_sound").css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../_img/general/sound.png', sizingMethod='image')");
	$('.sound').attr('alt','stop');
	window.opener.music_play();
}

function stop_music() {
	$("img.img_sound").attr('src','../_img/general/sound_off.png');
	$("span.img_sound").css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../_img/general/sound_off.png', sizingMethod='image')");
	$('.sound').attr('alt','play');
	window.opener.music_stop();
}

function affiche_home(result) {
	
	//Changement du background;
	$("body").css("background","#010C12 url(../_img/general/effervescence.jpg) no-repeat scroll center top");
	$("#city_guide_corner").fadeIn();
	play_music();
	//affichage logo haut;
	//$("#header").show();
	// affiche menu
	//$("#footer").show();
}

$(document).ready(function(){
	$('.sound').bind('click',function() {
		if($(this).attr('alt') != 'stop') {
			play_music();
		} else {
			stop_music();
		}
	});
	


	$("#zoom2_haut").bind("click", function() {
		$.ajax({
		  type: "GET",
		  url: "/collection_zoom.php",
		  data: "article=" + $('#show_croquis_haut > div.article_selected').attr('id').split('_')[1],
		  success: function(result) {
		  	$("#background-content_zoom").html(result);
				$("#background-content_zoom").show();
		  },
		  complete: function() {
				correctPNG();
				$("#coloris").hide();
				$("a.close_zoom").bind("click", function() {
					$("#background-content_zoom").hide();
					$("#background-content_zoom").empty();
					$("#coloris").show();
				});
			}
		});
	});
	$("#zoom2_bas").bind("click", function() {
		$.ajax({
		  type: "GET",
		  url: "/collection_zoom.php",
		  data: "article=" + $('#show_croquis_bas > div.article_selected').attr('id').split('_')[1],
		  success: function(result) {
		  	$("#background-content_zoom").html(result);
				$("#background-content_zoom").show();
		  },
		  complete: function() {
				correctPNG();
				$("#coloris").hide();
				$("a.close_zoom").bind("click", function() {
					$("#background-content_zoom").hide();
					$("#background-content_zoom").empty();
					$("#coloris").show();
				});
			}
		});
	});

	$("div#show_croquis_haut > div").bind("click", function() {
		$.ajax({
		  type: "GET",
		  url: "/collection_zoom.php",
		  data: "article=" + $(this).attr('id').split('_')[1],
		  success: function(result) {
		  	$("#background-content_zoom").html(result);
				$("#background-content_zoom").show();
		  },
		  complete: function() {
				correctPNG();
				$("#coloris").hide();
				$("a.close_zoom").bind("click", function() {
					$("#background-content_zoom").hide();
					$("#background-content_zoom").empty();
					$("#coloris").show();
				});
			}
		});
	});	

	$("div#show_croquis_bas > div").bind("click", function() {
		$.ajax({
		  type: "GET",
		  url: "/collection_zoom.php",
		  data: "article=" + $(this).attr('id').split('_')[1],
		  success: function(result) {
		  	$("#background-content_zoom").html(result);
				$("#background-content_zoom").show();
		  },
		  complete: function() {
				correctPNG();
				$("#coloris").hide();
				$("a.close_zoom").bind("click", function() {
					$("#background-content_zoom").hide();
					$("#background-content_zoom").empty();
					$("#coloris").show();
				});
			}
		});
	});	

	$("li.print").bind('click', function() {
		window.open("/collection_print.php?article1=" + $('#show_croquis_haut > div.article_selected').attr('id').split('_')[1] + "&article2=" + $('#show_croquis_bas > div.article_selected').attr('id').split('_')[1]);
	});
});

$(document).ready(function(){

	$("#envoi_ami").bind("click", function() {
				$("#form_ami").show();
				$("#close").show();
				$("#diagonale").hide();
				$("#diagonale_ami").show();
				
				$("#coloris").hide();
				$("#article_croquis").hide();
				$("#utils").hide();	
	});
	
	$("#fermer").bind("click", function() {
				$("#form_ami").hide();
				$("#close").hide();
				$("#diagonale").show();
				$("#diagonale_ami").hide();
				$("#merci_news").hide();
				
				$("#coloris").show();
				$("#article_croquis").show();
				$("#utils").show();	
	});
	$("input.retour").bind("click", function() {
		$("#fermer").trigger('click');
	});
	
});

	
$(document).ready(function(id){
		/*$("ul#coloris li.color").each(function(i){
				$(this).mouseover(
					function(){	
							$(this).children(".croquis_bulle").show();
					}
				).mouseout(
					function(){
							$(this).children(".croquis_bulle").hide();
					}
				);
		});*/
		$("ul#coloris li.color").bind('mouseover',function() {
			$(this).children('div').show();
		});
		$("ul#coloris li.color").bind('mouseout',function() {
			$(this).children('div').hide();
		});
	});

$(document).ready(function() {
	var nb = $('#all_closeup > div.closeup').length;
	var selected = $('#all_closeup > div.closeup').index($('#all_closeup > div.closeup:visible'));
	var description = $('#all_closeup > div.closeup:visible').children("div.my_closeup_description").html();
	show_closeup_desc(((selected * 1) +1),nb,description);
	 if(nb == 1) {
		 $('#right_arrow').hide();
		  $('#left_arrow').hide();
	 }
	 
	$('#right_arrow').bind('click', function() {
	var nb = $('#all_closeup > div.closeup').length;
	
	var selected = $('#all_closeup > div.closeup').index($('#all_closeup > div.closeup:visible'));

				if(selected == (nb-1)) {
					var new_selected = 0;
				} else {
					new_selected = selected + 1;
				}	
				$('#all_closeup > div.closeup').hide();
				$('#all_closeup > div.closeup:eq(' + new_selected + ')').show();
				var description = $('#all_closeup > div.closeup:visible').children("div.my_closeup_description").html();
				show_closeup_desc(((new_selected * 1) +1),nb,description);	
	});
	
	

	$('#left_arrow').bind('click', function() {
	var nb = $('#all_closeup > div.closeup').length;
	var selected = $('#all_closeup > div.closeup').index($('#all_closeup > div.closeup:visible'));
				if(selected == 0) {
					var new_selected = nb - 1;
				} else {
					new_selected = selected - 1;
				}
				if(nb == 1) {
					$('#left_arrow').hide();
					$('#right_arrow').hide();
				}
				$('#all_closeup > div.closeup').hide();
				$('#all_closeup > div.closeup:eq(' + new_selected + ')').show();
				var description = $('#all_closeup > div.closeup:visible').children("div.my_closeup_description").html();
				show_closeup_desc(((new_selected * 1) +1),nb,description);	
	});

});

function show_closeup_desc(index,total,description) {
	$("#closeup_number").html(index + "/" + total);
	$("#closeup_description").html(description);
}



$(document).ready(function() {
			// ********************* 
			// *  CROQUIS HAUT     *
			// *********************
			$('.croquis_haut_right2').bind('click', function() {
				var nb = $('#show_croquis_haut > div').length;
				
				var selected = $('#show_croquis_haut > div').index($('#show_croquis_haut > div.article_selected'));
				if(selected == (nb-1)) {
					var new_selected = 0;
				} else {
					new_selected = selected + 1;
				}
				$('td.spot_haut > img').attr('src','/_img/collection/point_off.gif');
				$('td.spot_haut > img:eq(' + new_selected + ')').attr('src','/_img/collection/point_on.gif');
				
				$('#show_croquis_haut > div').hide();
				$('#show_croquis_haut > div').removeClass('article_selected');
				$('#show_croquis_haut > div:eq(' + new_selected + ')').show();		
				$('#show_croquis_haut > div:eq(' + new_selected + ')').addClass('article_selected');		
			});
			
			$('td.spot_haut > img').bind('click', function() {
				var nb = $('td.spot_haut > img').length;
				var selected = $('td.spot_haut > img').index($(this));
				new_selected = selected;
				$('td.spot_haut > img').attr('src','/_img/collection/point_off.gif');
				$('td.spot_haut > img:eq(' + new_selected + ')').attr('src','/_img/collection/point_on.gif');
				
				$('#show_croquis_haut > div').hide();
				$('#show_croquis_haut > div').removeClass('article_selected');
				$('#show_croquis_haut > div:eq(' + new_selected + ')').show();		
				$('#show_croquis_haut > div:eq(' + new_selected + ')').addClass('article_selected');		
			});

			$('.croquis_haut_left2').bind('click', function() {
				var nb = $('#show_croquis_haut > div').length;
				var selected = $('#show_croquis_haut > div').index($('#show_croquis_haut > div.article_selected'));
				if(selected == 0) {
					var new_selected = nb-1;
				} else {
					new_selected = selected - 1;
				}
				$('td.spot_haut > img').attr('src','/_img/collection/point_off.gif');
				$('td.spot_haut > img:eq(' + new_selected + ')').attr('src','/_img/collection/point_on.gif');
				
				$('#show_croquis_haut > div').hide();
				$('#show_croquis_haut > div').removeClass('article_selected');
				$('#show_croquis_haut > div:eq(' + new_selected + ')').show();		
				$('#show_croquis_haut > div:eq(' + new_selected + ')').addClass('article_selected');		
			});
						
			
			// ********************* 
			// *  CROQUIS BAS     *
			// *********************
			$('.croquis_bas_right2').bind('click', function() {
				var nb = $('#show_croquis_bas > div').length;
				var selected = $('#show_croquis_bas > div').index($('#show_croquis_bas > div.article_selected'));
				if(selected == (nb-1)) {
					var new_selected = 0;
				} else {
					new_selected = selected + 1;
				}
				$('td.spot_bas > img').attr('src','/_img/collection/point_off.gif');
				$('td.spot_bas > img:eq(' + new_selected + ')').attr('src','/_img/collection/point_on.gif');
				
				$('#show_croquis_bas > div').hide();
				$('#show_croquis_bas > div').removeClass('article_selected');
				$('#show_croquis_bas > div:eq(' + new_selected + ')').show();		
				$('#show_croquis_bas > div:eq(' + new_selected + ')').addClass('article_selected');		
			});
			
			$('td.spot_bas > img').bind('click', function() {
				var nb = $('td.spot_bas > img').length;
				var selected = $('td.spot_bas > img').index($(this));
				new_selected = selected;
				$('td.spot_bas > img').attr('src','/_img/collection/point_off.gif');
				$('td.spot_bas > img:eq(' + new_selected + ')').attr('src','/_img/collection/point_on.gif');
				
				$('#show_croquis_bas > div').hide();
				$('#show_croquis_bas > div').removeClass('article_selected');
				$('#show_croquis_bas > div:eq(' + new_selected + ')').show();		
				$('#show_croquis_bas > div:eq(' + new_selected + ')').addClass('article_selected');		
			});

			$('.croquis_bas_left2').bind('click', function() {
				var nb = $('#show_croquis_bas > div').length;
				var selected = $('#show_croquis_bas > div').index($('#show_croquis_bas > div.article_selected'));
				if(selected == 0) {
					var new_selected = nb-1;
				} else {
					new_selected = selected - 1;
				}
				$('td.spot_bas > img').attr('src','/_img/collection/point_off.gif');
				$('td.spot_bas > img:eq(' + new_selected + ')').attr('src','/_img/collection/point_on.gif');
				
				$('#show_croquis_bas > div').hide();
				$('#show_croquis_bas > div').removeClass('article_selected');
				$('#show_croquis_bas > div:eq(' + new_selected + ')').show();		
				$('#show_croquis_bas > div:eq(' + new_selected + ')').addClass('article_selected');		
			});
			
		});
		
		
String.prototype.isMailAddr = function checkMailAddr() {
	var addr = this.split("@");
	if(addr.length==1 || addr.length>2) return false;
	var dom = addr[1].split(".");
	if(dom.length == 1) return false;
	var domLen = dom.length
	if(domLen>2 && (dom[domLen-1]).length==0) domLen--;
	if(dom[domLen-1].length<2 || dom[domLen-1].length>3) return false;
	for(var i=0;i<domLen;i++) { if(dom[i].length==0) return false; }

	var acc = addr[0].split(".");
	for(i=0;i<acc.length;i++) { if(acc[i].length==0) return false; }
	var okChars = "abcdefghijklmnopqrstuvwxyz";
	okChars += okChars.toUpperCase()+"0123456789-_";
	var testString = acc.join("")+"."+dom.join("");
	if("."==testString) return false;
	i=0;
	while( i<testString.length ) { 
		if('.'==testString.substr(i,1)) {
			okChars = okChars.substr(0,okChars.length-1);
		} else {
			if(okChars.indexOf(testString.substr(i,1))==-1 ) return false;
		}
		i++;
	}
	return true;
}
/*<!-- COMPARER LES COUPES -->*/

$(document).ready(function() {
	$('#suivant').bind('click', function() {
		var nb = $('#modele_comparer > .test').length;
		var selected = $('#modele_comparer > .test').index($('#modele_comparer > div.article_selected'));
		if(selected == (nb-1)) {
			var new_selected = 0;
		} else {
			new_selected = selected + 1;
		}
		$('#modele_comparer > .test').hide();
		$('#modele_comparer > .test').removeClass('article_selected');
		$('#modele_comparer > div:eq(' + new_selected + ')').show();		
		$('#modele_comparer > div:eq(' + new_selected + ')').addClass('article_selected');
	});

	$('#precedent').bind('click', function() {
		var nb = $('#modele_comparer > .test').length;
		var selected = $('#modele_comparer > .test').index($('#modele_comparer > div.article_selected'));
		if(selected == 0) {
			var new_selected = (nb-1);
		} else {
			new_selected = selected - 1;
		}
		$('#modele_comparer > .test').hide();
		$('#modele_comparer > .test').removeClass('article_selected');
		$('#modele_comparer > div:eq(' + new_selected + ')').show();		
		$('#modele_comparer > div:eq(' + new_selected + ')').addClass('article_selected');
	});
});


/*<!-- CARTE CITY GUIDE -->*/
   $(document).ready(function(){
           $("#background-content").fadeIn(2000);
   });
   
$(document).ready(function(id){
		$("#Map .area").each(function(i){
				i++;
				$("#point"+i).mouseover(
					function(){	
							$("#blog"+i).show();
					}
				).mouseout(
					function(){
						$("#blog"+i).fadeOut("slow");
					}
				);
				
		
		});
	
	});