/*
	Autor: Grzegorz Jaworek
	E-mail: grzegorz.jaworek@gmail.com
	www: http://gjaworek.pl 
	Tel.: +48 519 133 159
*/
var glb_busy=0;
var glb_date=0;
var glb_defualt_date=0;
var glb_date_picker="datepicker-home";

jQuery(document).ready(function(){
	jQuery('.thumbs a').lightBox();
	jQuery('.gal div p a').lightBox();
	Cufon.replace('#menu a', {
		fontFamily: 'sansumi',
		hover: true
	});
	Cufon.replace('#bottom li a', {
		fontFamily: 'sansumi',
		hover: true
	});
	Cufon.replace('#player a span', {
		fontFamily: 'sansumi',
		hover: true
	});
	Cufon.replace('.sansumi', {
		fontFamily: 'sansumi',
		hover: true
	});
	Cufon.replace('.admin h1', {
		fontFamily: 'sansumi',
		textShadow: '-3px -3px black'
	});

	Cufon.replace('h2', {
		fontFamily: 'sansumi'
	});
	Cufon.replace('h3', {
		fontFamily: 'sansumi'
	});
	Cufon.replace('h4', {
		fontFamily: 'sansumi'
	});
	jQuery(window).load(function(){

//light_pos();

		jQuery('.div3').each( function(){
			jQuery(this).css('height',jQuery(this).parent().height());
		});
		jQuery('.sidebar').each( function(){
			if (jQuery(this).parent().height()>jQuery(this).height()) {
				jQuery(this).css('height', jQuery(this).parent().height());
			}
		});
		jQuery('.top-module').each( function(){
			jQuery(this).parent().parent().css('background-position','330px '+(jQuery(this).height()-32)+'px');
		});
	});

	jQuery('a.subpage-nav').attr('href','javascript:void(0)');
	jQuery('a.subpage-nav').click( function () {
		pagenext = jQuery(this).attr('rel');
		jQuery('.subpage').hide();
		jQuery('#'+pagenext).show();
		jQuery('.subpage-nav').removeClass('active');
		jQuery('.'+pagenext).addClass('active');
	});
	
	$('#category-carousel').jcarousel({
		vertical: true,
		scroll: 3,
        initCallback: mycarousel_initCallback,
        buttonNextHTML: null,
        buttonPrevHTML: null
	});
});

function mycarousel_initCallback(carousel) {
    jQuery('#category-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#category-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};


function $_(id) {
    return document.getElementById(id);
}


function kstr(i)
{
jQuery('.page-nav').parent('li').removeClass('active');
jQuery('#krl'+i).addClass('active');
var title="";
if(i==1){title="Accueil";}
if(i==2){title="Programmation";}
if(i==3){title="À propos de nous";}
if(i==5){title="Videos";}
if(i==6){title="Restaurant";}
if(i==7){title="Contacter";}

$_('kr_h2').innerHTML=title;
Cufon.replace($_('kr_h2'), {fontFamily: 'sansumi'})


if(i==0)
{
kr_date_pic("datepicker-home");
$_('page-home').style.display="block";
$_('page-accueil').style.display="none";
$_('page-photos').style.display="none";
}
else if(i==4)
{
kr_date_pic("datepicker-photos");
$_('page-home').style.display="none";
$_('page-accueil').style.display="none";
$_('page-photos').style.display="block";
}
else
{
kr_date_pic("datepicker-accueil");
$_('box_txt').innerHTML=$_('txt'+i).innerHTML;
$_('page-home').style.display="none";
$_('page-accueil').style.display="block";
$_('page-photos').style.display="none";

}

jQuery('.top-module').each( function(){
jQuery(this).parent().parent().css('background-position','330px '+(jQuery(this).height()-32)+'px');});
if(i==0){window.scroll(0,0);}else{window.scroll(0,500);}
}

function kr_date_pic(pic_actual)
{
//if(pic_actual==glb_date_picker){return;}

jQuery("#datepicker-home").datepicker('destroy');
jQuery("#datepicker-accueil").datepicker('destroy');
jQuery("#datepicker-photos").datepicker('destroy');

$_(pic_actual+'_div').innerHTML=$_(glb_date_picker+'_div').innerHTML;

glb_date_picker=pic_actual;

$('#'+glb_date_picker).datepicker({
  defaultDate: krdate_diff(),
  onChangeMonthYear: function(year, month, inst)
{setTimeout( function(){ cal_write(year,month)},100);}});


}



function gal_ch(id,i,ik)
{
if(glb_busy==1){return;}


glb_busy=1;
$_('kr_gal').style.background="url('images/loader.gif') no-repeat top center";
$_('kr_gal').style.height="50px";

   for(k=1;k<=ik;k++)
   {
   if(k!=i)
   {$_('krgl_'+k).className="";} //unselect
   }
$_('krgl_'+i).className="active";

advAJAX.post({url : "index.php",parameters : {"ajax" : 1,"nr":1,"id":id},
onInitialization : function(obj){},
onComplete : function(){},
onSuccess : function(obj)
{
$_('kr_gal').innerHTML=obj.responseText;
//light_pos();
$_('kr_h4').innerHTML=$_('krgl_'+i).innerHTML;
	Cufon.replace($_('kr_h4'), {
		fontFamily: 'sansumi'
	});



$_('kr_gal').style.background="none";
jQuery('.thumbs a').lightBox();
glb_busy=0;

},
onError : function(obj){}
});

return false;
}


function trimAll(sString)
{
while (sString.substring(0,1) == ' ')
{
sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length-1, sString.length) == ' ')
{
sString = sString.substring(0,sString.length-1);
}
return sString;
}


function check_form(id,err)
{
if(err==1)
{$_(id).style.color="#701424";}
else
{$_(id).style.color="#628AB5";}
}


function cont_send()
{
var id1=$_('form_name').value;
var id2=$_('form_email').value;
var id3=$_('form_message').value;
var err=0;
check_form("labl1",0);
check_form("labl2",0);
check_form("labl3",0);

if(trimAll(id1)==""){check_form("labl1",1);err=1;}
if(trimAll(id2)==""){check_form("labl2",1);err=1;}
if(trimAll(id3)==""){check_form("labl3",1);err=1;}
if(err==1){return;}

$_('span_cnt').innerHTML="Pease wait...";
advAJAX.post({url : "index.php",parameters : {"ajax" : 1,"nr":2,"id1":id1,"id2":id2,"id3":id3},
onInitialization : function(obj){},
onComplete : function(){},
onSuccess : function(obj)
{
$_('span_cnt').innerHTML="Thank you. Your message has been sent.";
$_('form_message').value="";

},
onError : function(obj){}
});

return false;
}


function getFlashObject(movieName) {
    if (window.document[movieName]) {
        return window.document[movieName];
    }
    if (navigator.appName.indexOf("Microsoft Internet") == -1) {
        if (document.embeds && document.embeds[movieName])
            return document.embeds[movieName]; 
    } else {
        return document.getElementById(movieName);
    }
}

function next() {
var flash = getFlashObject("monFlash2");
flash.SetVariable("player:jsNext", "");
}
function prev() {
     var flash = getFlashObject("monFlash2");
    flash.SetVariable("player:jsPrevious", "");
}

function frj_moth(m)
{
if(m==1){return "Janvier";}
if(m==2){return "Février";}
if(m==3){return "Mars";}
if(m==4){return "Avril";}
if(m==5){return "Mai";}
if(m==6){return "Juin";}
if(m==7){return "Juillet";}
if(m==8){return "Août";}
if(m==9){return "Septembre";}
if(m==10){return "Octobre";}
if(m==11){return "Novembre";}
if(m==12){return "Décembre";}
}



