// Starte Sildeshow Script
function setCurrent (manualSlide) {
  if (len > 1) {
    curOrder = Number(document.forms["slideshow"].order.value);
    current += (manualSlide) ? manualSlide - curOrder : curOrder;

    if (manualSlide == 0 || manualSlide == len-1) {
      current = manualSlide;
    } // if
    else if (curOrder == 0) {
      current = Math.round(Math.random() * (len_random - 1));
    }
      
    // Check if we are below 0 or greater the maximum length of the array index:
    if (current < 0)
      current = len-1;
    else if (current >= len)
      current = 0;
  }
} // setCurrent

function startStopSlideshow (kind) {
  newround = kind;
  if (document.getElementById("startstop").firstChild.nodeValue == lang_pause_slide) {
    document.getElementById("startstop").firstChild.nodeValue = lang_play_slide;
    window.clearInterval(hndl);
  }
  else {
    document.getElementById("startstop").firstChild.nodeValue = lang_pause_slide;
    next();
  }
} // startStopSlideshow

function next(manualSlide) {
  // Check if we are below 0 or greater the maximum length of the array index:
  curOrder = Number(document.forms["slideshow"].order.value);

  // Order ascending and last picture reached:
  if (current == 0 && newround < 1 && curOrder == 1 && loopprompt == 1) {
    if (manualSlide != 1) {
      startStopSlideshow (2);
    }
    alert (lang_last_pic_reached);
  }
  // Order descending and first picture reached:
  else if (current == (len - 1) && newround < 1 && curOrder == -1 && loopprompt == 1) {
    if (manualSlide != 1) {
      startStopSlideshow (2);
    }
    alert (lang_first_pic_reached);
  }
  // Random and all pictures shown:
  else if (len_random == 0 && newround < 1 && curOrder == 0) {
    if (manualSlide != 1 && loopprompt == 1) {
      startStopSlideshow (2);
    }
    if (loopprompt == 1) {
      alert (lang_all_pics_viewed);
    }
    theimage_random = theimage;
    len_random = theimage_random.length;
  }

  if (newround != 2) {
    newround = 0;

    var siObj = document.images["slideimage"];
    var interval = document.forms["slideshow"].interval.value;
    
    // Transision script for make picture visible:
    if(document.all && dotrans == 1 && !window.opera)
      eval("siObj.filters." + transtype + ".apply()");
  
    var cur_img_nbr = current + 1;
    if (curOrder == 0) {
      siObj.src = theimage_random[current][1];
      cur_img_nbr = theimage_random[current][0];
      temp1 = theimage_random.slice(0,current);
      temp2 = theimage_random.slice(current+1, len_random);
      theimage_random = temp1.concat(temp2);
      len_random = theimage_random.length;
    } // if
    else {
      siObj.src = theimage[current][1];
    } // else
    document.forms["slideshow"].number.value = cur_img_nbr + "/" + len;
  
    // Transision script for make picture invisible:
    if(document.all && dotrans == 1 && !window.opera)
      eval("siObj.filters." + transtype + ".play()");

    setCurrent ();

    if (!window.opera) {
      nextpic.src = theimage[current][1];
      nextpic.onload=function() {
        if (document.getElementById("startstop").firstChild.nodeValue == lang_pause_slide) {
          hndl = clearTimeout(hndl);
          hndl = window.setTimeout("next()", document.forms["slideshow"].interval.value * 1000);
        } // if slide is playing
      } // onload
    } // if not opera
    else {
      if (document.getElementById("startstop").firstChild.nodeValue == lang_pause_slide) {
        hndl = clearTimeout(hndl);
        hndl = window.setTimeout("next()", document.forms["slideshow"].interval.value * 1000);
      } // if slide is playing
    } // else opera
  } // if newround != 2
  else {
    newround = 1;
  }
} // next

function openslideshow(url,window_width,window_height,new_window) {
  if (new_window == 2 || new_window == 1) {
    var width_avail = screen.availWidth-15;
    var height_avail = screen.availHeight-60;
    var width_full = screen.width;
    var height_full = screen.height;

    // Callculate the spaces from left and top to center the new window:
    var left_space = ((width_avail - window_width) > 0) ? parseInt((width_avail - window_width) / 2) : 0;
    var top_space = ((height_avail - window_height) > 0) ? parseInt((height_avail - window_height) / 2) : 0;
    if (new_window == 2) {
      window_width = width_avail;
      window_height = height_avail;
      left_space = 0;
      top_space = 0;
      url += "&maw="+(window_width-97)+"&mah="+(window_height-194)+"&msw="+width_full+"&msh="+height_full;
    } // if complete picture (whole window)

    slideshow_window = window.open(url,"slideshowwindow","resizable=yes,dependent=yes,hotkeys=no,location=no,menubar=no,scrollbars=yes,status=yes,toolbar=no,width="+window_width+",height="+window_height+",left="+left_space+",top="+top_space+"");
  } // if new_window
  else {
    window.location.href=url;
  } // else new_window
} // openslideshow
//Ende Slideshw Script

// Start Rechtsklick Script
var message="© Copyright liegt beim Fotografen des Bildes und bei Photo Frontal. \n \n Bilder können in vier verschiedenen Ausführungen gemietet werden. \n \nBilder können in digitaler Form gekauft werden.";
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}
function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}
document.oncontextmenu=new Function("alert(message);return false")
 
//Ende Rechtsklick Script

//Starte Open Window Script
function opendetailwindow() { 
   window.open('','detailwindow','toolbar=no,scrollbars=yes,resizable=no,width=680,height=480');
}

function winopen(){
 window.open("./templates/photofront/ausstellung_ifa.html", "myfenster"," toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizeable=0,width=400,height=500");
}

function winopen2(){
 window.open("./templates/photofront/ausstellung_zuerichsee.html", "myfenster"," toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizeable=0,width=400,height=500");
}

function winopen3(){
 window.open("./templates/photofront/ausstellung_st_urban.html", "myfenster"," toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizeable=0,width=450,height=550");
}

function winopen4(){
 window.open("./templates/photofront/ausstellung_st_urban2.html", "myfenster"," toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizeable=0");
}

function winopen5(){
 window.open("./templates/photofront/ausstellung_baumgartner.html", "myfenster"," toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizeable=0,width=450,height=550");
}

function winopen6(){
 window.open("./templates/photofront/ausstellung_businessguide.html", "myfenster"," toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizeable=0,width=450,height=550");
}

function agbs_register() {
    window.open('agbs_register.php','AGBs_register','toolbar=no,scrollbars=yes,resizable=yes,width=700,height=550');
  }

function kontakt_fotograf() {
    window.open('templates/photofront/kontaktfotografformular.html','Kontakt_Fotograf','toolbar=no,scrollbars=yes,resizable=yes,width=700,height=550');
  }
// Ende Open Window Script


var enablepersist="on" //Enable saving state of content structure using session cookies? (on/off)
var memoryduration="7" //persistence in # of days

var contractsymbol='./templates/photofront/images/off.gif' //Path to image to represent contract state.
var expandsymbol='./templates/photofront/images/on.gif' //Path to image to represent expand state.


/////No need to edit beyond here //////////////////////////

function getElementbyClass(rootobj, classname){
var temparray=new Array()
var inc=0
var rootlength=rootobj.length
for (i=0; i<rootlength; i++){
if (rootobj[i].className==classname)
temparray[inc++]=rootobj[i]
}
return temparray
}

function sweeptoggle(ec){
var inc=0
while (ccollect[inc]){
ccollect[inc].style.display=(ec=="contract")? "none" : ""
inc++
}
revivestatus()
}


function expandcontent(curobj, cid){
if (ccollect.length>0){
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="none")? "none" : ""
curobj.src=(document.getElementById(cid).style.display=="none")? expandsymbol : contractsymbol
}
}

function revivecontent(){
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="none"
}

function revivestatus(){
var inc=0
while (statecollect[inc]){
if (ccollect[inc].style.display=="none")
statecollect[inc].src=expandsymbol
else
statecollect[inc].src=contractsymbol
inc++
}
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="none")
selectedItem+=ccollect[inc].id+"|"
inc++
}
if (get_cookie(window.location.pathname)!=selectedItem){ //only update cookie if current states differ from cookie's
var expireDate = new Date()
expireDate.setDate(expireDate.getDate()+parseInt(memoryduration))
document.cookie = window.location.pathname+"="+selectedItem+";path=/;expires=" + expireDate.toGMTString()
}
}

function do_onload(){
uniqueidn=window.location.pathname+"firsttimeload"
var alltags=document.all? document.all : document.getElementsByTagName("*")
ccollect=getElementbyClass(alltags, "switchcontent")
statecollect=getElementbyClass(alltags, "showstate")
if (enablepersist=="on" && get_cookie(window.location.pathname)!="" && ccollect.length>0)
revivecontent()
if (ccollect.length>0 && statecollect.length>0)
revivestatus()
}

if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload

if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate

function getposOffset(overlay, offsettype){
var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
var parentEl=overlay.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function overlay(curobj, subobj){
if (document.getElementById){
var subobj=document.getElementById(subobj)
subobj.style.left=getposOffset(curobj, "left")+"px"
subobj.style.top=getposOffset(curobj, "top")+"px"
subobj.style.display="block"
return false
}
else
return true
}

function overlayclose(subobj){
document.getElementById(subobj).style.display="none"
}
