/*********************************************
 * Special Order bvba
 * (c) Ken Pimontel, ken at specialorder dot be
 * Purpose: Base JQ script settings
 *
 * NOTES
 * From base site 0003
 *
 * DEPENDENCIES
 *
 * TODO
 *
 * HISTORY
 * Last change <!-- hhmts start -->2009-09-16 10:41:15<!-- hhmts end -->
 * 090331 ADDED Topmenu li:not(.active)
 * 090331 UPDATE SideMenu-T2 afgewerkt
 * 090327 ADDED auto form label width
 * 090327 ADDED a.box
 * 090120 First version
 *********************************************/


 // Logging function - kan je gebruiken in de chain. $("blabla").log("Wat je wil zeggen").fadeofzo...
jQuery.fn.log = function (msg) {
      console.log("%s: %o", msg, this);
      return this;
  };


jQuery.fn.fancybox.defaults.path = 'http://nethome.be/_js/fancybox-1.2.1/';
$(document).ready(function() {
	 $("a.box").fancybox({
	 	'hideOnContentClick': true,
	 	'zoomSpeedIn': 500,
	 	'zoomSpeedOut': 500,
	 	'frameWidth': 500,
	 	'frameHeight': 600,
	 	'overlayShow': true,
	 	'overlayOpacity': 0.75
	 	});

 });

// Datatables
$(document).ready(function() {
	$('#kadertable').dataTable();
});


$(document).ready(function() {
	$('table.datatable').dataTable({
		"aaSorting": [1,'desc'],
		"iDisplayLength": 10
	});
} );



//jsddm
var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open()
{  jsddm_canceltimer();
   jsddm_close();
   ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

function jsddm_close()
{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{  closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
      closetimer = null;}}

$(document).ready(function()
{  $('#TopMenu > li').bind('mouseover', jsddm_open)
   $('#TopMenu > li').bind('mouseout',  jsddm_timer)});

document.onclick = jsddm_close;


// regular cycle
$('.cycle').cycle({
	fx:      'scrollRight',
	timeout:  6000,
	easing:  'easeInQuad'
});



// cycle slideshow

$(document).ready(function(){
    $('body#workdetail #loading').fadeOut(500);
    $('body#workdetail #scrollable').fadeIn('slow');
    $('body#workdetail #items').cycle({
        fx:     'scrollRight',
        speed:  500,
        // 0 = on click
        timeout: 0,
        easing: 'backinout',
        pager:  '#secindex',
        // enable cleartype corrections. Only necessary to do this when using a 'fade' transition in combination with either text slides or PNGs with transparency.
        cleartype: 1,
        pagerAnchorBuilder: function(idx, slide) {
            // return sel string for existing anchor
            return '#secindex li:eq(' + (idx) + ') a';
        }
    });
});


// cylcle for artistdetail
$(document).ready(function(){
    $('body#artistdetail #loading').fadeOut(500);
       // hover (over,out)
       // toggel (click, click, click, ...)
    $('body#artistdetail ul#secindex').mouseover(
        function(){
            $('#artistinfo:visible').hide();
            $('#scrollable:hidden').fadeIn('slow');
        });
    $('body#artistXXXdetail #main').mouseover(
        function(){
            $('#scrollable:visible').hide();
            $('#artistinfo:hidden').fadeIn('slow');
        });


    $('body#artistdetail #items').cycle({
        fx:     'scrollRight',
        speed:  500,
        // 0 = on click
        timeout: 0,
        easing: 'backinout',
        pager:  '#secindex',
        // enable cleartype corrections. Only necessary to do this when using a 'fade' transition in combination with either text slides or PNGs with transparency.
        cleartype: 1,
        pagerAnchorBuilder: function(idx, slide) {
            // return sel string for existing anchor
            return '#secindex li:eq(' + (idx) + ') a';
        }
    });
});

// a hrefs
$(document).ready(function(){
    $("a[href$=pdf]")
        .addClass("pdf")
        .attr({ target: "_blank" });
    $("a[href$=zip]").addClass("zip");
    $("a[href$=psd]").addClass("psd");
    $("a[href*=mailto]").addClass("mailto");
});


// menufixes
$(document).ready(function(){
    $('body#artistdetail #TopMenu li#artists').addClass("active");
    $('body#workdetail #TopMenu li#gallery').addClass("active");
});

// Secondary animation
$("#secondary img:not(.noani)").fadeTo("slow", 0.6); // This sets the opacity of the thumbs to fade down to 60% when the page loads
$("#secondary img:not(.noani)").hover(function(){
    $(this).fadeTo("fast", 1.0); // This should set the opacity to 100% on hover
    },function(){
    $(this).fadeTo("fast", 0.6); // This should set the opacity back to 60% on mouseout
});

// Blokje animation
//$("div.blokje2 img").fadeTo("slow", 0.6); // This sets the opacity of the thumbs to fade down to 60% when the page loads
$(".blokje1").hover(function(){
    $(this > ".blokje2 img").fadeTo("fast", 1.0); // This should set the opacity to 100% on hover
    },function(){
    $(this > ".blokje2 img").fadeTo("fast", 0.6); // This should set the opacity back to 60% on mouseout
});

