
jQuery.preloadImages = function()
{
	for(var i = 0; i<arguments.length; i++)
	{
		jQuery("<img>").attr("src", arguments[i]);
	}
}

$.preloadImages("pics/tool_collect.gif", "pics/tool_collect_a.gif","pics/tool_edit_data.gif", "pics/tool_edit_data_a.gif","pics/tool_entry.gif", "pics/tool_entry_a.gif","pics/tool_pdf.gif","pics/tool_pdf_a.gif","pics/tool_print.gif", "pics/tool_print_a.gif","pics/tool_send_data.gif", "pics/tool_send_data_a.gif");

  $(document).ready(function(){
      $("#nav-one li").hover(
         function(){ $("ul", this).fadeIn("fast"); }, 
         function() { } 
      );
   if (document.all) {
         $("#nav-one li").hoverClass ("sfHover");
      }
      
      $('a#toggle').each(function() {
         $(this).toggle(
				function(){ $('div#toggleDiv').fadeIn("slow"); }
         	,function(){ $('div#toggleDiv').fadeOut("slow"); }
      	);
      });
  });
  
   $.fn.hoverClass = function(c) {
      return this.each(function(){
         $(this).hover( 
            function() { $(this).addClass(c);  },
            function() { $(this).removeClass(c); }
         );
      });
   };   
   
   function openLayer(what, attrib, attrib2, attrib3)
   {
      if(what.match(/LOGINKONTAKT/)) {
         $('div#layer_wrapper').load('/module/forms/login_contact.inc.php', {
            ml_projektshort : 'ks_nrw_context'
         });
      } else if (what.match(/LOGINLAYER/)) {
         $('div#layer_wrapper').load('/module/forms/login_layer.inc.php', {
            ml_projektshort : 'ks_nrw_context'
         });
      } else if (what.match(/SENDAFRIEND/)) {
         $('div#layer_wrapper').load('/module/forms/send_a_friend_layer.inc.php', {
            ml_projektshort : 'ks_nrw_context',
            text : attrib2,
            kindOfRequest : attrib3,
            personData : attrib
         });
      } else if (what.match(/NEWSLETTERLAYER/)) {
         if (attrib.value != 'meine-mail@domain.de' && attrib.value != 'my mail@domain.de')
            $('div#layer_wrapper').load('/module/forms/newsletter_layer.inc.php', {
                  emailAddress: attrib.value,
                  ml_projektshort : 'ks_nrw_context'
            });
         else
            $('div#layer_wrapper').load('/module/forms/newsletter_layer.inc.php', {
            ml_projektshort : 'ks_nrw_context'
         });
      }
      
      $('div#layer_wrapper').ready(function(){
         $('div#layer_wrapper').slideDown('slow');
      });
      showAjaxWaitDialog(true, 'layer_wrapper');
   }
  
   
   function setLanguage( idLanguage ) 
   {
      var url = LINK_ROOT+"-/"+pos+firstUrlString+"&amp;idLanguage=" + idLanguage;
      parent.document.location.replace( url )
   }
   function setLanguageAndPage( idLanguage, page ) 
   {
      var url = LINK_ROOT+"?"+page+secondUrlString+"&amp;idLanguage=" + idLanguage;
      parent.document.location.replace( url )
   }
   
   
   
   function changeContentHeight()
   {  
   /*
      if( document.getElementsByTagName("body")[0].offsetWidth > 1024 )
           document.getElementsByTagName("body")[0].style.width = "1024px";
      else
           document.getElementsByTagName("body")[0].style.width = "";
      //height = window.innerHeight ? window.innerHeight : document.body.offsetHeight
   */
   
      /* breite des content relativ */      
      width =  window.innerWidth ? window.innerWidth : document.body.offsetWidth
      if( document.getElementById("content_wrapper") )
         document.getElementById("content_wrapper").style.width = (width-212) + "px";
      
      /* h?he des content relativ */   
      bodyHeight = window.innerHeight ? window.innerHeight : document.body.offsetHeight
      height = bodyHeight - changeContentHeight.vMargin
      
      if ( document.getElementById( "content_wrapper" ) ) 
         document.getElementById( "content_wrapper" ).style.height = height + "px";
      
      /*abstand unten*/   
      if( document.getElementById("left_box_inner") )
         document.getElementById("left_box_inner").style.height = (bodyHeight-19) + "px";   
      if( document.getElementById("leftDetailPic") )
         document.getElementById("leftDetailPic").style.height = (bodyHeight-19) + "px";   
      if( document.getElementById("html_wrapper_inner") )
         document.getElementById("html_wrapper_inner").style.height = (bodyHeight-19) + "px";
         
      if( document.getElementById("nav-one") )
      { 
         if(document.all)
         {        
            /*      
            */
         }else
         {
            if ( document.getElementById("nav-one").offsetWidth > 791 ) //nav-verteilung relativ
               document.getElementById("logo_ks").style.marginLeft = (document.getElementById("nav-one").offsetWidth-808)+"px";
            else
               document.getElementById("logo_ks").style.marginLeft = "0px";
         }       
      }
      
   }
   changeContentHeight.vMargin = 150
   
   init = window.init || []
   window.onresize = changeContentHeight
   
   window.onload = function() {
   for ( var i = 0; i < init.length; ++i )
     init[i]()
   }
   
   function displayImage(url,w,h, title, copyright, photographer, description)
   {
      var params='dependent=yes,scrollbars=auto,toolbar=no,resizable=yes';
      if(typeof w=="undefined"||w>775)
         w=775;
      if(typeof h=="undefined"||h>560)
         h=560;
      params+=',width='+(w+25)+',height='+(h+45);
      var address = encodeURI('popup.pic.php?url='+url+'&amp;title='+title+'&amp;copyright='+copyright+'&amp;photographer='+photographer+'&amp;description='+description);
      if(top.imageWindow)
         top.imageWindow.close();
      top.imageWindow=window.open(address,'KsNRWImage',params);
      top.imageWindow.focus();
   }

