  openCalc = function() {
    if($('#qclc').val() > 0) {
    $('#sclc').attr('href','/kalkulatory/?id=' + $('#qclc').val());
    $('#sclc').click();
    $('#qclc').val('0');
    }
    //qclc
  }
  
  
  
  function ccena() {

  }
  
		// initialise plugins
		jQuery(function(){
		
		
  		$('.neqt .il').live('change', function() {
				 ccena();
		});
		
  		$('.neqt .cn').live('change', function() {
				 ccena();
		});
		
			jQuery('ul.sf-menu').superfish({
            delay:       100,                            // one second delay on mouseout
            animation:   {height:'show'},  // fade-in and slide-down animation
            speed:       'normal',                          // faster animation speed
            autoArrows:  false,                           // disable generation of arrow mark-up
            dropShadows: true                            // disable drop shadows
        });

			jQuery('ul.sf-menu2').superfish({
            delay:       100,                            // one second delay on mouseout
            animation:   {height:'show'},  // fade-in and slide-down animation
            speed:       'normal',                          // faster animation speed
            autoArrows:  false,                           // disable generation of arrow mark-up
            dropShadows: true                            // disable drop shadows
        });

        jQuery('#recommends-ul').jcarousel({
            size: $('#recommends-ul li').length,
            scroll: 1,
            auto: 3
        });


				$('ul#logos').innerfade({
						speed: 1000,
						timeout: 5000,
						type: 'sequence',
						containerheight: '50px'
				});

			$("#sclc").fancybox({
     'width':638,
     'height':480,
     'autoScale'         : false,
     'transitionIn'      : 'elastic',
     'transitionOut'     : 'elastic',
     'type'          : 'iframe'
			});
$('#waitPage').hide('fast');

$('.zmim').tooltip({
    delay: 0,
    showURL: false,
    bodyHandler: function() {
        return '<img src="'+$(this).attr('rel')+'">';
    }
});


				var replaceElements = $('.offer-box');

				for (q = 0; q < replaceElements.length; q++) {
          //$().html('asws');
          //$(replaceElements[q]).attr('id')
          //alert($(replaceElements[q]).attr('id'));

          var productName = $('#'+$(replaceElements[q]).attr('id')+ ' .details .product-name').html();
          var productUrl = $('#'+$(replaceElements[q]).attr('id')+ ' .details .product-name').attr('href');
          var productSymbol = $('#'+$(replaceElements[q]).attr('id')+ ' .details .product-symbol em').html();
          var productPrice = $('#'+$(replaceElements[q]).attr('id')+ ' .details .product-price strong').html();
          if (productPrice == '0.00') {
          	productPrice = 'Wycena indywidualna';
          }
          var productPriceStrike = $('#'+$(replaceElements[q]).attr('id')+ ' .details .product-price strike').html();
          if (productPriceStrike == null) {
            productPriceStrike = '';
          }
                    productName = productName.replace('"','`');
          productName = productName.replace('"','`');  
          swfobject.embedSWF("/static/swf/offerBox.swf", 'det'+$(replaceElements[q]).attr('id'), "162", "99", "9.0.0", "expressInstall.swf", { productUrl: productUrl, productName: productName, productSymbol: escape('Symbol: <font color="#838a91">'+productSymbol+'</font>'), productPrice: productPrice, productPriceStrike: productPriceStrike  }, {wmode: 'transparent'});
        }

          swfobject.embedSWF("/static/swf/tq.swf", 'spla', "640", "207", "9.0.0", "expressInstall.swf", { xml_file: '/static/swf/sample.xml'  }, {wmode: 'transparent'});



				var replaceElements = $('.offer-box-full');

				for (q = 0; q < replaceElements.length; q++) {
          //$().html('asws');
          //$(replaceElements[q]).attr('id')
          //alert($(replaceElements[q]).attr('id'));

          var productName = $('#'+$(replaceElements[q]).attr('id')+ ' .details .product-name').html();
          var productUrl = $('#'+$(replaceElements[q]).attr('id')+ ' .details .product-name').attr('href');
          var productSymbol = $('#'+$(replaceElements[q]).attr('id')+ ' .details .product-symbol em').html();
          var productPrice = $('#'+$(replaceElements[q]).attr('id')+ ' .details .product-price strong').html();
          if (productPrice == '0.00') {
          	productPrice = 'Wycena indywidualna';
          }
          var productPriceStrike = $('#'+$(replaceElements[q]).attr('id')+ ' .details .product-price strike').html();
          if (productPriceStrike == null) {
            productPriceStrike = '';
          }
          productName = productName.replace('"','`');
          productName = productName.replace('"','`');          
          
          swfobject.embedSWF("/static/swf/offerBoxFull.swf", 'det'+$(replaceElements[q]).attr('id'), "492", "99", "9.0.0", "expressInstall.swf", { productUrl: productUrl, productName: productName, productPrice: productPrice, productPriceStrike: productPriceStrike, productSymbol: escape('Symbol: <font color="#838a91">'+productSymbol+'</font>')  }, {wmode: 'transparent'});
        }


        swfobject.embedSWF("/static/swf/customers.swf", 'customersa', "340", "120", "9.0.0", "expressInstall.swf", {  }, {wmode: 'transparent'});

        swfobject.embedSWF("/static/swf/h1.swf?a", 'ng', "450", "52", "9.0.0", "expressInstall.swf", { etykieta: $('#ng').attr('rel') }, {wmode: 'transparent'});

        var h3elements = $('h3.ng-h3-flash');

        for (w = 0; w < h3elements.length; w++) {
          var etykieta = $(h3elements[w]).html();
          etykieta = etykieta.replace('"','`');
          etykieta = etykieta.replace('"','`');  
          $(h3elements[w]).html('<span id="en'+$(h3elements[w]).attr('id')+'"></span>')
          swfobject.embedSWF("/static/swf/h3.swf?", 'en'+$(h3elements[w]).attr('id'), "320", "22", "9.0.0", "expressInstall.swf", { etykieta: etykieta }, {wmode: 'transparent'});

        }

        var h3elements = $('h3.ng-arrows');

        for (w = 0; w < h3elements.length; w++) {
          var etykieta = $(h3elements[w]).html();
          etykieta = etykieta.replace('"','`');
          etykieta = etykieta.replace('"','`');
          $(h3elements[w]).html('<span id="en'+$(h3elements[w]).attr('id')+'"></span>')
          swfobject.embedSWF("/static/swf/h3.swf?", 'en'+$(h3elements[w]).attr('id'), "320", "22", "9.0.0", "expressInstall.swf", { etykieta: etykieta }, {wmode: 'transparent'});

        }

		});



		sendForm = function() {
		  $('.szapytanie-status').html('Przesyłanie formularza. Proszę czekać.');
      $('.szapytanie-status').show('sexy');
      $('.szapytanie-status').removeClass('szapytanie-status-err');
      $.ajax({
         type: "POST",
         url: "/kontakt/wyslij",
         data: "imie_nazwisko="+$('#eimie_nazwisko').val()+"&firma="+$('#efirma').val()+"&email="+$('#eemail').val()+"&telefon="+$('#etelefon').val()+"&tresc="+$('#etresc').val()+"",
         success: function(msg){

           if (msg == 'ER') {
            $('.szapytanie-status').html('Wypełnij poprawnie wszystkie pola.');
            $('.szapytanie-status').addClass('szapytanie-status-err');
            $('.szapytanie-status').show('sexy');
           } else {
            $('.szapytanie-status').html('Formularz został poprawnie wysłany.');
            $('.szapytanie-status').show('sexy');
            $('.szapytanie').hide('sexy');
           }
         }
       });

       return false;
    }




addItem = function() {
  arrRows = $('#otable .row');
  className = '';

  if ($(arrRows[arrRows.length-1]).hasClass('hv')) { className =''; }
  else {className ='hv';  }
  //new Insertion.Before('olastrow', '<tr id="row'+arrRows.length+'" class="row '+ className +'">'+$('nnum').innerHTML.replace('nnum', arrRows.length).replace('nkc', arrRows.length).replace('nkh', arrRows.length)+'</tr>');
  $('#olastrow').before('<tr id="row'+arrRows.length+'" class="neqt row '+ className +'">'+$('#nnum').html().replace('nnum', arrRows.length).replace('nkc', arrRows.length).replace('nkh', arrRows.length)+'</tr>');
  reloadNum();
  return false;
}

clearInput = function(element) {
  if (element.value == ' - ') {
  element.value = '';
  }
}

checkOther = function (element, toggle) {
  if (element[element.selectedIndex].value == "inne") {
    $(toggle).style.display = '';
  }
  else {
    $(toggle).style.display = 'none';
  }
}

removeRow = function(nnum) {
  if ($('#row' + nnum) ) {
    $('#row' + nnum).remove();
  }
  reloadNum();
}

reloadNum = function () {
    arrRows = $('#otable .row');
    p = 1;
    for (i = 0; i < arrRows.length; i++) {
      if ($(arrRows[i]).attr('id') != 'nnum') {
      //  if ($(arrRows[i]).attr('id').replace('row', 'pos'))) {
          $(arrRows[i]).attr('id').replace('row', 'pos').innerHTML = p;
      //  }
        p++;
      }
    }
}
