function urldecode( str ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: AJ
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Brett Zamir
	// +   improved by: CrioArts
    // %          note: info on what encoding functions to use from: http://xkr.us/articles/javascript/encode-compare/
    // *     example 1: urldecode('Kevin+van+Zonneveld%21');
    // *     returns 1: 'Kevin van Zonneveld!'
    // *     example 2: urldecode('http%3A%2F%2Fkevin.vanzonneveld.net%2F');
    // *     returns 2: 'http://kevin.vanzonneveld.net/'
    // *     example 3: urldecode('http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a');
    // *     returns 3: 'http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a'
    
    var histogram = {};
    var ret = str.toString();
    
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The histogram - replica of the one in urlencode.
	histogram["'"]   = '%27';
    histogram['(']   = '%28';
    histogram[')']   = '%29';
    histogram['*']   = '%2A';
    histogram['~']   = '%7E';
    histogram['!']   = '%21';
    histogram['%20'] = '+';
	histogram['-'] = '%96';
	
    histogram['+']   = '%2B';
    histogram['']   = '%BE';
    histogram['']   = '%9A';
    histogram['']   = '%E8';
    histogram['']   = '%9D';
	histogram['']   = '%9E';
	histogram['']   = '%FD';
	histogram['']   = '%E1';
	histogram['']   = '%ED';
	histogram['']   = '%E9';
    histogram[''] = '%FA';
    histogram[''] = '%E4';
	histogram[''] = '%F4';
	histogram[''] = '%80';
	histogram[''] = '%F3';
	histogram[''] = '%F2';
	
    histogram[''] = '%C8';
	histogram[''] = '%8A';
	histogram[''] = '%8E';
	histogram[''] = '%C9';
    histogram[''] = '%C1';
	histogram[''] = '%DD';
	histogram[''] = '%CD';
	histogram[''] = '%DA';	
	histogram[''] = '%BC';
	histogram[''] = '%D8';
	histogram[''] = '%F8';
	histogram[''] = '%EC';

	histogram[''] = '%EF';
	histogram[''] = '%CF';
	histogram[''] = '%E5';
	histogram[''] = '%C5';
 
    for (replace in histogram) {
        search = histogram[replace]; // Switch order when decoding
        ret = replacer(search, replace, ret) // Custom replace. No regexing   
    }
    
    // End with decodeURIComponent, which most resembles PHP's encoding functions
    ret = decodeURIComponent(ret);
 
    return ret;
}

function changeDetailPrice(p_ret_price) {
	  
	var c_opts=new Array();
	var c_op_prices =new Array();
	var c_op_names =new Array();
	var price_with_opt = p_ret_price;
	var opt_names = " ";
	
	for (var i=1;i<=6;i++){
		if(document.getElementById('opt_'+i)){
			c_opts[i-1] = document.getElementById('opt_'+i).checked;		
			c_op_prices[i-1] = document.getElementById('op_pr_'+i).innerHTML;		
			c_op_names[i-1] = document.getElementById('op_name_'+i).innerHTML;		
		}
	}
		
	for (var j=1;j<=6;j++){
		if(c_opts[j-1] != null && c_opts[j-1]==true){
			price_with_opt = parseFloat(price_with_opt) + parseFloat(c_op_prices[j-1]);			
			opt_names = opt_names + '&nbsp&nbsp + ' + c_op_names[j-1];
		}
	}
	
	document.getElementById('product_price').innerHTML = price_with_opt.toFixed(2);
	if(document.getElementById('product_pr_vat')) document.getElementById('product_pr_vat').innerHTML = (price_with_opt*1.2).toFixed(2);
	document.getElementById('optionals_added').innerHTML = opt_names;

}



function detailInfo(p_prodId, p_tab)
  {
	var xmlHttp=getHTTPObject();
	
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
			document.getElementById('galeria').innerHTML= urldecode(xmlHttp.responseText);		
			for (var i=1;i<=3;i++){
				document.getElementById('info_'+i).className = ""
			}				
			document.getElementById('info_'+p_tab).className = "activated";	
		}
	}
	  
	xmlHttp.open("GET","include/ajax/ajax_detailInfo.php?tab="+p_tab+"&prodId="+p_prodId,true);	
    xmlHttp.send(null);
}
  
function getHTTPObject()
  {
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");		
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
	return xmlHttp;
}
  
function trim(sValue){
		return sValue.replace(/^\s+|\s+$/g, "");
	}

	
function productAmountValidation(p_formular){			
	var chyba = "";
	var vzorPoctu = /(^\d{1,5}$)/;
	
	if(trim(p_formular.amount.value) == ""){
		chyba += "- You have to fill in the <b><u>amount</u></b>! <br>";
	}	
	else{				
		if(!vzorPoctu.test(p_formular.amount.value)){					              
			chyba += "- Wrong amount <b><u>format</u></b>!<br>";
		}	
	}	

	if(chyba=="") return true;
	else{	
		document.getElementById('error_place').innerHTML = chyba;
		p_formular.amount.value = 1;
		return false;
	}	
}	
	
	
