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));
  if( document.getElementById('serach_condition').value != '')
    var sSearchPhrase = document.getElementById('serach_condition').value;
  /*var sSearchNarrow = document.getElementById('search_narrow_condition').value;*/
  
  if (e.type == "keydown") {
	if(code == 13) {
	  location.href = sShopAddr + sLangShort + '/Search/' + sSearchPhrase + '/Wyszukiwanie/';
      //document.search_form_basic.submit;
	}
  }
}
function doNothing() {}
function setBoxVisible(_this, sId) {
	
    var domH1 = $$('#idBottomBox a');
	
	$A(domH1).each(function(dom){
		dom.removeClass('title-visible');
		dom.addClass('title-hidden');
	});
	
	var domCont = $$('#idBottomBox .content');
	$A(domCont).each(function(dom){
		dom.removeClass('content-visible');
		dom.addClass('content-hidden');
	});
	
	_this.removeClass('title-hidden');
	_this.addClass('title-visible');
	
	$(sId).removeClass('content-hidden');
	$(sId).addClass('content-visible');
}
/*function showHide(aShow, aHide){
	
	var i=0;
	if(aHide.length>0)
	for each (var item in aHide) {
	  var id = "";
	  id = String(item);
	  document.getElementById(id).style.display = 'none';
	}
	
	if(aShow.length>0)
	 for each (var item in aShow) {
	  document.getElementById(item).style.display = 'block';
	}
} */
/*
function show(id){
	
	if($(id) != null)
	$(id).style.display = 'block';
}
function hide(id){
	if($(id) != null)
	$(id).style.display = 'none';
	
}
*/
function show(id){
	
	if($(id) != null)
	$(id).disabled = false;
}
function hide(id){
	if($(id) != null)
	$(id).disabled = true;
}
function uncheckOption(id){
    
    if($(id) != null)
    
    $(id).checked = false;
    
}
function isPersonalPickup(id,hideID){
    
    if($(id).checked == true && $(id).value == 5){
        $(hideID).checked = false;
        $(hideID).disabled = true;
    }
    else{
        $('deliveryType3').checked = false;
        $('deliveryType3').disabled = true;    
    }
    
}
function checkOptionValue(inputObj){
	var objLength = inputObj.length;
	if(objLength == undefined){
		if(inputObj.checked)
			return inputObj.value;
		else
			return "";
	}else{
		for(var i = 0; i < objLength; i++) {
			if(inputObj[i].checked) {
				return inputObj[i].value;
			}
		}
	}
	return "";
}
function print_r(theObj,indent){
      var output="";
      if (indent == undefined) { indent = "  "; } else { indent += "  "; }
      if(theObj.constructor == Array || theObj.constructor == Object) {
        for(var p in theObj){
          if(theObj[p].constructor == Array|| theObj[p].constructor == Object){
              var type = (theObj[p].constructor == Array) ? "Array" : "Object";
              output += indent+"["+p+"]("+type+")=>\n";
              output += print_r(theObj[p],indent);
          } else { output += indent+"["+p+"]:"+theObj[p]+"\n"; }
        }
      }
      return output;
  }
 
function fontSize(id, size){
	
	 if($(id) != null)
	 $(id).style.fontSize = size+'px';
}
function showHideSiteMapBranch(id){
    if($('childrenOf'+id) != null && $('picture'+id) != null){
        
        if($('childrenOf'+id).style.display=='none'){
            
            $('picture'+id).src = sShopAddr+'shared/'+sSmartyEngine+'/img/site-map-minus.gif';
            $('childrenOf'+id).style.display='block';
            $('category'+id).style.fontWeight='bold';  
            $('category'+id).style.color='#0066b3';   
        } 
        else{
            $('picture'+id).src = sShopAddr+'shared/'+sSmartyEngine+'/img/site-map-plus.gif';
            $('childrenOf'+id).style.display='none';
            $('category'+id).style.fontWeight='normal';  
            $('category'+id).style.color='#9F9F9F';        
        }
        
    }
}
function set_right_menu_height(additionalHeight,elementId){
    var left_height = document.getElementById('main_page_left').offsetHeight;
    var right_height = document.getElementById('menu_right').offsetHeight;
                        //alert("left_height" + left_height);
                        //alert("right_height" + right_height);
    if(left_height>right_height){
        var l_h = left_height - 27;
        /*if(l_h>=1000){
            l_h = l_h + additionalHeight+2;
        }
        else{
            l_h = l_h + additionalHeight;
        }*/
        document.getElementById('menu_right').style.height=(l_h) + "px" ;
    }
    else{
        var r_h = right_height - 134;
        /*if(l_h>=1000){
            r_h = r_h + additionalHeight+2;
        }
        else{
            r_h = r_h + additionalHeight - 94;
        }*/
        document.getElementById('page_content').style.height=(r_h) + "px" ;
    }
        
}
function submit_form(formId){
    if($(formId).onsubmit())
        {//this check triggers the validations
           $(formId).submit();
        }
}
function submit_form_by_name(formName){ 
    if(document.formName.onsubmit())
     {//this check triggers the validations
        alert(formName);
        document.formName.submit();
     }
}
function showProductListBox(box,content){
    
    $('new_btn').removeClass('new_btn_active');    
    $('announcement_btn').removeClass('announcement_btn_active');
    $('promotion_btn').removeClass('promotion_btn_active');
    $('new_content').removeClass('new_content_active');    
    $('announcement_content').removeClass('announcement_content_active');
    $('promotion_content').removeClass('promotion_content_active');
    
    $('new_btn').removeClass('new_btn_unactive');    
    $('announcement_btn').removeClass('announcement_btn_unactive');
    $('promotion_btn').removeClass('promotion_btn_unactive');
    $('new_content').removeClass('new_content_unactive');    
    $('announcement_content').removeClass('announcement_content_unactive');
    $('promotion_content').removeClass('promotion_content_unactive');
    
    if(box == 'new_btn'){
        $('new_btn').addClass('new_btn_active');    
        $('announcement_btn').addClass('announcement_btn_unactive');
        $('promotion_btn').addClass('promotion_btn_unactive');
        $('new_content').addClass('new_content_active');    
        $('announcement_content').addClass('announcement_content_unactive');
        $('promotion_content').addClass('promotion_content_unactive');
    }
    if(box == 'announcement_btn'){
        $('new_btn').addClass('new_btn_unactive');    
        $('announcement_btn').addClass('announcement_btn_active');
        $('promotion_btn').addClass('promotion_btn_unactive');
        $('new_content').addClass('new_content_unactive');    
        $('announcement_content').addClass('announcement_content_active');
        $('promotion_content').addClass('promotion_content_unactive');
    }
    if(box == 'promotion_btn'){
        $('new_btn').addClass('new_btn_unactive');    
        $('announcement_btn').addClass('announcement_btn_unactive');
        $('promotion_btn').addClass('promotion_btn_active');
        $('new_content').addClass('new_content_unactive');    
        $('announcement_content').addClass('announcement_content_unactive');
        $('promotion_content').addClass('promotion_content_active');
    }
    
}
function toggle(div_id) {
    var el = document.getElementById(div_id);
    if ( el.style.display == 'none' ) {    el.style.display = 'block';}
    else {el.style.display = 'none';}
}
function blanket_size(popUpDivVar) {
    if (typeof window.innerWidth != 'undefined') {
        viewportheight = window.innerHeight;
    } else {
        viewportheight = document.documentElement.clientHeight;
    }
    if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
        blanket_height = viewportheight;
    } else {
        if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
            blanket_height = document.body.parentNode.clientHeight;
        } else {
            blanket_height = document.body.parentNode.scrollHeight;
        }
    }
    
    //var popup_size = document.documentElement.clientHeight;
    
    var blanket = document.getElementById('blanket');
    blanket.style.height = blanket_height + 'px';
    var popUpDiv = document.getElementById(popUpDivVar);
    popUpDiv_height=blanket_height/2-450;//150 is half popup's height
    popUpDiv.style.top = popUpDiv_height + 'px';
}
function window_pos(popUpDivVar) {
    if (typeof window.innerWidth != 'undefined') {
        viewportwidth = window.innerHeight;
    } else {
        viewportwidth = document.documentElement.clientHeight;
    }
    if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
        window_width = viewportwidth;
    } else {
        if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
            window_width = document.body.parentNode.clientWidth;
        } else {
            window_width = document.body.parentNode.scrollWidth;
        }
    }
    
    var popUpDiv = document.getElementById(popUpDivVar);
    window_width=window_width/2-225;//150 is half popup's width
    popUpDiv.style.left = window_width + 'px';
}
function popup(windowname) {
    blanket_size(windowname);
    window_pos(windowname);
    toggle('blanket');
    toggle(windowname);
            
    
}
function getPosition(e) {
    e = e || window.event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    } 
    else {
        var de = document.documentElement;
        var b = document.body;
        cursor.x = e.clientX + 
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY + 
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
    return cursor;
}
function showHideSiteMapBranchPages(id){
    
    if($('pageChildrenOf'+id) != null && $('pagePicture'+id) != null){
            
        if($('pageChildrenOf'+id).style.display=='none'){
            $('pagePicture'+id).src = sShopAddr+'shared/'+sSmartyEngine+'/img/site-map-minus.gif';
            $('pageChildrenOf'+id).style.display='block';  
            $('page'+id).style.fontWeight='bold';  
            $('page'+id).style.color='#0066b3';  
        } 
        else{
            $('pagePicture'+id).src = sShopAddr+'shared/'+sSmartyEngine+'/img/site-map-plus.gif';
            $('pageChildrenOf'+id).style.display='none';
            $('page'+id).style.fontWeight='normal';  
            $('page'+id).style.color='#9F9F9F';    
        }
        
    }
}