//Browser identifizieren
var out = 0;
var vscrollstep = 30;
var browser = "<unknown>";

if (window.opera)		{browser = "OP";}
else if(document.all)	{browser = "MS";}
else{browser = "NS";}

function scU(no)
{
    if(!isNaN(no)) number = no;
    if(out) { out = 0; }
    else    { scrollV(-1); if(!out) { setTimeout("scU()",1); } }
}

function scD(no)
{
    if(!isNaN(no)) number = no;
    if(out) { out = 0; }
    else    { scrollV(1); if(!out) { setTimeout("scD()",1); } }
}

function scL()
{
    if(out) { out = 0; }
    else    { scrollH(-vscrollstep); if(!out) { setTimeout("scL()",1); } }
}

function scR()
{
    if(out) { out = 0; }
    else    { scrollH(vscrollstep); if(!out) { setTimeout("scR()",1); } }
}

function scrollV(vdir)
{
    var ycontent = document.getElementById("ycontent"+number);
    yPos = cutpx(ycontent.style.top);
    yPos = yPos+vdir;
    //if (yPos < 0)   { yPos = 0; }
    if (yPos > 0) { yPos = 0; }
	else if ((vdir>0)||(ycontent.scrollHeight + 0 > (ycontent.parentNode.offsetHeight - yPos))) ycontent.style.top = yPos;
//   	window.status = "vdir:"+vdir+" Pos:"+yPos + " height:"+ycontent.parentNode.offsetHeight+" scrollHeight:"+ ycontent.scrollHeight +" offsetTop:"+ ycontent.offsetTop;

}

function scrollH(hdir)
{
	var xcontent = document.getElementById("xcontent");
    xPos = cutpx(xcontent.style.left);
    xPos = xPos+hdir;
    //if (xPos < 0)   { xPos = 0; }
    if (xPos > 0) { xPos = 0; }

   	if ((hdir>0) || (xcontent.scrollWidth +0 > (Weite - xPos))) xcontent.style.left = xPos;
//    window.status = "hdir:"+hdir+" Pos:"+xPos + " width:"+(Weite - xPos) +" scrollWidth:"+ xcontent.scrollWidth+" Weite:"+Weite;
}

function scS()
{
    out = 1;
}

function mBP(who,dir)
{
    if(1)
    {
        big = 0;
        xPos = who.offsetLeft + who.offsetParent.offsetLeft;
        yPos = who.offsetTop + who.offsetParent.offsetTop;
//status = "who:"+who.id+"x:"+xPos+" y:"+yPos;

        w = who.width;
        h = who.height;
        neww = w*fac;
        newh = h*fac;
 // Unterscheidung wohin es aufklappt
 		switch(dir)
 		{
 			case 0:// Kante oben fixed -> symetrisch links-rechts

		        xPos -= Math.floor((neww-w)/fac);
		        break;
			case 1: // Kante unten fixed -> symetrisch links-rechts
		        xPos -= Math.floor((neww-w)/fac);
		        yPos -= Math.floor((newh-h));
		        break;
		    case 2: // Ecke oben links fixed
		    	//yPos = who.offsetParent.offsetTop;
		    	//xPos = who.offsetParent.offsetLeft;
		        break;
		    case 3: // Ecke unten links fixed
		        yPos -=  Math.floor((newh-h));
		        break;
		    case 4: // Ecke oben rechts fixed
		        xPos -= Math.floor((neww-w));
		        break;
		    case 5: // Ecke unten rechts fixed
		        xPos -= Math.floor((neww-w));
		        yPos -= Math.floor((newh-h));
		        break;
		}

        s = who.src;

        who = who.previousSibling;
        // jetzt haben wir das DIV
		if(who.hasChildNodes())
		{
			who.style.display = "block";
		}
		else
		{
//	        who.offsetLeft = xPos;
//	        who.offsetTop = yPos;

	        who.style.left = xPos;
	        who.style.top = yPos;

	        who.style.width = neww;
	        who.style.height = newh;
	        //s = s.substr(0,s.length-4) + "_hires.jpg";
//	        s = s.substr(0,s.lastIndexOf("/")+1)+"tn_"+s.substr(s.lastIndexOf("/")+1);
	        s = s.replace(/\/tn_/,"/");
	        //alert(s);
//window.status= "h:" + newh+" b:"+ neww+" old:"+h+"x"+w;

	        var nImg = new Image();
	        nImg.src = s;
	        nImg.width = neww;
	        nImg.height = newh;
	        nImg.style.width = neww;
	        nImg.style.height = newh;


	        nImg.style.display = "block";
	        who.appendChild(nImg);
    	}
    }
}

function mLP(who,dir)
{
    if(big)
    {
        big = 0;
        xPos = cutpx(who.style.left);
        yPos = cutpx(who.style.top);
        w = cutpx(who.style.width);
        h = cutpx(who.style.height);
        neww = Math.floor(w/fac);
        newh = Math.floor(h/fac);
        xPos = xPos; //xPos+Math.floor((w-neww)/fac);
        //yPos = yPos+Math.floor((h-newh)/fac);
        who.style.left = xPos;
        who.style.top = yPos;
        who.style.width = neww;
        who.style.height = newh;
        s = who.src;
        s = s.substr(0,s.length-10) + ".jpg";
        who.src = s;
    }
}

function cutpx(arg)
{
    ret = parseFloat(arg);
    //if(arg.substr(arg.length-2,arg.length)=="px") ret=arg.substr(0,arg.length-2);
    //ret = Math.floor(ret);
    if(isNaN(ret)) ret = 0;
// window.status = "arg:"+arg+" ret:"+ret;
    return ret;
}

function go2cms()
{
    window.open("cms/cms.php","CMS");
}

function hideNode(elem)
{
	if(elem.hasChildNodes())
		elem.style.display = "none";
}

function Fensterweite()
{
 if (window.innerWidth) return window.innerWidth;
 else if (document.body && document.body.offsetWidth) return document.body.offsetWidth;
 else return 0;
}

function Fensterhoehe()
{
 if (window.innerHeight) return window.innerHeight;
 else if (document.body && document.body.offsetHeight) return document.body.offsetHeight;
 else return 0;
}


function neuAufbau()
{
	if (Weite != Fensterweite())
	{
		Weite = Fensterweite();
		if(browser == "NS")
			document.getElementById("xcontainer").style.width= (Weite -(window.scrollMaxX?15:1));
		else if(browser == "MS")
			document.getElementById("xcontainer").style.width= Weite -22;//document.body.offsetWidth-21;
	}

}


