// # TOM 26.04.2010 

document.write('<'+'script src="/js/lib_m.js" type="text/javascript"'+'><'+'/script'+'>');

var Pager 		= new Array();
var source		= "";
var currentPos	= "";
var customer	= "";
var layereditQueue = new Array();
var edit_object_id = "";

function get_nl_numbers_of_year(src){
	
	var year = document.newsletter_form.year.value;
	var type = document.newsletter_form.nl_type.value;
	//mod Tom 01.2010
	//bei Type Wechsel erst das höchste Jahr dieses Typs ermitteln...
	if (src != 'year') {
		$.post("/search/year/", {
			type: type,
			modus: 'dataonly'
		}, function(data){
			highestyear = eval(data);
			$("#number").load("/search/number/", {year: highestyear, type: type});
			$("#year").load("/search/year/", {type: type});
			
		})
	} else {
		
		$("#number").load("/search/number/", {year: year, type: type});
	}
	
}


function cm_bwcheck()
{
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent.toLowerCase()
	this.dom=document.getElementById?1:0
	this.ns4=(!this.dom && document.layers)?1:0;
	this.op=window.opera 
	this.moz=(this.agent.indexOf("gecko")>-1 || window.sidebar)
	this.ie=this.agent.indexOf("msie")>-1 && !this.op
	this.safari=(this.agent.indexOf("safari")>-1)
	if(this.op){
		this.op5=(this.agent.indexOf("opera 5")>-1 || this.agent.indexOf("opera/5")>-1)
		this.op6=(this.agent.indexOf("opera 6")>-1 || this.agent.indexOf("opera/6")>-1)
		this.op7=this.dom&&!this.op5&&!this.op6
	}else if(this.moz) this.ns6 = 1
	else if(this.ie){
		this.ie4 = !this.dom && document.all
  	this.ie5 = (this.agent.indexOf("msie 5")>-1)
  	this.ie55 = (this.ie5 && this.agent.indexOf("msie 5.5")>-1)
  	this.ie6 = this.dom && !this.ie4 && !this.ie5 && ! this.ie55
  	this.ie7 = document.all && !document.XMLHTTPObject
  	
	}
	this.mac=(this.agent.indexOf("mac")>-1)
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.op5 || this.op6 || this.op7)
  this.usedom= this.ns6||this.op7
  this.reuse = this.ie||this.op7||this.usedom
  this.px=this.dom&&!this.op5?"px":""
	return this
}

var bw=new cm_bwcheck();

// Anzeigestatus 0 = aus, 1 = an
var imageGalleryLayer = 1;

// Layer Maße: Breite
var imageGalleryLayerWidth = 1008;
var mailLayerWidth = 712;
var archiveLayerWidth = 912;
var creditsLayerThreeWidth = 934;
var creditsLayerTwoWidth = 634;
var feedBackLayerWidth = 248;
var uploadLayerWidth = 248;

// Layer Maße: Höhe
var imageGalleryLayerHeight = 688;
var mailLayerHeight = 690;
var archiveLayerHeight = 614;
var creditsLayerThreeHeight = 735;
var creditsLayerTwoHeight = 735;
var feedBackLayerHeight = 121;
var uploadLayerHeight = 200;

var obj = null;


var currentPos 	= "";

function showGallery(src, pic_id) {
//console.log('src: '+src+' pic_id: '+pic_id);	
	source 	= src;
	id		= pic_id;
	
	if (showGallery.arguments.length > 2){
		if (showGallery.arguments[2] == 1){
			customer = 1;
			getImageCustomerDetails(id);
		}else{
			customer = 0;
			getImageDetails(id);	
		}
		
	}else{
		customer = 0;
		getImageDetails(id);
	}
	
	unhideGallery();
	
	
	$("#lb-pager").html(Pager_Output(source, id));
	imageGalleryLayer = 1;
	
	if (bw.ie && !document.documentElement.clientWidth) {
		getScroll();
		prepareIE('100%', 'hidden');
		setScroll(0,0);
	}
		
	
}

function showInboxGallery(src, pic_id) {
	source 	= src;
	id		= pic_id;
	

	customer = 0;
	getImageDetails(id, true);
	
	
	unhideGallery();
	
	
	$("#lb-pager").html(Pager_Output(source, id));
	imageGalleryLayer = 1;
	
	if (bw.ie && !document.documentElement.clientWidth) {
		getScroll();
		prepareIE('100%', 'hidden');
		setScroll(0,0);
	}
		
	
}

function showCategoryImageGallery(id, cat_id) {
	var result_num;
    unhideGallery();
    getImageDetails(id);
    ajaxLoader();
    $.ajax({
       type: "GET",
       url: "/search/categoryimageajax/",
       data: "object_id="+id+"&cat_id="+cat_id,
       dataType: "json",
       success: function(data){
            
            Pager        = data['pager'];
            prepareOutputForImageGallery(id + '');
       }
     });
}

function showGlobalImageGallery(id, all) {
    var result_num;
    unhideGallery();
    getImageDetails(id);
    ajaxLoader();
    $.ajax({
       type: "GET",
       url: "/search/globalimagesajax/",
       data: "object_id="+id+"&get_all="+all,
       dataType: "json",
       success: function(data){
            
            
           
            Pager        = data['pager'];
            prepareOutputForImageGallery(id);
       }
     });    
}

function showImageGallery(id, all) {
	var result_num;
	unhideGallery();
	getImageDetails(id);
	ajaxLoader();
	$.ajax({
	   type: "GET",
	   url: "/search/imagesajax/",
	   data: "object_id="+id+"&get_all="+all,
	   dataType: "json",
	   success: function(data){
			Pager		= data['pager'];
			prepareOutputForImageGallery(id);
	   }
	 });

}










function prepareOutputForImageGallery(id){
	source = 1;
	customer = 0;
	//getImageDetails(id);
	$("#lb-pager").html(Pager_Output_ImageGallery(source, id));
	imageGalleryLayer = 1;
	
	if (bw.ie && !document.documentElement.clientWidth) {
		getScroll();
		prepareIE('100%', 'hidden');
		setScroll(0,0);
	}
}

function Pager_Output_ImageGallery(source, id) {
	
	
	$("select").css("visibility", "hidden");
	
	maxPages 	= 8;
	shortened 	= 0;
	
	str = "";
	
	maxamount 	= Pager[source].length;
	
	currentPos 	= jQuery.inArray(id, Pager[source]);
	
	
	minValue = (currentPos-maxPages/2);
	maxValue = (currentPos+maxPages/2);
	
	showPages = maxamount;
	if (maxamount > maxPages) {
		showPages = maxPages;
		shortened = 1;
	}
	
	start = 0;
	if (minValue >= 0) start = minValue;
	end = (start+maxPages);
	if (end > maxamount) { 
		end = maxamount;
		start = end-maxPages;
		if (start < 0) start = 0;
	}
	
	$("#lb-nav-btnNext").css("display","none");
	$("#lb-nav-btnPrev").css("display","none");
	
	
	for (i = start; i < end; i++) {
		
		if (i == start && currentPos != 0) str += " <a href='#' onclick='showGallery("+source+", "+Pager[source][0]+", false);return false;'>1</a>&nbsp;";
		//zurück
		if (i == start && Pager[source][(currentPos-1)]) {
			str += "<a href='#' onclick='showGallery("+source+", "+Pager[source][(currentPos-1)]+", false);return false;'>&nbsp;PREVIOUS</a> | ";
			$("#lb-nav-btnPrev").css("display","block");
		}
		if (currentPos == i) { str += "<a href='#' class='act'>"+(i+1) + "</a> | "; } else { str += "<a href='#' onclick='showGallery("+source+", "+Pager[source][i]+", false); return false;'>" + (i+1) + "</a> | "; } 
		//weiter
		if (i == (end-1) && Pager[source][(currentPos+1)]) {
			str += "<a href='#' onclick='showGallery("+source+", "+Pager[source][(currentPos+1)]+", false);return false;'>NEXT&nbsp;</a>";
			$("#lb-nav-btnNext").css("display","block");
		}
		if (i == (end-1) && shortened == 1 && currentPos !=(maxamount-1)) str += " <a href='#' onclick='showGallery("+source+", "+Pager[source][(maxamount-1)]+", false);return false;'>"+maxamount+"</a>";
		
	}
    

	return str;
	
}

function Pager_Output(source, id) {

	ajaxLoader();
	
	$("select").css("visibility", "hidden");
	
	maxPages 	= 8;
	shortened 	= 0;
	
	str = "";
	
	maxamount 	= Pager[source].length;
	
	currentPos 	= jQuery.inArray(id, Pager[source]);
	
	minValue = (currentPos-maxPages/2);
	maxValue = (currentPos+maxPages/2);
	
	
	showPages = maxamount;
	if (maxamount > maxPages) {
		showPages = maxPages;
		shortened = 1;
	}
	
	start = 0;
	if (minValue >= 0) start = minValue;
	end = (start+maxPages);
	if (end > maxamount) { 
		end = maxamount;
		start = end-maxPages;
		if (start < 0) start = 0;
	}
	
	$("#lb-nav-btnNext").css("display","none");
	$("#lb-nav-btnPrev").css("display","none");
	
	for (i = start; i < end; i++) {
		
		if (i == start && currentPos != 0) str += " <a href='#' onclick='showGallery("+source+", "+Pager[source][0]+", "+customer+");return false;'>1</a>&nbsp;";
		//zurück
		if (i == start && Pager[source][(currentPos-1)]) {
			str += "<a href='#' onclick='showGallery("+source+", "+Pager[source][(currentPos-1)]+", "+customer+");return false;'>&nbsp;zurück</a> | ";
			$("#lb-nav-btnPrev").css("display","block");
		}
		if (currentPos == i) { str += "<a href='#' class='act'>"+(i+1) + "</a> | "; } else { str += "<a href='#' onclick='showGallery("+source+", "+Pager[source][i]+", "+customer+"); return false;'>" + (i+1) + "</a> | "; } 
		//weiter
		if (i == (end-1) && Pager[source][(currentPos+1)]) {
			str += "<a href='#' onclick='showGallery("+source+", "+Pager[source][(currentPos+1)]+", "+customer+");return false;'>weiter&nbsp;</a>";
			$("#lb-nav-btnNext").css("display","block");
		}
		if (i == (end-1) && shortened == 1 && currentPos !=(maxamount-1)) str += " <a href='#' onclick='showGallery("+source+", "+Pager[source][(maxamount-1)]+", "+customer+");return false;'>"+maxamount+"</a>";
		
	}
    

	return str;
	
}

function hideGalleryInfos() {

	$("#lb-center2").fadeOut(500, function(){
		$('#lb-center2').css({'height':'730px'});
	});
	$("#lb-center3").fadeOut(500, function(){
		$('#lb-center3').css({'height':'730px'});
	});
	
	$("#lb-archive1").fadeOut(500, function(){
		$('#lb-archive1').css({'height':'730px'});
	});
	
	$("#lb-creditsThree1").fadeOut(500, function(){
		$('#lb-creditsThree1').css({'height':'730px'});
	});
	$("#lb-creditsThreeMedia").fadeOut(500, function(){
		$('#lb-creditsThreeMedia').css({'height':'730px'});
	});
	$("#lb-creditsTwo1").fadeOut(500, function(){
		$('#lb-creditsTwo1').css({'height':'730px'});
	});
	
	$("#lb-feedBack1").fadeOut(500, function(){
		$('#lb-feedBack1').css({'height':'730px'});
	});
	$("#lb-feedBack1").fadeOut(500, function(){
		$('#lb-feedBack1').css({'height':'730px'});
	});
	$("#confirm_dialog").fadeOut(500, function(){
		$('#confirm_dialog').css({'height':'730px'});
	});
	$("#confirm_dialog_news").fadeOut(500, function(){
		$('#confirm_dialog_news').css({'height':'730px'});
	});
	$("#confirm_abort_news").fadeOut(500, function(){
		$('#confirm_abort_news').css({'height':'730px'});
	});
	
	$("#lb-overlay").fadeOut(500);
	
	
	$("#affilliate_webgains2").css("display", "inline");
	$("#affilliate_webgains3").css("display", "inline");
	$(".DIVWEFOR").css("display", "inline");
	
	if (document.getElementById('div_popup1')){
		$("#div_popup1").css("display", "inline");	
	}
	

	$("select").css("visibility", "visible");
	$("#lb-center1").fadeOut(500);
	$("body").css("position", "");
	$("body").css("height", "");
	$("body").css("overflow","auto");
// HIER	
/*
	$("#lb-image").attr({
		src: ""
		});
*/		
	var innergal = "<table><tr><td><img class = 'lb-image' id = 'lb-image' src='' /></td></tr></table>";
	$("#lb-image-wrap").html(innergal);
	
	
	$("#lb-archive1 iFrame").attr("src", "about:blank");
		
	//Mail-Layer:
	
	$('#inputs_wrapper').show();
	$('#lb-wrapmail :input').val("");
	$('#lb-wrapmail #error').html("");
	$('#lb-wrapmail #warning').hide();
	$('#lb-fileUpload1').hide();
	$("#lb-mailform :input").parent().removeClass("highlight");
	$('#lb-wrapmail #success').hide();
	
	imageGalleryLayer = 0;
	
	if (bw.ie && !document.documentElement.clientWidth) {
		
		setScroll(0,this.yPos);
		prepareIE("auto", "auto");
	}
}

function unhideGallery(){
	
	if (window.innerWidth) {
		width = window.innerWidth;
	} else if (bw.ie && !document.documentElement.clientWidth) {
		width = document.body.offsetWidth;
	} else if (bw.ie7) {
		width = document.documentElement.clientWidth;
	}
	
	if (window.innerHeight) {
		height = window.innerHeight;
	} else if (bw.ie && !document.documentElement.clientHeight) {
		height = document.body.offsetHeight;
	} else if (bw.ie7) {
		height = document.documentElement.clientHeight;
	} 
	
	
	
	
		
	pos_left = (width-imageGalleryLayerWidth)/2;
	pos_top	 = (height-imageGalleryLayerHeight)/2;
	pos_left 	= Math.ceil(pos_left);
	pos_top 	= Math.ceil(pos_top);
	
	if (pos_top < 0) pos_top = 0;
	
	$("#affilliate_webgains2").css("display", "none");
	$("#affilliate_webgains3").css("display", "none");
	$(".DIVWEFOR").css("display", "none");
	$("#div_popup1").css("display", "none");
	
	
	$("#lb-overlay").css("height", height);
	$("body").css("position", "relative");
	$("body").css("overflow","hidden");
	$("body").css("height", height);
	$("#lb-center1").fadeIn(500);
	$("#lb-overlay").css("display", "block");
	$("#lb-overlay").css("filter", "alpha(opacity=70)");
	$("#lb-center1").css("left", pos_left+"px");
	$("#lb-center1").css("top", pos_top+"px");
}

function next(){
	showGallery(source, Pager[source][currentPos+1], customer);
}
function previous(){
	showGallery(source, Pager[source][currentPos-1], customer);
}

//HIER
function ajaxLoader(){
	if ($("#lb-innerwrap").hasClass("whiteLayer")){
		//$("#lb-image").attr({src: "/css/default/img/ajax-loader-white.gif"});
		var innergal = "<table><tr><td><img class = 'lb-image' id = 'lb-image' src='/css/default/img/ajax-loader-white.gif' /></td></tr></table>";
		$("#lb-image-wrap").html(innergal);
	}else{
		//$("#lb-image").attr({src: "/css/default/img/ajax-loader.gif"});	
		var innergal = "<table><tr><td><img class = 'lb-image' id = 'lb-image' src='/css/default/img/ajax-loader.gif' /></td></tr></table>";
		$("#lb-image-wrap").html(innergal);	
	}
	
}



function showCreditInput(){

	$('#lb-overlay').attr({onclick: ''});
	$('#lb-overlay').show();
	
}


/*
Ajax Request für Bildinformationen
*/
function getImageDetails(id, isInbox) {
	
	if (typeof object_group_type == "undefined") is_profile = false; else is_profile = object_group_type;
	
	if (getImageDetails.arguments.length > 1 || is_profile == 4){
		$.getJSON("/image/getdetails/", {id: id, isinbox: isInbox}, function(data) {
			writeImageData(data, false);
		});			
	}else{
		$.getJSON("/image/getdetails/", {id: id}, function(data) {
			writeImageData(data, false);
		});
	}
	
	

}



/*
Ajax Request für Bildinformationen
*/
function getImageCustomerDetails(id) {

	$.getJSON("/image/getcustomerimagedetails/", {id: id}, function(data) {
			
			writeImageData(data, true);
		});
	

}



function writeImageData(item, isCustomerGallery){
	//image
	/*
	$("#lb-image").attr({ 
          src: "/prev/616x616"+item['path']+"/"+item['file'],
          alt: item['title']
        });
	*/
//console.dir(item);		
	var vpath = "http://video.gosee.de"+ item['path'];
	//var vfile = "c0d16b8a826bc469e208de7e9f4f0d97.flv";
	var vfile = item['file'];
	var scpath = item['screenshot_path'];
	var scfile = item['screenshot_file'];
	var scwidth = item['width'];
	var scheight = item['height'];
	
	if(item['type'] == 3) {
		//local
		//var innergal = "<table><tr><td><!--[if lte IE 7]><span></span><![endif]--><object width='600' height='500' id='flvPlayer'><param name='bgcolor' value='#ffffff'><param name='allowFullScreen' value='true'><param name='base' value='.'><param name='movie' value='/js/default/flvplayer/flvplayer.swf?playerpath=http://goseedev2/js/default/flvplayer&contentpath=" + vpath + "&video=" + vfile + "' width='616'><embed src='/js/default/flvplayer/flvplayer.swf?playerpath=http://goseedev2/js/default/flvplayer&contentpath=" + vpath + "&video=" + vfile + "' width='616' height='616' allowFullScreen='true' base='.' bgcolor='#ffffff' type='application/x-shockwave-flash'></object></td></tr></table>";
		
		//var innergal = "<table><tr><td><!--[if lte IE 7]><span></span><![endif]--><object width='600' height='360' id='flvPlayer'><param name='bgcolor' value='#ffffff'><param name='allowFullScreen' value='false'><param name='base' value='.'><param name='movie' value='/flash/GoSee.swf?videoURL=" + vpath + "/" + vfile + "&videoPreviewURL=http://video.gosee.de/bild/vorschau/" + scwidth + "x" + scheight + scpath + "/" + scfile + "' ><embed src='/flash/GoSee.swf?videoURL=" + vpath + "/" + vfile + "&videoPreviewURL=http://video.gosee.de/bild/vorschau/" + scwidth + "x" + scheight + scpath + "/" + scfile + "' width='600' height='360' allowFullScreen='true' base='.' bgcolor='#ffffff' type='application/x-shockwave-flash'></object></td></tr></table>";
		
		var innergal ="<div id='player2'></div><script type='text/javascript'>swfobject.embedSWF('/flash/GoSee.swf', 'player2', '600', '360', '10.0.0', null, {videoURL:'" + vpath + "/" + vfile + "', videoPreviewURL:'http://video.gosee.de/bild/vorschau/" + scwidth + "x" + scheight + scpath + "/" + scfile + "'});</script>";
		
		
		//var innergal = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="GoseePlayer_big_v1" width="630" height="374" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"><param name="FlashVars" value="xmlUrl=/xml/getStructure/news_id/<?=$item['news_id']?>" /><param name="movie" value="/swf/GoseePlayer_big_v1.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="true" /><embed src="/flash/GoseePlayer_big_v1.swf" quality="high" bgcolor="#ffffff" width="630" height="375" name="GoseePlayer_big_v1" align="middle"	FlashVars="xmlUrl=/xml/getstructure/news_id/<?=$this->news_id?>" play="true"		loop="false"		quality="high" 	allowScriptAccess="sameDomain"		allowFullScreen="true"		type="application/x-shockwave-flash"		pluginspage="http://www.adobe.com/go/getflashplayer"></embed></object>';
		
		// Dev Server
		//var innergal = "<table><tr><td><!--[if lte IE 7]><span></span><![endif]--><object width='600' height='500' id='flvPlayer'><param name='bgcolor' value='#ffffff'><param name='allowFullScreen' value='true'><param name='base' value='.'><param name='movie' value='/js/default/flvplayer/flvplayer.swf?playerpath=http://gosee.customer.keppler-it.net/js/default/flvplayer&contentpath=" + vpath + "&video=" + vfile + "' width='616'><embed src='/js/default/flvplayer/flvplayer.swf?playerpath=http://gosee.customer.keppler-it.net/js/default/flvplayer&contentpath=" + vpath + "&video=" + vfile + "' width='616' height='616' allowFullScreen='true' base='.' bgcolor='#ffffff' type='application/x-shockwave-flash'></object></td></tr></table>";
	} else {
		var innergal = "<table><tr><td><!--[if lte IE 7]><span></span><![endif]--><img class = 'lb-image' id = 'lb-image' src='/prev/616x616" + item['path'] + "/" + item['file'] + "' alt = '" + item['title'] + "' /></td></tr></table>";
	
	}
	
	$("#lb-image-wrap").html(innergal);
	
	
		
    //restliche Elemente
	if (item['title']) {$("#lb-image-title").css("display", "block"); $("#lb-image-title").text(stripslashes(item['title']));} else {$("#lb-image-title").css("display", "none");}
	if (item['description']) { $("#lb-description-tr").css("display", "block");$("#lb-description").text(stripslashes(item['description']))} else {$("#lb-description-tr").css("display", "none");}
	if (item['photographer']) { $("#lb-photographer-tr").css("display", "block");$("#lb-photographer").text(stripslashes(item['photographer']))} else {$("#lb-photographer-tr").css("display", "none");}
	if (item['illustration']) { $("#lb-illustration-tr").css("display", "block");$("#lb-illustration").text(stripslashes(item['illustration']))} else {$("#lb-illustration-tr").css("display", "none");}
	if (item['model']) { $("#lb-model-tr").css("display", "block"); $("#lb-model").text(stripslashes(item['model']))} else {$("#lb-model-tr").css("display", "none");}
	if (item['styling']) {$("#lb-styling-tr").css("display", "block"); $("#lb-styling").text(stripslashes(item['styling']))} else {$("#lb-styling-tr").css("display", "none");}
	if (item['hair']) {$("#lb-hair-tr").css("display", "block"); $("#lb-hair").text(stripslashes(item['hair']))} else {$("#lb-hair-tr").css("display", "none");}
	if (item['makeup']) {$("#lb-makeup-tr").css("display", "block"); $("#lb-makeup").text(stripslashes(item['makeup']))} else {$("#lb-makeup-tr").css("display", "none");}
	if (item['location']) {$("#lb-location-tr").css("display", "block"); $("#lb-location").text(stripslashes(item['location']))} else {$("#lb-location-tr").css("display", "none");}
	if (item['production']) {$("#lb-production-tr").css("display", "block"); $("#lb-production").text(stripslashes(item['production']))} else {$("#lb-production-tr").css("display", "none");}
	if (item['postproduction']) {$("#lb-postproduction-tr").css("display", "block"); $("#lb-postproduction").text(stripslashes(item['postproduction']))} else {$("#lb-postproduction-tr").css("display", "none");}
	if (item['agency']) {$("#lb-agency-tr").css("display", "block"); $("#lb-agency").text(stripslashes(item['agency']))} else {$("#lb-agency-tr").css("display", "none");}
	if (item['ad']) {$("#lb-ad-tr").css("display", "block"); $("#lb-ad").text(stripslashes(item['ad']))} else {$("#lb-ad-tr").css("display", "none");}
	if (item['cd']) {$("#lb-cd-tr").css("display", "block"); $("#lb-cd").text(stripslashes(item['cd']))} else {$("#lb-cd-tr").css("display", "none");}
	if (item['ab']) {$("#lb-ab-tr").css("display", "block"); $("#lb-ab").text(stripslashes(item['ab']))} else {$("#lb-ab-tr").css("display", "none");}
	if (item['client']) {$("#lb-client-tr").css("display", "block"); $("#lb-client").text(stripslashes(item['client']))} else {$("#lb-client-tr").css("display", "none");}
	
	if (item['planner']) {$("#lb-planner-tr").css("display", "block"); $("#lb-planner").text(stripslashes(item['planner']))} else {$("#lb-planner-tr").css("display", "none");}
	if (item['usage']) {$("#lb-usage-tr").css("display", "block"); $("#lb-usage").text(stripslashes(item['usage']))} else {$("#lb-usage-tr").css("display", "none");}
	if (item['aa']) {$("#lb-aa-tr").css("display", "block"); $("#lb-aa").text(stripslashes(item['aa']))} else {$("#lb-aa-tr").css("display", "none");}
	if (item['producer']) {$("#lb-producer-tr").css("display", "block"); $("#lb-producer").text(stripslashes(item['producer']))} else {$("#lb-producer-tr").css("display", "none");}
	if (item['copywriter']) {$("#lb-copywriter-tr").css("display", "block"); $("#lb-copywriter").text(stripslashes(item['copywriter']))} else {$("#lb-copywriter-tr").css("display", "none");}
	if (item['pc']) {$("#lb-pc-tr").css("display", "block"); $("#lb-pc").text(stripslashes(item['pc']))} else {$("#lb-pc-tr").css("display", "none");}
	if (item['director']) {$("#lb-director-tr").css("display", "block"); $("#lb-director").text(stripslashes(item['director']))} else {$("#lb-director-tr").css("display", "none");}
	if (item['dop']) {$("#lb-dop-tr").css("display", "block"); $("#lb-dop").text(stripslashes(item['dop']))} else {$("#lb-dop-tr").css("display", "none");}
	if (item['editing']) {$("#lb-editing-tr").css("display", "block"); $("#lb-editing").text(stripslashes(item['editing']))} else {$("#lb-editing-tr").css("display", "none");}
	if (item['serviceproduction']) {$("#lb-serviceproduction-tr").css("display", "block"); $("#lb-serviceproduction").text(stripslashes(item['serviceproduction']))} else {$("#lb-serviceproduction-tr").css("display", "none");}
	if (item['visualeffects']) {$("#lb-visualeffects-tr").css("display", "block"); $("#lb-visualeffects").text(stripslashes(item['visualeffects']))} else {$("#lb-visualeffects-tr").css("display", "none");}
	if (item['animation']) {$("#lb-animation-tr").css("display", "block"); $("#lb-animation").text(stripslashes(item['animation']))} else {$("#lb-animation-tr").css("display", "none");}
	if (item['sounddesign']) {$("#lb-sounddesign-tr").css("display", "block"); $("#lb-sounddesign").text(stripslashes(item['sounddesign']))} else {$("#lb-sounddesign-tr").css("display", "none");}
	if (item['setdesign']) {$("#lb-setdesign-tr").css("display", "block"); $("#lb-setdesign").text(stripslashes(item['setdesign']))} else {$("#lb-setdesign-tr").css("display", "none");}
	if (item['music']) {$("#lb-music-tr").css("display", "block"); $("#lb-music").text(stripslashes(item['music']))} else {$("#lb-music-tr").css("display", "none");}
	if (item['cast']) {$("#lb-cast-tr").css("display", "block"); $("#lb-cast").text(stripslashes(item['cast']))} else {$("#lb-cast-tr").css("display", "none");}
	if (item['hms']) {$("#lb-hms-tr").css("display", "block"); $("#lb-hms").text(stripslashes(item['hms']))} else {$("#lb-hms-tr").css("display", "none");}
	if (item['casting']) {$("#lb-casting-tr").css("display", "block"); $("#lb-casting").text(stripslashes(item['casting']))} else {$("#lb-casting-tr").css("display", "none");}
	
	
	/*
	usage   Usage
	aa   Advertising Agency
	producer   TV-Producer
	copywriter   Copywriter
	pc   Production Company
	director   Director
	dop   DOP
	editing   Editing
	serviceproduction    Service Production
	visualeffects   Visual Effects
	animation    Animation
	sounddesign   Sound Design
	setdesign   Set Design
	music   Music
	
	cast   Cast
	hms HMS
	casting  Casting
	*/
	
	
	if (item['customer_id'] && item['customer_id'] != "0" && !isCustomerGallery) {
		$("#lb-customer_name-tr").css("display", "block");
		if (item['href']){
			$("#lb-customer_name-a").attr("href", item['href']);
		}else{
			$("#lb-customer_name-a").css("display", "none");
		}
	} else {$("#lb-customer_name-tr").css("display", "none");}
	
	
}




function prepareIE(height, overflow){
	bod = document.getElementsByTagName('body')[0];
	bod.style.height = height;
	bod.style.overflow = overflow;

	htm = document.getElementsByTagName('html')[0];
	htm.style.height = height;
	htm.style.overflow = overflow; 
}

function deleteLogo(){
	$("#obj_img").attr({
			src: ""
		});		
	$("#obj_path").attr({
			value: ""
		});
	$("#obj_file").attr({
			value: ""
		});
}

function removeFromCustomerImage(id, cust_id){
	$.getJSON("/member/removecustomerimage/", {id: id}, function(data) {
			if (data > 0){
				$("#image-gallery-li-"+id).remove();
				$("#images-count").attr({value: $("#images-count").val()-1});	
				
				removeItemFromPager(id,cust_id);
				
				return true;
			}
			
		});
}

function removeItemFromPager(id,cust_id){
	tmp 			= new Array();
	tmp[cust_id] 	= new Array();
	for (item in Pager[cust_id]){
		if (Pager[cust_id][item] == id) continue;
		tmp[cust_id].push(Pager[cust_id][item]);
	}
	Pager = tmp;
}

function removeNewsItem(id){
	parent.$("#form-news-count-objects").val(eval(parent.$("#form-news-count-objects").val())-eval(1));
	$(".form-image-gallery").find(".item-"+id).remove();
	$("#insert_id_"+id).remove();
}


function editNewsItem(object_id){
	
	$("#form-news-method").attr({value: 2});
	$("#news-addimage-path").val(object_id);
	$("#form-news-picture-object-id").val(object_id);
	
	$.getJSON("/member/getinboxobjectdetails/", {id: object_id}, function(dataNewsItem) {
			
			writeNewsItemInput(dataNewsItem);
			parent.$("#account-addimage").css({display: "block"});			
				
			
		});
	
	
}

function writeNewsItemInput(item){

	for (var key in item){
		$("#news-addimage-"+key).attr({value: item[key]});
	}
	$("#editMetaData > img").attr({src: "/prev/96x80"+item['path']+"/"+item['file']});

}

function cancelUploadNewsItem(){
	
	parent.$("#form-account-addimage > .account-image-inputs :input").attr({value: ""});
	parent.$("#profile-image-upload").attr({value: ""});
	$("#form-news-method").attr({value: 1});
	$("#account-addimage").css({display:"none"});
	
}

function validateNewsItem(){
	/*$(".account-image-inputs > .form-row :input")*/
	if ($('#news-addimage-title').val().length > 0){
		return true;
	}
	$("#account-image-news-title").addClass("highlight");
	$("#form-error-msg-news").css({display:"block"});
	return false;
	
}

function editArtist(id){
	
	//anpassen der Höhe des Eingabefeldes nach Fehlermeldung
	errorheight = $("#error-msg-artist").height()+17;
	if (errorheight == 17) errorheight = 0;
	offset = $("#imageform-artist").offset();
	if (offset.top < 630) offset.top = 630;
	if (typeof correctedOffset == "undefined"){
		$("#imageform-artist").css({top: offset.top+errorheight});
		correctedOffset = true;
	}else{
		$("#imageform-artist").css({top: offset.top});
	}
	$("#imageform-artist").css({display:"block"});	
	
	
	if (id){
		//vorhandenen Artist bearbeiten
		$("#edit-artist-checkboxes :input").removeAttr("checked");
		$("#artist-firstname").attr({value: $("#id_"+id+"_firstname").val()});
		$("#artist-lastname").attr({value: $("#id_"+id+"_lastname").val()});
		$("#artist-picture").attr({src: "/prev/166x109"+$("#id_"+id+"_path").val()+"/"+$("#id_"+id+"_file").val()});
		$("#artist-path").attr({value: $("#id_"+id+"_path").val()});
		$("#artist-file").attr({value: $("#id_"+id+"_file").val()});
		
		$("#edit-artist-header-1").css({display: "none"});
		$("#edit-artist-header-2").css({display: "block"});
		$("#edit-artist-header-2 > span").text($("#id_"+id+"_firstname").val()+" "+$("#id_"+id+"_lastname").val());
		
		$("#artist-method").attr({value: "update"});
		$("#artist-id").attr({value: id});
		$("#edit-artist-header").text("Artist \""+$("#id_"+id+"_firstname").val()+" "+$("#id_"+id+"_lastname").val()+"\" bearbeiten:");
		
		locations = $("#id_"+id+"_location_id").val().split(",");
		categories = $("#id_"+id+"_category_id").val().split(",");
		for (loc_id in locations){
			$("#artist-location-"+locations[loc_id]).attr({checked: "checked"});
		}
		for (cat_id in categories){
			$("#artist-category-"+categories[cat_id]).attr({checked: "checked"});
		}
		
		$("#form-delete-artist").attr({
									onclick: "deleteArtist("+id+"); return false;",
									href: "javascript:deleteArtist("+id+");"
									});
		$("#form-delete-artist").show();
		
	}else{
		//neuen Artist anlegen
		$("#edit-artist-basic :input").attr({value: ""});
		$("#artist-path").attr({value: ""});
		$("#artist-file").attr({value: ""});
		$("#artist-method").attr({value: "insert"});
		
		$("#edit-artist-checkboxes :input").removeAttr("checked");
		$("#artist-picture").attr({src: "/css/default/img/dot_clear.gif"});	
		
		$("#edit-artist-header-1").css({display: "block"});
		$("#edit-artist-header-2").css({display: "none"});
		
		$("#form-delete-artist").hide();
		
	}
	
	$(".scroll-container").removeClass("highlight-border");
	$("#edit-artist").slideDown();
	return false;
}

function canceleditArtist(){
	$("#edit-artist").slideUp();
	$("#imageform-artist").css({display:"none"});
	parent.$("#form-account-addimage > .account-image-inputs :input").attr({value: ""});
	parent.$("#profile-image-upload").attr({value: ""});
	$("#form-delete-artist").show();
}


function deleteArtist(id){
	
		$.getJSON("/artist/delete", {artist_id: id});
	
}


function addnewsimage(path_file, id){
	
	var count = eval(parent.$("#form-news-count-objects").val())+eval(1);
	
	if (count < 11){
	
		/*parent.$("#insert_ids").val(parent.$("#form-image-gallery-insert_ids").val()+id+',');*/
		parent.$("#form-account-news").append("<input name='data[insert_ids][]' value='"+id+"' id='insert_id_"+count+"' type='hidden' />");
		parent.$("#form-news-count-objects").val(count);
		
		parent.$(".item-"+count).toggleClass("empty");
		parent.$(".item-"+count).find(".img-container").append("<!--[if lte IE 7]><span></span><![endif]--><img src='/prev/96x80"+path_file+"' alt='"+path_file+"' />");
		parent.$(".item-"+count).find(".img-tools").append("<a href='javascript:void(0);' onclick='removeNewsItem("+count+"); return false;' class='left img-gallery-trash' title='delete image'><span class='hidden'>delete</span></a>");
		parent.$(".item-"+count).find(".img-tools").append("<a href='javascript:void(0);' onclick='editNewsItem("+id+");' class='right img-gallery-edit' title='edit image'><span class='hidden'>edit</span></a>");
		
		
		parent.$("#form-news-picture_id").val(count);
		
		//leeren der Input-Felder
		parent.$("#form-account-addimage > .account-image-inputs :input").attr({value: ""});
		parent.$("#profile-image-upload").attr({value: ""});
		parent.$("#account-addimage").css({display: "none"});
	}else{
		parent.$("#form-account-news").append("<input name='data[insert_ids][]' value='"+id+"' id='insert_id_"+count+"' type='hidden' />");
		parent.$("#form-news-count-objects").val(count);
		
		parent.$("#ul-image-gallery").append("<li class='item-"+count+"'><div class='img-container'><!--[if lte IE 7]><span></span><![endif]--><img alt='"+path_file+"' src='/prev/96x80"+path_file+"'/></div><div class='img-tools clearfix'></div></li>");
		parent.$(".item-"+count).find(".img-tools").append("<a href='javascript:void(0);' onclick='removeNewsItem("+count+"); return false;' class='left img-gallery-trash' title='delete image'><span class='hidden'>delete</span></a>");
		parent.$(".item-"+count).find(".img-tools").append("<a href='javascript:void(0);' onclick='editNewsItem("+id+");' class='right img-gallery-edit' title='edit image'><span class='hidden'>edit</span></a>");
		
		parent.$("#form-news-picture_id").val(count);
		
		//leeren der Input-Felder
		parent.$("#form-account-addimage > .account-image-inputs :input").attr({value: ""});
		parent.$("#profile-image-upload").attr({value: ""});
		parent.$("#account-addimage").css({display: "none"});
	}
}


function scrollLink(link, id, link2, id2){
	
	$.getJSON("/news/category/id/"+id, function(category){
		additional = "";
		if (link2) additional = link2+id2;
		window.location.href = '/news/'+category+'/'+link+id+'/jsscroll/'+$("#searchresultbox").scrollTop()+additional;
	});
	
	
}

function scrollMemberLink(link, id, link2, id2){
	
	$.getJSON("/member/directlink/id/"+id, function(directlink){
		
		additional = "";
		if (link2) additional = link2+id2;
		
		if (directlink.length > 0){
			window.location.href = '/'+directlink+'/jsscroll/'+$("#searchresultbox").scrollTop()+additional;
		}else{
			window.location.href = link+id+'/jsscroll/'+$("#searchresultbox").scrollTop()+additional;
		}
		
		
	});
	
	
}

function scrollArtistLink(link, id, link2, id2){
	
	additional = "";
	if (link2) additional = link2+id2;
	

	window.location.href = link+id+'/jsscroll/'+$("#searchresultbox").scrollTop()+additional;
	
}

function openWin(uri,name,w,h,l,t,_options){
	if (!uri) return false;
	if (!w) w=400;
	if (!h) h=500;
	if (!l) l=10;
	if (!t) t=10;
	if (!_options) _options='scrollbars=no,resizable=1,status=1';
	popup = window.open(uri,name,"width="+w+",height="+h+",left="+l+",top="+t+","+_options)
	popup.focus();
}

function stripslashes(str)
{
	return str.replace(/\\/g, '');
}

function invertLayer(){
	if (!$("#lb-innerwrap").hasClass("whiteLayer")){
		$("#lb-innerwrap").toggleClass("whiteLayer");
		$("#lb-pagination").toggleClass("whiteLayer");
		$("#lb-nav-btnClose").toggleClass("whiteLayer");
		$('#lb-customer_name-a').toggleClass("whiteLayer");
		
		//buttons
		$("#lb-nav-btnPrev").toggleClass("invertPrevButton");
		$("#lb-nav-btnNext").toggleClass("invertNextButton");
		
	}
	
}

function showCategoriesOfArtists(cat_id, cust_id){
	
	$.getJSON("/member/getartistsbycatid", {cat_id: cat_id, cust_id: cust_id}, function(result) {
			$("#list-artists-by-categories").html('');
			for (i=0; i<=result.length; i++){
				$("#list-artists-by-categories").append("<li class='clearfix'><a href='/artist/show/id/"+result[i]['artist_id']+"'>"+result[i]['lastname']+", "+result[i]['firstname']+"</a> | Categories: "+result[i]['category_id']+" | Location: "+result[i]['location_id']+"</li>");	
			}
			
		});
}

function getClipDetails(id){
	$.getJSON("/newsfilm/getcredits", {object_id: id}, function(result) {
		$('#film_title').text(result['base']['title']);
		$('#film_description').text(result['base']['description']);
		$('#film_credits').text("");
		for (var item in result['credits']){
			$('#film_credits').append("<b>"+item+"</b> "+result['credits'][item]+" ");
		}
		
	});
}



function validate_send_mail_fields(){
	pstring = "";
	
	
	$.each($('#lb-mailform :input'), function(i, element){
		
		pstring +=  element.name+'='+element.value+'&';
		
		
	});
	
	var strLen = pstring.length;
	pstring = pstring.slice(0,strLen-1); 

	
	$.ajax({
	   type: "POST",
	   url: "/index/sendmail/",
	   data: pstring,
	   dataType: "json",
	   success: function(msg){
			$("#lb-mailform #error").html("");
			$("#lb-mailform :input").parent().removeClass("highlight");
			$('#lb-wrapmail #warning').css({display:'none'});
			
	   		if (msg['success'] != true){
	   			$('#lb-wrapmail #warning').css({display:'inline'});
	   			$('#captcha_wrapper').load("/index/captcha/", function(){
	   				for (var el in msg){
		   				if (el != "success"){
		   					$("#lb-mailform #error").append("<p>"+msg[el]+"</p>");
		   					$("#lb-mailform #"+el).parent().addClass("highlight");
		   					//.css({"border-color": "#CC0088"});
		   				}
		   			}	
	   			});
	   			
	   		}else{
	   		
	   			$('#lb-wrapmail #success').css({display:'inline'});
	   			$('#lb-wrapmail :input').val("");
				$('#lb-wrapmail #error').html("");
				$('#lb-wrapmail #warning').hide();
				$('#inputs_wrapper').hide();
				
				$("#lb-mailform :input").parent().removeClass("highlight");
				
				$('#lb-center2').css({'height':'128px'});
				//pausecomp(2000);
				//hideGalleryInfos();
				
				
			
	   		}

	   }
	 });

}



function showMailLayer(id, companyname, is_job){
	
	if (showMailLayer.arguments.length > 2){
		$('#send_to_id').attr({name:"send_to_job_id"});
		$('#upload-attachment-view').load("/jobs/uploadattachmentview/");
	}
	
	if (window.innerWidth) {
		width = window.innerWidth;
	} else if (bw.ie && !document.documentElement.clientWidth) {
		width = document.body.offsetWidth;
	} else if (bw.ie7) {
		width = document.documentElement.clientWidth;
	}
	
	if (window.innerHeight) {
		height = window.innerHeight;
	} else if (bw.ie && !document.documentElement.clientHeight) {
		height = document.body.offsetHeight;
	} else if (bw.ie7) {
		height = document.documentElement.clientHeight;
	} 
	
	
	
	
		
	pos_left = (width-mailLayerWidth)/2;
	pos_top	 = (height-mailLayerHeight)/2;
	pos_left 	= Math.ceil(pos_left);
	pos_top 	= Math.ceil(pos_top);
	
	if (pos_top < 0) pos_top = 0;
	
	$("select").css("visibility", "hidden");	
	$('#captcha_wrapper').load('/index/captcha/');
	$("#affilliate_webgains2").css("display", "none");
	$("#affilliate_webgains3").css("display", "none");
	$("#lb-overlay").css("height", height);
	$("body").css("position", "relative");
	$("body").css("overflow","hidden");
	$("body").css("height", height);
	$("#lb-center2").fadeIn(500);
	$("#lb-overlay").css("display", "block");
	$("#lb-overlay").css("filter", "alpha(opacity=70)");
	$("#lb-center2").css("left", pos_left+"px");
	$("#lb-center2").css("top", pos_top+"px");
	
	$(".hot-links > #link").css("display", "none");
	$('#lb-center2 #company_name').html(companyname);
	$('#send_to_id').val(id);
}


function showArchiveLayer(object_group_type){
	
	if (window.innerWidth) {
		width = window.innerWidth;
	} else if (bw.ie && !document.documentElement.clientWidth) {
		width = document.body.offsetWidth;
	} else if (bw.ie7) {
		width = document.documentElement.clientWidth;
	}
	
	if (window.innerHeight) {
		height = window.innerHeight;
	} else if (bw.ie && !document.documentElement.clientHeight) {
		height = document.body.offsetHeight;
	} else if (bw.ie7) {
		height = document.documentElement.clientHeight;
	}
	
	pos_left = (width-archiveLayerWidth)/2;
	pos_top	 = (height-archiveLayerHeight)/2;
	pos_left 	= Math.ceil(pos_left);
	pos_top 	= Math.ceil(pos_top);
	
	if (pos_top < 0) pos_top = 0;
	
	$("select").css("visibility", "hidden");
	$("#lb-innerarchiveProfile select").css("visibility", "visible");
	$("#affilliate_webgains2").css("display", "none");
	$("#affilliate_webgains3").css("display", "none");
	$("#lb-overlay").css("height", height);
	$("body").css("position", "relative");
	$("body").css("overflow","hidden");
	$("body").css("height", height);
	
	$("#lb-archive1 iFrame").attr("src", "/profile/archiveiframe/type/"+object_group_type);
		
	$("#lb-archive1").fadeIn(500);
	$("#lb-overlay").css("display", "block");
	$("#lb-overlay").css("filter", "alpha(opacity=70)");
	$("#lb-archive1").css("left", pos_left+"px");
	$("#lb-archive1").css("top", pos_top+"px");
	
	$(".hot-links > #link").css("display", "none");
	
}


function decideLayer(object_id, src, uploadqueue){
	
	if (typeof layereditQueue == "object" && layereditQueue[0] && layereditQueue[0].length > 0){
					
		object_id = layereditQueue[0];	
			
	}
	
	if (activeLayer[object_id] == 3){
		showCreditsLayerThree(object_id, src, uploadqueue);
	}else{
		showCreditsLayerTwo(object_id, src, uploadqueue);
	}
	
}


function showCreditsLayerThree(object_id, src, uploadqueue){
//console.log('ID:'+object_id+' src:'+src);	


	if (showCreditsLayerThree.arguments.length > 2){
//console.log('A');		
		if (typeof layereditQueue == "object" && layereditQueue[0] && layereditQueue[0].length > 0){
//console.log('B');	
//console.log(layereditQueue);				
			object_id = layereditQueue[0];	
				
		}else{
			clearFileUpload();
			layereditQueue == new Array();
			$('#showEdit_07 .basic').toggle(); 
			$('#showEdit_07 .edit').toggle();
			return false;
		}
	}
	
	edit_object_id = object_id;
	
	cleanFields(src);
	
	if (src == "inbox_object") {
		getObjectDetails(object_id, src, true);
	}else{
		getObjectDetails(object_id, src);
	}

	
	if (window.innerWidth) {
		width = window.innerWidth;
	} else if (bw.ie && !document.documentElement.clientWidth) {
		width = document.body.offsetWidth;
	} else if (bw.ie7) {
		width = document.documentElement.clientWidth;
	}
	
	if (window.innerHeight) {
		height = window.innerHeight;
	} else if (bw.ie && !document.documentElement.clientHeight) {
		height = document.body.offsetHeight;
	} else if (bw.ie7) {
		height = document.documentElement.clientHeight;
	}
	

	pos_left = (width-creditsLayerThreeWidth)/2;
	pos_top	 = (height-creditsLayerThreeHeight)/2;
	pos_left 	= Math.ceil(pos_left);
	pos_top 	= Math.ceil(pos_top);
	
	if (pos_top < 0) pos_top = 0;
	
	if (src == 'credits_image' || src == 'credits_image_film') {
		cleanFields('credits_image_film');
//console.log('B');		
		$("select").css("visibility", "hidden");
		$("#lb-innercreditsProfile select").css("visibility", "visible");
		$("#affilliate_webgains2").css("display", "none");
		$("#affilliate_webgains3").css("display", "none");
		$("#lb-overlay").css("height", height);
		$("body").css("position", "relative");
		$("body").css("overflow", "hidden");
		$("body").css("height", height);
		$("#lb-creditsThreeMedia").fadeIn(500);
		
		$("#lb-overlay").css("display", "block");
		$("#lb-overlay").css("filter", "alpha(opacity=70)");
		$("#lb-creditsThreeMedia").css("left", pos_left + "px");
		$("#lb-creditsThreeMedia").css("top", pos_top + "px");
		
		$(".hot-links > #link").css("display", "none");
	}
	else {
	
		$("select").css("visibility", "hidden");
		$("#lb-innercreditsProfile select").css("visibility", "visible");
		$("#affilliate_webgains2").css("display", "none");
		$("#affilliate_webgains3").css("display", "none");
		$("#lb-overlay").css("height", height);
		$("body").css("position", "relative");
		$("body").css("overflow", "hidden");
		$("body").css("height", height);
		$("#lb-creditsThree1").fadeIn(500);
		
		$("#lb-overlay").css("display", "block");
		$("#lb-overlay").css("filter", "alpha(opacity=70)");
		$("#lb-creditsThree1").css("left", pos_left + "px");
		$("#lb-creditsThree1").css("top", pos_top + "px");
		
		$(".hot-links > #link").css("display", "none");
	}
	
}





function showCreditsLayerTwo(object_id, src, uploadqueue){

	if (showCreditsLayerTwo.arguments.length > 2){
//console.log('A');		
		if (typeof layereditQueue == "object" && layereditQueue[0] && layereditQueue[0].length > 0){
//console.log('B');	
//console.log(layereditQueue);				
			object_id = layereditQueue[0];	
				
		}else{
			clearFileUpload();
			layereditQueue == new Array();
			$('#showEdit_07 .basic').toggle(); 
			$('#showEdit_07 .edit').toggle();
			return false;
		}
	}
	
	edit_object_id = object_id;
	
	cleanFields(src);
	
	if (src == "inbox_object") {
		getObjectDetails(object_id, src, true);
	}else{
		getObjectDetails(object_id, src);
	}
	
	if (window.innerWidth) {
		width = window.innerWidth;
	} else if (bw.ie && !document.documentElement.clientWidth) {
		width = document.body.offsetWidth;
	} else if (bw.ie7) {
		width = document.documentElement.clientWidth;
	}
	
	if (window.innerHeight) {
		height = window.innerHeight;
	} else if (bw.ie && !document.documentElement.clientHeight) {
		height = document.body.offsetHeight;
	} else if (bw.ie7) {
		height = document.documentElement.clientHeight;
	}
	

	pos_left = (width-creditsLayerTwoWidth)/2;
	pos_top	 = (height-creditsLayerTwoHeight)/2;
	pos_left 	= Math.ceil(pos_left);
	pos_top 	= Math.ceil(pos_top);
	
	if (pos_top < 0) pos_top = 0;
	
//auskomm. da sich die Sichtbarkeit nicht mehr herstellen lässt				
	//$("select").css("visibility", "hidden");
	//$("#lb-innercreditsProfile select").css("visibility", "visible");
	$("#affilliate_webgains2").css("display", "none");
	$("#affilliate_webgains3").css("display", "none");
	$("#lb-overlay").css("height", height);
	$("body").css("position", "relative");
	$("body").css("overflow","hidden");
	$("body").css("height", height);
	$("#lb-creditsTwo1").fadeIn(500);
	
	$("#lb-overlay").css("display", "block");
	$("#lb-overlay").css("filter", "alpha(opacity=70)");
	$("#lb-creditsTwo1").css("left", pos_left+"px");
	$("#lb-creditsTwo1").css("top", pos_top+"px");
	
	$(".hot-links > #link").css("display", "none");
	
}


function showFeedBackLayer(){
	
 	/* if (showFeedBackLayer.arguments.length > 2){
		if (layereditQueue[0].length > 0){
			object_id = layereditQueue[0];	
		}else{
			alert(layereditQueue);
		}
	} 
	
	edit_object_id = object_id;
	
	cleanFields(src);
	getObjectDetails(object_id, src);*/
	
	if (window.innerWidth) {
		width = window.innerWidth;
	} else if (bw.ie && !document.documentElement.clientWidth) {
		width = document.body.offsetWidth;
	} else if (bw.ie7) {
		width = document.documentElement.clientWidth;
	}
	
	if (window.innerHeight) {
		height = window.innerHeight;
	} else if (bw.ie && !document.documentElement.clientHeight) {
		height = document.body.offsetHeight;
	} else if (bw.ie7) {
		height = document.documentElement.clientHeight;
	}
	

	pos_left = (width-feedBackLayerWidth)/2;
	pos_top	 = (height-feedBackLayerHeight)/2;
	pos_left 	= Math.ceil(pos_left);
	pos_top 	= Math.ceil(pos_top);
	
	if (pos_top < 0) pos_top = 0;
	
		
	$("select").css("visibility", "hidden");
	$("#lb-innercreditsProfile select").css("visibility", "visible");	
	$("#affilliate_webgains2").css("display", "none");
	$("#affilliate_webgains3").css("display", "none");
	$("#lb-overlay").css("height", height);
	$("body").css("position", "relative");
	$("body").css("overflow","hidden");
	$("body").css("height", height);
	$("#lb-feedBack1").fadeIn(500);
	
	$("#lb-overlay").css("display", "block");
	$("#lb-overlay").css("filter", "alpha(opacity=70)");
	$("#lb-feedBack1").css("left", pos_left+"px");
	$("#lb-feedBack1").css("top", getScrollY()+pos_top+"px");
	
	setTimeout("hideGalleryInfos()",3000);
	
	$(".hot-links > #link").css("display", "none");
	
	
}

function showConfirmationLayer(){

	
	if (window.innerWidth) {
		width = window.innerWidth;
	} else if (bw.ie && !document.documentElement.clientWidth) {
		width = document.body.offsetWidth;
	} else if (bw.ie7) {
		width = document.documentElement.clientWidth;
	}
	
	if (window.innerHeight) {
		height = window.innerHeight;
	} else if (bw.ie && !document.documentElement.clientHeight) {
		height = document.body.offsetHeight;
	} else if (bw.ie7) {
		height = document.documentElement.clientHeight;
	}
	

	pos_left = (width-feedBackLayerWidth)/2;
	pos_top	 = (height-feedBackLayerHeight)/2;
	pos_left 	= Math.ceil(pos_left);
	pos_top 	= Math.ceil(pos_top);
	
	if (pos_top < 0) pos_top = 0;
	
		
	$("select").css("visibility", "hidden");
	$("#lb-innercreditsProfile select").css("visibility", "visible");	
	$("#affilliate_webgains2").css("display", "none");
	$("#affilliate_webgains3").css("display", "none");
	$("#lb-overlay").css("height", height);
	$("body").css("position", "relative");
	$("body").css("overflow","hidden");
	$("body").css("height", height);
	$("#confirm_dialog").fadeIn(500);
	
	$("#lb-overlay").css("display", "block");
	$("#lb-overlay").css("filter", "alpha(opacity=70)");
	$("#confirm_dialog").css("left", pos_left+"px");
	$("#confirm_dialog").css("top", getScrollY()+pos_top+"px");
	

	$(".hot-links > #link").css("display", "none");
	
	
}

function showNewsConfirmationLayer(){

	if ($('#sortable .layer_02').length != 0){
		
		
		sendNews();
		
		return true;
		
	}
	
	
	if (window.innerWidth) {
		width = window.innerWidth;
	} else if (bw.ie && !document.documentElement.clientWidth) {
		width = document.body.offsetWidth;
	} else if (bw.ie7) {
		width = document.documentElement.clientWidth;
	}
	
	if (window.innerHeight) {
		height = window.innerHeight;
	} else if (bw.ie && !document.documentElement.clientHeight) {
		height = document.body.offsetHeight;
	} else if (bw.ie7) {
		height = document.documentElement.clientHeight;
	}
	

	pos_left = (width-feedBackLayerWidth)/2;
	pos_top	 = (height-feedBackLayerHeight)/2;
	pos_left 	= Math.ceil(pos_left);
	pos_top 	= Math.ceil(pos_top);
	
	if (pos_top < 0) pos_top = 0;
	
		
	$("select").css("visibility", "hidden");
	$("#lb-innercreditsProfile select").css("visibility", "visible");	
	$("#affilliate_webgains2").css("display", "none");
	$("#affilliate_webgains3").css("display", "none");
	$("#lb-overlay").css("height", height);
	$("body").css("position", "relative");
	$("body").css("overflow","hidden");
	$("body").css("height", height);
	$("#confirm_dialog_news").fadeIn(500);
	
	$("#lb-overlay").css("display", "block");
	$("#lb-overlay").css("filter", "alpha(opacity=70)");
	$("#confirm_dialog_news").css("left", pos_left+"px");
	$("#confirm_dialog_news").css("top", getScrollY()+pos_top+"px");
	

	$(".hot-links > #link").css("display", "none");
	
	
}

function showNewsAbortLayer(){

	
	if (window.innerWidth) {
		width = window.innerWidth;
	} else if (bw.ie && !document.documentElement.clientWidth) {
		width = document.body.offsetWidth;
	} else if (bw.ie7) {
		width = document.documentElement.clientWidth;
	}
	
	if (window.innerHeight) {
		height = window.innerHeight;
	} else if (bw.ie && !document.documentElement.clientHeight) {
		height = document.body.offsetHeight;
	} else if (bw.ie7) {
		height = document.documentElement.clientHeight;
	}
	

	pos_left = (width-feedBackLayerWidth)/2;
	pos_top	 = (height-feedBackLayerHeight)/2;
	pos_left 	= Math.ceil(pos_left);
	pos_top 	= Math.ceil(pos_top);
	
	if (pos_top < 0) pos_top = 0;
	
		
	$("select").css("visibility", "hidden");
	$("#lb-innercreditsProfile select").css("visibility", "visible");	
	$("#affilliate_webgains2").css("display", "none");
	$("#affilliate_webgains3").css("display", "none");
	$("#lb-overlay").css("height", height);
	$("body").css("position", "relative");
	$("body").css("overflow","hidden");
	$("body").css("height", height);
	$("#confirm_abort_news").fadeIn(500);
	
	$("#lb-overlay").css("display", "block");
	$("#lb-overlay").css("filter", "alpha(opacity=70)");
	$("#confirm_abort_news").css("left", pos_left+"px");
	$("#confirm_abort_news").css("top", getScrollY()+pos_top+"px");
	

	$(".hot-links > #link").css("display", "none");
	
}


function showUploadLayer(src, jumper){

 	
 	$('#ajax_btn_upload').click(function(){
 		ajaxFileUpload(src);
 		hideGalleryInfos();
 	});
 	
	if (window.innerWidth) {
		width = window.innerWidth;
	} else if (bw.ie && !document.documentElement.clientWidth) {
		width = document.body.offsetWidth;
	} else if (bw.ie7) {
		width = document.documentElement.clientWidth;
	}
	
	if (window.innerHeight) {
		height = window.innerHeight;
	} else if (bw.ie && !document.documentElement.clientHeight) {
		height = document.body.offsetHeight;
	} else if (bw.ie7) {
		height = document.documentElement.clientHeight;
	}
	

	pos_left = (width-uploadLayerWidth)/2;
	pos_top	 = (height-uploadLayerHeight)/2;
	pos_left 	= Math.ceil(pos_left);
	pos_top 	= Math.ceil(pos_top);
	
	if (pos_top < 0) pos_top = 0;
	
		
	$("select").css("visibility", "hidden");
	$("#lb-innercreditsProfile select").css("visibility", "visible");
	$("#affilliate_webgains2").css("display", "none");
	$("#affilliate_webgains3").css("display", "none");
	$("#lb-overlay").css("height", height);
	$("body").css("position", "relative");
	$("body").css("overflow","hidden");
	$("body").css("height", height);
	$("#lb-fileUpload1").fadeIn(500);
	
	$("#lb-overlay").css("display", "block");
	$("#lb-overlay").css("filter", "alpha(opacity=70)");
	$("#lb-fileUpload1").css("left", pos_left+"px");
	$("#lb-fileUpload1").css("top", pos_top+"px");
	
	$(".hot-links > #link").css("display", "none");
	
	if(undefined  === jumper) jumper = '';
	$("#lb-fileUpload1 a").attr({ href: "#"+ jumper});


}



/*
Ajax Request für Bildinformationen
*/
function getObjectDetails(id, src, isinbox) {
	
	if (getObjectDetails.arguments.length > 2){
		$.getJSON("/profile/getobjectdetails/", {id: id,isinbox: isinbox}, function(data) {
			
			writeObjectData(data, src);
			
		});
	}else{
		$.getJSON("/profile/getobjectdetails/", {id: id}, function(data) {
			
			writeObjectData(data, src);
			
		});
	}
	
	
	

}

// TOM 04.2010 
function writeObjectData(data, src){
	
//console.log('src:' + src);	

	if (data.type == 3){
//console.log('data 3');
//console.log(data);	
		if (src == 'credits_image') {
			// wenn type = 3 (film) und kommt aus Medienarchiv wird das Form creditsThreeMedia im Layer angesprochen
			// sonst gibt es Konflickte in JQuery beim auf ruf des nächsten Objekts wenn dies ein Image ist (Film Felder im Speicher) 
			src = 'credits_image_film';
		}	

		$('#image_film').attr('src', 'http://video.gosee.de/bild/vorschau/150x150'+data['screenshot_path']+"/"+data['screenshot_file']);
		
		$.each(data, function (i, field){
//console.log(i);			
			if (i == 'imagesearch'){
				if (field == '1'){
					$('#credits_film_'+i).check();
					$('#credits_film_'+i).val('1');
				}else{
					$('#credits_film_'+i).uncheck();
					$('#credits_film_'+i).val('1');
				}
			}else{
//console.log('credits_film_'+i+' _'+field);				
				$('#credits_film_'+i).val(field);
			}
			$('#credits_film_'+i).attr('name', 'f['+src+']['+i+']');
			
		});
		
// hier fkt für ThreeMedia wenn src credits image

		if (src == 'credits_image_film') {
//console.log('YEPP');		
			$('#lb-creditsThreeMedia form').attr('id', 'form_'+src);
			// wenn type = 3 (film) und kommt aus Medienarchiv wird das Form creditsThreeMedia im Layer angesprochen
		
			
		
				$('#lb-creditsThreeMedia-save_btn').one("click", function(e){
					saveApp(src);
				});
			
			
		} else {
			
			$('#lb-creditsThree1 form').attr('id', 'form_'+src);
			
		
				$('#lb-creditsThree1-save_btn').one("click", function(e){
					saveApp(src);
				});
			
		}

		
		
	}else{
		
		$('#image_img').attr('src', '/prev/150x150'+data['path']+"/"+data['file']);
		
		$.each(data, function (i, field){
			if (i == 'imagesearch') {
				if (field == '1') {
					$('#credits_image_' + i).check();
					$('#credits_image_' + i).val('1');
				}
				else {
					$('#credits_image_' + i).uncheck();
					$('#credits_image_' + i).val('1');
				}
			}else if (i == 'imagesearch_type' && field > 0) {

//select für credts news cat setzen
			$("#credits_image_imagesearch_type").val(field);	
				
			}else {
			
				$('#credits_image_' + i).val(field);
			}
			$('#credits_image_'+i).attr('name', 'f['+src+']['+i+']');
			
		});
	
		$('#lb-creditsTwo1 form').attr('id', 'form_'+src);
		
	
		$('#lb-creditsTwo1-save_btn').one("click", function(e){
			saveApp(src);
		});
	}
	
	
	
	
}

function cleanFields(src){
	
	$('#form_'+src+' :input').val('');
	
}
