
function playnext(){
  var dest = 'oblongTech_mp3Player';
  var flashvars = {'mp3File':'Friend_In_France.mp3'};
  var params = {'name':dest,'play':'true','menu':'false','quality':'best','wmode':'transparent','allowFullScreen':'true','allowScriptAccess':'sameDomain'} 
  var attributes = {'id':dest,'name':dest};
  swfobject.embedSWF('oblongTech_mp3Player.swf', dest, 1, 1, "9.0.0", "expressInstall.swf", flashvars, params, attributes, function(){});
 }
function stopaudio(){ jQuery('#oblongTech_mp3Player').remove(); }

function rotateImage(){

 elem = jQuery('#banner_images .image-selected')
 .css({'z-index':0})
 .removeClass('image-selected')
 .animate({'opacity':0},1000,'linear',function(e){  })
 .get(0)
 ;
 
 var i = jQuery('#banner_images .image').index(elem);
 var s = jQuery('#banner_images .image').size();
 var j = (i<s-1 ? i+1 : 0 );
 
 jQuery('#banner_images .image').eq(j)
 .css({'z-index':9})
 .addClass('image-selected')
 .animate({opacity:1},1000,'linear',function(e){  })
 ;
 
 }

function open_diary(){
 init_loader();
 jQuery.get('popup_diary_week.php','',function(data){
 if(jQuery('#popup3').size()>0)jQuery('#popup3').remove();
 width = jQuery(document).width();
 height = jQuery(document).height();
 var top = jQuery(window).scrollTop() + 50;//jQuery(window).height()/2 - 275;
 html = ''
 +'<div id="popup3" class="popup3 popup" style="width:'+width+'px;height:'+height+'px;"><div class="popup3-bgnd"></div>'
 +'<div id="popup_diary" class="popup_diary" style="top:'+top+'px;">'+data+'</div>'
 +'</div>';
 jQuery(document.body).append(html);
 jQuery(window).bind('resize',popup3_resize).bind('scroll',popup3_scroll);
 });
 }
function open_diary2(src){
 src = typeof(src)=='undefined' ? 'popup_diary_week.php' : src;
 if(jQuery('#popup3').size()>0)jQuery('#popup3').remove();
 width = jQuery(document).width();
 height = jQuery(document).height();
 var top = jQuery(window).scrollTop() + 50;//jQuery(window).height()/2 - 275;
 html = ''
 +'<div id="popup3" class="popup3 popup" style="width:'+width+'px;height:'+height+'px;"><div class="popup3-bgnd"></div>'
 +'<iframe id="iframe_diary" name="popup_diary" src="'+src+'" style="top:'+top+'px;" scrolling="no" allowtransparency="true" frameborder="0"></iframe>'
 +'</div>';
 jQuery(document.body).append(html);
 jQuery(window).bind('resize',popup3_resize).bind('scroll',popup3_scroll);
 }

function test_months(start_date,end_date){
 //get dates
 var start = [start_date.getFullYear(),start_date.getMonth()+1,start_date.getDate()];
 var end = [end_date.getFullYear(),end_date.getMonth()+1,end_date.getDate()];
 
 //enable months
 var q1 = jQuery('#month-tags .tag');
 q1.removeClass('tag-disabled')
 //select all months if none selected
 if(jQuery('#month-tags .tag-selected').size()<0){ q1.trigger('click',[true]); }
 
 //enable period tags
 jQuery('#period-tags .tag').removeClass('tag-disabled');
 
 //disable months out-of-range
 var md = month_diff(start_date,end_date);
 if(md<12){
  q1.each(function(i,e){
  if(!((start[1]>end[1])&&(i>start[1]-2||i<end[1]))
   && !(start[1]<end[1]&&(i>start[1]-2&&i<end[1]))
   && !(start[1]==end[1]&&start[1]==i+1)
   || (start[1]==end[1]&&i!=start[1]&&i==0)
   ){ jQuery(e).trigger('click',[false]).addClass('tag-disabled'); }
   });
  
  //less than a month in period
  var days = days_diff(start_date,end_date);  
  if(md<1&&days<27){
   t = jQuery('#period-tags .tag:eq(3)');
   if(t.addClass('tag-disabled').hasClass('tag-selected')){
   t.prev().trigger('click');
   }}
  if(days<14){
   t = jQuery('#period-tags .tag:eq(2)');
   if(t.addClass('tag-disabled').hasClass('tag-selected')){
   t.prev().trigger('click');
   }}
  if(days<7){
   t = jQuery('#period-tags .tag:eq(1)');
   if(t.addClass('tag-disabled').hasClass('tag-selected')){
   t.prev().trigger('click');
   }}
  }
 
 }

function month_diff(d1,d2){
	var months;
	months = (d2.getFullYear()-d1.getFullYear())*12;
	months -= d1.getMonth();
	months += d2.getMonth();
	return months; 
	}
function days_diff(start_date,end_date){
	var mspd = 1000 * 60 * 60 * 24;
	var msdiff = end_date.getTime() - start_date.getTime();
	var days = msdiff / mspd;
	return Math.floor(days);
	}
function daysinmonth(m,y){ return (new Date(y,m,0)).getDate(); }
function weekofmonth(date){
 day = date.getDate();
 wom = Math.ceil(day/7);
 dim = daysinmonth(date.getMonth()+1,date.getFullYear());
 if(wom>3){
 womr = Math.ceil((dim+1-day)/7); 
 switch(womr){
  case 1: wom = 4; break;
  case 2: wom = 5; break;
  }
  }
 return wom;
 }

