// www.ferien-oase.ch

var relX=80;
var relY=20;
var img=0;
var gcZF=1;
var movX=0;
var movY=0;

// function SysError()	{return true}
// window.onerror=SysError;

// http://www.jjam.de/JavaScript/Dialogbox/Confirm.html
var ie5=(document.getElementById&&document.all&&document.styleSheets)?1:0;
var nn6=(document.getElementById&&!document.all)?1:0;

// basierend auf  http://selfhtml.teamone.de/dhtml/beispiele/anzeige/dhtml.htm

var DHTML=0,DOM=0,MS=0,NS=0,OP=0;
if(window.opera) { OP=1; }
if(document.getElementById) { DHTML=1; DOM=1; }
if(document.all && !OP) { DHTML=1; MS=1; }
if(window.netscape && window.screen && !DOM && !OP) { DHTML=1; NS=1; }
// alert('DHTML='+DHTML+'; DOM='+DOM+'; MS='+MS+'; NS='+NS+'; OP='+OP+';');

function bookmark() { if (document.all) window.external.AddFavorite('http://www.ferien-oase.ch'); }


function dat(delta)
{
    d=new Date();
    t=d.getTime()+(delta*86400*1000);
    d.setTime(t);
    // d.setHours(13);
    // d.setMinutes(0);
    // d.setSeconds(0);
    s=d.toLocaleString();
    a=s.substring(0,s.length-9);
    // alert('datum='+a);
    // this.title=a;
    // this.alt=a;
    return(a);
}

// basierend auf http://selfhtml.teamone.de/dhtml/beispiele/navigation.htm
// und http://www.jjam.de/JavaScript/Dialogbox/Prompt.html

function gcPopUp(i)
{
    img=i;j=i+1;
    if(img<(gcImg.length-1))	nxt=img+1;
    else	nxt=1;
    if(img>1)	last=img-1;
    else	last=(gcImg.length-1);
    iAnz=gcImg.length-1;
    if (gcZF !=1) {sZF=' ('+gcZF*100+'%)'} else {sZF=''}
    sZF='';
t='<table width=334 height=280 border=0 cellspacing=4 cellpadding=0><tr height=19>'
+'<td align="left" style="font-size:0.84em;">'
+'<input type="button" class="btn" onClick="zoom(0.8);return false;" value="-">'
+' <input type="button" class="btn" onClick="zoom(1.25);return false;" value="+">'
+' <b>Bild '+img+' von '+iAnz+sZF+'</b></td><td align="right">'
+'<input type="button" class="btn" onClick="gcPopUp('+last+');return false;" value="<<">'
+' <input type="button" class="btn" onClick="gcPopUp('+nxt+');return false;" value=">>">'
+' <input type="button" class="btn" onClick="hide();return false;" value="X">'
+'</td></tr><tr><td colspan=2 align="center"><img src="'+gcImg[img]+'" name="bigimg" class="popup"></td></tr>';
if ( gcLeg[img] != ' '){t=t+'<tr><td colspan=2 align="center">'+gcLeg[img]+'</td></tr></table>';}
t=t+'</table>';

    if(document.documentElement && document.documentElement.scrollTop>=0)
    {
	document.getElementById("gcPopUp").innerHTML=t;
	document.getElementById("gcPopUp").style.visibility="visible";
	absX=relX;
	absY=document.documentElement.scrollTop+relY;
    }
    else if(document.body && document.body.scrollTop>=0)
    {
	document.getElementById("gcPopUp").innerHTML=t;
	document.getElementById("gcPopUp").style.visibility="visible";
	absX=relX;
	abyY=document.body.scrollTop+relY;
    }
    else if(window.pageYOffset>=0)
    {
	document.getElementById("gcPopUp").document.write(t);
	document.getElementById("gcPopUp").document.close();
	document.getElementById("gcPopUp").visibility="visible";
	absX=relX;
	absY=window.pageYOffset+relY;
    }
    else
    {
	absX=relX;
	absY=relY;
    }

   if (self.pageYOffset) // all except Explorer 
    { xo = self.pageXOffset; yo = self.pageYOffset; } 
   else if (document.documentElement && document.documentElement.scrollTop) // Explorer 6 Strict 
      { xo = document.documentElement.scrollLeft; yo = document.documentElement.scrollTop; } 
     else if (document.body) // all other Explorers 
        { xo = document.body.scrollLeft; yo = document.body.scrollTop; }

    absY=yo+relY+movY;
    absX=xo+relX+movX;

    document.getElementById("gcPopUp").style.left=absX;
    document.getElementById("gcPopUp").style.top=absY;
    document.bigimg.width=document.bigimg.width*gcZF;
    
}

function zoom(i)
{
    document.bigimg.width=document.bigimg.width*i;
    gcZF=gcZF*i;
}

function hide()
{
    popup=getElem("id","gcPopUp",null);
    img=0;

    if(MS)
    {
	popup.style.visibility='hidden';
	popup.innerHTML='';
    }
    else if(DOM)
    {
	popup.style.visibility='hidden';
	popup.style.top=-500;
    }
    else if(NS)
    {
	popup.visibility='hide';
	popup.top=-500;
    }
  gcZF=1;
    
}

function handleMove(ev)
{
    if(!MS)
    {
	Event = ev;
	if(Event.screenX<270) gcPopUp();
	else if(Event.screenX>420)	hide();
    }
}

function MShandleMove()
{
    if(MS)
    {
	if(window.event.clientX<270)		gcPopUp();
	else if(window.event.clientX>420)	hide();
    }
}

function Event_init()
{
    if(DOM && !MS && !OP)
    {
	getElem("tagname","body",0).addEventListener("mousemove", handleMove, true);
    }
    if(NS)
    {
	document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove=handleMove;
    }
    if (DOM && OP)
    {
	document.onmousemove=handleMove;
	NavLinksPos=42; //Position des Bereiches NavLinks
	// getElem("id","NavLinks",null).style.pixelTop=NavLinksPos;
    }
    if (MS) getElem("tagname","body",0).onmousemove=MShandleMove;
}


// ----------------------------------------

function getElem(p1,p2,p3)
{
    var Elem;
    if(DOM)
    {
	if(p1.toLowerCase()=="id")
	{
    	    if (typeof document.getElementById(p2) == "object") Elem=document.getElementById(p2);
	    else Elem = void(0);
	    return(Elem);
	}
	else if(p1.toLowerCase()=="name")
	{
	    if (typeof document.getElementsByName(p2) == "object") Elem=document.getElementsByName(p2)[p3];
	    else Elem = void(0);
	    return(Elem);
	}
	else if(p1.toLowerCase()=="tagname")
	{
	    if (typeof document.getElementsByTagName(p2) == "object" || (OP && typeof document.getElementsByTagName(p2) == "function")) Elem=document.getElementsByTagName(p2)[p3];
	    else Elem = void(0);
	    return(Elem);
	}
	else return void(0);
    }
    else if(MS)
    {
	if(p1.toLowerCase()=="id")
	{
	    if (typeof document.all[p2] == "object") Elem=document.all[p2];
	    else Elem=void(0);
	    return(Elem);
	}
	else if(p1.toLowerCase()=="tagname")
	{
	    if (typeof document.all.tags(p2) == "object") Elem=document.all.tags(p2)[p3];
	    else Elem=void(0);
	    return(Elem);
	}
	else if(p1.toLowerCase()=="name")
	{
	    if (typeof document[p2] == "object") Elem=document[p2];
	    else Elem=void(0);
	    return(Elem);
	}
	else return void(0);
    }
    else if(NS)
    {
	if(p1.toLowerCase()=="id" || p1.toLowerCase()=="name")
	{
	    if (typeof document[p2] == "object") Elem=document[p2];
	    else Elem=void(0);
	    return(Elem);
	}
	else if(p1.toLowerCase()=="index")
	{
	    if(typeof document.layers[p2] == "object") Elem=document.layers[p2];
	    else Elem=void(0);
	    return(Elem);
	}
	else return void(0);
    }
}

function getCont(p1,p2,p3) {
   var Cont;
   if(DOM && getElem(p1,p2,p3) && getElem(p1,p2,p3).firstChild) {
     if(getElem(p1,p2,p3).firstChild.nodeType == 3)
       Cont = getElem(p1,p2,p3).firstChild.nodeValue;
     else
       Cont = "";
     return(Cont);
   }
   else if(MS && getElem(p1,p2,p3)) {
     Cont = getElem(p1,p2,p3).innerText;
     return(Cont);
   }
   else return void(0);
}

function getAttr(p1,p2,p3,p4) {
   var Attr;
   if((DOM || MS) && getElem(p1,p2,p3)) {
     Attr = getElem(p1,p2,p3).getAttribute(p4);
     return(Attr);
   }
   else if (NS && getElem(p1,p2)) {
       if (typeof getElem(p1,p2)[p3] == "object")
        Attr=getElem(p1,p2)[p3][p4]
       else
        Attr=getElem(p1,p2)[p4]
         return Attr;
       }
   else return void(0);
}

function setCont(p1,p2,p3,p4) {
   if(DOM && getElem(p1,p2,p3) && getElem(p1,p2,p3).firstChild)
     getElem(p1,p2,p3).firstChild.nodeValue = p4;
   else if(MS && getElem(p1,p2,p3))
     getElem(p1,p2,p3).innerText = p4;
   else if(NS && getElem(p1,p2,p3)) {
     getElem(p1,p2,p3).document.open();
     getElem(p1,p2,p3).document.write(p4);
     getElem(p1,p2,p3).document.close();
   }
}

// -------------------------------------
//*****************************************************************************
// Do not remove this notice.
//
// Copyright 2001 by Mike Hall.
// See http://www.brainjar.com for terms of use.
//*****************************************************************************

// Determine browser and version.

function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

// Global object to hold drag information.

var dragObj = new Object(); 
// dragObj.zIndex = 0;

function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  // dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";



  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  dragObj.elEndLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elEndTop   = parseInt(dragObj.elNode.style.top,  10);
  
  movX=movX+dragObj.elEndLeft-dragObj.elStartLeft;
  movY=movY+dragObj.elEndTop-dragObj.elStartTop;
 

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}



