// Funktion zur Einbindung der korrekten Stylesheetdatei in den Browser

var plattform = "win";

if (navigator.userAgent.indexOf("Win")!= -1) {
         plattform = "win";
}
if (navigator.userAgent.indexOf("Mac")!= -1) {
         plattform = "mac";
}
if((navigator.userAgent.indexOf("Mac")!= -1) && (navigator.userAgent.indexOf("MSIE 5") != -1)) {
         plattform = "win";
}

if ((navigator.userAgent.indexOf("Mac")!= -1) || ( (navigator.userAgent.indexOf("MSIE") < 0) &&  (navigator.appVersion.substring(0,1) < 6)) ){
 plattform = "mac";
}

 plattform = "win";




document.write("<link href=\"../../lib/css/"+plattform+".css\" REL=\"STYLESHEET\" TYPE=\"text/css\">");
document.write("<link href=\"../../lib/css/div"+plattform+".css\" REL=\"STYLESHEET\" TYPE=\"text/css\">");

function rollover(bild_org,bild_change)
{
     //imgChange    = new Image();
    // imgChange.src = bild_change;
        /*
         if(navigator.appName == "Netscape")
                {
                    document.linie.document.images[bild_org].src = imgChange.src;
                }
                else
                {
                  window.document.images[bild_org].src = imgChange.src;
                }
               */
     document.getElementById(bild_org).src =bild_change;  
      
}
function rollover1(bild_org,bild_change)
{
     imgChange    = new Image();
     imgChange.src = bild_change;
     document.getElementById(bild_org).src =bild_change;  
}

var browser = "?";
var aidi = "?";
var clicked = 2;
var helper = 2;
var x = 0;

function getBrowser()
{
    
    if(document.layers)
    { browser="NS4";}
    if(document.all)
    {browser="IE4OP5";}
    if(document.getElementById)
    {browser="IE5NS6";}
    return browser;
}

function show(aidi)
{
	browser = getBrowser();	
	
    helper  = clicked / 2;
	if (helper == Math.round(helper))
	 {
	 	//alert( helper +" :: "+Math.round(helper));
	    

			 if(browser == "IE4OP5")
				{
		   		document.all[aidi].style.visibility = "visible";
				
				}
		    if (browser == "NS4")
				{
		    	document.layers[aidi].visibility="show";
		
			    }
		    if(browser=="IE5NS6")
				{
			    document.getElementById(aidi).style.visibility="visible";
		
		    	}
	 }
	 if (helper != Math.round(helper))
	 	{
	 	hide(aidi,1);
		//alert( helper +" ungleich "+Math.round(helper));
	 	}
	 
	 		
	 clicked = clicked + 1; 				
				
}

function hide(aidi,x)
{
     browser = getBrowser();
     if(browser == "IE4OP5")
		{
   		document.all[aidi].style.visibility = "hidden";
		}
    if (browser == "NS4")
		{
    	document.layers[aidi].visibility="hide";
	    }
    if(browser == "IE5NS6")
		{
	    document.getElementById(aidi).style.visibility="hidden";
    	}
	
	if (x != 1)
	{
		clicked = clicked + 1;	
	}
		
}

function showLayer(aidi)
{
	browser = getBrowser();	
	
	if(browser == "IE4OP5")
		document.all[aidi].style.visibility = "visible";
	if (browser == "NS4")
		document.layers[aidi].visibility="show";
	if(browser=="IE5NS6")
		document.getElementById(aidi).style.visibility="visible";
}

function hideLayer(aidi,x)
{
     browser = getBrowser();
     
	if(browser == "IE4OP5")
		document.all[aidi].style.visibility = "hidden";
	if (browser == "NS4")
		document.layers[aidi].visibility="hide";
	if(browser=="IE5NS6")
		document.getElementById(aidi).style.visibility="hidden";		
}


function popup(PopURL,FName,x,y,posx,posy)
{
        if (!(posx)) posx=20;
        if (!(posy)) posy=20;
        ie=(document.all)?true:false;
        ie4 = navigator.appVersion.indexOf("MSIE 4");
        if (! window.cc_child)
        {
                cc_child = window.open(PopURL, FName,'location=no,menubar=no,resizable=no,status=no,scrollbars=yes,width='+x+',height='+y+', top='+posy+', left='+posx);
                //if (posx) cc_child.moveTo(posx,posy);
                window.cc_child.focus();
                return;
        }

        if (ie && ie4 < 0)
        {
                if (window.cc_child.closed)
                {
                        cc_child = window.open(PopURL, FName,'location=no,menubar=no,resizable=no,status=no,scrollbars=yes,width='+x+',height='+y+', top='+posy+', left='+posx);
                        //if (posx) cc_child.moveTo(posx,posy);
                        window.cc_child.focus();
                        return;
                }
        }

        if (window.cc_child)
        {
                if (ie && ie4 < 0)
                        {  window.cc_child.close(); }
                cc_child = window.open(PopURL, FName,'location=no,menubar=no,resizable=no,status=no,scrollbars=yes,width='+x+',height='+y+', top='+posy+', left='+posx);
                //if (posx) cc_child.moveTo(posx,posy);
                window.cc_child.focus();
        }
}

var isActive="";	

function showTh(id)
{
	if(isActive!="")
	{
		hideTh(isActive);
	}
	var dispElement = document.getElementById("thShadowDiv"+id);
	if(dispElement)
	{
		dispElement.style.visibility="visible";
		isActive = id;
	}
}

function hideTh(id)
{
	var dispElement = document.getElementById("thShadowDiv"+id);
	if(dispElement)
	{
		dispElement.style.visibility="hidden";
		isActive = "";
	}
}		

var _errors    = "";

function appendErrorMessage(msgError) {
    _errors += ((_errors != "") ? "\n":"") + "- " + msgError;
}

function validateField(field, msgError, minLength, maxLength) {
    if (!minLength) {
        minLength = 1;
    }
    if (!maxLength ) {
		maxLength = Number.MAX_VALUE;		
    }
    var value = trim(field.value)
	if (value)
	{
    if (value.length < minLength || value.length > maxLength) {
        appendErrorMessage(msgError);        
        return false;
    }
	}
    return true;
}

function validateEmail(field, msgError) {
	if (!isEmail(field.value)) {
        appendErrorMessage(msgError)
        return false;
	}
	return true;
}

function validateURL (field, msgError, optional) {
	if (optional)
	{
		var value = trim(field.value);
		if (value.length == 0) {
			return true;
		}
	}
	if (!isURL(field.value)) {
        appendErrorMessage(msgError)
        return false;
	}
	return true;
}

function trim(str)
{
	if (str)
	{
   return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
   }
}

function isEmail(str) {
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

function isURL (url) {
  var urlPattern = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
  return urlPattern.test(url.toLowerCase());
}

function getLayer(layerName)
{
	var theLayer =  null;
	if (document.getElementById) {
		theLayer= document.getElementById(layerName);
	} else if (document.all) {
		theLayer= eval("document.all."+layerName);
	} else if (document.layers){
		theLayer= eval("document.layers."+layerName);
	}	
	return theLayer;
}

if(document.all && !document.getElementById) {
    document.getElementById = function(id) {
         return document.all[id];
    }
}

