wdTHideAjaxArea = null;
wdAjaxAreaOpen = false;
wdAjaxAreaPinned = false;
wd_ajax_currentIFCode = null;

function wd_scheduleSlideOut( timeInMS ) {
	// Falls gepinnt, nix tun
	if (wdAjaxAreaPinned) return;
	
	// Falls bereits zu, fertig!
	if ( !(wdAjaxAreaOpen === true) ) return;

	// Falls Timer bereits aktiviert, fertig
	if ( (wdTHideAjaxArea != undefined) && (wdTHideAjaxArea != null) ) return;	

	// SlideOut-Timer aktivieren
	wdTHideAjaxArea = window.setTimeout( 'wd_AjaxAreaSlideOut()', timeInMS );	
}

function wd_stopSlideOutTimer() {
	// Falls SlideOut-Timer schon aktiv, diesen abbrechen
	if ( (wdTHideAjaxArea != undefined) && (wdTHideAjaxArea != null) ) {
		window.clearTimeout(wdTHideAjaxArea);
		wdTHideAjaxArea = null;		
	}
}

function wd_MouseOver() {
	wd_stopSlideOutTimer();
}

function wd_MouseOut() {
	wd_scheduleSlideOut( 1500 );
}

function wd_showAjaxAreaAlternative() {
	$("wd_a_content").innerHTML=" ";	
	wd_showAjaxArea();
	
	if ( $("wd_a").getWidth() < 1 ) {
		window.setTimeout("wd_showAjaxAreaAlternative()", 750);
		return;
	}
	
	wcCoord = $("wd_a").positionedOffset();
	h = $("wd_a_wf").getHeight();
	$("wd_a_content_nopadding").setStyle({
		'left' : wcCoord.left,
		'top' : wcCoord.top,
		'width' : (Math.max($("wd_a").getWidth() - 15, 0)) + "px",
		'height' : (Math.max($("wd_a_wf").getHeight() - 25, 0)) + "px"		
	});
	
	$("wd_a_content").hide();
	$("wd_a_content_nopadding").show();
}

function wd_showAjaxArea() {
	$("wd_a_content").show();
	$("wd_a_content_nopadding").hide();
	// Falls bereits offen, fertig!
	if ( wdAjaxAreaOpen === true ) return;

	// Höhe anpassen	
	$("wd_a_content").setStyle({
		'height' : ($("wd_a_wf").getHeight() - 35) + "px"
	});
	
	// Anzeigen
	$("wd_a_content").setStyle({ 'overflow': 'hidden' });
	
	wcCoord = $("wd_a_wf").positionedOffset();
	$("wd_a").setStyle({
		'top' : wcCoord.top+"px",		
		'display': 'block',
		'width' : '0px'
	});
	wdAjaxAreaOpen = true;
	
	$("wd_wc_tr").hide();
	$("wd_wc_br").hide();
	
	// start effect
	new Effect.Morph("wd_a", {
		  style: {'width': '315px'}, // CSS Properties
		  duration: 0.5, // Core Effect properties
		  afterFinish : function() {
				$("wd_a_content").setStyle({ 'overflow': 'auto' });
			}
	});
}

function wd_AjaxAreaSlideOut() {
	wd_stopSlideOutTimer();
	
	wdAjaxAreaOpen = false;
	wdAjaxAreaPinned = false;
	
	$("wd_a_content").setStyle({ 'overflow': 'hidden' });	

	new Effect.Morph("wd_a", {
		style: {'width': '0px'}, // CSS Properties
		duration: 0.5, // Core Effect properties
		afterFinish : function() {
			$("wd_wc_tr").show();
			$("wd_wc_br").show();
			$("wd_a").setStyle({ 'display': 'none' });
			$("wd_a_content_nopadding").hide();
		}
	});
}

function wd_addFav(ifCode) {
	wd_showAjaxArea();
	return ifjs_favAddDel( ifCode, false, {
		'outID' : "wd_a_content",
		'closeFunc' : 'wd_AjaxAreaSlideOut()',
		'onAdded' : function() {
			wd_showAjaxArea();
			wd_scheduleSlideOut( 5000 );
			$("fav_add").hide();
			$("fav_del").show();
		}
	} );
}

function wd_delFav(ifCode) {
	wd_showAjaxArea();
	return ifjs_favAddDel( ifCode, true, {
		'outID' : "wd_a_content",
		'closeFunc' : 'wd_AjaxAreaSlideOut()',
		'onDeleted' : function() {
			wd_showAjaxArea();
			wd_scheduleSlideOut( 5000 );
			$("fav_del").hide();
			$("fav_add").show();
		}
	} );
}

function wd_contact(ifCode) {
	wd_showAjaxAreaAlternative();
	wdAjaxAreaPinned = true;
	return ifjs_contactWoman(ifCode, {
		'outID' : "wd_a_content_nopadding",
		'ajaxParams' : "nopic=1",
		'closeFunc' : 'wd_AjaxAreaSlideOut()',
		'onSuccess' : function() {
			$("wd_ordericon").hide();
			$("wd_ordericon2").hide();
			$("wd_orderedicon").show();
			$("wd_orderedicon2").show();
		}
	} );
}

function wd_tellafriend( ifCode) {
	wd_showAjaxAreaAlternative();
	wdAjaxAreaPinned = true;
	return ifjs_tellAFriend( ifCode, {
		'outID' : "wd_a_content_nopadding",
		'ajaxParams' : "nopic=1",
		'closeFunc' : 'wd_AjaxAreaSlideOut()' 
	});
}
