var headerHover ='erkenntnis-und-entertainment.de: <span class="headerlinks"><a href="http://www.erkenntnis-und-entertainment.de/blog/" title="Erkenntnis und Entertainment in Bernds persönlichem Weblog">blog</a> | <span class="selected"><a href="http://fotos.erkenntnis-und-entertainment.de/" title="Startseite Fotos">fotos</a></span> | <a href="http://www.erkenntnis-und-entertainment.de/blog?page_id=4" title="Texte &amp; Theorie (mit Guibert-Special)">texte</a> | <a href="http://www.erkenntnis-und-entertainment.de/blog?page_id=5" title="Freie Arbeiten, Experimente, Spielkram">labor</a></span>';

function touchDeviceTest() {
	var el = document.createElement('div');
	el.setAttribute('ongesturestart', 'return;');
	if(typeof el.ongesturestart == "function"){
		return true;
	}else {
		return false
	}
}

function initEEheader () {
	var isStart = true;
	var loc = document.location.href;
	 $("#eefotonav a").each(function (i) {
		var theID = $(this).attr('id');
	 if (loc.indexOf(theID)>0) {
		 $(this).wrap('<span class="selected"></span>');
		 $(this).css('text-decoration','underline'); /* Nur für den verf... IE6 */
		 isStart = false;
	 }
	 
	 
									  
	});
	 if (isStart) {
		 $("#start").wrap('<span class="selected"></span>');
		 $("#start").css('text-decoration','underline'); /* Nur für den verf... IE6 */
	 }

	
}



function initHover (itemindx) {
	var newURL =  $(".itemimg a:eq("+itemindx+")").attr("href");
	var newTitle =  $(".itemimg a:eq("+itemindx+")").attr("title");
	
	$(".item:eq("+itemindx+")").click(function () {
      location.href= newURL;
									 });
	$(".item:eq("+itemindx+")").attr("title", newTitle);
	
}

function initteaser (teaserindx) {
	var newURL =  $(".teaserimg a:eq("+teaserindx+")").attr("href");
	var newTitle =  $(".teaserimg a:eq("+teaserindx+")").attr("title");
	
	$(".teaseritem:eq("+teaserindx+")").click(function () {
      location.href= newURL;
									 });
	$(".teaseritem:eq("+teaserindx+")").attr("title", newTitle);
	
}

function hoverLogo() {
	restoreHeader = $("#eefotologo").html();
	$("#eefotologo").html(headerHover);
	
}

function restoreLogo () {
	$("#eefotologo").html(restoreHeader);
}




$(document).ready(function () {
	initEEheader();
	
	if(touchDeviceTest()==false) {
		$(".item, .teaseritem").hover(function (){$(this).css('background','#ddd');},function (){$(this).css('background','#fff');});
	$(".item, .teaseritem").css('cursor', 'pointer');
	}
	
    $(".itemimg a").each(function (i) {initHover(i)});
	$(".teaserimg a").each(function (i) {initteaser(i)});
	
	$("#eefotologo").hover(function (){hoverLogo();}, function (){restoreLogo();});
	
});

