// round bottom corners 
// DD_roundies.addRule('.rounded_button', '0 0 7px 7px', true);
DD_roundies.addRule('.round_border_all', '7px 7px 7px 7px', true);

// jQuery konfilkt mit mootools

var $j = jQuery.noConflict();

/*
 * jQuery :nth-last-child - v0.2 - 2/13/2010
 * http://benalman.com/projects/jquery-misc-plugins/
 * 
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */
(function($j){var c=/:(nth)-last-child(?:\((even|odd|[\dn+-]*)\))?/,a=$j.expr,b=a.filter.CHILD;a[":"]["nth-last-child"]=function(h,g,e,k){var j=e[0].match(c),f=$j(h.parentNode).children(),d;j=a.preFilter.CHILD(j);b(h,j);d=f.eq(f.length-h.nodeIndex)[0];return b(d,j)}})(jQuery);

// image preloader
jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}




// sync height and add classes

$j(document).ready(function(){

	// initialisiere ddsmoothmenutopnav ueber flash
	ddsmoothmenutopnav.init({
		mainmenuid: "topnav", //menu DIV id
		orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
		classname: 'ddsmoothmenutopnav', //class added to menu's outer DIV
		//customtheme: ["#1c5a80", "#18374a"],
		contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
	})  
	$j('#topnav ul li:last-child').css('background-image', 'none'); 
	$j('#topnav ul li ul li:last-child').css('background-image', 'url(fileadmin/template/images/c3c3c3_80.png)'); 

  // initialisiere ddsmoothmenu unter flash
	ddsmoothmenu.init({
			mainmenuid: "smoothmenu1", //menu DIV id
			orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
			classname: 'ddsmoothmenu', //class added to menu's outer DIV
			//customtheme: ["#1c5a80", "#18374a"],
			contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
		})
		
	$j('#smoothmenu1 ul li.firstlev:last-child a').css('background-image', 'none'); 
	$j('#smoothmenu1 ul li.firstlev:nth-last-child(2) a').css('background-image', 'none'); 



// function construct
function neuraManipulateDom()  {
    var windowheight = $j(window).height(); // hoehe Viewpoint
	var col3height = windowheight - 375+65; // 15+15+15+48+header+teaser+nav
	
	var minwidth = $j('div.page_margins').css('minWidth'); // 950 px
	var minwidthvalue = parseFloat(minwidth, 10); // 950
	var windowwidth = $j(window).width(); // Fensterbreite
	var availablePixels = windowwidth - minwidthvalue;
	
	if(availablePixels > 0) {
		var newMarginLeft = availablePixels * 0.4; // 40%
	} else {
		var newMarginLeft = 15; // 15px = default
	}
	
	// console.log(newMarginLeft);
	// console.log(minwidthvalue);
	
	// Hoehe anpassen wenn Fenster hoeher 550px
    if(windowheight > 550) {
		$j('div#col3_content').css({
			'height' : col3height+'px', 
			'overflow-x' : 'hidden'
		});	
		
	}

	
	// Breite anpassen
	$j('div.innerpage').css({
		'marginLeft' : newMarginLeft +'px'
	});
	$j('div#footer_content').css({
		'marginLeft' : newMarginLeft +'px'
	});	
	
};


	neuraManipulateDom();

	$j(window).resize(function(){ 
		neuraManipulateDom();
	});  	
  
	// IMG Preloader
	$j.preloadImages(
		"fileadmin/template/images/flag_en_ro.gif",
		"fileadmin/template/images/flag_de_ro.gif",
		"fileadmin/template/searchbox/bg_go_hover.gif"
	); 
	
	// Langmenu hover
    $j("#lng_en").hover(
      function () {
        $j(this).attr("src","fileadmin/template/images/flag_en_ro.gif");
      }, 
      function () {
        $j(this).attr("src","fileadmin/template/images/flag_en.gif");
      }
    );
    $j("#lng_de").hover(
      function () {
        $j(this).attr("src","fileadmin/template/images/flag_de_ro.gif");
      }, 
      function () {
        $j(this).attr("src","fileadmin/template/images/flag_de.gif");
      }
    );  
  


  $j('.sameheight').syncHeight();
  $j(window).resize(function(){ 
    $j('.sameheight').syncHeight();
  });
  
  // at least unhide menu
	$j('#header #topnav').css({
			'height' : 'auto', 
			'overflow' : 'visible'
		});	
  


  
});




// Bildwechsel Startseite
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}