// JavaScript Document
fsnd_statistics = new Image(1,1);
fsnd_single_page = new Image(1,1);
fsnd_statistics.src = "http://counter.fsnd.de/add_stats.php?id=71&pwd=vierzehn"+"&refer="+escape(document.referrer)+"&scrd="+screen.colorDepth+"&scrw="+screen.width+"&doc_url="+document.URL;
fsnd_single_page.src = "http://counter.fsnd.de/single_page.php?id=71&pwd=vierzehn&url="+document.URL;

var showBackGround = true;
var mobileSafari = false;
var initLightbox = true;
var showNews = false;
var showAccordion = true;
var agent = navigator.userAgent.toLowerCase();
var version = navigator.appVersion.toLowerCase();
var bgImage = '/fileadmin/templates/images/background/Kennwort.jpg';

/*
alert( "navigator.userAgent: " + navigator.userAgent +
	   "\nnavigator.appVersion: " + navigator.appVersion + 
	   "\nnavigator.appMinorVersion: " + navigator.appMinorVersion );
*/
if( ( agent.indexOf('iphone') !=-1 ) || ( agent.indexOf('ipad') !=-1 ) ||
	( version.indexOf('iphone') !=-1 ) || ( version.indexOf('ipad') !=-1 ) )
{
	mobileSafari = true;
	//alert("Mobile Safari!");
}

function startup()
{
	//location.hash = 'currentPage';
}

function ie_reload()
{
	//alert("reload for IE");
	if( init )
	{
		//location.reload(true);
		//window.history.go(0);
		//window.location.replace(window.location.href); 
		init = false;
	}
}

/* mail functions */
function checkemail( pEmail )
{
  if( pEmail.indexOf('@') == -1) 
  {
    return false;
  }
  if(pEmail.indexOf('.') == -1) 
  {
    return false;
  }
  return true;
}

function chkForm() 
{
  if (document.sendmail.Nachname.value == "") 
  {
    alert( "Please enter your name!" );
    document.sendmail.Nachname.focus();
    return false;
  }
  if (document.sendmail.Email.value == "") 
  {
    alert( "Please enter your email address!" );
    document.sendmail.Email.focus();
    return false; 
  }
  if( !checkemail( document.sendmail.Email.value ) )
  { 
  	alert( "The email address you entered does not seem to be valid!" );
	document.sendmail.Email.focus();
	return false; 
  }
  
  if (document.sendmail.Comment.value == "") 
  {
    alert( "Please enter a message!" );
    document.sendmail.Comment.focus();
    return false;
  }
  
  if (document.sendmail.captcha.value == "") 
  {
    alert( "Please enter the code in the image!" );
    document.sendmail.captcha.focus();
    return false;
  }
  
  return true;
}

var j = jQuery.noConflict();

function initLightBox()
{
	j(".lightbox").lightbox( {navbarOnTop: 0, resizeSpeed: 300, overlayOpacity: 0.4, strings : { prevLinkTitle: "vorheriges Bild", nextLinkTitle: "nächstes Bild", prevLinkText:  "&laquo;&nbsp;&nbsp;", nextLinkText:  "&nbsp;&nbsp;&raquo;",closeTitle: "schließen", image: "Bild", of: "von"}});
}

j(document).ready(function()
{
	if( showBackGround )
	{
		  //  Initialize Backgound Stretcher
		  j(document).bgStretcher({ images: [bgImage], imageWidth: 1024, imageHeight: 768 });
	}
	if( showNews )
	{
		 j("#news").easySlider({prevId:'prevSlide',nextId:'nextSlide',firstShow:false,auto:true,nextText:'',prevText:'',pause:2000});
	}
	if( showAccordion )
	{
		//j("#referenz").easySlider({prevId:'prevSlide',nextId:'nextSlide',firstShow:true,nextText:'',prevText:''});
		
		j(function() {
					  j("#referenzen").accordion({ autoHeight: false, 
												   active: false, 
												   collapsable: true, 
												   event: 'mouseover', 
												   animated: 'bounceslide' });
					 });
		
	}
	if( initLightbox )
	{
		initLightBox();
	}
});
