function goLang(id) {document.getElementById("sendLang").value = id;}
function changeSFDesign(design) {$('#thDesign').val(design);}
/**
 * pager
 */
// udalost na spodnim pageru, vyvola stejnou na hornim
function subpager_change(idcko) {
	copy_values(true);
	$('#enable_jump').val(1);
	var new_id = idcko.substr(0, idcko.length - 1);
	if (idcko == "on_page_products2") { change_count(true); } 
	else if (idcko == "submitak2") { pager(document.getElementById('to_page').value); } 
	else { eval(document.getElementById(new_id).href); }
}
// zkopiruje spodni pager na horni, nebo naopak
function copy_values(up) {
	var idcka_horni = new Array("", "");
	if (up == true) {
		document.getElementById("on_page_products").selectedIndex = document.getElementById("on_page_products2").selectedIndex;
		document.getElementById("to_page").value = document.getElementById("to_page2").value;
	} else {
		document.getElementById("on_page_products2").selectedIndex = document.getElementById("on_page_products").selectedIndex;
		document.getElementById("to_page2").value = document.getElementById("to_page").value;
		document.getElementById("product_count2").innerHTML = document.getElementById("product_count").innerHTML;
		document.getElementById("actual_page_text2").innerHTML = document.getElementById("actual_page_text").innerHTML;
		document.getElementById("number_of_pages_text2").innerHTML = document.getElementById("number_of_pages_text").innerHTML;
	}
}
function next() { var hodn = parseInt(document.getElementById("actual_page").value) + 1; pager(hodn);}
function previous() { var hodn = parseInt(document.getElementById("actual_page").value) - 1; pager(hodn);}
function change_count() { refresh_count(parseInt(document.getElementById("product_count").innerHTML)); reset_to_first_page(); my_blur(); pager(1);}
function reset_to_first_page() { document.getElementById("actual_page").value = 1; document.getElementById("actual_page_text").innerHTML = "1";}
function my_blur() { document.getElementById("submitak").focus(); }
function refresh_count(product_count, on_page_products) {
	if (!on_page_products) {
		poc = document.getElementById("on_page_products"); on_page_products = poc.options[poc.selectedIndex].value;
	} else {
		select_obj = document.getElementById("on_page_products");
		for (i = 0; i < select_obj.options.length; i++) {
			if (parseInt(select_obj.options[i].innerHTML) == on_page_products) { select_obj.options[i].selected = true;} 
			else { select_obj.options[i].selected = false; }
		}
	}
	document.getElementById("product_count").innerHTML = product_count;
	document.getElementById("product_count2").innerHTML = product_count;
	pocet_stran = Math.ceil(product_count / on_page_products);
	document.getElementById("number_of_pages").value = pocet_stran;
	if (pocet_stran != 0) {
		document.getElementById("number_of_pages_text").innerHTML = pocet_stran;
		document.getElementById("number_of_pages_text2").innerHTML = pocet_stran;
	} else {
		document.getElementById("number_of_pages_text").innerHTML = "1";
		document.getElementById("number_of_pages_text2").innerHTML = "1";
	}
}
function pager(page) {
	if (!page) page = document.getElementById("actual_page").value;
	page = parseInt(page);
	if (isNaN(page)) page = 1;	
	window.location.hash = page;		
   if (page > parseInt(document.getElementById("number_of_pages").value) || page <= 0) return;
	poc = document.getElementById("on_page_products");
	pocet = poc.options[poc.selectedIndex].value;
	dataSource = url + "inc/ajax/apager.php?actual_page=" + page + "&count=" + pocet + "&preurl=" + url;
	
	$.get(url + "inc/ajax/apager.php", {'actual_page': page, 'count':pocet, 'preurl': url}, function(data){
    var products = data;
		document.getElementById("products").innerHTML = products; document.getElementById("actual_page_text").innerHTML = page;
		document.getElementById("actual_page").value = page; copy_values(false);
               /* setTimeout (init_promo(), 2000);*/
    set_pager_url();
    var pos = $("#products").position();
    window.scrollTo(pos.left,pos.top-100);
  });
	
/*	if(XMLHttpRequestObject) {
    	XMLHttpRequestObject.open("GET", dataSource, true);
    	XMLHttpRequestObject.onreadystatechange = function()
 		{
			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
				var products = XMLHttpRequestObject.responseText;
				document.getElementById("products").innerHTML = products; document.getElementById("actual_page_text").innerHTML = page;
				document.getElementById("actual_page").value = page; copy_values(false);
               /* setTimeout (init_promo(), 2000);*/
  //              set_pager_url();
		//	}
	//	}
//		XMLHttpRequestObject.send(null);
//	}
	 /*if($('#enable_jump') && $('#enable_jump').val() == 1)
    {window.scrollTo(0,450);
    $('#enable_jump').val(0);}*/
   
    
}
/**
 * search
 */
function request_search(other_form) { if (!other_form) { other_form = "advSearch"; } msgBox(window_search); dataSource = url + "inc/ajax/asearch.php" + formData2QueryString(document.getElementById(other_form));	getData(dataSource, "list"); }
function search_subcategories(sel, index, id_next) {
	sel.blur();
	document.getElementById("submit_it").focus(); document.getElementById("tech_parameters").innerHTML = "";
	id_parent = sel.options[index].value; document.getElementById("sc" + id_next).innerHTML = "";
	if (!id_parent || id_parent == 0) {
		if (document.getElementById("id_category" + eval(id_parent - 1))) {search_tech_parameters(eval(id_parent - 1));} 
		else {var obj = document.getElementById("id_category");	search_tech_parameters(obj.options[obj.selectedIndex].value);}
		return;
	}	
	dataSource = url + "inc/ajax/acategories.php?id_parent=" + id_parent;	
	if(XMLHttpRequestObject) {
    	XMLHttpRequestObject.open("POST", dataSource, true);
    	XMLHttpRequestObject.onreadystatechange = function()
 		{
			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
				var response_options = XMLHttpRequestObject.responseText;
				if (response_options) {
					response_options = "<label><span class='descr'>&nbsp;</span><select name='id_sub_category[" + id_next + "]' id='id_category" + id_next + "' class='sizeL' onchange='search_subcategories(this, this.selectedIndex, " + eval(id_next + 1) + ");'><option value='0'>" + sel.options[0].innerHTML + "</option><option value='0'>" + sel.options[1].innerHTML + "</option>" + response_options;
					response_options += "</select></label><div class='sub-category' id='sc" + eval(id_next + 1) + "'></div>";
					document.getElementById("sc" + id_next).innerHTML = response_options;    
				}
			}  
		}    
		XMLHttpRequestObject.send(null);
	}	
	window.setTimeout("search_tech_parameters(" + id_parent + ")", 400);
}
function search_tech_parameters(id_parent) {
	if (!id_parent || id_parent == 0) return;	
	dataSource1 = url + "inc/ajax/atechparameters.php?id_parent=" + id_parent;
	if(XMLHttpRequestObject) {
    	XMLHttpRequestObject.open("POST", dataSource1, true);
    	XMLHttpRequestObject.onreadystatechange = function()
 		{
			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
				var response_tech_parameters = XMLHttpRequestObject.responseText;
				document.getElementById("tech_parameters").innerHTML = response_tech_parameters;
			}  
		}    
		XMLHttpRequestObject.send(null);
	}			
}
/**
 * filter
 */
function enabledFilter(index){for(i=0;i<=index;i++){$("#eFilter"+i).removeAttr("disabled");}}
function setFilterAll(index) {
    var total = $("#eFilterTotal").val() * 1;
    for(i=index;i<total;i++){
        $("#eFilter"+i).val('0');
    }
}
function checkChildFilter(index,param,values) {
    //alert('index = ' + index +' / param = ' + param + ' / values = ' + values);
    $("#fastFind select").attr("disabled","disabled");
    index += 1;
    enabledFilter(index);
    if (values == 0) {
        $("#eFilter"+index).attr("disabled","disabled");        
    }
    setFilterAll(index);
    //$("#eFilter"+index).html('<option value="5">dfgdfgdfgdfg</option>');
	dataSource = url + "inc/ajax/afilterElaborate.php?param=" + param + "&values=" + values;
	if(XMLHttpRequestObject) {
    	XMLHttpRequestObject.open("GET", dataSource, true);
    	XMLHttpRequestObject.onreadystatechange = function()
 		{
			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
				var params = XMLHttpRequestObject.responseText;
              //  $("#eFilter"+index).html(params);
                   $("#eFilter"+index + " > option").remove();
                   $("#eFilter"+index).append(params);
			}
		}
		XMLHttpRequestObject.send(null);
	}
}
function change_patron_only(){
    var patron_only = 0;
    if (document.getElementById("patron_only").checked) {patron_only = 1;}
	dataSource = url + "inc/ajax/afilter.php?patron_only=" + patron_only + "&preurl=" + url;
	if(XMLHttpRequestObject) {
    	XMLHttpRequestObject.open("GET", dataSource, true);
    	XMLHttpRequestObject.onreadystatechange = function()
 		{
			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
				var products = XMLHttpRequestObject.responseText;
				document.getElementById("products").innerHTML = products;
				reset_to_first_page();
				pocet = document.getElementById("filter_product_count").value;
				refresh_count(pocet);
				my_blur();
			}
		}
		XMLHttpRequestObject.send(null);
	}
}
function change_stored_only(){
    var stored_only = 0;
    if (document.getElementById("stored_only").checked) {stored_only = 1;}
	dataSource = url + "inc/ajax/afilter.php?stored_only=" + stored_only + "&preurl=" + url;
	if(XMLHttpRequestObject) {
    	XMLHttpRequestObject.open("GET", dataSource, true);
    	XMLHttpRequestObject.onreadystatechange = function()
 		{
			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
				var products = XMLHttpRequestObject.responseText;
				document.getElementById("products").innerHTML = products;
				reset_to_first_page();
				pocet = document.getElementById("filter_product_count").value;
				refresh_count(pocet);
				my_blur();
			}
		}
		XMLHttpRequestObject.send(null);
	}
}
function change_layout() {
	select_object = document.getElementById("layout_id"); id = select_object.options[select_object.selectedIndex].value;
	if (parseInt(id) <= 0) return;	
	dataSource = url + "inc/ajax/apager.php?layout_id=" + id + "&preurl=" + url;	
	if(XMLHttpRequestObject) {
    	XMLHttpRequestObject.open("GET", dataSource, true);
    	XMLHttpRequestObject.onreadystatechange = function()
 		{
			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
				var products = XMLHttpRequestObject.responseText;
				document.getElementById("products").innerHTML = products; 
				reset_to_first_page(); 
				refresh_count(parseInt(document.getElementById("product_count").innerHTML), parseInt(document.getElementById("layout_on_page_count").value));  
				my_blur();
			}
		}
		XMLHttpRequestObject.send(null);
	}
}
function change_sort(direction) {
	if (!direction) {direction = 1;} select_object = document.getElementById("sort_select");
	id = select_object.options[select_object.selectedIndex].value;
	if (parseInt(id) <= 0) return;	
	dataSource = url + "inc/ajax/apager.php?sort_method_id=" + id + "&direction=" + direction + "&preurl=" + url;	
	getData(dataSource, "products"); my_blur();	
}
function switchParamsMenu(param_val) {
	dataSource = url + "inc/ajax/aswitchParamFilter.php?param_val=" + param_val + "&preurl=" + url;
	if(XMLHttpRequestObject) {
    	XMLHttpRequestObject.open("POST", dataSource, true);
    	XMLHttpRequestObject.onreadystatechange = function()
 		{
         if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
            window.location.reload(true);
         }  
		}    
		XMLHttpRequestObject.send(null);
	}
	return false;
}
function multi_filter(other_form) {
	if (!other_form) {other_form = "quickMenu";}
   //reset_to_first_page();
	dataSource = url + "inc/ajax/afilter.php" + formData2QueryString(document.getElementById(other_form)) + "&preurl=" + url;
	if(XMLHttpRequestObject) {
    	XMLHttpRequestObject.open("POST", dataSource, true);
    	XMLHttpRequestObject.onreadystatechange = function()
 		{
			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
				var products = XMLHttpRequestObject.responseText;
				document.getElementById("products").innerHTML = products;    
				pocet = document.getElementById("filter_product_count").value;
				refresh_count(pocet);
				my_blur();
			}  
		}    
		XMLHttpRequestObject.send(null);
	}			
}

function multi_filter_variants(id_product) {
	var other_form = "quickMenu";
	dataSource = url + "inc/ajax/aproduct_group.php" + formData2QueryString(document.getElementById(other_form)) + "&preurl=" + url+"&id_product="+id_product;
	if(XMLHttpRequestObject) {
    	XMLHttpRequestObject.open("POST", dataSource, true);
    	XMLHttpRequestObject.onreadystatechange = function()
 		{
			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
				var products = XMLHttpRequestObject.responseText;
				document.getElementById("product_group").innerHTML = products;
				my_blur();
			}
		}
		XMLHttpRequestObject.send(null);
	}
}

function filter(constrain_name, constrain_object) {
	constrain_id = constrain_object.options[constrain_object.selectedIndex].value;
	if (constrain_id == 0) return;
	reset_to_first_page();
	dataSource = url + "inc/ajax/afilter.php?constrain_name=" + constrain_name + "&constrain_id=" + constrain_id + "&preurl=" + url;
	if(XMLHttpRequestObject) {
    	XMLHttpRequestObject.open("GET", dataSource, true);
    	XMLHttpRequestObject.onreadystatechange = function()
 		{
			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
				var products = XMLHttpRequestObject.responseText;
				document.getElementById("products").innerHTML = products;    
				pocet = document.getElementById("filter_product_count").value;
				refresh_count(pocet);
				my_blur();
			}  
		}    
		XMLHttpRequestObject.send(null);
	}
}
/**
 * survey
 */
function vote(id,id_survey){
	if (readCookie("survey" + id_survey) != null) {alert(survey_error); return;}	
	ajax_call(url + "inc/ajax/asurvey.php?id=" + id);
	document.getElementById("survey" + id).value = parseInt(document.getElementById("survey" + id).value) + 1;
	var i = 0; var total = 0;
	for (i = 0; i < surveys.length; i++) {
		total += parseInt(document.getElementById("survey" + surveys[i]).value);
	}
	for (i = 0; i < surveys.length; i++) {
		var vote = parseInt(document.getElementById("survey" + surveys[i]).value);
		var proc = Math.floor((vote / total) * 100);
		document.getElementById("surveybar" + surveys[i]).style.width = proc + "%";
		document.getElementById("surveyvote" + surveys[i]).innerHTML = " (" + vote + ")";
		document.getElementById("surveyproc" + surveys[i]).innerHTML = proc + " %";
	}
	createCookie("survey" + id_survey, 1, 5);
}
// show msgBox
function msgBox(text){
    jQuery.blockUI({
        message: '<div id="msgboxText"><p>' + text + '</p></div>',
        fadeIn: 500,
        fadeOut: 500,
        timeout: 2000,
        showOverlay: false,
        css: {
            width: '350px',
            padding: '10px',
            border: '3px solid red',
            backgroundColor: '#fff',
            '-webkit-border-radius': '10px',
            '-moz-border-radius': '10px',
            opacity: 1,
            color: '#000'
        }
    }); 
}
// check layout setting after page reload
function pageReloadBlock(){
	shop_block = $.cookie('shop_block');
	shop_block = (shop_block == null || shop_block == 'none') ? [] : shop_block.split(',');
	for(i=0;i<shop_block.length;i++){ if (shop_block[i] != '-'){ $('#'+shop_block[i]).hide(); }}	
}
// save layout setting cookie
function checkHideBlock(id){
	animatedcollapse.toggle(id); var date = new Date(); date.setTime(date.getTime() + (3 * 24 * 60 * 60 * 1000));    
    shop_block=$.cookie('shop_block');
    shop_block=(shop_block == null || shop_block == 'none') ? [] : shop_block.split(',');
    found = jQuery.inArray(id, shop_block);
    if(found== -1){shop_block[shop_block.length] = id;}else{shop_block[found] = '-';}  
    shop_block=jQuery.unique(shop_block); shop_block = shop_block.join(',');
    $.cookie('shop_block', shop_block, { path: '/', expires: date });    
}
// pri registraci aby bralo Enter
function Check_Key_Login(e) {
   var $key=0;
   if (document.all){$key=window.event.keyCode;}else{$key=e.which;}
   if ($key==13){document.getElementById("logs").submit();}
}
// auto refresh na zmenu jazyka v poste
function Change_Lang() {
	selected_lang = document.getElementById("langs"); selected_lang = selected_lang.options[selected_lang.selectedIndex];
	selected_lang = selected_lang.value; document.getElementById("lang").value = selected_lang; document.getElementById("language").submit();
}
//ShowImage
function ShowImage(filename) {window.open(encodeURI(url + "foto.php?img=" + filename), "_blank", "toolbar=no,scrollbars=no,location=no,status=no,width=100,height=100,resizable=1,screenX=150,screenY=150", false);}
function new_window(url1) {window.open(encodeURI(url1), "_blank", "toolbar=no,scrollbars=yes,location=no,status=no,width=800,height=550,resizable=1,screenX=100,screenY=150", false);}
function createCookie(name,value,days) {
	if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString();}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	} return null;
}
function verify_length(id, length, text) {var obj = document.getElementById(id); if (obj.value.length < length) {alert(text);obj.focus();return false;} return true;}
function valid_email (email) {var validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i; if (email.search(validRegExp) == -1) {return false;}else{return true;}}
/**
* COMPARE
*/
function add_compare(id, id_category) {
/*	ajax_call(url + "inc/ajax/acompare.php?id=" + id + "&id_category" + id_category);*/
$.get(url + "inc/ajax/acompare.php",{id: id, id_category: id_category});
}
function show_compare() {new_window(url + "compare.php");}
function send_to_friend(id) {window.open(encodeURI(url + "send_to_friend.php?id=" + id), "_blank", "toolbar=no,scrollbars=yes,location=no,status=no,width=480,height=440,resizable=1,screenX=100,screenY=150", false);}
function remove_from_compare(id){ajax_call(url + "inc/ajax/acompare.php?remove_id=" + id);location.assign(location.href);}
/**
* SCHRANKA
*/
function add_to_repository (id) {getData(url + "inc/ajax/arepository.php?id=" + id, "repository_count");msgBox(window_after_repository);}
function sel_to_repository() {
    var elems = document.getElementsByTagName("input");
    for(i = 0; i < elems.length; i++){if(elems[i].checked == true){elems[i].checked = false;}}
	getData(url + "inc/ajax/arepository.php?sel=true", "repository_count");msgBox(window_after_repository);
}

function pause(numberMillis)
{
var now = new Date();
var exitTime = now.getTime() + numberMillis;
while (true)
{
now = new Date();
if (now.getTime() > exitTime)
return;
}
}

function sel_from_repository() {
    /*
    var elems = document.getElementsByTagName("input");
    for(i = 0; i < elems.length; i++){if(elems[i].checked == true){elems[i].checked = false;}}
	getData(url + "inc/ajax/arepository.php?sel_from=true", "repository_count");msgBox(window_after_repository);	
    //window.location.href = window.location.pathname;
    //opener.location.reload();
    window.location.reload();
    //reset_to_first_page();*/
   var str = $("input[name*='compare']:checked").serialize();
    //$("input[name*='compare']").removeAttr('checked');   url + "inc/ajax/arepository.php?sel_from=true&"+str
   
    getData(url + "inc/ajax/arepository.php?sel_from=true&"+str, "repository_count"); // repository_count , demoView
    pause(1000);
    msgBox(window_repository_remmove);
    window.location.reload(false);
}
function flush_repository() {ajax_call(url + "inc/ajax/arepository.php?flush=1");document.getElementById("repository_count").innerHTML = "0";msgBox(window_repository_flush);}
/**
 ** HLIDACI PES
 */
function add_one_to_watchdog (id){ getData(url + "inc/ajax/awatch_dog.php?id=" + id+"&action=add","watch_dog_count"); msgBox(window_dog_add);}  
function sel_to_watchdog(){
  var elems = document.getElementsByTagName("input");
  for(i = 0; i < elems.length; i++){if(elems[i].checked == true){elems[i].checked = false;}} getData(url + "inc/ajax/awatch_dog.php?sel=true","watch_dog_count"); msgBox(window_dog_add);  
}  
function remove_select_watchdog(){
	var	boxs = document.getElementsByName("checkproduct[]"); var i = 0; var ids = "";
	for (i = 0; i < boxs.length; i++) {if (boxs[i].checked == true) {ids += boxs[i].value + ';';}}
	getData(url + "inc/ajax/awatch_dog.php?idsdel=" + ids,"watch_dog_count");
	msgBox(window_dog_rem);window.location.href=window.location.href;
}
function remove_from_watchdog (id){ getData(url + "inc/ajax/awatch_dog.php?id=" + id+"&action=remove","watch_dog_count"); msgBox(window_dog_rem); window.location.assign(window.location.href);}  
function flush_watchdog() {ajax_call(url + "inc/ajax/awatch_dog.php?flush=1");document.getElementById("watch_dog_count").innerHTML = "0";msgBox(window_dog_rem);window.location.href=window.location.href;}
/**
 * zjisteni hodnoty poukazky
 */  
function GetVoucherValue(use_voucher,uniq_id){ getData(url + "inc/ajax/avoucher.php?use_voucher=" + use_voucher + "&uniq_id=" + uniq_id,"voucher_value_block") ;}  
/**
 * menova kalkulacka
 */
function Calculate_Currency(code){ var price=document.curr_calc.in_price.value; var index=document.curr_calc.currency.selectedIndex; var code=document.curr_calc.currency.options[index].value;	getData(url + "inc/ajax/acurrencies.php?price=" + price + "&code=" + code,"out_price") ;}
/**
* zalozky
*/
function zal_menu_select(id) {
  var obal = document.getElementById("zalozkMenu"); var zalozky = obal.getElementsByTagName("A"); var i = 0;
  for (i = 0; i < zalozky.length; i++) {if ("zal" + id == zalozky[i].id) {zalozky[i].className = "act";}else{zalozky[i].className = "";}}
}
/**
* RATING
*/
function get_sel_rating() {
	var butts = document.getElementsByName("ratingbutton");var i = 0;
	for (i = 0; i < butts.length; i++) {if (butts[i].checked == true) return butts[i].value;}return null;
}


function rate(id, extend, note) {
	var mark = get_sel_rating();if (mark == null) return;
	var dest = ""; if (extend == 0) dest = "rating_form"; else dest = "product_content";
	if(rating_check(id) == false) { msgBox("Nelze hlasovat 2x pro stejný produkt");return;}
	getData(url + "inc/ajax/arating.php?id_product=" + id + "&mark=" + mark + "&extend=" + extend + "&note=" + encodeURI(note) + "&preurl=" + url, dest);	
	var note_rated_span = document.getElementById("note_rated");
	if (note != document.getElementById("def_rating_text").value)
    {
        note_rated_span.innerHTML = parseInt(note_rated_span.innerHTML) + 1;
    }
}

function rate_only(id, extend, note) {
	var mark = get_sel_rating();if (mark == null) return;
	var dest = ""; if (extend == 0) dest = "rating_form"; else dest = "product_content";
	
	$.get(url + "inc/ajax/arating.php",{id_product: id, mark: mark, extend: extend, note: encodeURI(note), preurl: url}, function(){
    show_rating(id);
  });
	
	/*4(url + "inc/ajax/arating.php?id_product=" + id + "&mark=" + mark + "&extend=" + extend + "&note=" + encodeURI(note) + "&preurl=" + url, dest);*/	
	/*var note_rated_span = document.getElementById("note_rated");*/
/*	if (note != document.getElementById("def_rating_text").value)
    {
        note_rated_span.innerHTML = parseInt(note_rated_span.innerHTML) + 1;
    }
*/
}

function forward_to_rate(id, extend, note) {
  show_rating_with_rate(id, $("input[@name=ratingbutton]:checked").val());
}

function rate_to_div(id, extend, note,divId,already,auth) {
    if(already!=''){
     msgBox(window_rating_cant_add);
     return;
    }
	var mark = get_sel_rating();if (mark == null) return;
	var dest = ""; if (extend == 0) dest = "rating_form"; else dest = divId;
	var fce = "getData('"+url + "inc/ajax/arating.php?id_product=" + id + "&mark=" + mark + "&extend=" + extend + "&note=" + encodeURI(note) + "&preurl=" + url+"','"+ dest+"')";
    var t = setTimeout(fce,500);
	var note_rated_span = document.getElementById("note_rated");
	if (note != document.getElementById("def_rating_text").value)
       {note_rated_span.innerHTML = parseInt(note_rated_span.innerHTML) + 1;
       
    }
        if(auth == '1')
            msgBox(window_rating_add_auth);
        else
            msgBox(window_rating_add);
    }

function show_rating_with_rate(id, rate) {zal_menu_select(3);getData(url + "inc/ajax/arating.php?id_product=" + id + "&rating="+rate+"&extend=1" + "&preurl=" + url, "product_content");}    

function show_rating(id) {zal_menu_select(3);getData(url + "inc/ajax/arating.php?id_product=" + id + "&extend=1" + "&preurl=" + url, "product_content");}
function show_product_info(id) {zal_menu_select(1);getData(url + "inc/ajax/aproduct.php?id=" + id + "&extend=1" + "&preurl=" + url, "product_content");}
function show_product_info_immediate(id,status) {zal_menu_select(1); getData(url + "inc/ajax/aproduct.php?id=" + id + "&extend=1" + "&preurl=" + url + "&immediately=" + status, "product_content");}

function show_rating_to_div(id,divId)
{ 
   // alert(fce);
   fce = "getData('"+url + "inc/ajax/arating.php?id_product=" + id + "&extend=1" + "&preurl=" + url+"','"+divId+"')";
   //alert(fce);
   var t = setTimeout(fce,100);
}
function show_product_info_to_div(id,divId) {getData(url + "inc/ajax/aproduct.php?id=" + id + "&extend=1" + "&preurl=" + url, divId);}
function show_forum_to_div(id,divId) {
  fce = "getData2('"+url + "inc/ajax/aforum.php?id_product=" + id + "&preurl=" + url+"','"+ divId+"')";
   //alert(fce);
   var t = setTimeout(fce,1000);}
/**
* FORUM
*/
function show_forum(id) {zal_menu_select(2);getData(url + "inc/ajax/aforum.php?id_product=" + id + "&preurl=" + url, "product_content");}
function show_forum_news(id) {getData(url + "inc/ajax/anewsforum.php?id_news=" + id + "&preurl=" + url, "news_forum");}
function forum_add(id_product,to_authorize,divId) {
    var dest = "product_content";
    if(divId)
        dest = divId;
	var subject = document.getElementById("subject").value;	subject = encodeURI(subject);
	var name = encodeURI(document.getElementById("name").value); var email = encodeURI(document.getElementById("email").value);
	var text = encodeURI(document.getElementById("text").value); var id_product_forum = (document.getElementById("id_product_forum").value * 1);	
	var require_admin = 0;
	if (document.getElementById("require_admin").checked == true) require_admin = 1;
    getData(url + "inc/ajax/aforum.php?id_product=" + id_product + "&title=" + subject + "&email=" + email + "&name=" + name + "&content=" + text + "&require_admin=" + require_admin + "&id_product_forum=" + id_product_forum, dest);
	var forum_count = document.getElementById("forum_count"); forum_count.innerHTML = parseInt(forum_count.innerHTML) + 1; 
	if(to_authorize == 0){msgBox(window_forum_add);}
	else{msgBox(window_forum_add_authorize);}	
}


function forum_news_add(id_product) {
	var subject = encodeURI(document.getElementById("subject").value); var name = encodeURI(document.getElementById("name").value);
	var email = encodeURI(document.getElementById("email").value); var text = encodeURI(document.getElementById("text").value);
	var id_product_forum = document.getElementById("id_product_forum").value;	
	getData(url + "inc/ajax/anewsforum.php?id_news=" + id_product + "&title=" + subject + "&email=" + email + "&name=" + name + "&content=" + text + "&id_product_forum=" + id_product_forum, "news_forum");
	msgBox(window_forum_add);	
}
function forum_reply(id_product_forum) {document.getElementById("id_product_forum").value = id_product_forum;var subj_text = document.getElementById("forum" + id_product_forum + "subject").innerHTML;document.getElementById("subject").value = "Re: " +  subj_text;}
/**
* DOWNLOAD
*/
function show_download(id) {zal_menu_select(4);getData(url + "inc/ajax/adownload.php?id=" + id + "&preurl=" + url, "product_content");}
/**
*  PRODUCT VISIT
*/
var call_product_visits = false;
/**
* ON MOUSE OVER IMAGE 
**/
var timerT = false;
function show_small(element, filename, title, url) {
	var baseElem = $(element);
	if (show_small_image == false) return;
	if (timerT) clearTimeout(timerT); 
	var posl_lomitko = filename.lastIndexOf("/") + 1;
	if (!filename || filename.substring(posl_lomitko) == "none.gif") return;
	var old_filename = filename.substring(posl_lomitko + 3);var small_div = document.getElementById("smallDiv");var path = filename.substring(0, posl_lomitko);
	var new_filename = "sm_" + old_filename;
	small_div.innerHTML = "<a href='" + url + "'><img src='" + path + new_filename + "' alt='" + title + "' title='" + title + "' /></a>";
	$("#smallDiv").positionBy({target: baseElem, targetPos: 0, elementPos: 0});
	var cmd = "del_show()";timerT = setTimeout(cmd, 600);
}
function show_design(element, filename) {
	var baseElem = $(element);
	if (show_small_image == false) return;
	if (timerT) clearTimeout(timerT);
    var small_div = document.getElementById("smallDiv");
	small_div.innerHTML = "<img src='" + url + 'images/' + filename + "'/>";
	$("#smallDiv").positionBy({target: baseElem, targetPos: 0, elementPos: 0});
	var cmd = "del_show()";timerT = setTimeout(cmd, 600);
}
function show_matters(element, filename) {
	var baseElem = $(element);
	if (show_small_image == false) return;
	if (timerT) clearTimeout(timerT);
    var small_div = document.getElementById("smallDiv");
	small_div.innerHTML = "<img src='" + filename + "' alt='" + baseElem[0].alt + "' onclick='checkMatter(this)' />";
	$("#smallDiv").positionBy({target: baseElem, targetPos: 0, elementPos: 0});
	var cmd = "del_show()";timerT = setTimeout(cmd, 600);
}
function del_show() {clearTimeout(timerT);var small_div = document.getElementById("smallDiv");small_div.style.visibility = "visible";}
function image_hide() {var small_div = document.getElementById("smallDiv");small_div.style.visibility = "hidden";}
var ttXpos = 0, ttYpos = 0;
var ttXadd = 10, ttYadd = -10;
var ttDisplay = 0, ttHoldIt = 0;
function intrigue(text){getData(url + "inc/ajax/aintriguer.php?inp=" + text,"intriguer") ;}
function intriguePos(text,pos,size_def)

{
    var size='';
    if(size_def){size = '&with_size='+size_def};
   // alert(url + "inc/ajax/aintriguer.php?inp=" + text+"&pos="+pos+size);
    getData(url + "inc/ajax/aintriguer.php?inp=" + text+"&pos="+pos+size,"intriguer_change");
}

function intrigue_club(text)
{
	getData(url + "inc/ajax/aintriguer_club.php?inp=" + text,"intriguer2") ;
	var t = setTimeout('getClubIntrigValue()',250);
}


function fill_product_title(text,divId)
{
	getData(url + "inc/ajax/aproducttitle.php?inp=" + text,divId) ;
	
}

function getClubIntrigValue()
{
	var sel=document.getElementById("resultList2");
	if(sel != null && sel.length == 1)
	{
    	document.getElementById("search_club_keyword").value=sel.options[0].text;
    	document.getElementById("id_club").value=sel.options[0].value;
    	document.getElementById("intriguer2").innerHTML="";
	}
}
function select_icon()
{
	var iconSelection = document.getElementById('icon_selection');
	var selIcon = iconSelection.options[iconSelection.selectedIndex].value;
	var preview = document.getElementById('printing_own_image_preview');
	if(selIcon > 0)
	{
		dataSource = url + "inc/ajax/aprintingimage.php?printing_icon=" + selIcon;
		if(XMLHttpRequestObject) 
		{
    		XMLHttpRequestObject.open("GET", dataSource, true);
	    	XMLHttpRequestObject.onreadystatechange = function()
 			{
				if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200)
				{
					var result = XMLHttpRequestObject.responseText;
					preview.innerHTML = result;
				}  
			}    
			XMLHttpRequestObject.send(null);
		}
	}
	else
	{
		preview.innerHTML = '';
	}
}
function display_printing_image(){
	var preview =   document.getElementById('printing_own_image_preview');
	var uplTarget = document.getElementById('uplTarget');
	iframeContent = uplTarget.contentDocument.getElementById('uploaded_image').innerHTML;
	preview.innerHTML = iframeContent;
	return true;
}
function copy_printing_content(){window.parent.display_printing_image();}
function change_printing_text(line){
	var printingTextInput = document.getElementById('printing_text_' + line);
	var printingTextDiv = document.getElementById('printing_text_preview_' +line);
	printingTextDiv.innerHTML = printingTextInput.value;
}
function changeForm(type) {
   var asel='step'+type;
   document.getElementById(asel+'_select').disabled=false;
   obj= listAndReturnElem('step'+type+'_butt','input');
   if(obj)
       obj.setAttribute('style','');
   obj= listAndReturnElem('step'+type+'_change','a');
   if(obj)
       obj.setAttribute('style','display:none');
   var i=type+1;
   do{
        div=listAndReturnElem('step'+i,'div');
       
        if(div){
               div.setAttribute('style','display:none');
       }
       i++;
  }while(i<=3);
}
function listAndReturnElem(name,type){
     var1=document.getElementsByTagName(type);
     for(i=0;i<var1.length;i++){
     var2=var1.item(i);
     if(name==var2.getAttribute('id')){
           return var2;
     }
   }
     return null;
}
function autorapr_search(nodeid, nodename){
    var input = document.getElementById('assemblyGroupNodeId');
    var inputName = document.getElementById('assemblyGroupName');
     input.value=nodeid;
     inputName.value=nodename;
    document.getElementById('autorapr_search').submit();
}
function autorapr_article_details(articleid,articlelink){
     var aid = document.getElementById('articleId');
     var alid = document.getElementById('articleLinkId');
     aid.value=articleid;
     alid.value=articlelink;
     document.getElementById('autorapr_details').submit();
}
function autorapr_article_ddetails(darticleid){
     var aid = document.getElementById('darticleId');
     aid.value=darticleid;
     document.getElementById('autorapr_direct_details').submit();
}

function print_order(){
    var form = document.getElementById("order");
    form.setAttribute("target", "new");
    document.getElementById("print_order_input").value=1;
    form.submit();
     document.getElementById("print_order_input").value=0;
     form.setAttribute("target", "");
}

function choosePromoList(){
    promo_buttons = document.getElementsByName("choose-promo");
    id_product = document.getElementById("promo_id_product").value;
    var id=0;
    var title = '';
    for(i = 0;i<promo_buttons.length;i++){
        butt = promo_buttons[i];
        if(butt.checked){
            var new_value = butt.value;
            var exploded = new_value.split("|");
            id = exploded[0];
            title = exploded[1];
        }
    }
    document.getElementById("promoaction_id_"+id_product).value = id;
    document.getElementById("promoaction_title_"+id_product).innerHTML = title;
    $.modal.close();
   }
 function closePromo(){
    $.modal.close();
 }

 function closeModal(){
     $.modal.close();
     return false;
 }
  String.prototype.trim = function() {
        return this.replace(/^\s+|\s+$/g,"");
}


function rating_check(id)
{
var set = true;
$.ajax({
      url: url + "inc/ajax/arating_check.php",
      global: false,
      type: "POST",
      data: ({id : id}),
      dataType: "txt",
      async:false,
      success: function(msg){
         if(msg == "false") { set = false;}else{set = true;}
      }
   }
   
   
);

return set;
}


function plash_select(id)
{

  $(".plashProducts img").removeClass();
  $("#plash"+id + " > img").addClass('actp');
  $("#plashSelect").val(id);

}

function str_all_replace (search, replace, subject, count) {
    // Replaces all occurrences of search in haystack with replace  
    // 
    // version: 1109.2015
    // discuss at: http://phpjs.org/functions/str_replace
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Gabriel Paderni
    // +   improved by: Philip Peterson
    // +   improved by: Simon Willison (http://simonwillison.net)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   bugfixed by: Anton Ongson
    // +      input by: Onno Marsman
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    tweaked by: Onno Marsman
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   input by: Oleg Eremeev
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Oleg Eremeev
    // %          note 1: The count parameter must be passed as a string in order
    // %          note 1:  to find a global variable in which the result will be given
    // *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
    // *     returns 1: 'Kevin.van.Zonneveld'
    // *     example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
    // *     returns 2: 'hemmo, mars'
    var i = 0,
        j = 0,
        temp = '',
        repl = '',
        sl = 0,
        fl = 0,
        f = [].concat(search),
        r = [].concat(replace),
        s = subject,
        ra = Object.prototype.toString.call(r) === '[object Array]',
        sa = Object.prototype.toString.call(s) === '[object Array]';
    s = [].concat(s);
    if (count) {
        this.window[count] = 0;
    }
 
    for (i = 0, sl = s.length; i < sl; i++) {
        if (s[i] === '') {
            continue;
        }
        for (j = 0, fl = f.length; j < fl; j++) {
            temp = s[i] + '';
            repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
            s[i] = (temp).split(f[j]).join(repl);
            if (count && s[i] !== temp) {
                this.window[count] += (temp.length - s[i].length) / f[j].length;
            }
        }
    }
    return sa ? s : s[0];
}


function OpenBlock(idBl)
{
  $('#' + idBl).toggle();
}

function HideBlock(idBl)
{
  $('#' + idBl).hide();
}


function HideAllExtra()
{
$('#plashRocket').hide();
$('#detInfobox').hide();
$('#detTechnology').hide();
}

