//anti flicker
try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}



/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);




$(function() {
/*	$('.callback-button').nyroModal({ height: 500, width: 460, padding:0}); */
		$('.callback-button, .faq-button').nyroModal({ 
		bgColor: '#333',
		width: 460,
		height: 550,
		padding: 0,
		resizeable: false,
		autoSizable: false,
			css: { // Default CSS option for the nyroModal Div. Some will be overwritten or updated when using IE6
			bg: {
			  zIndex: 100,
			  position: 'fixed',
			  top: 0,
			  left: 0,
			  height: '100%',
			  width: '100%'			  
			},
			wrapper: {
			  zIndex: 101,
			 height: '500px',
			  position: 'fixed',
			  top: '50%',
			  left: '50%'
			},
			wrapper2: {
			},
			content: {
			  overflow: 'auto'
			},
			loading: {
			  zIndex: 102,
			  position: 'fixed',
			  top: '50%',
			  left: '50%',
			  marginTop: '-50px',
			  marginLeft: '-50px'
			}
		  },
		  hideContent: function(elts, settings, callback) {elts.contentWrapper.hide();callback();}
		});
		
		$('.feature-button').nyroModal({ 
		bgColor: '#333',
		width: 650,
		height: 550,
		padding: 0,
		resizeable: false,
		autoSizable: false,
			css: { // Default CSS option for the nyroModal Div. Some will be overwritten or updated when using IE6
			bg: {
			  zIndex: 100,
			  position: 'fixed',
			  top: 0,
			  left: 0,
			  height: '100%',
			  width: '100%'			  
			},
			wrapper: {
			  zIndex: 101,
			 height: '500px',
			  position: 'fixed',
			  top: '50%',
			  left: '50%'
			},
			wrapper2: {
			},
			content: {
			  overflow: 'auto'
			},
			loading: {
			  zIndex: 102,
			  position: 'fixed',
			  top: '50%',
			  left: '50%',
			  marginTop: '-50px',
			  marginLeft: '-50px'
			}
		  },
		  hideContent: function(elts, settings, callback) {elts.contentWrapper.hide();callback();}
		});

	//$("#id31 .nav3-grid dt a").click(function () {
	//	rueckruf();
	//	return false;
	//});
	

	// Sie sind Neukunde?
	$(".link-44").click(function () {
		rueckruf();
		return false;
	});

	// Sie wollen Partner werden?
	$(".link-63").click(function () {
		rueckruf();
		return false;
	});



	/*
		Produkte Modul
	-------------------------------------------------------------------------------
	*/
	/*
	* zInit()
	*
	* Build Crossbrowser Z-Index Grid
	*		
	*/
	function zInit() {	
		
		var wrapperElems = $("#produkte-ring ul li");
		var wrapperElemsMax = jQuery(wrapperElems).length;		
		jQuery.each(wrapperElems, function(i, val) {
			zIndex = wrapperElemsMax + i;
			jQuery(val).css({zIndex:""+zIndex+""});				
		});
	}

	//Z-Index Fix init
	zInit();

	var gewaehlt;
	var infotextid;
	var $cur,zIndex_tmp;
	var thisElem;
	var nextElem;
	
    $("#produkte-ring ul li a").hover(
      function () {

		thisElem =  $(this).parent().attr("class");		
		setTextId(thisElem);		
		$(this).parent().css({zIndex: 100});
		$(".infotext").css({
			backgroundImage: "url(/fileadmin/templates/rce/images/ajax-loader.gif)",
			backgroundRepeat: "no-repeat",
			backgroundPosition: "center"
		});
	    	$(".infotext").hide();
		$(this).next().load("/index.php?id="+infotextid+" .content-spalte-mitte-bg .content", function() {			
			$(this).append('<div class="ecke"><!-- --></div>');
		});	
		$(this).next().show();
	  
      }, 
      function () {
		  zInit();
         $(this).next().hide();
		 //zInit();
      }
    );

	
	
	 $("#produkte-ring ul li a").click(function () {
     
	  thisElem =  $(this).parent().attr("class");		
	  setTextId(thisElem);	  
	
	  $("#main .produkte-icon-switcher .icon").attr("class","icon");	   
	  $(".produkte-icon-switcher .icon").addClass(thisElem);
	  $(".content-spalte-rechts .subcontent-unit-border").load("/index.php?id="+infotextid+" .content-spalte-rechts .subcontent-unit-border");   
	  
		$(this).next().hide();

	  return false;
	});


	$(".produkte-icon-switcher .icon").addClass(thisElem);
	$("#produkte-ring ul li:first").attr("class");	
	
	$(".produkte-icon-switcher .vor").click(function() {		
		if(thisElem == undefined) { 
			nextElem = $("#produkte-ring ul li.beschaffung").attr("class"); 
		}else {
			nextElem = $("#produkte-ring ul li."+thisElem).next().attr("class");
		}
		if(nextElem) {
			thisElem = nextElem;
			 $("#main .produkte-icon-switcher .icon").attr("class","icon");
			$(".produkte-icon-switcher .icon").addClass(thisElem);
			setTextId(thisElem);
			  $(".content-spalte-rechts .subcontent-unit-border").load("/index.php?id="+infotextid+" .content-spalte-rechts .subcontent-unit-border");   
		}		

		return false;
	});

	
	$(".produkte-icon-switcher .zurueck").click(function() {
		
		nextElem = $("#produkte-ring ul li."+thisElem).prev().attr("class");				
		if(nextElem) {
			thisElem = nextElem;
			 $("#main .produkte-icon-switcher .icon").attr("class","icon");
			$(".produkte-icon-switcher .icon").addClass(thisElem);		
			setTextId(thisElem);
			 $(".content-spalte-rechts .subcontent-unit-border").load("/index.php?id="+infotextid+" .content-spalte-rechts .subcontent-unit-border");   

		}
		return false;
	});
	

	function setTextId(gewaehlt) {		
		switch (gewaehlt)	{
			case "beschaffung":
				infotextid = 53;
			break;		
			case "installation":
				infotextid = 52;
			break;	
			case "entstoerung":
				infotextid = 51;
			break;		
			case "bestands-verwaltung":
				infotextid = 50;
			break;		
			case "anwendungs-verteilung":
				infotextid = 49;
			break;		
			case "anwender-betreuung":
				infotextid = 48;
			break;		
			case "umzug-anpassung":
				infotextid = 47;
			break;	
			case "rce-service-monitor":
				infotextid = 46;
			break;					
		}
	}
		
	
});


/*
	Rückruf per Function
*/
function rueckruf() {		
			 $.nyroModalManual({
				 url: 'index.php?id=40',
				bgColor: '#333',
				width: 460,
				height: 500,
				padding:0,
				hideContent: function(elts, settings, callback) {elts.contentWrapper.hide();callback();}
			});		
}


		/* 
			Callback Button 
		
		$('.callback-button').nyroModal({ 
		bgColor: '#333',
		width: 460,
		height: 500,
		padding: 0,
		resizeable: false,
		autoSizable: false,
			css: { // Default CSS option for the nyroModal Div. Some will be overwritten or updated when using IE6
			bg: {
			  zIndex: 100,
			  position: 'fixed',
			  top: 0,
			  left: 0,
			  height: '100%',
			  width: '100%'			  
			},
			wrapper: {
			  zIndex: 101,
			 height: '500px',
			  position: 'fixed',
			  top: '50%',
			  left: '50%'
			},
			wrapper2: {
			},
			content: {
			  overflow: 'hidden'
			},
			loading: {
			  zIndex: 102,
			  position: 'fixed',
			  top: '50%',
			  left: '50%',
			  marginTop: '-50px',
			  marginLeft: '-50px'
			}
		  }
		});
		*/