// ****************************************************************
// * FrontMedien                                                  *
// *                                                              *
// * Autor:    Joerg Tropf                                        *
// * eMail:    joerg.tropf@netcomposer.de                         *
// * Company : NetComposer Ltd. & Co. KG                          *
// *                                                              *
// * Date:     2010-03-18                                         *
// ****************************************************************



// ****************************************************************
// SpamProtect
// ****************************************************************

function UnCryptMailto(s) {
	var ckey=7;
	var n=0;
	var r="";
	for(var i=0; i < s.length; i++) {
		n=s.charCodeAt(i);
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n-(ckey));
	}
	return r;
}
function linkTo_UnCryptMailto(s)	{
	location.href=UnCryptMailto(s);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}








// ****************************************************************
// Gallery
// ****************************************************************

function closediv() {
	// jQuery start
	$(document).ready(function(){
		$("#showdiv").fadeOut("slow");
		$("body").css("overflow", "auto");
	});	// jQuery ende
}




function showpict(nummer, breite, hoehe, name) {

	var currentScrollPosition = $(document).scrollTop();
	var pageX =  $(window).width();
	var pageY =  $(window).height();
	var unten = 35;	// Rand unten

	// stylebreite = (breite > (pageX-20)) ? "width:"+(pageX-10)+"px;" : "width:"+(breite)+"px;";
	
	if (breite > (pageX-20)) breite = pageX-10;
	style = "width:"+(breite)+"px;"
	
	if (hoehe > (pageY-50)) {
		hoehe = pageY-50;
		style = "height:"+(hoehe)+"px;"
	}

// if (hoehe > (pageY-100)) { hoehe = pageY-100; breite  }

	$("body").css("overflow", "hidden");
	$("#showdiv").css('top',currentScrollPosition);
	$("#showdiv").fadeIn("slow");
	$("#showdiv_content").css('left', ((pageX / 2)-(breite / 2)));
	$("#showdiv_content").css('top', ((pageY / 2)-((hoehe+unten) / 2)));
	$("#showdiv_content").html("<a href=\"JavaScript:closediv();\"><img src=\"daten/screenshots/bilder_"+nummer+".jpg\" style=\""+style+"\" /><div style=\"margin-top:2px;\">"+name+"</div><div style=\"margin-top:2px;\">CLOSE</div></a>");
}




// ****************************************************************
// misc
// ****************************************************************

	function showdiv(name) {
		$('#'+name).toggle("slow");
	}



	function hideandshow(hide, show) {
		$('#'+hide).slideUp('slow', function() {
			$('#'+show).slideDown('slow');
		});
		// $('#'+show).delay(zeit).slideDown('slow');
	}






$(document).ready( function() {

	// Inputfelder
	$(".inputfield").focus(function(){
		aktiv = $("input").index(this);
		$(this).addClass("green");
	})
	.blur(function(){
		$(this).removeClass("green");
	});


	// Suchfeld
	$("#query").keyup(function() {
		var myval = $(this).val().trim();
		if (myval == '')
			$(this).css("background-image", "url(../bilder/suche_texthintergrund.png)");
		else
			$(this).css("background-image", "none");
	});

});
