// Initialisiert Basic javascript function
var $jq = jQuery.noConflict();

$jq(document).ready(function() {

  /*
   * Initiate Firebug log console
   */
/*  try {
        console.assert(1);
    } catch(e) {
        if (typeof loadFirebugConsole == 'function') {
             loadFirebugConsole();
        }  else {
            console = {
                log: function() {},
                debug: function() {},
                info: function() {},
                warn: function() {},
                assert: function() {}
            }
        }
    }
*/	
  /*
   * Set tooltip properties
   */
	$jq('#tippInfo img, #hotlineInfo img').tooltip({ 
	    delay: 0 ,
	    showURL: false 
	});

	$jq('#myformularwithtooltip img').tooltip({ 
	    delay: 0 ,
	    showURL: false 
	});
	
	$jq('#myformularwithshadowtooltip img').tooltip({ 
	    track: true,
	    delay: 0, 
	    showBody: " ### ", 
	    extraClass: "toptions", 
	    fixPNG: true, 
    	showURL: false
	});
	
	$jq('.sTooltip img').tooltip({ 
      delay: 0 ,
      showBody: "###", 
      extraClass: "toptionsinfo", 
      track: true,
      showURL: false 
  	});

	/*
  	 * Tooltipp in den Tarifoptionen des Warenkorbs
  	 */
  	$jq("td.toptionstooltip").tooltip({ 
  	    track: true,
	    delay: 0, 
	    showBody: " ### ", 
	    extraClass: "toptions", 
	    fixPNG: true, 
    	showURL: false
	}); 
	
	//$jq('#navigationreiter > ul').tabs(  {selected: 1 }); 
	
	/* 
	 * Set Slide UP and Down im Profil
	 */
	
    /* Menu auf und zuklappen  OnMousover - nicht mehr benötigt */
	/*
    $jq("#click_show_sub1").mouseover(function () {
      $jq("#left_menu_sub1").slideDown("normal");
    });
    */
  
  /*
   * Find all the input elements with title attributes
   * and set title value to default value
   */
  $jq(function() {
    $jq('input[title!=""]').hint();
  });

  /*
   * Find all Images and set ALT Tags to empty String
   */
  $jq(function() {
	    $jq('img[alt!=""]').attr('alt','');
	  });

  /*
   * Makes Shopingcart widget open close persistent
   */
  /*
  if($jq.cookie('shopCart',{expires: 7, path: '/'})==1) {
    $jq('a#shoping_cart_icon').attr('title','Warenkorb schließen');
    $jq('#shoping_cart_icon img').attr('src','/images/korb_open.gif');
    $jq('#shoping_cart_icon img').attr('alt','Warenkorb schließen');
    $jq('div.warenkorbOffen').css('display','block');
  } else {
    $jq('a#shoping_cart_icon ').attr('title','Warenkorb öffnen');
    $jq('#shoping_cart_icon img').attr('src','/images/korb_close.gif');
    $jq('#shoping_cart_icon img').attr('alt','Warenkorb öffnen');
    $jq('div.warenkorbOffen').css('display','none');
  }
  */
  
  /*
   * Opens and closes shopingcart widget
   */
  /*
  $jq('#shoping_cart_icon').click(function() {
      $jq('div.warenkorbOffen').slideToggle('slow',function() {
      
        if($jq('div.warenkorbOffen').css('display')=='none') {
          $jq.cookie('shopCart', 0,{expires: 7, path: '/'});
          $jq('a#shoping_cart_icon').attr('title','Warenkorb öffnen');
          $jq('#shoping_cart_icon img').attr('src','/images/korb_close.gif');
          $jq('#shoping_cart_icon img').attr('alt','Warenkorb öffnen');
          
        } 
        else
        {
          $jq.cookie('shopCart',1,{expires: 7, path: '/'});
          
          $jq('a#shoping_cart_icon').attr('title','Warenkorb schließen');
          $jq('#shoping_cart_icon img').attr('src','/images/korb_open.gif');
          $jq('#shoping_cart_icon img').attr('alt','Warenkorb schließen');
        }
      });
  });
  */
  
  /*
   * Im Webshop die MouseoverFunktionalität bei Buttons herstellen
   */
  	$jq("#tarif_mit_handy_bestellen").mouseover(function () {
  		$jq("#tarif_mit_handy_bestellen").attr('src','/images/btn_tarif_mit_handy_bestellen_hover.gif')  ;
    });
  	
  	$jq("#tarif_mit_handy_bestellen").mouseout(function () {
  		$jq("#tarif_mit_handy_bestellen").attr('src','/images/btn_tarif_mit_handy_bestellen.gif')  ;
    });
  	
  	$jq("#tarif_mit_hard_bestellen").mouseover(function () {
  		$jq("#tarif_mit_hard_bestellen").attr('src','/images/btn_tarif_mit_hard_bestellen_hover.gif')  ;
    });
  	
  	$jq("#tarif_mit_hard_bestellen").mouseout(function () {
  		$jq("#tarif_mit_hard_bestellen").attr('src','/images/btn_tarif_mit_hard_bestellen.gif')  ;
    });
  	
  	$jq("#tarif_bestellen").mouseover(function () {
  		$jq("#tarif_bestellen").attr('src','/images/btn_tarif_bestellen_hover.gif')  ;
    });
  	
  	$jq("#tarif_bestellen").mouseout(function () {
  		$jq("#tarif_bestellen").attr('src','/images/btn_tarif_bestellen.gif')  ;
    });
  
  /*
   * Sets the window location if selectboxes onchange
   * in handy overview page
   */
  $jq('select#hersteller').change(function() {
    window.location=$jq('select#hersteller').val();
  });
  
  $jq('select#mobileSelect').change(function() {
  
    if($jq('select#mobileSelect').val().length>0)
    {
      window.location=$jq('select#mobileSelect').val();
    }
  });
  
  $jq('select#tarifAuswahl').change(function() {
  
    if($jq('select#tarifAuswahl').val().length>0)
    {
      window.location=$jq('select#tarifAuswahl').val();
    }
  });
  
  /*
   * Change user to new handydetails page if he change 
   * Marken selection
   */
  $jq('select#markeLink').change(function() {
  
    if($jq('select#markeLink').val().length>0)
    {
      window.location=$jq('select#markeLink').val();
    }  
  });
  
  /*
   * Change user to new handydetails page if he change 
   * Marken selection
   */
  $jq('select#tarifLink').change(function() {
  
    if($jq('select#tarifLink').val().length>0)
    {
      window.location=$jq('select#tarifLink').val();
    }  
  });
  
    /*
   * Change user to new handydetails page if he change 
   * Marken selection
   */
  $jq('select#zuzahlungLink').change(function() {
  
    if($jq('select#zuzahlungLink').val().length>0)
    {
      window.location=$jq('select#zuzahlungLink').val();
    }  
  });
  
 
  
  /* Image Preview in Backoffice for Thumbnails */
  if(typeof window.imagePreview_a == 'function')
  {
    imagePreview_a();
  }
  /* Image Preview in Frontend for Banner */
  if(typeof window.imagePreview_img == 'function')
  {
    imagePreview_img();
  }
  
  
  /**
   * Double check if we've got a function called data adapter
   */
  if(typeof window.dataAdapter == 'function')
  {
    dataAdapter('marke');
  }
});