/* *****************************************
//  WebTank javascript File
//  Title: 2011_nordi.js	
//  File updated: 2011-09-20 12:16:20
// 
//  Do NOT manually edit this generated file
// **************************************** */


/* FUNCTIONS */

function test() {

	var position = $("#photobook .images").position();
	var number = ( position.left / 300 ) * -1;
	
	$("#photobook_text .texts").css("margin-left", position.left + "px");

}

/* INIT */

$(document).ready( function() {
	
	$(".menu ul > li > ul > li:last-child").css("cssText", "border-bottom: none !important;");
	
	//
	
	$(".menu ul > li > a").mouseover( function() {

//		console.log("MOUSE OVER");
		
		if( $(this).parent().children("ul").length != 0 ) {
			
			var parent_width = $(this).parent().width();
			
//			console.log("parent_width = " + parent_width);
			
			//
			
			var is_bigger = false;
			
			$(this).parent().children("ul").children("li").each( function() {
			
				var child_width = $(this).width();
				
//				console.log("child_width = " + child_width);
				
				if( child_width > parent_width ) {
				
					is_bigger = true;
				
				}
			
			} );
			
			//
			
//			console.log("is_bigger = " + is_bigger);
			
			if( is_bigger ) {
			
				
			
			} else {
			
				$(this).parent().children("ul").children("li").css("cssText", "display: block !important; width: " + $(this).parent().width() + "px !important; margin: 0px !important; border-bottom: 1px solid #000000 !important;"); 
				$(this).parent().children("ul").children("li:last-child").css("cssText", "display: block !important; width: " + $(this).parent().width() + "px !important; margin: 0px !important; border-bottom: none !important;"); 
				
			}
			
		}
		
	} );
	
	//
	
	$(".menu ul > li > ul > li > a").mouseover( function() {
	
//		console.log("MOUSE OVER");
		
		if( $(this).parent().children("ul").length != 0 ) {
			
//			console.log("" + $(this).width());

			var width = $(this).width();
			
			var position = $(this).parent().children("ul").position();
			
			var left = width - position.left;
			
			//
			
			$(this).parent().children("ul").css("left", ( width + 10 ) + "px");
			
		}
			
	} );
	
	/*  */
	
	if( $("#jcarousel").length != 0 ) {
	
		$("#jcarousel").jcarousel( {	
			auto: 3,
			scroll: 1,
			wrap: 'last',
			itemVisibleInCallback: {
				onAfterAnimation: test
			}
		} );
		
	}
	
} );

