jQuery.noConflict();
	jQuery.fn.resetMainView = function(myID,viewLevelVal,targetIndexVal,doSlide) {
		var parentIndexVal = jQuery('#'+myID+'_index').val();
		var displayTypeVal = jQuery('#'+myID+'_displayType').val();
		var boxtemplateVal = jQuery('#'+myID+'_boxtemplate').val();
		var currentRootVal = jQuery('#'+myID+'_currentRoot').val();
		var uid_parentVal = jQuery('#'+myID+'_uid_parent').val();
		var displayTypeRootVal = jQuery('#displayTypeRoot').val();
		var boxtemplateRootVal = jQuery('#boxtemplateRoot').val();
		var loaderClass = '#dblboxen_mainLoader';
		
		var uid_cObjVal = jQuery('#uidcObj').val();
		var mainAreaClass = '.dblboxen_mainWrap'+uid_cObjVal;
		var uidFilterVal = '';
		var uid_contentVal = 0;
		if(viewLevelVal==0){
			uidFilterVal = jQuery('#uidFilterVal').val();
			uid_contentVal = uid_cObjVal;
		}else{
			uidFilterVal = '';
			uid_contentVal = jQuery('#'+myID+'_uid_content').val();
                        
		}
		//alert('boxtemplateVal='+boxtemplateVal+' boxtemplateRootVal='+boxtemplateRootVal);
		jQuery(loaderClass).css('display','block');
		jQuery(mainAreaClass).fadeOut('slow', function() {
			if(doSlide){
                            
				 jQuery('.dblbox_startBody').slideToggle();
			}
			jQuery.ajax({
				type: "post",			
				url: "index.php",		
				async: true, 
				data: {
					eID: "tx_cndbl_web_fe_ajax",	
					piID:3,
					actionID:1,
					dataTypeID:1,
					viewLevel:viewLevelVal,
					displayType:displayTypeVal,
					boxtemplate:boxtemplateVal,
					uid_content:uid_contentVal,
					currentRoot:currentRootVal,
					uid_parent:uid_parentVal,
					displayTypeRoot:displayTypeRootVal,
					boxtemplateRoot:boxtemplateRootVal,
					parentIndex:parentIndexVal,
					uidFilter:uidFilterVal,
					uid_cObj:uid_cObjVal
				},
				dataType: "text/xml",
				success: function(response) {
					if(response!=null && response.length > 0) {
						 var new_content = response;
						 jQuery(mainAreaClass).html(new_content);
						 jQuery(mainAreaClass).fadeIn();
						 jQuery.fn.initDBLContainter(targetIndexVal);
						 jQuery.fn.initMainView();
						 if(displayTypeVal == 2){
							jQuery.fn.initCycle();
						 }
					}else{
						jAlert('Der Vorgang konnte aufgrund eines internen Fehlers nicht ausgef&uuml;hrt werden.', 'Responseerror');
					}
					
					jQuery(loaderClass).css('display','none');
				},
			   	error: function(x,e) {
					errStatusText = '';
					if(x.status==0){
						errStatusText ='Server Connection Error.';
					}else if(x.status==404){
						errStatusText ='Requested URL not found.';
					}else if(x.status==500){
						errStatusText ='Internal Server Error.';
					}else if(e=='parsererror'){
						errStatusText ='Error:\nParsing JSON Request failed.';
					}else if(e=='timeout'){
						errStatusText ='Request Time out.';
					}else {
						errStatusText ='Unknow Error:\n'+x.responseText;
					}
					jAlert('Der Vorgang konnte aufgrund eines internen Fehlers nicht ausgef&uuml;hrt werden.<br />'+x.responseText, errStatusText);
					jQuery(loaderClass).css('display','none');				
				}
			});
		  });
	};
jQuery(document).ready(function(){
	jQuery.fn.initMainView = function() {
		jQuery('#dblboxDetailBack').click(function(event){
			var myID = jQuery(this).attr('id');
			var viewLevelVal =  parseInt(jQuery('#'+myID+'_viewLevel').val())-1;
			var targetIndexVal = jQuery('#'+myID+'_parentIndex').val();
			var doSlide = false;
			if(viewLevelVal==0){
					doSlide = true;
			}
			jQuery.fn.resetMainView(myID,viewLevelVal,targetIndexVal,doSlide);
		});
		jQuery('.dblboxDetail').click(function(event){
			var myID = jQuery(this).attr('id');
			var viewLevelVal =  parseInt(jQuery('#'+myID+'_viewLevel').val())+1;
			var targetIndexVal = 0;
			var doSlide = false;
			if(viewLevelVal==1){
					doSlide = true;
			}
			jQuery.fn.resetMainView(myID,viewLevelVal,targetIndexVal,doSlide);
		});
	};
	/*
	var winWidth = jQuery(window).width();
	var winHeight = jQuery(window).height();
	var resizeTimeout = 0;
	jQuery.fn.setTitleWrapCSS = function(winWDiff) {
		var col1TopW = jQuery('#col1_top').width();
		if(col1TopW>190){
			var left = ((col1TopW/100))*7;
		}else{
			var left = ((col1TopW/100))*8;
		}
		var paddingLeft = (left/100)*290;
		
		jQuery('div.dblslidebox .tx_cndblwebTitleWrap').css('left',left+'px');
		
		
		var newWidth = ((col1TopW/100))*60;
		
		jQuery('div.dblslidebox .tx_cndblwebTitleWrap').css('top','332px');
		jQuery('div.dblslidebox .tx_cndblwebTitleWrap').css('width',newWidth+'px');
		jQuery('div.dblslidebox .tx_cndblwebTitleWrap').css('padding-left',paddingLeft+'px');
		var imgLeft =col1TopW+44;
		var imgTop = 137;
		jQuery('div.dblslidebox .dblslidebox_image').css('left',imgLeft+'px');
		jQuery('div.dblslidebox .dblslidebox_image').css('top',imgTop+'px');
	}
	jQuery.fn.setTitleWrapCSS();
	*/
	jQuery.fn.initCycle = function() {
		/*
		jQuery(window).resize(function (){
			
			var winWDiff = winWidth - jQuery(window).width();
			onResize = function() {
			//The method which sets the LEFT css property which triggers 
			//window.resize again and it was a infinite loop
					jQuery.fn.setTitleWrapCSS(winWDiff);
				
			}

			//New height and width
			
			var winNewWidth = jQuery(window).width(),
			winNewHeight = jQuery(window).height();

			// compare the new height and width with old one
			if(winWidth!=winNewWidth || winHeight!=winNewHeight)
			{
			window.clearTimeout(resizeTimeout);
			resizeTimeout = window.setTimeout(onResize, 10);
			}
			//Update the width and height
			winWidth = winNewWidth;
			winHeight = winNewHeight;
			
		});	
		*/
		var slideboxElements = jQuery(".dblslideboxshow > div").size();
		var redirectMS = parseInt(jQuery('#cndblpi1_redirectms').val());
		if(slideboxElements>1){
			var showTimeout = 400;
			if(redirectMS>slideboxElements){
				showTimeout = Math.floor(redirectMS / slideboxElements);
			}
			jQuery(".dblslideboxshow").cycle({
			   fx: "fade",
			   timeout: showTimeout,
			   cleartype: 1
			});
			//jQuery('div.dblslideboxshow').css('position','inherit');
		}
		
	}
	

	jQuery.fn.initDBLContainter();
	jQuery.fn.initMainView();
	jQuery.fn.initCycle();


});
