function swapImage(imgName, swapImgName)
{
	document[imgName].src= swapImgName;
}

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}


function chkR( str, from, to ) {
	if ( str < from ) return false;
	if ( str > to ) return false;
	return true;
    }
    function isAlphaNum(s) {
        return chkR(s,"a","z") || chkR(s,"A","Z") || chkR(s,"0","9");
    }
    function isWord(s) {
        var i;
	if ( s.length == 0 ) {
	    return false;
	}
	for ( i=0; i<s.length; i++) {
	    var c = s.charAt(i);
	    if ( ! isAlphaNum(c) ) {
	        if ( i == 0 ) return false;
		if ( i == s.length - 1 ) return false;
	        if ( c != "-" ) 
	            return false;
	    }
	}
        return true;
    }

    function isWordOrDot(s) {
        var i;
	if ( s.length == 0 ) {
	    return false;
	}
	for ( i=0; i<s.length; i++) {
	    var c = s.charAt(i);
	    if ( ! isAlphaNum(c) ) {
	        if ( i == 0 ) return false;
		if ( i == s.length - 1 ) return false;
	        if ( (c != "-") && (c != ".") ) 
	            return false;
	    }
	}
        return true;
    }



    function check_mail(mail) {
      var idx = mail.indexOf( "@" );
      if ( idx == -1 || idx == 0 || idx == mail.length - 1) {
          return 0;
      } else {
          var user = mail.substring(0, idx);
          var host = mail.substring(idx + 1, mail.length);
          //
          // test mail
          //if ( ! isWordOrDot( user ) ) return false;
          //
          // test host
          var tok = host.split(".");
          for ( idx = 0; idx < tok.length; idx++ ) {
              if ( ! isWord( tok[ idx ] ) ) return false;
          }
          return true;
      }
    }

    function testsubmit () {
    //alert(document.kontaktformular.usertext.value.length);
if (document.kontaktformular.name.value == "") 
         {
	    alert( "Bitte geben Sie Ihren Namen ein!" );
	    return false;
	} 
if (document.kontaktformular.mail.value == "") 
         {
	    alert( "Bitte geben Sie Ihre eMail-Adresse ein!" );
	    return false;
	} 
        if ( document.kontaktformular.mail.value == "user@provider.suffix"
	|| ! check_mail( new String(document.kontaktformular.mail.value) ) )
 {
	    alert("Die eMail-Adresse ist falsch eingegeben!" );
	    return false;
	} 
if (document.kontaktformular.text.value == "") 
         {
	    alert( "Das Nachrichtenfeld darf nicht leer bleiben!" );
	    return false;
	} 


	return true;

    }
    
    
function fadeIn(id, millisec){
//alert("huhu");
	document.getElementById(id).style.zIndex=4;
	opacity(id,0,100,millisec);
}
function fadeOut(id, millisec){
	opacity(id,100,0,millisec);	
	setTimeout("document.getElementById('" + id + "').style.zIndex=-2",millisec);
}

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
	return true;
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	//object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function einblenden(divID)
{
//alert(divID);
var obj = document.getElementById(divID);
obj.style.visibility="visible";
}
function ausblenden(divID)
{
//alert(divID);
var obj = document.getElementById(divID);
obj.style.visibility="hidden";
} 
    
