/* Denso custom functions */

/* Homepage news menu animations and styles*/
function initNewsMenu() {
  /*$('ul.newssource').hide();*/
  $('ul.newssource').addClass('withborder'); 
  $('ul.newssource').addClass('newssource');
  $('ul.newssource li:last-child').addClass('noborder');
  $('.newssourcedivider:last').nextAll('h1:first').addClass('newssourcetitle mydenso');
  $('.newssource').prev().addClass('newssourcetitleopen');
  $('.newssource').prev().click(
    function() {
        $(this).toggleClass("newssourcetitleopen");
        $(this).next().slideToggle('fast');      	
      }
    );
  }

/* FCE  Certifications scroll control */

function initCertificationsScroller() {
	 
	 $('.scrollercontainer').map( function() {
		if ( ($(this).find('.scroller div:first img').length  >= $(this).find('.itemsrequiredforscroll').val()) && (!($(this).find('.forcestatic:checkbox').val() > 0)) ) {
	    		//$(this).find('div:eq(1)').find('div:first img').length
	    		//for debugging
	    		//alert( $(this).children('div:eq(1)').html() + '   \n Size: ' + $(this).children('div:eq(1)').find('div:first img').length + 'field value: ' +  $(this).find('.itemsrequiredforscroll').val());
			
			//add cycle effects
			$(this).find('.scroller').cycle({ 
   			 	fx:     'scrollLeft',
   			 	continuous: 1, 
   			 	speed:    22000,
    				timeout: 10,
    				height: 50,
    				delay: 0,
    				easing: 'linear'
			});
   		}
   		else {
   			$(this).find('.scroller').addClass('static');
   		}
      	});
}



function subMenu() {
  $('#submenu ul').hide(); 
  $('#subsmenu li.firstlevel').addClass('firstlevel');
  $('#submenu a.firstlevel').click(
    function() {
        $(this).toggleClass("firstlevelopen");
        $(this).next().slideToggle('fast');        	
      }
    );
  }    





function  doImageLightbox(imageText,deText,closeImg) {
	
	$('div.tx-chgallery-pi1 a[@rel*=lightbox]').lightBox({
		overlayBgColor: '#03B3EC',
		overlayOpacity: 0.75,
		txtClose: closeImg,
		imageBtnPrev: '/fileadmin/templates/images/lightbox_previous.png',
		imageBtnNext: '/fileadmin/templates/images/lightbox_next.png',
		imageLoading: '/fileadmin/templates/images/image_loading.gif',
		txtImage: imageText,
		txtOf: deText 
	});  // Select all links that contains lightbox in the attribute rel	

}


$(document).ready(function() {

//news menu initilization
initNewsMenu();

// FCE certifications scroll control
initCertificationsScroller();



// Gallery remove next previous link in speciall cases
//$('div.pagebrowser div.prev:empty').css("background-image","none");
//$('div.prev').not(':has(a)').css('background-image','none');

//$('div.next:empty').css("background-image","none");





}); 
//END document ready()

