// Copyright (C) 1999 Dan Steinman Available at http://www.dansteinman.com/dynapi/
// aktualisiert für Netscape6 (v5) CR
function BrowserCheck() {
	var b = navigator.appName;
	if (b.indexOf("Netscape")>=0) 	{this.b = "ns"}
		else 			{if (b.indexOf("Microsoft Internet Explorer")>=0) {this.b = "ie"}
										else 	  {this.b = b   }
					}	
	this.v   = parseInt(navigator.appVersion)
	this.ns  = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ie  = (this.b=="ie" && this.v>=4)
	this.ie4 = (navigator.userAgent.indexOf('MSIE 4')>0)
	this.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0)
	this.ie6 = (navigator.userAgent.indexOf('MSIE 6')>0)
	if (this.ie5) this.v = 5
	if (this.ie6) this.v = 6
	this.min = (this.ns||this.ie)
}
is = new BrowserCheck()
var Opera = window.opera ? true : false;
//***********
function MM_preloadImages() { //v3.0
  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];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//*** Fensterabmessungen bestimmen
function getDim() 	{if (is.ns) 	{winW=window.innerWidth; winH=window.innerHeight
					 offW=window.pageXOffset; offH=window.pageYOffset}
			 if (is.ie && !Opera)	
					{winW=document.body.clientWidth; winH=document.body.clientHeight
					 offW=document.body.scrollLeft;  offH=document.body.scrollTop }
			 if (Opera)	{winW=window.innerWidth; winH=window.innerHeight
					 offW=window.pageXOffset; offH=window.pageYOffset}
			}


//*************
function OpenWindow(theURL,winName,winCenter,x,y,features) {
  var param = "width=" + x + ",height=" + y + ( features=="" ? "" : "," + features );
  var win = window.open(theURL,winName,param);

  if (theURL.indexOf('http://') == -1) {
    if (winCenter) win.moveTo((screen.width-x)/2,(screen.height-y)/2);
    win.focus(); 
  }
}

//**************
ln	=	 1;
g	=	'.gif'
d	=	'Div'

//******************************************************************
//bild-und layerfunktionen: tauschen, verstecken/zeigen, verschieben
//ly = layername; target=bildname; img = bildpfad; lp = linke position; tp = obere position
//ln = zahle der layers in netscaoe, fuers dokument feststellen, damit keine fehler entstehen
// wenn noch nicht alle layers verfuegbar sind.

function rpi (target,img,ly)	{
				if (is.ie) 	{document[target].src = img}
				if (is.ns4) 	{if(ly!="null") { document.layers[eval('"'+ly+'"')].document[target].src=img}
						else 		{ document[target].src = img}}
				if (is.ns5) 	{document[target].src = img}
			}

function getsrc (target,ly)	{
				if (is.ie) 	{img=document[target].src}
				if (is.ns4) 	{if(ly!="null") {img =document.layers[eval('"'+ly+'"')].document[target].src}
						else 		{img = document[target].src}}
				if (is.ns5) 	{img = document[target].src }
			return img}

function showly(ly) 	{
				if (is.ns4) 	{document.layers[eval('"'+ly+'"')].visibility="visible"}
				if (is.ie) 	{document.all[''+ly].style.visibility = "visible"}
				if (is.ns5) 	{var lytg=document.getElementById(ly);lytg.style.visibility='visible'}
		  	}

function hidely(ly) 	{
				if(is.ns4)	{document.layers[eval('"'+ly+'"')].visibility="hide"}
			 	if (is.ie) 	{document.all[''+ly].style.visibility = "hidden"}
				if (is.ns5) 	{var lytg=document.getElementById(ly); lytg.style.visibility='hidden'}
			}

function setpos (ly,lp,tp) 
			{ly=eval('"'+ly+'"')
				if (is.ie)   	{document.all[''+ly].style.left=lp;  document.all[''+ly].style.top=tp }
				if (is.ns4)	{document.layers[ly].top=tp;	document.layers[ly].left=lp}
				if (is.ns5) 	{var lytg=document.getElementById(ly); lytg.style.left=lp; lytg.style.top=tp}
			}

function setX (ly,lp) 
			{ly=eval('"'+ly+'"'); 
				if (is.ie)   	{document.all[''+ly].style.left=lp}
				if (is.ns4)	{document.layers[ly].left=lp}
				if (is.ns5) 	{var lytg=document.getElementById(ly); lytg.style.left=lp}
			}


function cliply(ly,t,r,b,l) 	{ly=eval('"'+ly+'"');
				 if (is.ns4) 	{document.layers[ly].clip.top=t;    	document.layers[ly].clip.right=r; 
						 document.layers[ly].clip.bottom=b; 	document.layers[ly].clip.left=l}
			      	 if (is.ie)   	{document.all[''+ly].style.clip = "rect("+t+"px "+r+"px "+b+"px "+l+"px)"}
				 if (is.ns5)    {document.getElementById(ly).style.clip= "rect("+t+"px "+r+"px "+b+"px "+l+"px)"}
				}





function layerWrite(id,nestref,text) 	{

	if (is.ns4) 	{
		var lyr = (nestref)? eval('document.'+nestref+'.document.'+id+'.document') : document.layers[id].document
		lyr.open()
		lyr.write(text)
		lyr.close()
			}

	else 		{if (is.ie) 	{document.all[id].innerHTML 	= text}

			 else		{var lytg=document.getElementById(id);
					 lytg.innerHTML 		= text}		
			}
		
					}



function 
procurl (url,steps)  	{url=url.replace('//','/'); sep='/'; loc=''; base=''; 
		    	  if(url.indexOf('\\')>0) {sep='\\'}
			 for (m=1; m<=steps; m++)
				{l    = url.split(sep).length
				 if (l>1) {
				 loc  = url.split(sep)[l-1]; 
				 base = url.substring(0,url.length-loc.length-1)
				 url  = base;}
				}
			}

//
// Browserspezifisches Stylesheet benutzen.
//
if ( is.ie ) 	{links = document.all.tags("link");
    	      	 if (links[1]) 	{  // nn.css deaktivieren
      				links[0].disabled=true;
      				links[1].disabled=false;
      				}

    		}

//******* IE5.5 Grafik-Fix ***
//**** Bilder die in IE5.5 manchmal im ersten ANlauf nicht vollständig geladen werden (letzte Bildzeile leer)
//*** damit nicht alle bilder neu geladen werden, wird ein bestandteil des pfades angegeben, z.B. bei den
//*** betroffenen Key Visuals bei Lilly "bild"
function gfreload(bezeichner)	
				{for (n=0; n<document.images.length; n++) 
				{if (document.images[n].src.indexOf(bezeichner)>0) 
				{imgsrc=document.images[n].src; document.images[n].src=imgsrc} }

			}

//***********
function pr()		{if (is.e4) 
{alert("Ihre Browser-Version unterstützt nicht das Drucken über Javascript!\n\nBitte drücken Sie STRG+P um den Seiteninhalt zu drucken.")}
	else {window.print()}
}



//*****
function alphStrip(str) { // wenn z.b  eingegeben wird "Etwa 7,5 " kommt raus "7.5"
			 if (str.indexOf(',')>-1) 
				{str=str.split(',').join('.')}
			 if (str.split('.').length>2)
				{str=str.split('.')[0]+'.'+str.split('.')[1]};
				 //falls Komma als Dezimaltrennzeichen vorkommt, punkt draus.
				 //bei mehreren kommata/punkten nur ersten als dezimalzeichen auffassen

			 val=str; for (n=0; n<str.length; n++) 
				{
				 s = str.substring(n,n+1);
				 if ( ((s>'9') || (s<'0'))  && (s!='.') )
					{val=val.replace(s,'')}
				}
				// alles ausser zahlen und . wegwerfen
			 return val
			}

//********

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

//************ COOKIES ***********
/*   Folgendes basiert auf den public domain Cookiefunktionen von BILL DORTCH */

function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));}
//  Function to return the value of the cookie specified by "name".
function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;   }
  return null;}
//  Function to create or update a cookie.
function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
     "; path=/" +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");}
//  Function to delete a cookie. (Sets expiration date to start of epoch)
function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";}}

function MM_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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 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];}}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}




function OpenShop() {OpenWindow('http://www.cormatex.de/shop/shop','CREWorangeShop',0,780,650,'scrollbars=yes,resizable=no')}
function OpenNewsletter() {OpenWindow('http://www.cormatex.de/newsletter','CREWorangeNewsletter',0,450,350,'scrollbars=yes,resizable=no')}
