﻿// Main js file for custom functions / actions


// Admin area

// Show the options for the subnode / childs
function showChooseParentNode() {

    var myOpen = function(hash) { $('select').addClass('selectElement'); hash.w.show(); };
    var myClose = function(hash) { $('select').removeClass('selectElement'); $('#jqmParentWindow').hide(); hash.o.remove(); }
    $('#jqmParentWindow').jqm({ modal: true, onShow: myOpen, onHide: myClose }).jqmAddClose('li a').jqmShow();

}

var currentIndex = 1;


// Default start
$(document).ready(function() {

      // Fill the frontpage with extra links
    if ($('#teaser').length > 0)
    {
        
        // declare the different images
        setInterval("slideSwitch()", 6000);
    }
});

function slideSwitch() {
    var $active = $('#teaser IMG.active');

    if ($active.length == 0) $active = $('#teaser IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next = $active.next().length ? $active.next()
	        : $('#teaser IMG:first');

    $active.addClass('last-active');

    $next.css({ opacity: 0.0 })
	        .addClass('active')
	        .animate({ opacity: 1.0 }, 1000, function() {
	            $active.removeClass('active last-active');
	        });
	        
     //set random image
     var srcFile = "ima/firstpage/image_" + Math.floor(Math.random()*14) + ".jpg" ;
     var teaser = $('#teaser');
    $('#teaser2 a').remove();
    
     $('#teaser').html('<a href="page_204.aspx"><img src="' + srcFile + '" border="0" width="450" /></a>');
     $('#teaser2').html('<a href="page_204.aspx"><img src="' + srcFile + '" border="0" width="450" /></a>');
}
