var white_gif = new Image();
white_gif.src = "images/global/white.gif";

function highlight_artist(name, ort, bild) {
	//alert(name+" | "+encodeURI(name));
	//var str = $(this).text();
	
	$("div#artist p").stop(true, true);
	//$("div#artist").hide();
	
	$("div#artist h1").html(name);
	$("div#artist h2").html(ort);
	
	//$("div#artist p img").html(ort);
	//document.getElementById("artist_shot").src = bild;
	
	$("div#artist p").html("");
	$("div#artist p").html('<img src="images/global/white.gif" width="64" height="63" border="0" alt="" id="artist_shot">');
	//alert(bild);
	if(bild.indexOf("headshot") != -1) {
		$("div#artist p img").attr("src", "../2009/cms/"+bild);
	}
	
	//$("div#artist").show();
	//$("div#artist").get(0).style.removeAttribute('filter');
	
	$("div#artist p").fadeIn(animSpeed);
	
	
}
		
function lowlight_artist() {
	$("div#artist h1").html("&nbsp;");
	$("div#artist h2").html("&nbsp;");
	$("div#artist p").fadeOut(animSpeed/10);
}
//var newX = 0;

function do_something() {
	alert("hallo");
}


function reset_newX() {
	newX = 0;
	//alert(newX);
	//alert('des gibts jo ned!');
}

function check_scroll_v(cat,section_name,show_name) {
	//alert("check scroll | cat: "+cat+" | section_name: "+section_name+" | show_name: "+show_name);
	//alert("hi");
	if(show_name != "show") {
		//alert("hi");
		boost_wert = 1;
		
		//$("div#btn_up").hide();
		//$("div#btn_down").hide();
		
		scrollHoehe = $("div#scroll_v_holder").height();
		anzeigeHoehe = $("div#scroll_v_holder").parent().height();
	
		scroll_diff = scrollHoehe - anzeigeHoehe;
		max_scroll = (scroll_diff*-1) + 13;
	
		//alert(max_scroll);
		//alert("hi! | "+anzeigeHoehe+" vs "+scrollHoehe);
		if(max_scroll < 0){
			//alert("hi! | "+$("div#scroll_v_holder").parent().height()+" vs "+$("div#scroll_v_holder").height());
			$("div#btn_down").show();
		}
		
	}
}
/*
$(function() {
Ê $('.last_img').live('load', function(){
Ê Ê check_scroll_v("test","test","test");
Ê });
});
*/


function scroll_v(richtung, animSpeed) {
	
	//animSpeed = 87;
	
	maxX = 507 - $("div#scroll_v_holder").height();
		
	if((richtung == "+") && (newX < 0)) {
		
		$("div#scroll_v_holder").animate({ top: richtung+'='+animSpeed}, 500, "easeOutExpo");
		
		newX += animSpeed;
	}
	
	if((richtung == "-") && ( newX > maxX )) {
				
		$("div#scroll_v_holder").animate({ top: richtung+'='+animSpeed}, 500, "easeOutExpo");
		
		newX -= animSpeed;
	}
	
	//alert(richtung+" hallo welt: "+newX+" - "+maxX+" - "+newX);
}

function scroll_v_2() {
	
	x_pos = $("div#scroll_v_holder").position().top;
	new_x_pos = x_pos + (scroll_einheit * scroll_v_richtung * boost_wert);
	
	
	
	if(new_x_pos < max_scroll) {
		new_x_pos = max_scroll;
		$("div#btn_down").hide();
		stop_scroll();
	} else if(new_x_pos > 0) {
		new_x_pos = 0;
		$("div#btn_up").hide();
		stop_scroll();
	} else {
		$("div#btn_up").show();
		$("div#btn_down").show();
	}
	
	//$("div#scroll_v_holder").animate({ top: new_x_pos }, interval_zeit-1);
	$("div#scroll_v_holder").css("top", new_x_pos);
	//alert($("div#scroll_v_holder").scrollTop() +" - "+ new_x_pos);
	
	
}


var scroll_v_richtung = 0;
var scrollHoehe = 0;
var anzeigeHoehe = 0;
var scroll_diff = 0;
var min_scroll = 0;
var max_scroll = 0;

var scroll_einheit = 10;
var boost_wert = 1;
var interval_zeit = 40;

function boost_scroll() {
	boost_wert = 3;
}

function reboost_scroll() {
	boost_wert = 1;
}

function stop_scroll() {
	clearInterval(scrollInt);
	scroll_v_richtung = 0;
	boost_wert = 1;
}

function start_scroll(richtung) {
	scroll_v_richtung = richtung;
	
	
	//alert(boost_wert);
	scrollInt = setInterval(scroll_v_2, interval_zeit);
}

function open_ebook() {
	
	//document.getElementById("artist_name").value = artist_name;
	//alert(artist_name);
	document.ebook_creator.submit();
}

var aktIMG = 1;
var lastIMG = 1;


function do_something() {
	alert("hallo");
}

function reset_show() {
	//newX = 0;
	alert('des gibts jo ned!');
}

var neues_X = 0;
//function startShow(firstIMG, IMGanzahl) {

function startShow(firstIMG) {
	//alert("starte mit: "+firstIMG);
	animSpeed = 645;
	
	aktIMG = firstIMG;
	//lastIMG = IMGanzahl;
	
	//alert($("div#galerie_holder").position().left);
	
	//newX = animSpeed*(aktIMG-1)*-1;
	
	neues_X = $("div#img_holder_"+aktIMG).position().left * -1;
	
	//$("div#galerie_holder").animate({ left: newX }, 0 );
	//$("div#galerie_holder").animate({ left: neues_X}, 500, "easeOutExpo");
	
	$("div#galerie_holder").css("left", neues_X);
	
	
	
	lastIMG = Math.round($("span#zaehler").html());
	
	$("div#btn_left").css({'left' : '215px', 'top' : '210px'});
	$("div#btn_right").css({'left' : '900px', 'top' : '210px'});
	
	
	if(aktIMG <= 1) {
		$("div#btn_left").hide();
		$("span#btn_left_small").hide();
	} else {
		$("div#btn_left").show();
		$("span#btn_left_small").show();
	}
	
	if(aktIMG >= lastIMG) {
		$("div#btn_right").hide();
		//$("span#btn_right_small").hide();
		$("span#btn_right_small").css('visibility', 'hidden');
	} else {
		$("div#btn_right").show();
		//$("span#btn_right_small").show();
		$("span#btn_right_small").css('visibility', 'visible');
	}
	
	
	//alert($("div#btn_right").css("display"));
	
	//$("div#galerie_holder").position().left(300);
	var str = aktIMG + " of "+lastIMG;
	$("span#zaehler").html(str);
	
	var swipeOptions=
			{
				swipe:swipe,
				threshold:0
			}
	//$( "#galerie_holder" ).draggable({ axis: 'x' });//, containment: ".galerie"
	
	$("div#contentcol").swipe( swipeOptions );
}

function swipe(event, direction) {
	//alert(("Gewischt: " + direction ));
}

function scroll_h(richtung) {
	
	//alert($("div#galerie_holder").position().left);
	//alert(richtung+" | "+aktIMG+" | "+lastIMG);
	animSpeed = 645;

	//maxX = 507 - $("div#imagewall_holder").height();
	
	//if((richtung == "-") && (newX<0)) {
	if((richtung == "-")) {
		//alert(richtung);
		//$("div#galerie_holder").animate({ left: richtung+'='+animSpeed}, 500, "easeOutExpo");
		//newX += animSpeed;
		aktIMG --;
		
	}
	
	//if((richtung == "+") && (aktIMG<lastIMG)) {
	if((richtung == "+")) {
		//alert(richtung);
		//alert("here");
		//$("div#galerie_holder").animate({ left: richtung+'='+animSpeed}, 500, "easeOutExpo");
		
		//naechstes_IMG = Math.round(aktIMG) + 1;
		
		
		//newX -= animSpeed;
		aktIMG ++;
		
		
	}
	
	neues_X = $("div#img_holder_"+aktIMG).position().left * -1;
	//alert(aktIMG+" | "+neues_X+" | "+$("div#galerie_holder").position().left);
	
	$("div#galerie_holder").animate({ left: neues_X}, 1000, "easeOutQuart");
	
	var str = aktIMG + " of "+lastIMG;
	$("span#zaehler").html(str);
	
	if(aktIMG <= 1) {
		$("div#btn_left").hide();
		$("span#btn_left_small").hide();
	} else {
		$("div#btn_left").show();
		$("span#btn_left_small").show();
	}
	
	if(aktIMG >= lastIMG) {
		$("div#btn_right").hide();
		//$("span#btn_right_small").hide();
		$("span#btn_right_small").css('visibility', 'hidden');
	} else {
		$("div#btn_right").show();
		//$("span#btn_right_small").show();
		$("span#btn_right_small").css('visibility', 'visible');
	}
	
	//alert(window.location.hash);
	var hash_array = window.location.hash.split('/');
	hash_array.pop();
	hash_array.pop();
	
	hash_array.push(aktIMG);
	
	der_hash = hash_array.join('/');
	der_hash += '/';
	//alert(hash_array[hash_array.length-1])
	window.location.hash=der_hash;
	
}


/* VIDEO */
//var animSpeed = 350;
//var the_video = $("#movie");
//document.getElementById('movie');
//var source_mp4 = $("#source_mp4");
//document.getElementById('source_mp4');

var inter;
var out;

function hide_video_final() {	
	$('#video_overlay').hide();
	$("#movie").get(0).pause();
}

function hide_video() {
	out = setTimeout("hide_video_final()", 100)
}

function klaeren() {
	//alert(out);
	if(out) {
		clearTimeout(out);
		clearInterval(inter);
	}
}

function do_nothing() {
	//alert("do_nothing");
	inter = setInterval("klaeren()", 10);
}

var video_obj;

function show_video(datei, poster) {
	//var the_video = $("#movie");
	//var source_mp4 = $("#source_mp4");
	
	//$('#video_overlay').fadeIn(animSpeed);
	$('#video_overlay').show();
	
	video_obj = new SWFObject("http://fpdownload.adobe.com/strobe/FlashMediaPlayback_101.swf", "video_swf", "480", "272", "10.1.0", "#1C1815");
		video_obj.addParam("allowFullScreen", "true");
		video_obj.addParam("allowscriptaccess", "always");

		//aktion_obj.addVariable("src", "");
		video_obj.addVariable("src", "http://bigoudi.de/2011/"+datei);
		video_obj.addVariable("poster", "http://bigoudi.de/2011/"+poster);
		video_obj.addVariable("playButtonOverlay", "false");
		video_obj.addVariable("autoPlay", "true");
		video_obj.addVariable("allowFullScreen", "true");
	
	if(video_obj.write("video_div")) {
	//if(3==4) {
		//alert(poster);
	} else {
		//alert(the_video);
		
		$("#movie").attr("src", datei);
		
		//$("#source_mp4").attr("src", datei);
		$("#movie").attr("poster", poster);
		//the_video.poster = poster;
		
		var the_video = $('#movie').get(0);
		$(the_video).get(0).load();
		$(the_video).get(0).play();
		
		//alert($("#source_mp4").get(1));
	}
	
	
	
	
	
	//alert(source_mp4.src);
}
/* End VIDEO */

