
// jQuery Scripts
var $j = jQuery.noConflict();

function sliderDown(srcId,srcPos){
	$j('#'+srcId).animate({top:'-'+srcPos+'px'}, 1000, function() {
		$j('#'+srcId+' #sliderOpenArrow').css({display:'none'});
		$j('#'+srcId+' #sliderCloseArrow').css({display:'block'});
	});
}
function sliderUp(srcId,srcPos){
	$j('#'+srcId).animate({top:'-'+srcPos+'px'}, 1000, function() {
		$j('#'+srcId+' #sliderOpenArrow').css({display:'block'});
		$j('#'+srcId+' #sliderCloseArrow').css({display:'none'});
	});
}



function blendOver(getID) {
	var $alt = $j('#'+getID+' IMG.topslice');
	if($alt.next().length){
		var $neu = $alt.next();
	}else{
		var $neu = $j('#'+getID+' IMG:first');
	}
	$alt.addClass('secondslice');
	$alt.removeClass('topslice');
	$neu.css({opacity: 0.0});
	$neu.addClass('topslice');
	
	$neu.animate({opacity: 1.0}, 2000, function() {
		$alt.removeClass('secondslice');
	});
}
function slipOver(getID) {
	var $alt = $j('#'+getID+' IMG.topslice');
	if($alt.next().length){
		var $neu = $alt.next();
	}else{
		var $neu = $j('#'+getID+' IMG:first');
	}
	$alt.addClass('secondslice');
	$alt.removeClass('topslice');
	$neu.css({left: '-250px'});
	$neu.addClass('topslice');
	
	$neu.animate({left: '0px'}, 500, function() {
		$alt.removeClass('secondslice');
	});
}
function blendOverDivs(getID) {
	var $alt = $j('#'+getID+' DIV.topslice');
	if($alt.next().length){
		var $neu = $alt.next();
	}else{
		var $neu = $j('#'+getID+' DIV:first');
	}
	$alt.addClass('secondslice');
	$alt.removeClass('topslice');
	$neu.css({opacity: 0.0});
	$neu.addClass('topslice');
	
	$neu.animate({opacity: 1.0}, 2000, function() {
		$alt.removeClass('secondslice');
	});
}


function teaseOver(getID,getTeaser) {
	var $alt = $j('#'+getID+' div.topslice');
	var $altbtn = $j('#'+getID+' div.buttonlist a.on');
	
	$j('#'+getID+' div.buttonlist a.first').unbind('click');
	$j('#'+getID+' div.buttonlist a.second').unbind('click');
	$j('#'+getID+' div.buttonlist a.third').unbind('click');
	$j('#'+getID+' div.buttonlist a.fourth').unbind('click');
	
	if(getTeaser == 1){
		var $neu = $j('#'+getID+' div.first');
		var $neubtn = $j('#'+getID+' div.buttonlist a.first');
	}else if(getTeaser == 2){
		var $neu = $j('#'+getID+' div.second');
		var $neubtn = $j('#'+getID+' div.buttonlist a.second');
	}else if(getTeaser == 3){
		var $neu = $j('#'+getID+' div.third');
		var $neubtn = $j('#'+getID+' div.buttonlist a.third');
	}else if(getTeaser == 4){
		var $neu = $j('#'+getID+' div.fourth');
		var $neubtn = $j('#'+getID+' div.buttonlist a.fourth');
	}else{
		if($alt.next('div.teaser').length){
			var $neu = $alt.next('div.teaser');
			var $neubtn = $altbtn.next('a.button');
		}else{
			var $neu = $j('#'+getID+' div.teaser:first');
			var $neubtn = $j('#'+getID+' div.buttonlist a:first');
		}
	}
	
	$alt.addClass('secondslice');
	$alt.removeClass('topslice');
	$altbtn.removeClass('on');
	
	$neu.css({opacity: 0.0});
	
	$neu.addClass('topslice');
	$neubtn.addClass('on');
	
	$neu.animate({opacity: 1.0}, 250, function() {
		$alt.removeClass('secondslice');
		$j('#'+getID+' div.buttonlist a.first').click(function() {
			teaseOver('aejqTeaser',1);
		});
		$j('#'+getID+' div.buttonlist a.second').click(function() {
			teaseOver('aejqTeaser',2);
		});
		$j('#'+getID+' div.buttonlist a.third').click(function() {
			teaseOver('aejqTeaser',3);
		});
		$j('#'+getID+' div.buttonlist a.fourth').click(function() {
			teaseOver('aejqTeaser',4);
		});
	});
}


function setTeaseOverButtons(getID){
	$j('#'+getID+' div.buttonlist a.first').hover(function() {
		teaseOverQuick(getID,1);
	});
	$j('#'+getID+' div.buttonlist a.second').hover(function() {
		teaseOverQuick(getID,2);
	});
	$j('#'+getID+' div.buttonlist a.third').hover(function() {
		teaseOverQuick(getID,3);
	});
	if($j('#'+getID+' div.buttonlist a.fourth')){
		$j('#'+getID+' div.buttonlist a.fourth').hover(function() {
			teaseOverQuick(getID,4);
		});
	}
	if($j('#'+getID+' div.buttonlist a.fivth')){
		$j('#'+getID+' div.buttonlist a.fivth').hover(function() {
			teaseOverQuick(getID,5);
		});
	}
}
function teaseOverQuick(getID,getTeaser) {
	var $alt = $j('#'+getID+' div.topslice');
	var $altbtn = $j('#'+getID+' div.buttonlist a.on');
	
	switch(getTeaser){
		case 1:
			var $neu = $j('#'+getID+' div.first');
			var $neubtn = $j('#'+getID+' div.buttonlist a.first');
		break;
		case 2:
			var $neu = $j('#'+getID+' div.second');
			var $neubtn = $j('#'+getID+' div.buttonlist a.second');
		break;
		case 3:
			var $neu = $j('#'+getID+' div.third');
			var $neubtn = $j('#'+getID+' div.buttonlist a.third');
		break;
		case 4:
			var $neu = $j('#'+getID+' div.fourth');
			var $neubtn = $j('#'+getID+' div.buttonlist a.fourth');
		break;
		default:
			if($alt.next('div.teaser').length){
				var $neu = $alt.next('div.teaser');
				var $neubtn = $altbtn.next('a.button');
			}else{
				var $neu = $j('#'+getID+' div.teaser:first');
				var $neubtn = $j('#'+getID+' div.buttonlist a:first');
			}
		break;
	}
	
	$alt.removeClass('topslice');
	$neu.addClass('topslice');
	
	$altbtn.removeClass('on');
	$neubtn.addClass('on');
}


function etc_textcount(field_id,counter_id) {
	max = 320;
	anz = document.getElementById(field_id).value.length+1;
	document.getElementById(counter_id).value = ((max+1)-anz);
	if(anz > max){
		document.getElementById(counter_id).style.color="#ff0000";
		document.getElementById(field_id).value = document.getElementById(field_id).value.substr(0,320);
	} else if(anz < max && anz > (max-15)) {
		document.getElementById(counter_id).style.color="#ff9900";
	} else if(anz < max) {
		document.getElementById(counter_id).style.color="#00c000";
	}
}
function check_counter(field_id,counter_id) {
	max = 320;
	anz = document.getElementById(field_id).value.length+1;
	if(anz > max){
		return false;
	} else if(anz <= max) {
		return true;
	}
}

function clipbox(id) { 
	var boxlink = "cb_";
	var headlink = "hl_";
	if(document.getElementById(boxlink+id).className == "clipboxoff") {
		document.getElementById(boxlink+id).className = "clipboxon";
		document.getElementById(headlink+id).className = "clipboxon";
	} else {
		document.getElementById(boxlink+id).className = "clipboxoff";
		document.getElementById(headlink+id).className = "clipboxoff";
	}
}
function clipbox_drive(id) { 
	var boxlink = "cb_";
	var headlink = "hl_";
	if(document.getElementById(boxlink+id).className == "clipboxoff_drive") {
		document.getElementById(boxlink+id).className = "clipboxon_drive";
		document.getElementById(headlink+id).className = "clipboxon_drive";
	} else {
		document.getElementById(boxlink+id).className = "clipboxoff_drive";
		document.getElementById(headlink+id).className = "clipboxoff_drive";
	}
}

function etc_link(){
	if(document.getElementById('etc_link')){
		document.getElementById('etc_link').setAttribute("target", "_blank");
	}
}

function isMethodType(s){
	return (s == "function" || s == "object");
}
function openSlimFrame(getURL,width,height){
	Shadowbox.open({
        content:    getURL,
        player:     "iframe",
        title:      "",
        height:     height,
        width:      width
    });


	//Slimbox.open([[getURL,'', 'width='+width+', height='+height]],0,{resizeDuration: 400, resizeTransition: Fx.Transitions.Sine.easeInOut, opacity: 0.0, opacityDuration: 500, loop: 1, initialWidth: width, initialHeight: (height-100), animateCaption: 1, showCounter: 1, defaultIframeWidth: width, defaultIframeHeight: height, iframeScrolling: 'auto', enablePrintButton: 0, enableSaveButton: 0,counterText: 'Seite  {x} von {y}', psScriptPath: 'typo3conf/ext/pmkslimbox/savefile.php'});
	
}

function kalenderTuerchen(){
	openSlimFrame('/index.php?id=536',540,450);
}
					
function slimboxframe(url,width,height){
	Slimbox.open([[url,'', 'width='+width+', height='+height]],0,{resizeDuration: 400, resizeTransition: Fx.Transitions.Sine.easeInOut, opacity: 0.8, opacityDuration: 500, loop: 1, initialWidth: 250, initialHeight: 250, animateCaption: 1, showCounter: 1, defaultIframeWidth: 540, defaultIframeHeight: 230, iframeScrolling: 'auto', enablePrintButton: 0, enableSaveButton: 0,counterText: 'Seite  {x} von {y}', psScriptPath: 'typo3conf/ext/pmkslimbox/savefile.php'});
}

function getTheBox(vorwahl,nummer) {
	if(document.getElementById(vorwahl).value=="" || document.getElementById(nummer).value==""){
		slimboxframe('/index.php?id=66',540,230);
	}else{
		slimboxframe('/index.php?id=67',540,230);
	}
}
function sendProspekt(){
	if(document.getElementById('popup').value=="true") return true;
	return false;
}

function memoframe(){
	Slimbox.open([['/allkaufMemory/allkaufMemo.html','', 'width=800, height=600']],0,{resizeDuration: 400, resizeTransition: Fx.Transitions.Sine.easeInOut, opacity: 0.8, opacityDuration: 500, loop: 1, initialWidth: 250, initialHeight: 250, animateCaption: 1, showCounter: 1, defaultIframeWidth: 800, defaultIframeHeight: 600, iframeScrolling: 'auto', enablePrintButton: 0, enableSaveButton: 0,counterText: 'Seite  {x} von {y}', psScriptPath: 'typo3conf/ext/pmkslimbox/savefile.php'});
}

// etcToolTip Functions

var etcToolTip = null;// ToolTipEvent nicht unnötig ausführen
document.onmousemove = ToolTipEvent;

function ToolTipEvent(e) {
	if (etcToolTip != null) {
	//document.documentMode
		var ttx	= (document.all) ? window.event.x + etcToolTip.offsetParent.scrollLeft : e.pageX;
		var tty	= (document.all) ? window.event.y + etcToolTip.offsetParent.scrollTop  : e.pageY;
		var ttw	= etcToolTip.offsetWidth;
		var tth	= etcToolTip.offsetHeight;
		var ttcx= (document.all) ? window.event.x : e.clientX;
		var ttcy= (document.all) ? window.event.y : e.clientY;
		var clw	= (document.all) ? document.documentElement.clientWidth : document.body.clientWidth;
		var clh	= (document.all) ? document.documentElement.clientHeight : document.body.clientHeight;
		var max	= (clw-ttw);
		var may	= (clh-tth);
		//x und y vom Cursor wird auf den Style des ToolTips übertragen
		//etcToolTip.style.left	= (ttx + 15) + "px";
		
		if(ttcx>=max){
			etcToolTip.style.left= (ttx - (ttcx-max) - 15) + "px"
		}else{
			etcToolTip.style.left= (ttx + 15) + "px";
		}
		
		if(ttcy>=may){
			etcToolTip.style.top= (tty - (ttcy-may) - 15) + "px"
		}else{
			etcToolTip.style.top= (tty + 15) + "px";
		}
	}
}

function ToolTipShow(id) {
	etcToolTip = document.getElementById(id);
	ToolTipEvent;
	etcToolTip.style.display = "block"//ToolTip wird sichtbar
	etcToolTiph = document.getElementById(id+"_1");
}

function ToolTipHide() {
	etcToolTip.style.display = "none";//ToolTip wird unsichtbar
}

var opac;
var ropac;
var desiredOpac = 100;
var desiredOpacOut = 20;
var step = 2;

function fadeIn(id){
	
	opac = parseInt(document.getElementById(id+'_opacity').value);
	
	if (opac < desiredOpac){
		
		opac += step;
		ropac = ( opac / 100 );
		
		document.getElementById(id+'_link').style.filter = "alpha(opacity=" + opac + ")";
		document.getElementById(id+'_link').style.opacity = ropac;
		document.getElementById(id+'_opacity').value = opac;
	}
	return true;
}

function fadeOut(id){
	
	opac = parseInt(document.getElementById(id+'_opacity').value);
	
	if (opac > desiredOpacOut){
		
		opac -= step;
		ropac = ( opac / 100 );
		
		document.getElementById(id+'_link').style.filter = "alpha(opacity=" + opac + ")";
		document.getElementById(id+'_link').style.opacity = ropac;
		document.getElementById(id+'_opacity').value = opac;
	}
	return true;
}

function hauswahl(){
	var groesse		= parseInt(document.getElementById('hugroesse').value);
	var preis		= parseInt(document.getElementById('hupreis').value);
	var kategorie	= parseInt(document.getElementById('hukategorie').value);
	if(kategorie==1) kategorie = 0;
	for(var i = 0; i < allhouses.length; i++){
		if((groesse==0 || allhouses[i]["groesse"]==groesse) && (preis==0 || allhouses[i]["preis"]==preis) && (kategorie==0 || allhouses[i]["kategorie"]==kategorie || allhouses[i]["kategorie2"]==kategorie)){
			fadeIn(allhouses[i]["name"]);
		}else{
			fadeOut(allhouses[i]["name"]);
		}
	}
	var timer = window.setTimeout(hauswahl, 10);
	return true;
}
function hauswahlCookie(){
	var datum = new Date();
	var zusatzzeit = 1000 * 60 * 60 * 12;
	var zeit = new Date(datum.getTime() + zusatzzeit);
	document.cookie = "Preis=" + parseInt(document.getElementById('hupreis').value) + "; expires=" + zeit.toGMTString() + ";";
	document.cookie = "Groesse=" + parseInt(document.getElementById('hugroesse').value) + "; expires=" + zeit.toGMTString() + ";";
	document.cookie = "Typ=" + parseInt(document.getElementById('hukategorie').value) + "; expires=" + zeit.toGMTString() + ";";
	return true;
}
function hauswahlCookieTyp(){
	var datum = new Date();
	var zusatzzeit = 1000 * 60 * 60 * 12;
	var zeit = new Date(datum.getTime() + zusatzzeit);
	document.cookie = "Typ=" + parseInt(document.getElementById('hkat').value) + "; expires=" + zeit.toGMTString() + ";";
	document.forms[0].submit();
	return true;
}
function garten(typ){
	document.getElementById('moderntext').style.display="none";
	document.getElementById('moderngr').style.display="none";
	document.getElementById('klassischtext').style.display="none";
	document.getElementById('klassischgr').style.display="none";
	document.getElementById('mediterrantext').style.display="none";
	document.getElementById('mediterrangr').style.display="none";
	document.getElementById('introtext').style.display="none";
	document.getElementById(typ+'text').style.display="block";
	document.getElementById(typ+'gr').style.display="block";
}

