//satelliten links in extra fenster
    function tellafriend (url) {
    	fenster = window.open(url, "tellafriend", "width=387,height=436,top=200, left=400, resizable=yes");
     	fenster.focus();
     	return false;
    }
    function kontakt (url) {
    	fenster = window.open(url, "kontakt", "width=310,height=610,top=200, left=400, resizable=yes");
     	fenster.focus();
     	return false;
    }
    function presse (url) {
    	fenster = window.open(url, "presse", "width=384,height=358,top=200, left=400, resizable=yes");
     	fenster.focus();
     	return false;
    }
    function agb (url) {
    	fenster = window.open(url, "agb", "width=588px,height=495px,top=200, left=400, scrollbars=yes,resizable=yes");
     	fenster.focus();
     	return false;
    }
    function impressum (url) {
    	fenster = window.open(url, "impressum", "width=421,height=424,top=200, left=400, resizable=yes");
     	fenster.focus();
     	return false;
    }

    function disclaimer (url) {
    	fenster = window.open(url, "disclaimer", "width=588px,height=495px,top=200, left=400, scrollbars=yes,resizable=yes");
     	fenster.focus();
     	return false;
    }
    function datenschutz (url) {
    	fenster = window.open(url, "datenschutz", "width=588px,height=495px,top=200, left=400, scrollbars=yes,resizable=yes");
     	fenster.focus();
     	return false;
    }

    function verbraucherinformation (url) {
    	fenster = window.open(url, "verbraucherinformation", "width=620px,height=495px,top=200, left=400, scrollbars=yes,resizable=yes");
     	fenster.focus();
     	return false;
    }

//------------------------------------------------

//---Preloader Menu-------------------------------
jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

$.preloadImages("img/menu6_off.png", "img/menu6_hover.png","img/menu12_off.png", "img/menu12_hover.png","img/menu24_off.png", "img/menu24_hover.png","img/topmenu/berat_off.png","img/topmenu/berat_hover.png","img/topmenu/berat_act.png","img/topmenu/gewerb_off.png","img/topmenu/gewerb_hover.png","img/topmenu/gewerb_act.png","img/topmenu/start_off.png","img/topmenu/start_hover.png","img/topmenu/start_act.png","img/topmenu/tipps_off.png","img/topmenu/tipps_hover.png","img/topmenu/tipps_act.png");

//rollover der menus-----------------------------
function imgSwap(oImg)
{
   var strOver  = "_hover"    // image to be used with mouse over
   var strOff = "_off"     // normal image
   var strImg = oImg.src
   if (strImg.indexOf(strOver) != -1) 
      oImg.src = strImg.replace(strOver,strOff)
   else
      oImg.src = strImg.replace(strOff,strOver)
}
//------------------------------------------------

window.onload=function() {document.contactform.reset();};
//---formular clear

      $.fn.clearForm = function() {
          return this.each(function() {
            var type = this.type, tag = this.tagName.toLowerCase();
            if (tag == 'form')
              return $(':input',this).clearForm();
            if (type == 'text' || tag == 'textarea')
              this.value = '';
            else if (type == 'checkbox' || type == 'radio')
              this.checked = false;
            else if (tag == 'select')
              this.selectedIndex = -1;
          });
        };    


//dropdownbox kontakt
  $(document).ready(function(){
    
    $(".push").click(function () {
      if ($("#michael").is(":hidden")) {
        $("#michael").slideDown("slow",
        	function callback(){
	        	$("#kontakta").fadeIn("slow" 		
	        	);
			});
        
     	        					
      } else {
      	$("#kontakta").fadeOut("slow",
      	function callback2(){
      		$("#michael").slideUp("slow"
      			      		);  
      	}
      	);
 		
      }
    });

  });


        jQuery(document).ready(function(){

            $('#contactform').submit(function(){

                var action = $(this).attr('action');

                $('#submit')
                .before('<img src="img/ajax-loader.gif" class="loader" />')
                .attr('disabled','disabled');

                $.post(action, { 
                    Anrede: $('input[name=Anrede]:checked').val(),
                    Vorname: $('#Vorname').val(),
                    Nachname: $('#Nachname').val(),
                    email: $('#email').val(),
                    Strasse: $('#Strasse').val(),
                    Nr: $('#Nr').val(),
                    Plz: $('#Plz').val(),
                    Wohnort: $('#Wohnort').val(),
                    Gasversorger: $('#Energieanbieter').val(),
                    Jahresverbrauch: $('#Jahresverbrauch').val(),
                    Nachricht: $('#message').val()
                },
                function(data){
                    $('#contactform #submit').attr('disabled','');
                    $('.response').remove();
                    $('#contactform ol #responsemarker').before('<span class="response"><p>'+data+'<\/p><\/span>');
                    $('.response').slideDown();
                    $('#contactform img.loader').fadeOut(500,function(){$(this).remove()});
                    if(data=='Nachricht wurde gesendet') {
                    $('#michael').animate({opacity:1.0}, 3000).slideUp('slow');
                    $('form').clearForm()
                    }
                }
          
            );

                return false;

            });

        });
        
    

//------------------------------------------------

//Popup Layer

        jQuery(document).ready(function($) {
            $('a[rel*=facebox]').facebox({
                loading_image : 'loading.gif',
            	close_image   : 'closelabel.gif'
            }) 
        })
//------------------------------------------------   

/* Copyright (c) 2006 Mathias Bank (http://www.mathias-bank.de)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * 
 * Thanks to Hinnerk Ruemenapf - http://hinnerk.ruemenapf.de/ for bug reporting and fixing.
 */
jQuery.extend({
 getURLParam: function(strParamName){
	  var strReturn = "";
	  var strHref = window.location.href;
	  var bFound=false;
	  
	  var cmpstring = strParamName + "=";
	  var cmplen = cmpstring.length;

	  if ( strHref.indexOf("?") > -1 ){
	    var strQueryString = strHref.substr(strHref.indexOf("?")+1);
	    var aQueryString = strQueryString.split("&");
	    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
	      if (aQueryString[iParam].substr(0,cmplen)==cmpstring){
	        var aParam = aQueryString[iParam].split("=");
	        strReturn = aParam[1];
	        bFound=true;
	        break;
	      }
	      
	    }
	  }
	  if (bFound==false) return null;
	  return strReturn;
	}
});             
