function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

/* Standard Roll Over */
function rollOver(nameOfImage, nameOfFile) {
  if (document.images) {
    document.images[nameOfImage].src = nameOfFile
  }
}


/* Image Pre-Loader v.3.0 */
function MM_preloadImages() {

  var d=document;
  if(d.images) {
    if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
    for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0) { d.MM_p[j]=new Image; d.MM_p[j++].src=a[i]; }
  }

}

// Alle Bilder cachen :
// bennötigt in header.php erzeugtes JavaScriptArray imagesToLoad
document.preloadImages = new Object();
function preloadImages() {
  for(i=0;i<imagesToLoad.length;i++) {
    document.preloadImages[i] = new Image();
    document.preloadImages[i].src = imagesToLoad[i];
  }
}

// Action- und Eventhandler :
function selectThemestandortChanged(obj, formname) {
  v = obj.value;
  if(v > 0) {
    document.forms[formname].submit();
  }
}

function selectVotingfilmChanged(obj) {
  v = obj.value;
  if(v > 0) {
    document.forms["voting_linkForm"].elements["filmedinumber"].value = v;
    document.forms["voting_linkForm"].submit();
  }
}

function votingButtonClicked() {
  for(i=0;i<document.forms["votingForm"].votingStars.length;i++){
    if(document.forms["votingForm"].votingStars[i].checked == true){
      document.forms["votingForm"].submit();
    }
  }
}

function newsletterButtonClicked() {
  document.forms["newsletterForm"].submit();
}

function lotteryButtonClicked() {
  document.forms["lotteryForm"].submit();
}

function birthdayButtonClicked() {
  document.forms["birthdayForm"].submit();
}

function buttonParentContactCLicked () {
  document.forms["parentSpaceConactForm"].submit();
}

// Foto-Gallerien in Spiel und Spass
// Prototype
function getPhotoGallery_prototype(filmedinumber) {
	new Ajax.Request(
		"/server/fun_photo_ajax.php?ajaxAction=loadGallery&filmedinumber="+filmedinumber,
		{
			onSuccess: function(transport) {
				eval(unescape(transport.responseText));
			}
		}
	);
	$('fun_photoGalleryShowPhoto').src = "/style/default/pics/fun_photo/gallery_dummy.gif";
}



function nextPhotoGalleryImage() {
  currentImageIndex++;
  if(currentImageIndex > galleryImages.length-1) currentImageIndex = 0;
  $("galleryImage").src = path + galleryImages[currentImageIndex];
  $("fun_photoGalleryDescCount").innerHTML = "Foto Nr. "+(currentImageIndex + 1)+" von "+galleryImages.length;
}

function previousPhotoGalleryImage() {
  currentImageIndex--;
  if(currentImageIndex < 0) currentImageIndex = galleryImages.length -1;
  $("galleryImage").src = path + galleryImages[currentImageIndex];
  $("fun_photoGalleryDescCount").innerHTML = "Foto Nr. "+(currentImageIndex + 1)+" von "+galleryImages.length;
}






// Wallpaper-Gallerien in Spiel und Spass
// Ben�igt dojo.io
function getWallpaperGallery(filmedinumber) {
  var args = {
    url:    "/server/fun_wallpaper_ajax.php?ajaxAction=loadGallery&filmedinumber="+filmedinumber,
    mimetype: "text/plain",
    method:   "POST",
    sync:   true,
    error:    function(type, errObj){
      alert("Fehler!");
    },
    load:   function(type, data, evt){
      eval(unescape(data));
    }
  };

  dojo.byId('fun_wallpaperGalleryShowPhoto').src = "/style/default/pics/fun_wallpaper/gallery_dummy.gif";
  dojo.io.bind(args);
}

function nextWallpaperImage() {
  currentImageIndex++;
  if(currentImageIndex > galleryImages.length-1) currentImageIndex = 0;
  dojo.byId("galleryImage").src = path + galleryImages[currentImageIndex];
  dojo.byId("fun_wallpaperGalleryDescTitle").innerHTML = galleryTitle+" Nr. "+(currentImageIndex + 1)+" von "+galleryImages.length;
  setWallpaperResolutionLinks();
}

function previousWallpaperImage() {
  currentImageIndex--;
  if(currentImageIndex < 0) currentImageIndex = galleryImages.length -1;
  dojo.byId("galleryImage").src = path + galleryImages[currentImageIndex];
  dojo.byId("fun_wallpaperGalleryDescTitle").innerHTML = galleryTitle+" Nr. "+(currentImageIndex + 1)+" von "+galleryImages.length;
  setWallpaperResolutionLinks();
}

function setWallpaperResolutionLinks () {
  linktemplate = "<a href=\"#\" onclick=\"wallpaperPopup('FILENAME', 'WIDTH', 'HEIGHT');\">TEXT px</a>";
  resolutions = wallPaperResolutions[currentImageIndex];
  reslinks = new Array();

  for(i=0;i<resolutions.length;i++) {
    temp = linktemplate;
    temp = temp.replace(/FILENAME/, wallpath+resolutions[i][0]);
    temp = temp.replace(/WIDTH/, resolutions[i][1]);
    temp = temp.replace(/HEIGHT/, resolutions[i][2]);
    temp = temp.replace(/TEXT/, resolutions[i][1]+"x"+resolutions[i][2]);
    reslinks[reslinks.length] = temp;
  }

  reslinks = reslinks.join(" | ");
  dojo.byId("fun_wallpaperGalleryResolutions").innerHTML = reslinks;
}

function wallpaperPopup (fname, w, h) {
  winwidth = 3+ w + 3;
  winheight = 3 + 40 + 3 + h;
  wallpaperpopup = window.open('/popups/wallpaperpopup.php?filename='+fname+'&width='+w+'&height='+h, 'wallpaperpopup', 'height='+winheight+',width='+winwidth+',innerHeight='+winheight+',innerWidth='+winwidth+',left=10,top=10,screenX=10,screenY=10,dependent=yes,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
  wallpaperpopup.focus();
}







// Ausmalbilder-Gallerien in Spiel und Spass
// Ben�igt dojo.io
function getPaintpicGallery(filmedinumber) {
  var args = {
    url:    "/server/fun_paintpic_ajax.php?ajaxAction=loadGallery&filmedinumber="+filmedinumber,
    mimetype: "text/plain",
    method:   "POST",
    sync:   true,
    error:    function(type, errObj){
      alert("Fehler!");
    },
    load:   function(type, data, evt){
      eval(unescape(data));
    }
  };

  dojo.byId('fun_paintpicGalleryShowPhoto').src = "/style/default/pics/fun_paintpic/gallery_dummy.gif";
  dojo.io.bind(args);
}

function nextPaintpicImage() {
  currentImageIndex++;
  if(currentImageIndex > galleryImages.length-1) currentImageIndex = 0;
  dojo.byId("galleryImage").src = paintpicpath + galleryImages[currentImageIndex][1];
  dojo.byId("fun_paintpicGalleryDescTitle").innerHTML = galleryTitle+" Nr. "+(currentImageIndex + 1)+" von "+galleryImages.length;
  setPaintpicDownloadLink();
}

function previousPaintpicImage() {
  currentImageIndex--;
  if(currentImageIndex < 0) currentImageIndex = galleryImages.length -1;
  dojo.byId("galleryImage").src = paintpicpath + galleryImages[currentImageIndex][1];
  dojo.byId("fun_paintpicGalleryDescTitle").innerHTML = galleryTitle+" Nr. "+(currentImageIndex + 1)+" von "+galleryImages.length;
  setPaintpicDownloadLink();
}

function setPaintpicDownloadLink () {
  linktemplate = "<a href=\"#\" onclick=\"paintpicPopup('FILENAME', 'WIDTH', 'HEIGHT');\">Ausmalbild herunterladen (PDF)</a>";

  linkdata = galleryImages[currentImageIndex][0];

  temp = linktemplate;
  temp = temp.replace(/FILENAME/, paintpicpath+linkdata);
  temp = temp.replace(/WIDTH/, '800');
  temp = temp.replace(/HEIGHT/, '600');

  dojo.byId("fun_paintpicGalleryLinkDownload").innerHTML = temp;
}

function paintpicPopup (fname, w, h) {
  winwidth = 3+ w + 3;
  winheight = 3 + 40 + 3 + h;
  paintpicpopup = window.open(fname, 'paintpicpopup', 'height='+winheight+',width='+winwidth+',innerHeight='+winheight+',innerWidth='+winwidth+',left=10,top=10,screenX=10,screenY=10,dependent=yes,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
  paintpicpopup.focus();
}


function sticker_popup (filmedinumber) {
	var popup = window.open("/detail_film/sticker_popup.php?filmedinumber=" + filmedinumber, "", "width=500,height=450,location=no,menubar=no,status=no,toolbar=no");
}