/*! DEFAULT
Version: 2018/35
Author: AVIZO, a.s. http://www.avizo.cz
*/
function ready(fn) {
if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading"){
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
/*
if (document.readyState != 'loading'){
fn();
} else if (document.addEventListener) {
document.addEventListener('DOMContentLoaded', fn);
} else {
document.attachEvent('onreadystatechange', function() {
if (document.readyState != 'loading')
fn();
});
}*/
}
$.fn.outerHTML = function() {
var doc = this[0] ? this[0].ownerDocument : document;
return $('
', doc).append(this.eq(0).clone()).html();
};
// mapa funkci pro data-call-func
var myFunc = {
// po kliku na lokalitu zalozky: mapa, okres
setLZ: function (zalozka) { setLZ(zalozka); nastaveniValidaceLokalita(); }
// po kliku na lokalitu okres -> stat
,setLZ2: function (zalozka) { $('#selectstate').hide(); $('#selectkraj').show(); setLZ(zalozka); nastaveniValidaceLokalita(); }
};
function avTrackEvent(cat, act){
/*
ga('send', 'event', {
eventCategory: cat,
eventAction: act
});
*/
return true;
}
function trackGTM(ev, hash)
{
dataLayer.push({
'event': ev
,'hash' : hash
});
}
$(document).ready(function(){
// vyhledavani inzeratu
$(document).on('change',".order", function()
{
$("#hiddenorder").val($(this).val());
$("#hiddenzobrazit").val($("#zobrazitinzeratu").val());
$("#hfulltxtform").submit();
});
$(document).on('change',".zobrazitinzeratu", function()
{
$("#hiddenorder").val($("#order").val());
$("#hiddenzobrazit").val($(this).val());
$("#hfulltxtform").submit();
});
// tlacitko vyhledat - da do URL jen ty inputy, ktere jsou vyplnene
//$('#searchform').on("submit", function()
$(document).on('submit',"#hfulltxtform", function(e){
e.preventDefault();
var formUrl = upravFormUrl( this );
window.location.replace( formUrl );
return false;
});
if (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0) {
$(window).on('load', function(){
$('input:-webkit-autofill').each(function(){
var text = $(this).val();
var name = $(this).attr('name');
$(this).after(this.outerHTML).remove();
$('input[name=' + name + ']').val(text);
});
});
}
/* <-------------- link - target - start */
$( 'a[data-target]' ).click( function(){
var url = $(this).attr('href');
var trg = $(this).attr('data-target');
switch(trg){
case "top":
top.document.location = url;
break;
default:
window.open(url);
}
return false;
});
/* <-------------- link - target - konec */
/* <-------------- mobilni menu - start */
var kamPosunout = '-=250px';
$( '.mobile-menu-button' ).click(function(){
showHideMobileNav();
});
$( '#close-mobile-nav' ).click(function(){
showHideMobileNav();
});
function showHideMobileNav(){
if (kamPosunout == '-=250px') {
kamPosunout = '+=250px';
$( '#mobile-nav' ).show();
$( '#close-mobile-nav' ).show();
$( '#main-page' ).addClass('main-page-fixed');
$( 'body' ).addClass('body-mobile-nav-open');
$( '.order-box-container' ).hide();
} else {
kamPosunout = '-=250px';
$( '#main-page' ).removeClass('main-page-fixed');
$( '#close-mobile-nav' ).hide();
$( '.order-box-container' ).show();
}
if (kamPosunout == '-=250px') {
$( "#mobile-nav" ).animate({ 'right': kamPosunout }, {queue:false,duration:200}, function(){ $( '#mobile-nav' ).hide(); });
$( 'body' ).removeClass('body-mobile-nav-open');
} else {
$( "#mobile-nav" ).animate({ 'right': kamPosunout }, {queue:false,duration:200});
}
$( "#main-page" ).animate({ 'right': kamPosunout }, {queue:false,duration:200});
}
/* <-------------- mobilni menu - konec */
/* <-------------- velikost okna - start */
var sirkaOkna = parseInt($(window).width());
$(window).bind('resize',function(){
sirkaOkna = parseInt($(window).width());
if (sirkaOkna > 767){
//alert('full');
}
if (sirkaOkna < 767){
$( '.favlist-cat li' ).children( '.del-fav' ).show();
}
});
if (sirkaOkna > 767){
//alert('full');
}
/* <-------------- velikost okna - konec */
/* <-------------- checkbox - start */
_def_checkbox_start();
$( document ).on('click keyup', 'label.avizo-check', function(e){
if (e.type == 'keyup') {
if (e.keyCode !== 0 && e.keyCode !== 32) { e.preventDefault(); return false; }
}
if (e.target.type == 'radio') {
e.stopPropagation();
return false;
}
//console.log("on.click, e.type: "+e.target.type);
nastavCheckBoxAC(this, e);
});
/* <-------------- checkbox - end */
/* <-------------- vase avizo - rozbaleni buttonu pro topky - start */
/* $( document ).on( 'click', '.ma-list-top-service-buttons .icon-avizo-top', function() {
if ( $( this ).parents( 'li' ).hasClass( 'active' ) === false ) {
$( this ).parents( '.ma-list-top-service-buttons' ).find( 'li' ).removeClass( 'active' );
$( this ).parents( '.ma-list-top-service-buttons' ).find( '.btn' ).children( 'em' ).css( 'display' , 'none' );
$( this ).parents( 'li' ).addClass( 'active' );
$( this ).parents( 'li' ).find( '.btn' ).children( 'em' ).css( 'display' , 'inline' );
}
return false;
}); */
/* <-------------- vase avizo - rozbaleni buttonu pro topky - konec*/
/* <-------------- modalni okno - ovladani - start */
$( document ).on("click", '[data-modal]', function() {
var akceModal = $( this ).data('modal');
if (akceModal === 'close'){
$( this ).parents( '.modal' ).fadeOut(400);
$( 'body' ).removeClass( 'modal-body' );
}
return false;
});
/* <-------------- modalni okno - ovladani - konec*/
/*data-modal="close"*/
/* <-------------- schovavani konkretniho boxu - start */
_def_show_button();
$( document ).on("click", '.show-button', function() {
var ukaz = $( this ).attr('href');
var schovej = '.close-' + $( this ).attr( 'href' ).substring(1,$(this).attr( 'href' ).lenght);
$( schovej ).hide();
$( ukaz ).fadeIn('300');
return false;
});
$( document ).on("click", '.hide-button', function() {
var ukaz = '.close-' + $( this ).attr( 'href' ).substring(1,$(this).attr( 'href' ).lenght);
var schovej = $(ukaz).data('hide-item');
spustCF( $(this) );
if (schovej) $( schovej ).hide();
$( ukaz ).fadeIn('300');
return false;
});
/* <-------------- schovavani konkretniho boxu - end */
/* <-------------- zalozky - start */
_def_tab_navi();
$( document ).on("click", '.tab-navi a', function() {
var url = $( this ).attr('href');
$( this ).parents( '.tab-navi' ).children( 'li' ).children( 'a' ).removeClass( 'current' );
$( this ).addClass( 'current' );
spustCF( $(this) );
$( this ).parents( '.tab-navi' ).next( '.tab-container' ).children( '.tab-item' ).hide();
$( url ).fadeIn('300');
return false;
});
/* <-------------- zalozky - end */
/* <-------------- vyber rubriky - mobilni zobrazeni - start */
showHidePodSelectSection();
$(window).bind('resize',function(){
showHidePodSelectSection();
});
function showHidePodSelectSection(){
var sirkaOkna = parseInt($(window).width());
var celkovaHodnotaPodavani = $( '#celkovacenahodnota' ).text();
$( '.select-section-container-show-hide' ).unbind( 'click' );
if (sirkaOkna < 767){
//select-section-container-icon-show
$( '.pod-all-rub .select-section-container' ).each(function() {
if ( $( this ).children( 'h4' ).hasClass( 'select-section-container-icon-hide' )) {
$( this ).children( 'ul' ).show();
} else {
$( this ).children( 'h4' ).addClass( 'select-section-container-show-hide' );
$( this ).children( 'h4' ).removeClass( 'select-section-container-icon-hide' );
$( this ).children( 'h4' ).addClass( 'select-section-container-icon-show' );
$( this ).children( 'ul' ).hide();
}
});
/*
$( '.pod-all-rub .select-section-container h4' ).addClass( 'select-section-container-show-hide' );
$( '.pod-all-rub .select-section-container h4' ).addClass( 'select-section-container-icon-show' );
$( '.pod-all-rub .select-section-container ul' ).hide();
*/
if (celkovaHodnotaPodavani === 'ZDARMA'){
$( '.order-box-container' ).hide();
} else {
$( '.order-box-container' ).show();
}
$( '.select-section-container-show-hide' ).click(function(){
$( this ).parents( '.select-section-container-mobile' ).children( 'ul' ).slideToggle( '200' );
if ($(this).parents( '.select-section-container-mobile' ).children( '.select-section-container-show-hide' ).hasClass('select-section-container-icon-show')){
$(this).parents( '.select-section-container-mobile' ).children( '.select-section-container-show-hide' ).removeClass('select-section-container-icon-show');
$(this).parents( '.select-section-container-mobile' ).children( '.select-section-container-show-hide' ).addClass('select-section-container-icon-hide');
} else {
$(this).parents( '.select-section-container-mobile' ).children( '.select-section-container-show-hide' ).removeClass('select-section-container-icon-hide');
$(this).parents( '.select-section-container-mobile' ).children( '.select-section-container-show-hide' ).addClass('select-section-container-icon-show');
}
});
} else {
$( '.order-box-container' ).show();
$( '.pod-all-rub .select-section-container h4' ).removeClass( 'select-section-container-show-hide' );
$( '.pod-all-rub .select-section-container h4' ).removeClass( 'select-section-container-icon-show' );
$( '.pod-all-rub .select-section-container h4' ).removeClass( 'select-section-container-icon-hide' );
$( '.pod-all-rub .select-section-container ul' ).show();
}
}
/* <-------------- vyber rubriky - mobilni zobrazeni - konec */
/* <-------------- vypis inzeratu - nastroje - start */
$( '.alist' ).mouseenter(function(){
var sirkaOkna = parseInt($(window).width());
if (sirkaOkna > 767){
$( this ).children( '.alist-tool' ).children( 'a' ).each(function() {
var ukazat = 'ano';
if ( $( this ).hasClass( 'alist-service-top-on' ) || $(this).hasClass( 'alist-service-vip' ) ){
ukazat = 'ne';
}
if ( ukazat === 'ano') {
//$( this ).css('display', 'block').hide().fadeIn(300);
$( this ).show();
}
});
}
});
$( '.alist' ).mouseleave(function(){
var sirkaOkna = parseInt($(window).width());
if (sirkaOkna > 767){
$( this ).children( '.alist-tool' ).children( 'a' ).each(function() {
var schovat = 'ano';
if ( $( this ).hasClass( 'alist-service-top-on' ) || $(this).hasClass( 'alist-service-vip' ) ){
schovat = 'ne';
}
if ( schovat === 'ano') {
$( this ).hide();
}
});
}
});
/* <-------------- vypis inzeratu - nastroje konec */
/* <-------------- oblibene - nastroje - start */
$( '.favlist-cat li' ).mouseenter(function(){
var sirkaOkna = parseInt($(window).width());
if (sirkaOkna > 767){
$( this ).children( '.del-fav' ).show();
}
});
$( '.favlist-cat li' ).mouseleave(function(){
var sirkaOkna = parseInt($(window).width());
if (sirkaOkna > 767){
$( this ).children( '.del-fav' ).hide();
}
});
/* <-------------- oblibene - nastroje konec */
$( document ).on("click", '.smazatMyAlert', function(e) {
e.preventDefault();
var text = $(this).attr('data-text');
var forwardURL = $(this).attr('href');
myAlert(text,3,function(){ document.location=forwardURL});
return false;
});
// TOPky - presmerovane na zviditelneni
$("a[data-top-h]").removeAttr('href').css({cursor:'pointer'}).click(function(e){
e.preventDefault();
e.stopPropagation();
var hash = $(this).attr("data-top-h");
var url;
if ( $(this).data('gtm') )
{
trackGTM( $(this).data('gtm'), hash );
}
if (hash === '') {
url = "/topka/?id="+$(this).attr("data-top")+'&iframe=true&width=800&height=500';
$.prettyPhoto.open(url,'','');
} else {
url = "/zviditelneni/?hash="+$(this).attr("data-top-h");
window.location.href = url;
}
return false;
});
/*var tb = getCookie('tobagInz');
if ( tb != '' )
{
}*/
$('a[data-tobag]').removeAttr('href').css({cursor:'pointer'}).on("click", function(){
var url = $(this).data('tobag');
ajaxToBag(url, 0);
return false;
});
$('a[data-bag=yes]').on("click", function() {
var url = $(this).attr('href');
//* alert('s')
$.ajax({
type: "GET",
headers: {"Access-Control-Allow-Origin": "*.avizo.cz"},
url: url
}).done(function (data) {
if (data) {
//* alert(data);
var x = $(data).find("status").text();
var m = $(data).find("messg").text();
var _cf = $(data).find("cfirma").text();
var f = $(data).find("flogin").text();
if (m) {
var $o = $("div.alert");
if ($o.length > 0)
myAlert(m, 1, null);
else
myAlert(m, 1, null);
}
if (f == 1) {
window.location = "/prihlaseni/";
}
}
});
return false;
});
// naseptavac sekce
if ($( "#keywordSection" ).length > 0 ) {
$( "#keywordSection" ).autocomplete({
source: "/suggester/",
minLength: 2,
select: function( event, ui ) { setTimeout(function () { $( "#keywordSection" ).closest('form').submit(); }, 100); }
});
}
// naseptavac home
if ($( ".afult" ).length > 0 ) {
$( ".afult" ).autocomplete({
source: "/suggester/",
minLength: 2,
select: function( event, ui ) { setTimeout(function () { $( ".afult" ).closest('form').submit(); }, 100); }
});
}
if ($( "#hfulltxtformsb" ).length > 0 ) {
$( "#keywordsAds" ).autocomplete({
source: "/suggester/",
minLength: 2,
select: function( event, ui ) { setTimeout(function () { $( "#keywordsAds" ).closest('form').submit(); }, 100); }
});
$(document).on('change', '[name="r_ordersb"]', function (e)
{
$("#order").val( $(this).val() );
$("#hfulltxtformsb").submit();
});
// tlacitko vyhledat - da do URL jen ty inputy, ktere jsou vyplnene
$(document).on('submit',"#hfulltxtformsb", function(e){
e.preventDefault();
var formUrl = upravFormUrlSB( this );
if ( formUrl =='' ) return false;
//console.log( formUrl );
window.location.replace( formUrl );
return false;
});
}
// reklama sklik.cz
testReklamaSklik();
});
/** vypocita o kolik dni se prodlouzi inzerat pri nakupu TOP
* @param int puvodni pocet top ktere mel inz
* @param int nova pocet top ktere chce koupit
* @return int pocet dni o kolik se inz prodlouzi
*/
function topNaDnyProdlouzeniInzeratu(puvodni, nova)
{
var pocetDni = 0;
for(i=1;i<=nova;i++)
{
pocetDni += topNaDny((puvodni+i));
}
return pocetDni;
}
// prepocita topku na dny
function topNaDny(top)
{
// prvni 7 dní dopředu, druhá o 6 dní, třetí o 5 dní, čtvrtá o 4 dny, pátá a každá další o 3 dny.
if (top == 1 )
return 7;
if (top == 2 )
return 6;
if (top == 3 )
return 5;
if (top == 4 )
return 4;
return 3;
}
function spustCF($obj) {
var cf = $obj.data('call-func');
if (cf) {
if (myFunc[cf.name])
myFunc[cf.name](cf.param);
}
}
function _def_checkbox_start() {
$('.avizo-check').children('input[type="checkbox"]').hide();
$('.avizo-check').children('input[type="radio"]').hide();
$('.avizo-check').each(function(i,v)
{
if ( $(this).children(".avizo-check-button").length == 0 )
{
//$(this).wrapInner('
');
$(this).prepend('
');
$(this).prop("tabindex", 0);
$(this).attr("accesskey", genAccessKey(i) );
/*
var $input = $(this).find("input");
$(this).find("input").remove();
$(this).wrapInner('
')
$(this).prepend($input);
$(this).prepend('
');
$(this).prop("tabindex", 0);
$(this).attr("accesskey", 'X'); */
}
});
// $('.avizo-check').prepend('
');
$('.avizo-check input[type="checkbox"]').each(function() {
if ($(this).is(':checked')) {
$(this).parents('.avizo-check').addClass('checked');
$(this).parents('.avizo-check').find('.avizo-check-button').children('b').css('left','17px');
}
});
$('.avizo-check input[type="radio"]').each(function() {
if($(this).is(':checked')) {
$(this).parents('.avizo-check').addClass('checked');
$(this).parents('.avizo-check').find('.avizo-check-button').children('b').css('left','17px');
}
});
}
function _def_show_button() {
$( '.show-button' ).each(function() {
var schovej = $( this ).attr('href');
$( schovej ).hide();
});
}
function _def_tab_navi() {
$( '.tab-navi' ).each(function() {
$( this ).next( '.tab-container' ).children( '.tab-item' ).hide();
$( this ).next( '.tab-container' ).children( '.tab-item' ).first().show();
});
}
var logp=0;
function nastavCheckBoxAC(tthis, e) {
var typInput = $(tthis).find('input').attr( 'type');
//console.log("is:radio:"+$(tthis).children('input').is(':radio'));
if ($(tthis).is(':radio')) return;
if ($(tthis).hasClass("disabled")) return;
if (typInput == 'checkbox') {
if ($(tthis).find('input').is(':checked'))
_nastavCheckbox(tthis, false);
else
_nastavCheckbox(tthis, true);
}
if (typInput == 'radio') {
//e.preventDefault();
//console.log( (++logp)+". - nastavCheckBoxAC: radio, this:"+$(tthis).children('input').attr('name')+", e.type="+e.type+", e.target.type: "+e.target.type+", e.target.html: "+$(e.target).html() );
_nastavRadio(tthis, true);
}
}
function _nastavCheckbox(tthis, s) {
if (s === false) {
$(tthis).find('input').prop('checked',s);
$(tthis).find('input').attr('checked',s);
$(tthis).find('.avizo-check-button').children('b').animate({'left': '0px' }, '100ms' );
$(tthis).removeClass('checked');
} else {
$(tthis).find('input').prop('checked', s);
$(tthis).find('input').attr('checked',s);
$(tthis).find('.avizo-check-button').children('b').animate({'left': '17px' }, '100ms' );
$(tthis).addClass('checked');
}
//console.log("_nastavCheckbox: "+$(tthis).find('input')+", s:"+s);
}
function _nastavRadio(tthis, s) {
var inputName = 'input[name="'+$(tthis).find('input').attr( 'name' )+'"]';
// stary
$(inputName).each(function(i,el){
$label = $(this).parents('.avizo-check');
if ( $label.is(".checked") )
resetLabelRadio( $label );
});
// novy
if (s === true) {
$(tthis).find('input').prop('checked',true);
$(tthis).find('.avizo-check-button').children('b').animate({'left': '17px' }, '100ms' );
$(tthis).addClass('checked').removeClass('disabled');
} else {
$(tthis).addClass('disabled');
}
}
function resetLabelRadio( $label ){
$label.find('input').prop('checked',false);
$label.find('.avizo-check-button').children('b').animate({'left': '0px' }, '50ms' );
$label.removeClass('checked');
}
function myAlert(hl, typ, fnc) {
var $o = $("div.alert");
$o.find('alert-wrapper').removeClass("info").removeClass("error").addClass('info');
// zobrazi jen info pruh a za okamzik se ztrati
if (typ == 1) {
$o.find('.tlacitko').hide();
$o.find('.alert-close').hide();
$o.find('.alert-content').html(hl);
$o.show().delay(2500).fadeOut(800, function() {
if (typeof fnc === 'function') fnc();
});
} else {
var tlacitko = '
';
if (typ == 2)
tlacitko += 'Zavřít';
if (typ == 3)
tlacitko += 'Ok'
+' Storno';
tlacitko += '
';
$o.find('.alert-close').show();
$o.find('.alert-content').html(hl + tlacitko);
$o.find('.alert-close').on("click", function(){myAlertClose();});
$o.find('.b-zavri').on("click", function(){
myAlertClose();
});
$o.find('.b-zavri-ok').on("click", function(){
myAlertClose();
if (typeof fnc === 'function')
fnc();
});
$o.show();
}
return false;
}
function myAlertClose(){
var $o = $("div.alert");
$o.hide();
}
function validateEmail(email) {
if ( email.length < 4 )
{
return false;
}
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
if( !emailReg.test( email ) ) {
return false;
} else {
return true;
}
}
function upravFormUrl( form ) {
var l = $(form).attr('action');
if ($(form).attr('method') && $(form).attr('method').toLowerCase() === 'post') return true;
$("#pesEmail").val('');
if ( $("#lokalita_search").length > 0 ) {
if ( $("#lokalita_search").data('orig') != $("#lokalita_search").val() || $('input[name=lokalita_dist]').val() != '0' ) {
if ( $("#lokalita_nu").length > 0 && $("#lokalita_nu").val() != '') {
l = l.replace("/"+$("#lokalita_nu").val()+"/", "/");
}
}
}
if ( $("#lokalita_nu").length > 0 )
$("#lokalita_nu").val('');
//alert("orig: "+ $("#lokalita_search").data('orig') + "\n dist: "+$('input[name=lokalita_dist]').val())
//alert( "l="+l); return false;
var op = $(form).serialize();
var p = op.replace(/[^&]+=\.?(?:&|$)/g, '');
p = p.replace(/&$/, '');
var odd = l.indexOf("?") > -1 ? '&' : '?';
l += (p!=''?odd:'')+p;
return l;
}
function insertScriptEl( scriptElm ) {
var headElm = document.head || document.getElementsByTagName('head')[0];
headElm.appendChild(scriptElm);
}
function createScriptEl(path, id, ins ) {
var scriptElm = document.createElement('script');
scriptElm.type = 'text/javascript';
//scriptElm.async = 'async';
scriptElm.src = path;
if ( id )
scriptElm.id = id;
if ( ins == 1 )
insertScriptEl( scriptElm );
return scriptElm;
}
var sklikData = {};
function reklamaSklik( el, zoneId, w, h) {
sklikData = { elm: el, zoneId: zoneId, w: w, h: h };
var scriptElm = createScriptEl('//c.imedia.cz/js/script.js', 'js_sklik', 1 );
}
function testReklamaSklik(){
var ww = $(window).width(), div;
div = 'sklikReklama_RESP_SEZNAMKA';
if ( $("#" + div ).length > 0 ) {
// 468x60 pro od 961 do 1382, od 685 do 840
if ( ww > 960 && ww < 1383 || ww > 684 && ww < 841 )
reklamaSklik(div, 99615, 468, 60);
//600x190 pro rozliseni 1383 a vyse, od 841 do 960, od 685 do 767
else if( ww > 1382 || ww > 840 && ww < 961 || ww > 684 && ww < 768 )
reklamaSklik(div, 44284, 600, 190);
//300x250 pro 684 a nize
else if( ww < 685 )
reklamaSklik(div, 99620, 300, 250);
}
div = 'sklikReklama_RESP_EROTIKA';
if ( $("#" + div ).length > 0 ) {
// 468x60 pro od 961 do 1382, od 685 do 840
if ( ww > 960 && ww < 1383 || ww > 684 && ww < 841 )
reklamaSklik(div, 99710, 468, 60);
//600x190 pro rozliseni 1383 a vyse, od 841 do 960, od 685 do 767
else if( ww > 1382 || ww > 840 && ww < 961 || ww > 684 && ww < 768 )
reklamaSklik(div, 37481, 600, 190);
//300x250 pro 684 a nize
else if( ww < 685 )
reklamaSklik(div, 99715, 300, 250);
}
}
function genAccessKey(i)
{
//ABCDEFGHIJKLMNOPQRSTUVWXYZ
var chars = 'abcdefghijklmnopqrstuvwxyz0123456789_~@#$*()', result="", length=1;
//for (var i = length; i > 0; --i)
// result += chars[Math.round(Math.random() * (chars.length - 1))];
if (i > chars.length )
result = chars[0];
else
result = chars[i];
return result;
}
function setCookie(cname, cvalue, exdmins) {
var d = new Date();
d.setTime(d.getTime() + (exdmins * 60 * 1000));
var expires = "expires="+d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function getCookie(cname) {
var name = cname + "=";
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);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
function deleteCookie(cname) {
var d = new Date();
d.setTime(d.getTime() - (1000*60*60*24));
var expires = "expires=" + d.toGMTString();
//document.cookie = cname+"=;"+expires;
setCookie(cname, "", expires);
}
function ajaxToBag(url, p)
{
//, "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept"
// withCredentials - posila cookies na server, ale nesmi byt nastaveno headers: {"Access-Control-Allow-Origin": "*.avizo.cz"
// headers: {"Access-Control-Allow-Origin": "*"},
if ( p == 1 )
{
deleteCookie("_tobag");
}
$.ajax({
type: "GET",
xhrFields: {
withCredentials: true
},
url: url
}).done(function (data) {
if (data) {
var x = $(data).find("status").text();
var m = $(data).find("messg").text();
var _cf = $(data).find("cfirma").text();
var f = $(data).find("flogin").text();
if (m) {
myAlert(m, 1, null);
}
if (f == 1) {
setCookie("_tobag", url, 5);
window.location = "/prihlaseni/";
}
}
});
}
function upravFormUrlSB( form ) {
if ( $(form).attr('method') && $(form).attr('method').toLowerCase() === 'post')
return "";
var k = $.trim($("#keywordsAds").val());
if ( k == '' ) return "";
var l = $(form).attr('action');
l += encodeURIComponent( k ).replace(/-/g, '%2D').replace(/%20/g, '-').replace(/%2F/g,'-');
//encodeURIComponent(s).replace(/%20/g, '+')
var op = $(form).find(':not(input[name=keywords])').serialize();
var p = op.replace(/[^&]+=\.?(?:&|$)/g, '');
p = p.replace(/&$/, '');
var odd = l.indexOf("?") > -1 ? '&' : '/?';
l += (p!==''?odd:'')+p;
return l;
}