function priceFromSelect(selectValue)
{
	var myDiv = document.getElementById('price') ;
		
		if(netto)
		{
//			alert('promotionEnd:'+promotionEnd[selectValue]+(promotionEnd[selectValue] == '')+' priceSelectPromot:'+priceSelectPromot[selectValue]+' date:'+date);
			if((priceSelectPromot[selectValue] > 0) && (promotionStart[selectValue] == '' || promotionStart[selectValue] <= date) && (promotionEnd[selectValue] == '' || promotionEnd[selectValue] > date))
			{
				
				var priceTax = priceSelectTax[selectValue];
				var price = priceSelect[selectValue];
				var pricePromTax=priceSelectPromotTax[selectValue];
				var priceProm=priceSelectPromot[selectValue];
				
				myDiv.innerHTML = '<img src="'+addr+'shared/'+engin+'/img/prom.gif" alt="" />';
					
				if(product_new > 0)
					myDiv.innerHTML +='<img src="'+addr+'shared/'+engin+'/img/newMini.gif" alt="" />';
				
				if(product_recommend > 0)
					myDiv.innerHTML +='<img src="'+addr+'shared/'+engin+'/img/recomMini.gif" alt="" />';	
					
				myDiv.innerHTML += '<div><span class="label">'+ old_label+'</span> <span class="strike"><span class="value">' + priceTax + ' ' + currency + '</span></span></div>' ;
				myDiv.innerHTML += '<div><span class="label">' + brutto_label + '</span> <span class="value">' + pricePromTax + ' ' + currency + '</span></div>' ;
				myDiv.innerHTML += '<div class="without-tax"><span class="label">' + netto_label + '</span> <span class="value">' + priceProm + ' ' + currency +'</span></div>' ;

					
			}
			else	{
					var priceNetto = priceSelect[selectValue];
					var priceBrutto = priceSelectTax[selectValue];
					myDiv.innerHTML = '';
					if(product_new > 0)
						myDiv.innerHTML += '<img src="'+addr+'shared/'+engin+'/img/newMini.gif" alt="" />';
					if(product_recommend > 0)
						myDiv.innerHTML += '<img src="'+addr+'shared/'+engin+'/img/recomMini.gif" alt="" />';
					myDiv.innerHTML +='<div><span class="label">' + brutto_label + '</span> <span class="value">' + priceBrutto + ' ' + currency +'</span></div>';
					myDiv.innerHTML +='<div class="without-tax"><span class="label">' + netto_label + '</span> <span class="value">' + priceNetto + ' ' + currency + '</span></div>';
				}
					
		}else
			{
				var price = priceSelectTax[selectValue];
				
				
			if((priceSelectPromot[selectValue] > 0) && (promotionStart[selectValue] == '' || promotionStart[selectValue] <= date) && (promotionEnd[selectValue] == '' || promotionEnd[selectValue] > date))
				{
					var priceProm=priceSelectPromotTax[selectValue];
					myDiv.innerHTML = '<img src="'+addr+'shared/'+engin+'/img/prom.gif" alt="" />';
					if(product_new>0)
						myDiv.innerHTML += '<img src="'+addr+'shared/'+engin+'/img/newMini.gif" alt="" />';
					if(product_recommend>0)
					   myDiv.innerHTML += '<img src="'+addr+'shared/'+engin+'/img/recomMini.gif" alt="" />';
					
					myDiv.innerHTML += '<div><span class="label">'+ old_label+' </span> <span class="strike"><span class="value">' + price + ' ' + currency + '</span></span></div>' ;
					myDiv.innerHTML += '<div><span class="label">' + price_label + '</span> <span class="value">' + priceProm + ' ' + currency + '</span></div>' ;
							
				}else
					{
					myDiv.innerHTML = '';
					if(product_new>0)
						myDiv.innerHTML += '<img src="'+addr+'shared/'+engin+'/img/newMini.gif" alt="" />';
					if(product_recommend>0)
						myDiv.innerHTML +='<img src="'+addr+'shared/'+engin+'/img/recomMini.gif" alt="" />';

					myDiv.innerHTML += '<div><span class="label">' + price_label + '</span> <span class="value">' + price + ' ' + currency + '</span></div>';
					}
			}
}

function formPlusMinus(parentElement, sign)
{
 inputElement = parentElement.parentNode.getElementsByTagName('input').item(0);

 if(sign == '+' && (arguments.length==2 || (arguments.length>=3 && arguments[2]==(-1)) || (arguments.length>=3 && inputElement.value < arguments[2]))) inputElement.value++; // arguments[2]==(-1) - gdy produkt jest wyczerpany (nie istnieja informacje na jego temat w bazie danych) dajemy wowczas wolna reke administratorowi
 if(sign == '-' && (inputElement.value>1)) inputElement.value--;
}

function validEmail(frm){
    value = frm.elements['email'].value;
    _qfMsg = '';
    var regex = /^((\"[^\"\f\n\r\t\v\b]+\")|([\w\!\#\$\%\&'\*\+\-\~\/\^\`\|\{\}]+(\.[\w\!\#\$\%\&'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))$/;
    if (value == '' || !regex.test(value)) {
       _qfMsg = '- Nie właściwy lub nie isniejący adres e-mail';
       alert(_qfMsg);
       return false;
    }
    return true;
}


function number_format( number, decimals, dec_point, thousands_sep ) {
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: number_format(1234.5678, 2, '.', '');
    // *     returns 1: 1234.57

    var i, j, kw, kd, km;

    // input sanitation & defaults
    if( isNaN(decimals = Math.abs(decimals)) ){
        decimals = 2;
    }
    if( dec_point == undefined ){
        dec_point = ",";
    }
    if( thousands_sep == undefined ){
        thousands_sep = ".";
    }

    i = parseInt(number = (+number || 0).toFixed(decimals)) + "";

    if( (j = i.length) > 3 ){
        j = j % 3;
    } else{
        j = 0;
    }

    km = (j ? i.substr(0, j) + thousands_sep : "");
    kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep);
    kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).slice(2) : "");


    return km + kw + kd;
}


function flashSite(id,adres)
{
 var popup_width = 570;
 var popup_height = 570;
 var flashFile = 'http://www.tomi.e-s.pl/shared/default/swf/popup.swf';

 var margin_left=((screen.width)/2)-(popup_width/2);
 var margin_top=((screen.height)/2)-(popup_height/2);

 var oNewWin = window.open("about:blank","TomiCollection","width="+popup_width+",height="+popup_height+",top="+margin_top+",left="+margin_left+",resizable=0,scrollbars=no,menubar=no,status=no,toolbar=no,location=no,directories=no");
 oNewWin.document.open();
 oNewWin.document.write('<html>');
 oNewWin.document.write('<head>');
 oNewWin.document.write('<title>TomiCollection</title>');
 oNewWin.document.write('<meta name="title" content="TomiCollection" />');
 oNewWin.document.write('<style type="text/css">html,body{background:#2A2A2A; margin:0; padding:0;} img,object{border:none;} .main {height:'+popup_width+'px; width:'+popup_height+'px; position:absolute; top:50%; left:50%; margin-top:-'+(popup_width/2)+'px; margin-left:-'+(popup_height/2)+'px;}</style>');
 oNewWin.document.write('</head>');
 oNewWin.document.write('<body>');
 oNewWin.document.write('<div class="main">');
 oNewWin.document.write('<object width="'+popup_width+'" height="'+popup_height+'" type="application/x-shockwave-flash" data="'+flashFile+'">');
 oNewWin.document.write('<param name="movie" value="'+flashFile+'" />');
 oNewWin.document.write('<param name="FlashVars" value="id='+id+'&address_xml='+adres+'"/>');
 oNewWin.document.write('<param name="bgcolor" value="#000000" /></object>');
 oNewWin.document.write('</div>');
 oNewWin.document.write('</body>');
 oNewWin.document.write('</html>');
 oNewWin.document.close();
}

function handleKeySearch(e) 
{
  e = (!e) ? window.event : e;
  code = (e.charCode) ? e.charCode : ((e.keyCode) ? e.keyCode : ((e.which) ? e.which : 0));
  var sSearchPhrase = document.getElementById('serach_condition').value;

  if (e.type == "keydown") {
    if(code == 13) {
      location.href = sShopAddr + sLangShort + '/Search/' + sSearchPhrase + '/WYSZUKIWARKA/';
    }
  }
}
