var global_lightbox;
var global_illustrator;
var global_del=false;

var browserhandle=this;
// für Flash / JS Kommunikation

function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
      return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}

function SendDataToFlashMovie(neuimgid,illustratorid)
{
	
     var flashMovie=getFlashMovieObject("ki_details_illustrator");
    
     

     
     // Film von vorne laden
	//flashMovie.Rewind();
	flashMovie.GotoFrame(1);
	flashMovie.Play();
	flashMovie.SetVariable("/:neuimgid",neuimgid);
	flashMovie.SetVariable("/:neuid",illustratorid);
     
}


function RefreshMovie(neuimgid,illustratorid)
{
	SendDataToFlashMovie(neuimgid,illustratorid);
}


function Play_Video(neuimgid)
{
    var flashMovie=getFlashMovieObject("kbvideo");
    // Film von vorne laden
	flashMovie.GotoFrame(1);
	flashMovie.Play();
	flashMovie.SetVariable("/:videofile",neuimgid);
}


function AddToLightbox()
{


 var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        	alert('Das Bild wurde zur Lightbox hinzugefügt.');
        }
      }

	// serverseitiges script für rückgabe
	if(global_lightbox!=null){
    xmlHttp.open("GET","addtolightbox.php?id=" + global_lightbox,true);
    xmlHttp.send(null);
	}

}



function reloadPictureNewPage(profilid,bildid)
{
  	this.location.href="profil.php?id=" + profilid + "&selpic=" + bildid;
}
  
function reloadVideoNewPage(profilid,bildid)
{
  	this.location.href="profil.php?id=" + profilid + "&selpic=" + bildid + "&objtype=video";
}

// video reload
function reloadVideo(bildid,illustratorid)
  {
  	
  	if(document.getElementById('lightboxlink')!=null)
  		document.getElementById('lightboxlink').href ="#";
  	if(document.getElementById('btn_add_lightbox')!=null)
  		document.getElementById('btn_add_lightbox').src ="img/bt_add_to_lightbox_gray.gif";
  	
  		
//  	if(document.getElementById('empfehlenlink')!=null)
//  		document.getElementById('empfehlenlink').href ="javascript:alert('nicht möglich');";
  	
  	global_lightbox = bildid;
  	global_illustrator = illustratorid;
  	document.getElementById('bildcontent').visibility='none';
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        document.getElementById('bildcontent').innerHTML=xmlHttp.responseText;
        Play_Video(bildid);
        RefreshMovie(bildid,illustratorid);
        }
      }

    // serverseitiges script für rückgabe

    xmlHttp.open("GET","video.php?id=" + bildid,true);
    xmlHttp.send(null);

  }
  

function reloadPicture(bildid,illustratorid)
  {
  	
  	if(document.getElementById('lightboxlink')!=null)
  		document.getElementById('lightboxlink').href ="javascript:AddToLightbox();";
  		
  	if(document.getElementById('btn_add_lightbox')!=null)
  		document.getElementById('btn_add_lightbox').src ="img/bt_add_to_lightbox.gif";  	
  	
  	if(document.getElementById('empfehlenlink')!=null)
  		document.getElementById('empfehlenlink').href ="javascript:IllustratorEmpfehlen1();";
  	
  	global_lightbox = bildid;
  	global_illustrator = illustratorid;


document.getElementById('bildcontent').visibility='none';

  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        
        
        
        document.getElementById('bildcontent').visibility='none';
        document.getElementById('bildcontent').innerHTML=xmlHttp.responseText;

        document.getElementById('bildcontent').visibility='none';
       
        RefreshMovie(bildid,illustratorid);
        new Effect.Opacity('bildcontent', { from: 0, to: 1 }); return false;


        
        }
      }

// serverseitiges script für rückgabe

    xmlHttp.open("GET","bild.php?id=" + bildid,true);
    xmlHttp.send(null);

  }

function reloadPictureLightBox(bildid,illustratorid){


	if(global_del==false)
		reloadPicture(bildid,illustratorid);
}

function AddToLightbox2(id)
{
	global_lightbox = id;
	AddToLightbox();
}

function IllustratorEmpfehlen(id){
	this.location.href="profilempfehlen.php?id=" + id;
}

function IllustratorEmpfehlen1(){
	IllustratorEmpfehlen(global_illustrator);
}


function mausauf(id){
	document.getElementById(id).style.backgroundImage = 'url("img/border.gif")'; 
	
}

function mausaufdel(id){
	document.getElementById(id).style.backgroundImage = 'url("img/del.gif")'; 
	
}
function mausab(id){
	document.getElementById(id).style.backgroundImage = 'url("img/spacer.gif")'; 
}



function mausclick(id){
	
}

function DelFromLightbox(id)
{
	//alert('delklick');
	//event.cancelBubble = true;
	global_del=true;
	var xmlHttp;
	
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        global_del=false;
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        	global_del=false;
        	browserhandle.location.href="lightbox.php";
        }
      }

	// serverseitiges script für rückgabe
	if(global_lightbox!=null){
    xmlHttp.open("GET","delfromlightbox.php?id=" + id,true);
    xmlHttp.send(null);
	}

}


