  $(document).ready(function() {

 
 
 var _updateDatepicker_o = $.datepicker._updateDatepicker;// funkcija, kas ļauj strādāt cluetip arī pēc mēneša maiņas
$.datepicker._updateDatepicker = function(inst){ 
   _updateDatepicker_o.apply(this, [inst]); 
   
    $('td.eDiaDeTradicaoStyle').cluetip({splitTitle: '|',cluetipClass: 'jtip',arrows: true,dropShadow: true,});
	$('td.papildusNodarbibasStyle').cluetip({splitTitle: '|',cluetipClass: 'jtip',arrows: true,dropShadow: true,});
	$('td.MusuSeminariStyle').cluetip({splitTitle: '|',cluetipClass: 'jtip',arrows: true,dropShadow: true,});
	$('td.ParejieSeminariStyle').cluetip({splitTitle: '|',cluetipClass: 'jtip',arrows: true,dropShadow: true,});
	$('td.citiStyle').cluetip({splitTitle: '|',cluetipClass: 'jtip',arrows: true,dropShadow: true,});
	$('td.pirmdiena').cluetip({splitTitle: '|',cluetipClass: 'jtip',arrows: true,dropShadow: true,});
	$('td.otrdiena').cluetip({splitTitle: '|',cluetipClass: 'jtip',arrows: true,dropShadow: true,});
	$('td.tresdiena').cluetip({splitTitle: '|',cluetipClass: 'jtip',arrows: true,dropShadow: true,});
	$('td.ceturtdiena').cluetip({splitTitle: '|',cluetipClass: 'jtip',arrows: true,dropShadow: true,});
	$('td.piektdiena').cluetip({splitTitle: '|',cluetipClass: 'jtip',arrows: true,dropShadow: true,});
	$('td.sestdiena').cluetip({splitTitle: '|',cluetipClass: 'jtip',arrows: true,dropShadow: true,});
	$('td.svetdiena').cluetip({splitTitle: '|',cluetipClass: 'jtip',arrows: true,dropShadow: true,});
};
 
$('#calendar').datepicker({
 beforeShowDay: highlightEvents,

 dateFormat: 'yy-mm-dd',
 prevText: '&laquo;',
 nextText: '&raquo;',
 monthNames: ['Janvāris','Februāris','Marts','Aprīlis','Maijs','Jūnijs', 'Jūlijs','Augusts','Septembris','Oktobris','Novembris','Decembris'],
 monthNamesShort: ['JAN', 'FEB', 'MAR', 'APR', 'MAI', 'JUN', 'JUL', 'AUG', 'SEP', 'OKT', 'NOV', 'DEC'],
 dayNamesMin: ['S', 'P','O','T','C','P','S'],
 firstDay: 1

 });

$('#calendar').change(function(){
 var link = 'http://www.capoeira-latvia.lv?chpt=pasakumi&date=' + $('#calendar').val();
 document.location.replace(link);
});

//### qtip definition ###
$.fn.cluetip.defaults = {  // default options; override as needed
    width:            178,      // The width of the clueTip
    height:           'auto',   // The height of the clueTip. more info below [1]
    cluezIndex:       97,       // Sets the z-index style property of the clueTip
    positionBy:       'auto',   // Sets the type of positioning. more info below [2]
    topOffset:        15,       // Number of px to offset clueTip from top of invoking element. more info below [3]
    leftOffset:       15,       // Number of px to offset clueTip from left of invoking element. more info below [4]
    local:            false,    // Whether to use content from the same page for the clueTip's body
    hideLocal:        true,     // If local option is set to true, this determines whether local content
    attribute:        'rel',    // the attribute to be used for fetching the clueTip's body content
    titleAttribute:   'title',  // the attribute to be used for fetching the clueTip's title
    showTitle:        true,     // show title bar of the clueTip, even if title attribute not set
    cluetipClass:     'default',// class added to outermost clueTip div in the form of 'cluetip-' + clueTipClass. more info below [7]
    hoverClass:       '',       // class applied to the invoking element onmouseover and removed onmouseout
    waitImage:        true,     // whether to show a "loading" img, which is set in jquery.cluetip.css
    arrows:           false,    // if true, displays arrow on appropriate side of clueTip. more info below [8]
    dropShadow:       true,     // set to false if you don't want the drop-shadow effect on the clueTip
    dropShadowSteps:  6,        // adjusts the size of the drop shadow
    sticky:           false,    // keep visible until manually closed
    mouseOutClose:    true,    // close when clueTip is moused out
    activation:       'hover',  // set to 'click' to force user to click to show clueTip
    clickThrough:     true,    // if true, and activation is not 'click'
    tracking:         false,    // if true, clueTip will track mouse movement (experimental)
    delayedClose:     0,        // close clueTip on a timed delay (experimental)
    closePosition:    'title',    // location of close text for sticky cluetips; can be 'top' or 'bottom' or 'title'
    closeText:        'Close',  // text (or HTML) to to be clicked to close sticky clueTips
    truncate:         0,        // number of characters to truncate clueTip's contents. if 0, no truncation occurs

    fx: 			  {open:'show', openSpeed:  ''},
    hoverIntent: 	  {sensitivity: 3, interval: 30, timeout: 0},
    onActivate:       function(e) {return true;},
    onShow:           function(ct, c){},
    ajaxCache:        true,
    ajaxProcess:      function(data) {data = $(data).not('style, meta, link, script, title, td, a'); return data;},
    ajaxSettings: 	  {dataType: 'html'}
  };

  
    $('td.eDiaDeTradicaoStyle').cluetip({splitTitle: '|',cluetipClass: 'jtip',arrows: true,dropShadow: true,});
	$('td.papildusNodarbibasStyle').cluetip({splitTitle: '|',cluetipClass: 'jtip',arrows: true,dropShadow: true,});
	$('td.MusuSeminariStyle').cluetip({splitTitle: '|',cluetipClass: 'jtip',arrows: true,dropShadow: true,});
	$('td.ParejieSeminariStyle').cluetip({splitTitle: '|',cluetipClass: 'jtip',arrows: true,dropShadow: true,});
	$('td.citiStyle').cluetip({splitTitle: '|',cluetipClass: 'jtip',arrows: true,dropShadow: true,});
	$('td.otrdiena').cluetip({splitTitle: '|',cluetipClass: 'jtip',arrows: true,dropShadow: true,});
	$('td.tresdiena').cluetip({splitTitle: '|',cluetipClass: 'jtip',arrows: true,dropShadow: true,});
	$('td.ceturtdiena').cluetip({splitTitle: '|',cluetipClass: 'jtip',arrows: true,dropShadow: true,});
	$('td.piektdiena').cluetip({splitTitle: '|',cluetipClass: 'jtip',arrows: true,dropShadow: true,});
	$('td.sestdiena').cluetip({splitTitle: '|',cluetipClass: 'jtip',arrows: true,dropShadow: true,});
	$('td.svetdiena').cluetip({splitTitle: '|',cluetipClass: 'jtip',arrows: true,dropShadow: true,});

	
	$('#Perna_saraksts').datepicker({
 beforeShowDay: Ptrenini,
 dateFormat: 'yy-mm-dd',
 prevText: '&laquo;',
 nextText: '&raquo;',
 monthNames: ['Janvāris','Februāris','Marts','Aprīlis','Maijs','Jūnijs', 'Jūlijs','Augusts','Septembris','Oktobris','Novembris','Decembris'],
 monthNamesShort: ['JAN', 'FEB', 'MAR', 'APR', 'MAI', 'JUN', 'JUL', 'AUG', 'SEP', 'OKT', 'NOV', 'DEC'],
 dayNamesMin: ['S', 'P','O','T','C','P','S'],
 firstDay: 1
 });
  function Ptrenini(date) {
 var day = date.getDay(),Monday = 1, Wednesday = 3;
 var pirmdiena = [[Monday]];
 var tresdiena = [[Wednesday]];
 for (var i = 0; i < pirmdiena.length; i++){
	if (day == pirmdiena[i][0]){
	 return [true, 'Pertr', ] }}
 for (var i = 0; i < tresdiena.length; i++){
	if (day == tresdiena[i][0]){
	 return [true, 'Pertr', ] }}
 return [true, ''];
}

 	$('#Tubarao_saraksts').datepicker({
 beforeShowDay: Ttrenini,
 dateFormat: 'yy-mm-dd',
 prevText: '&laquo;',
 nextText: '&raquo;',
 monthNames: ['Janvāris','Februāris','Marts','Aprīlis','Maijs','Jūnijs', 'Jūlijs','Augusts','Septembris','Oktobris','Novembris','Decembris'],
 monthNamesShort: ['JAN', 'FEB', 'MAR', 'APR', 'MAI', 'JUN', 'JUL', 'AUG', 'SEP', 'OKT', 'NOV', 'DEC'],
 dayNamesMin: ['S', 'P','O','T','C','P','S'],
 firstDay: 1
 });
function Ttrenini(date) {
 var day = date.getDay(), Tuesday = 2, Wednesday = 3, Thursday = 4, Saturday = 6, Sunday = 0;
 var otrdiena = [[Tuesday]];
 var tresdiena = [[Wednesday]];
 var ceturtdiena = [[Thursday]];
 var sestdiena = [[Saturday]];
 var svetdiena = [[Sunday]];
 for (var i = 0; i < otrdiena.length; i++){
	if (day == otrdiena[i][0]){
	 return [true, 'Tubtr', ] }}
 for (var i = 0; i < tresdiena.length; i++){
	if (day == tresdiena[i][0]){
	 return [true, 'Pertr', ] }}
 for (var i = 0; i < ceturtdiena.length; i++){
	if (day == ceturtdiena[i][0]){
	 return [true, 'Tubtr', ] }}
 for (var i = 0; i < svetdiena.length; i++){
	if (day == svetdiena[i][0]){
	 return [true, 'Tubtr', ] }}
 for (var i = 0; i < sestdiena.length; i++){
	if (day == sestdiena[i][0]){
	 return [true, 'Pertr', ] }}
  return [true, ''];
}

 	$('#Jelgavas_saraksts').datepicker({
 beforeShowDay: Jtrenini,
 dateFormat: 'yy-mm-dd',
 prevText: '&laquo;',
 nextText: '&raquo;',
 monthNames: ['Janvāris','Februāris','Marts','Aprīlis','Maijs','Jūnijs', 'Jūlijs','Augusts','Septembris','Oktobris','Novembris','Decembris'],
 monthNamesShort: ['JAN', 'FEB', 'MAR', 'APR', 'MAI', 'JUN', 'JUL', 'AUG', 'SEP', 'OKT', 'NOV', 'DEC'],
 dayNamesMin: ['S', 'P','O','T','C','P','S'],
 firstDay: 1
 });
function Jtrenini(date) {
 var day = date.getDay(), Friday = 5,/*Saturday = 6,*/ Sunday = 0;
 var piektdiena = [[Friday]];
 //var sestdiena = [[Saturday]];
 var svetdiena = [[Sunday]];
 for (var i = 0; i < piektdiena.length; i++){
	if (day == piektdiena[i][0]){
	 return [true, 'Jelgtr', ] }}
 /*for (var i = 0; i < sestdiena.length; i++){
	if (day == sestdiena[i][0]){
	 return [true, 'Jelgtr', ] }}*/
 for (var i = 0; i < svetdiena.length; i++){
	if (day == svetdiena[i][0]){
	 return [true, 'Jelgtr', ] }}
  return [true, ''];
}

 	$('#Berni_riga').datepicker({
 beforeShowDay: BerniRtrenini,
 dateFormat: 'yy-mm-dd',
 prevText: '&laquo;',
 nextText: '&raquo;',
 monthNames: ['Janvāris','Februāris','Marts','Aprīlis','Maijs','Jūnijs', 'Jūlijs','Augusts','Septembris','Oktobris','Novembris','Decembris'],
 monthNamesShort: ['JAN', 'FEB', 'MAR', 'APR', 'MAI', 'JUN', 'JUL', 'AUG', 'SEP', 'OKT', 'NOV', 'DEC'],
 dayNamesMin: ['S', 'P','O','T','C','P','S'],
 firstDay: 1
 });
function BerniRtrenini(date) {
 var day = date.getDay(), /*Monday = 1, Thursday = 4,*/ Sunday = 0;
 //var pirmdiena = [[Monday]];
 //var ceturtdiena = [[Thursday]];
 var svetdiena = [[Sunday]];
 /*for (var i = 0; i < pirmdiena.length; i++){
	if (day == pirmdiena[i][0]){
	 return [true, 'Btr', ] }}
 for (var i = 0; i < ceturtdiena.length; i++){
	if (day == ceturtdiena[i][0]){
	 return [true, 'Btr', ] }}*/
 for (var i = 0; i < svetdiena.length; i++){
	if (day == svetdiena[i][0]){
	 return [true, 'Btr', ] }}
  return [true, ''];
}

 	$('#Berni_jelgava').datepicker({
 beforeShowDay: BerniJtrenini,
 dateFormat: 'yy-mm-dd',
 prevText: '&laquo;',
 nextText: '&raquo;',
 monthNames: ['Janvāris','Februāris','Marts','Aprīlis','Maijs','Jūnijs', 'Jūlijs','Augusts','Septembris','Oktobris','Novembris','Decembris'],
 monthNamesShort: ['JAN', 'FEB', 'MAR', 'APR', 'MAI', 'JUN', 'JUL', 'AUG', 'SEP', 'OKT', 'NOV', 'DEC'],
 dayNamesMin: ['S', 'P','O','T','C','P','S'],
 firstDay: 1
 });
function BerniJtrenini(date) {
 var day = date.getDay(), Friday = 5, Sunday = 0;
 var piektdiena = [[Friday]];
 var svetdiena = [[Sunday]];
 /*for (var i = 0; i < piektdiena.length; i++){
	if (day == piektdiena[i][0]){
	 return [true, 'Btr', ] }}*/
 for (var i = 0; i < svetdiena.length; i++){
	if (day == svetdiena[i][0]){
	 return [true, 'Btr', ] }}
  return [true, ''];
  
}
  });
 
//### FUNKCIJAS ###

//## Smoothy page change ##
var activeid = "jaunumi"; 
function show(id) {
if(id==activeid) return;

$("#"+activeid).removeClass("block");
$("#"+id).addClass("block");

$("#s_"+activeid).removeClass("selected_CH");
$("#s_"+id).addClass("selected_CH");

$("#"+activeid).fadeOut("fast",
function (){ $("#"+id).fadeIn("fast");} );
activeid = id;
return;
}; 

function pasakumiOver(id){
document.getElementById(id).setAttribute('src','images/hover_'+id+'.jpg');
}

function pasakumiOut(id){
document.getElementById(id).setAttribute('src','images/'+id+'.jpg');
}

function externalLink(page, chapter){
document.location.href=page+'.php?chpt='+chapter;
}

function loadChapter(id){
$("#"+id).addClass("block"); // parādam īsto chapter
$("#"+id).fadeIn("fast");
$("#s_"+id).addClass("selected_CH"); // iezīmējam mazo pogu
if(id == "jaunumi" || id == "pasakumi") // iezīmējam lielo pogu
    document.getElementById("b_sakums").style.border='1px solid #86CD0D';
else if(id == "vesture" || id == "capoeiralatvija" || id == "foto" || id == "video")
	document.getElementById("b_capoeira").style.border='1px solid #86CD0D';
else if(id == "nodarbibusaraksts" || id == "buj" || id == "riga" || id == "jelgava" || id == "bernunodarbibas")
	document.getElementById("b_nodarbibas").style.border='1px solid #86CD0D';
else if(id == "informacija" || id == "prieksnesumi")
	document.getElementById("b_kontakti").style.border='1px solid #86CD0D';
	 activeid = id;
}

function highlightBlockOver(block){  //page:sākums - image links:: OVER
document.getElementById(block).style.backgroundColor = "#E6E6E6";
document.getElementById(block).style.border = "5px solid #DFDFDF";

if(block == "block1")
document.getElementById(block).style.marginLeft = "-5px";
else if(block == "block2" || block == "block3"){
document.getElementById(block).style.marginLeft = "5px";}

document.getElementById(block).style.marginRight = "-5px";
document.getElementById(block).style.marginTop = "-5px";
}


function highlightBlockOut(block){  //page:sākums - image links:: OUT
document.getElementById(block).style.backgroundColor = "white";
document.getElementById(block).style.border = "none";

if(block == "block1"){
document.getElementById(block).style.marginLeft = "0px";
document.getElementById(block).style.marginRight = "0px";}

else if(block == "block2" || block == "block3"){
document.getElementById(block).style.marginLeft = "10px";
document.getElementById(block).style.marginRight = "0px"}

document.getElementById(block).style.marginTop = "0px";
}

function navigEven(check){ //smooth or via .html pāreja uz sadaļu Pasākumi
if(check == "jaunumi" || check == "pasakumi")
show('pasakumi');
else
externalLink('sakums', 'pasakumi')
}
