var letter="";

if (navigator.appName.indexOf("tscape") != -1) document.captureEvents(Event.KEYPRESS);

document.onkeypress = function (keyed) {
	input = (navigator.appName.indexOf("tscape") !=-1) ? keyed.which : event.keyCode;
	letter+=String.fromCharCode(input);
	if(letter=="login" || letter=="admin" ) {
		if ( typeof pid != 'undefined' ) location.href = "p-"+pid+".php?othertempl=hp2010_login.php";
		else if ( typeof mid != 'undefined' ) location.href = "m-"+mid+".php?othertempl=hp2010_login.php";
		else if ( typeof ch  != 'undefined' ) location.href = "index.php?ch="+ch+"&othertempl=hp2010_login.php";
		else location.href = "index.php?othertempl=hp2010_login.php";
	}
}

function mail_to (subject,domainpart,localpart) {
	var hrefstr = 'mailto:' + localpart + "@" + domainpart;
	if ( subject != '' ) hrefstr = hrefstr + "?subject=" + subject;
	location.href = hrefstr;
}

function Trim(s) {
  while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r')) s = s.substring(1,s.length);
  while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r') || (s.substring(s.length-1,s.length) == '\t')) s = s.substring(0,s.length-1);
  return s;
}



$(function(){
	$.getScript("/hp2010_javascript/win.js");	// qalidator
	$.each($("a:contains('[at]')"),function(){$(this).html($(this).html().replace('[at]','@'));}); // [at] -> @
	
	$.each($("#m1>li>ul"),function(){ $(this).css('background-position',"-"+$(this).parent()[0].offsetLeft-10+"px 0"); });
	
	$(".mehr a").prepend('&#9658;&nbsp;');
	
	setBodyLeft();
	
	var clicked=false;
	$("#m1 a")								.live("mouseover", 	function(){ if($.browser.msie){ $(".fruits").hide(); 										}else{ $("#fruit_act:animated").stop(); $(".fruits").fadeTo(300,0.0);	} })
												.live("mouseout",		function(){ if($.browser.msie){ $("#fruit_act").show(); 									}else{ $(".fruits:animated").stop(); $("#fruit_act").fadeTo(300,1.0);	} });
	$("#m2 a.hm2, #block1 a[rel]")	.live("mouseover", 	function(){ if($.browser.msie){ $("#"+$(this).attr("rel")).show(); 					}else{ $("#"+$(this).attr("rel")).stop().fadeTo(300,1.0); } })
												.live("mouseout", 	function(){ if(!clicked) if($.browser.msie){ $("#"+$(this).attr("rel")).hide(); 	}else{ $("#"+$(this).attr("rel")).stop().fadeTo(300,0.0); } }) // wenn klicked nicht ausfaden - reload 
												.live("click",			function(){ clicked=true; });
	$("#m3 a")								.live("mouseover", 	function(){ if($.browser.msie){ $(".fruits").hide(); 										}else{ $("#fruit_act:animated").stop(); $(".fruits").fadeTo(300,0.0);	} })
												.live("mouseout",		function(){ if($.browser.msie){ $("#fruit_act").show(); 									}else{ $(".fruits:animated").stop(); $("#fruit_act").fadeTo(300,1.0);	} });
												
	/************ Zitate *******************/
	
	if($("#block2 table").length > 1){
		$("#block2 table").css({"display":"none", "position":"absolute"});	
		$("#block2 table:first-child").css("display","block");
		var count = $("#block2 table").length;
		var act = 0;
		
		var int = setInterval(
			function(){
				$("#block2 table:eq("+act+")").fadeOut(2000);
				act = act+1<count?act+1:0;
				$("#block2 table:eq("+act+")").fadeIn(2000);
			}
		,7000);		
	}else{
		$("#block2 table:first-child").css("display","block");	
	}
	
	/*
	if($mblock != 1 && !$("#block2").html()){
		show();
		var i = setInterval(show,10000);
		var quote = "";
		var lastId=-1;
		function show(){
			$b2 = $("#block2");
			var fade = $b2.html()?2000:0;
			$b2.fadeOut(fade,function(){
				var id;
				do{
					id=Math.round(Math.random()*quotes.length-1);
					quote = quotes[id];
				}while(id==lastId || quote==undefined)
				lastId=id;
				
				
				$("#block2").html('<p><img src="'+quote[1]+'" alt="bild" height="64" width="77" /></p><p><strong>'+quote[0]+'</strong><br />'+quote[3]+'</p><blockquote><p>'+quote[2]+'</p></blockquote>');
				$b2.fadeIn(fade);
			});
		}		
	}*/
	/*************************************/										
});


$(window).resize(function(){
	setBodyLeft();					  
});	

function setBodyLeft() {
	/*if ( $("body").width() <= 1010 ) { 
		$("#cont").css( {"left":"0", "margin-left":"0"} );
	} else {
		$("#cont").css( {"left":"50%", "margin-left":"-495px"} );
	}*/
}
