// JavaScript Document
var paddingtop = 0;
$(document).ready(function() {
						//  alert($(document).height());
						   availH = $(document).height(); 
						   //alert(availH);
						   //availH = 700;
						//   $('#branding').height((12/100)*availH);
						  // $('#main').height((90/100)*availH);
                          
						  // $('#footer').height((5/100)*availH)-$('div.decomenu').height();
						  // $('#main').show(); 
						  // $('#main_content').height((80/100)*$('#main').height();
						/*   $('#main_content').css('margin-top',(availH-$('#main_content').height())/2);
                           offset = $('#main_content').offset();
						   $('#menu').css('left',offset.left);
			               $('#menu').css('top',offset.top - $('#menu').height());*/
						 
						$('a.alb_link').click(
							function() {
								$.ajax({
										 type: 'post',
										 data: {id: $(this).attr('id')},
										 url: '/albums/getAlbum',
										 success: function(data,status) {
											 $('#alb_detail').html(data);
											  $('img.imgzoom').fullsize();  
											  initMedia();
										 }
									   });
								
								return false;
							}
							
					 );
						

					   $('a.acces_media').click(
							  function() {
								  
								
								 // alert( $('#'+$(this).attr('id')+' ~ div.contenu_media').attr('open'));
								  
								 if ($('#'+$(this).attr('id')+' ~ div.contenu_media').attr('open') == "non" ) {
								  $('#'+$(this).attr('id')+' ~ div.contenu_media').show();
								  $('#'+$(this).attr('id')+' ~ div.contenu_media').attr('open','oui');
	  
								}else {
									$('#'+$(this).attr('id')+' ~ div.contenu_media').hide();
									$('#'+$(this).attr('id')+' ~ div.contenu_media').attr('open','non');													                     
								}
								return false;
																				  
						}
					 );	   
			
});
						  
						  
function initMedia() {
	 $('a.acces_media').click(
							  function() {
								  
								
								 // alert( $('#'+$(this).attr('id')+' ~ div.contenu_media').attr('open'));
								  
								 if ($('#'+$(this).attr('id')+' ~ div.contenu_media').attr('open') == "non" ) {
								  $('#'+$(this).attr('id')+' ~ div.contenu_media').show();
								  $('#'+$(this).attr('id')+' ~ div.contenu_media').attr('open','oui');
	  
								}else {
									$('#'+$(this).attr('id')+' ~ div.contenu_media').hide();
									$('#'+$(this).attr('id')+' ~ div.contenu_media').attr('open','non');													                     
								}
								return false;
																				  
						}
	 );	   
	
}
function openClose(elem) {
	if ($(elem).attr('open') == "non" ) {
					  $(elem).show();
					  $(elem).attr('open','oui');
					  
   }else {
					  $(elem).hide();
					  $(elem).attr('open','non');													                     
	 }
	
}
function getPhoto(elem) {
	$.ajax({
		      type: 'post',
			  data: {id: $(elem).attr('id')},
			  url: '/photo/download'
		   })
}
function sendNewsLetter() {
	if ($('#email').val() != 'my email' && $('#email').val() != '') {
		$.ajax({
			     type: 'post',
				 data: {email: $('#email').val()},
				 dataType: 'html',
				 url: '/accueil/registerEmail',
				 success: function(data,status) {
					 $('#email').val('my email');
					 $('#email').css('color','#999');
					 $('#infonlt').html(data);
				 }
			   });
	}else {
	}
}

function voirParole(elem) {
	if ($(elem).attr('open')== "non") {
		$('div.chanson').hide();
		$(elem).attr('open',"oui");
		p = $(elem).attr('parole');
		$('div.chanson[parole='+p+']').show();

	}else {
		//$('div.chanson').hide();
		$(elem).attr('open',"non");
		p = $(elem).attr('parole');
		$('div.chanson[parole='+p+']').hide();
	}
}

function hidePresse(elem) {
	pid=$(elem).attr('pid');
	$('#c_'+pid).hide();
	$('#cs_'+pid).css('display','block');
	$('#cs_'+pid).show();
}

function showPresse(elem) {
	pid=$(elem).attr('pid');
	$('#cs_'+pid).hide();
	$('#c_'+pid).show();
}
function setInputEmail() {
	 $('#email').val('');
	 $('#email').css('color','#333');
}

function validerMail() {
	message = true;
	if ($('input[name=subject]').val() != "") {
		if ($('input[name=message]').val() != "") {
			if ($('input[name=email]').val() != "") {
			}else {
				alert ('Indiquer votre email');
		    message=false;
			}
		}else {
			alert ('Votre message n\'a pas de contenu');
		    message=false;
		}
	}
	 else {
		 alert ('Indiquez un sujet à votre message');
		 message=false;
	 }
	
	
	 return message;
}

function validate(form_id,email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.forms[form_id].elements[email].value;
   if(reg.test(address) == false) {
      alert('Votre email semble invalide');
      return false;
   }else {
	  $.ajax({
			     type: 'post',
				 data: {email: address},
				 url: '/newsletter',
				 success: function (data,status) {
					 $('#news_send').html(data);
				 }
			  });
	 
	  
   }
   return false;
}
