$(function() { $('body').mouseover(function(){ $('input.msformitem_ajax:not(.msformitem_ajax_initialized)').keyup(function(){ dataString = $(this).serialize(); $.ajax({ type: 'POST', url: 'cgi/ajax.cernahruska.cz.msform.php', async: false, cache: false, data: dataString, dataType: 'json', success: function(data) { if (data.emptyId != null && data.emptyId !== 'undefined') { if (Object.prototype.toString.call(data.emptyId) === '[object Array]' ) { var index; for (index = 0; index < data.emptyId.length; ++index) { $(data.emptyId[index]).empty(); } } else { $(data.emptyId).empty(); } } if (data.replaceWith != null && data.replaceWith !== 'undefined') { if (Object.prototype.toString.call(data.replaceWith) === '[object Array]' ) { var index; for (index = 0; index < data.replaceWith.length; ++index) { $(data.replaceWithId[index]).replaceWith(data.replaceWith[index]); } } else { $(data.replaceWithId).replaceWith(data.replaceWith); } } if (data.changeVal != null && data.changeVal !== 'undefined') { if (Object.prototype.toString.call(data.changeVal) === '[object Array]' ) { var index; for (index = 0; index < data.changeVal.length; ++index) { $(data.changeValId[index]).val(data.changeVal[index]); } } else { $(data.changeValId).val(data.changeVal); } } if (data.addClass != null && data.addClass !== 'undefined') { if (Object.prototype.toString.call(data.addClass) === '[object Array]' ) { var index; for (index = 0; index < data.addClass.length; ++index) { $(data.addClassId[index]).addClass(data.addClass[index]); } } else { $(data.addClassId).addClass(data.addClass); } } if (data.removeClass != null && data.removeClass !== 'undefined') { if (Object.prototype.toString.call(data.removeClass) === '[object Array]' ) { var index; for (index = 0; index < data.removeClass.length; ++index) { $(data.removeClassId[index]).removeClass(data.removeClass[index]); } } else { $(data.removeClassId).removeClass(data.removeClass); } } if (data.fadeInId != null && data.fadeInId !== 'undefined') { if (Object.prototype.toString.call(data.fadeInId) === '[object Array]' ) { var index; for (index = 0; index < data.fadeInId.length; ++index) { $(data.fadeInId[index]).fadeTo('fast',1); } } else { $(data.fadeInId).fadeTo('fast',1); } } if (data.fadeOutId != null && data.fadeOutId !== 'undefined') { if (Object.prototype.toString.call(data.fadeOutId) === '[object Array]' ) { var index; for (index = 0; index < data.fadeOutId.length; ++index) { $(data.fadeOutId[index]).fadeTo('slow',0); } } else { $(data.fadeOutId).fadeTo('slow',0); } } if (data.showId != null && data.showId !== 'undefined') { if (Object.prototype.toString.call(data.showId) === '[object Array]' ) { var index; for (index = 0; index < data.showId.length; ++index) { $(data.showId[index]).show('slow'); } } else { $(data.showId).show('slow'); } } if (data.hideId != null && data.hideId !== 'undefined') { if (Object.prototype.toString.call(data.hideId) === '[object Array]' ) { var index; for (index = 0; index < data.hideId.length; ++index) { $(data.hideId[index]).hide('fast'); } } else { $(data.hideId).hide('fast'); } } if (data.propId != null && data.propId !== 'undefined') { if (Object.prototype.toString.call(data.propId) === '[object Array]' ) { var index; for (index = 0; index < data.propId.length; ++index) { if (data.propValue[index] == 'false') { $(data.propId[index]).prop(data.propName[index],false); } else if (data.propValue[index] == 'true') { $(data.propId[index]).prop(data.propName[index],true); } else { $(data.propId[index]).prop(data.propName[index],data.propValue[index]); } } } else { if (data.propValue == 'false') { $(data.propId).prop(data.propName,false); } else if (data.propValue == 'true') { $(data.propId).prop(data.propName,true); } else { $(data.propId).prop(data.propName,data.propValue); } } } if (data.attrId != null && data.attrId !== 'undefined') { if (Object.prototype.toString.call(data.attrId) === '[object Array]' ) { var index; for (index = 0; index < data.attrId.length; ++index) { if (data.attrValue[index] == 'false') { $(data.attrId[index]).attr(data.attrName[index],false); } else if (data.attrValue[index] == 'true') { $(data.attrId[index]).attr(data.attrName[index],true); } else { $(data.attrId[index]).attr(data.attrName[index],data.attrValue[index]); } } } else { if (data.attrValue == 'false') { $(data.attrId).attr(data.attrName,false); } else if (data.attrValue == 'true') { $(data.attrId).attr(data.attrName,true); } else { $(data.attrId).attr(data.attrName,data.attrValue); } } } if (data.removeAttrId != null && data.removeAttrId !== 'undefined') { if (Object.prototype.toString.call(data.removeAttrId) === '[object Array]' ) { var index; for (index = 0; index < data.removeAttrId.length; ++index) { $(data.removeAttrId[index]).removeAttr(data.removeAttr[index]); } } else { $(data.removeAttrId).removeAttr(data.removeAttr); } } if (data.insertBefore != null && data.insertBefore !== 'undefined') $(data.insertBeforeId).before(data.insertBefore); if (data.insertPrepend != null && data.insertPrepend !== 'undefined') $(data.insertPrependId).prepend(data.insertPrepend); if (data.insertAppend != null && data.insertAppend !== 'undefined') $(data.insertAppendId).append(data.insertAppend); if (data.insertAfter != null && data.insertAfter !== 'undefined') $(data.insertAfterId).after(data.insertAfter); if (data.insert != null && data.insert !== 'undefined') $(data.insertId).empty().append(data.insert); if (data.fadeToId != null && data.fadeToId !== 'undefined' && data.fadeTo != null && data.fadeTo !== 'undefined') $(data.fadeToId).fadeTo('fast',data.fadeTo); if (data.resetForm != null && data.resetForm !== 'undefined') $(data.resetForm)[0].reset(); if (data.alert != null && data.alert !== 'undefined') alert(data.alert); if (data.moveToId != null && data.moveToId !== 'undefined') $('html, body').animate({ scrollTop: $(data.moveToId).offset().top + 30 }, 500); if (data.moveInId != null && data.moveInId !== 'undefined') { if (data.moveIn == null || data.moveIn === 'undefined') data.moveIn = 'html, body'; $(data.moveIn).animate({ scrollTop: $(data.moveInId).offset().top + 30 }, 500); } } }); return false; }); $('input.msformitem_ajax:not(.msformitem_ajax_initialized)').addClass('msformitem_ajax_initialized'); $('select.msformitem_ajax:not(.msformitem_ajax_initialized)').change(function(){ dataString = $(this).parents('form').serialize(); $.ajax({ type: 'POST', url: 'cgi/ajax.cernahruska.cz.msform.php', async: false, cache: false, data: dataString, dataType: 'json', success: function(data) { if (data.emptyId != null && data.emptyId !== 'undefined') { if (Object.prototype.toString.call(data.emptyId) === '[object Array]' ) { var index; for (index = 0; index < data.emptyId.length; ++index) { $(data.emptyId[index]).empty(); } } else { $(data.emptyId).empty(); } } if (data.replaceWith != null && data.replaceWith !== 'undefined') { if (Object.prototype.toString.call(data.replaceWith) === '[object Array]' ) { var index; for (index = 0; index < data.replaceWith.length; ++index) { $(data.replaceWithId[index]).replaceWith(data.replaceWith[index]); } } else { $(data.replaceWithId).replaceWith(data.replaceWith); } } if (data.changeVal != null && data.changeVal !== 'undefined') { if (Object.prototype.toString.call(data.changeVal) === '[object Array]' ) { var index; for (index = 0; index < data.changeVal.length; ++index) { $(data.changeValId[index]).val(data.changeVal[index]); } } else { $(data.changeValId).val(data.changeVal); } } if (data.addClass != null && data.addClass !== 'undefined') { if (Object.prototype.toString.call(data.addClass) === '[object Array]' ) { var index; for (index = 0; index < data.addClass.length; ++index) { $(data.addClassId[index]).addClass(data.addClass[index]); } } else { $(data.addClassId).addClass(data.addClass); } } if (data.removeClass != null && data.removeClass !== 'undefined') { if (Object.prototype.toString.call(data.removeClass) === '[object Array]' ) { var index; for (index = 0; index < data.removeClass.length; ++index) { $(data.removeClassId[index]).removeClass(data.removeClass[index]); } } else { $(data.removeClassId).removeClass(data.removeClass); } } if (data.fadeInId != null && data.fadeInId !== 'undefined') { if (Object.prototype.toString.call(data.fadeInId) === '[object Array]' ) { var index; for (index = 0; index < data.fadeInId.length; ++index) { $(data.fadeInId[index]).fadeTo('fast',1); } } else { $(data.fadeInId).fadeTo('fast',1); } } if (data.fadeOutId != null && data.fadeOutId !== 'undefined') { if (Object.prototype.toString.call(data.fadeOutId) === '[object Array]' ) { var index; for (index = 0; index < data.fadeOutId.length; ++index) { $(data.fadeOutId[index]).fadeTo('slow',0); } } else { $(data.fadeOutId).fadeTo('slow',0); } } if (data.showId != null && data.showId !== 'undefined') { if (Object.prototype.toString.call(data.showId) === '[object Array]' ) { var index; for (index = 0; index < data.showId.length; ++index) { $(data.showId[index]).show('slow'); } } else { $(data.showId).show('slow'); } } if (data.hideId != null && data.hideId !== 'undefined') { if (Object.prototype.toString.call(data.hideId) === '[object Array]' ) { var index; for (index = 0; index < data.hideId.length; ++index) { $(data.hideId[index]).hide('fast'); } } else { $(data.hideId).hide('fast'); } } if (data.propId != null && data.propId !== 'undefined') { if (Object.prototype.toString.call(data.propId) === '[object Array]' ) { var index; for (index = 0; index < data.propId.length; ++index) { if (data.propValue[index] == 'false') { $(data.propId[index]).prop(data.propName[index],false); } else if (data.propValue[index] == 'true') { $(data.propId[index]).prop(data.propName[index],true); } else { $(data.propId[index]).prop(data.propName[index],data.propValue[index]); } } } else { if (data.propValue == 'false') { $(data.propId).prop(data.propName,false); } else if (data.propValue == 'true') { $(data.propId).prop(data.propName,true); } else { $(data.propId).prop(data.propName,data.propValue); } } } if (data.attrId != null && data.attrId !== 'undefined') { if (Object.prototype.toString.call(data.attrId) === '[object Array]' ) { var index; for (index = 0; index < data.attrId.length; ++index) { if (data.attrValue[index] == 'false') { $(data.attrId[index]).attr(data.attrName[index],false); } else if (data.attrValue[index] == 'true') { $(data.attrId[index]).attr(data.attrName[index],true); } else { $(data.attrId[index]).attr(data.attrName[index],data.attrValue[index]); } } } else { if (data.attrValue == 'false') { $(data.attrId).attr(data.attrName,false); } else if (data.attrValue == 'true') { $(data.attrId).attr(data.attrName,true); } else { $(data.attrId).attr(data.attrName,data.attrValue); } } } if (data.removeAttrId != null && data.removeAttrId !== 'undefined') { if (Object.prototype.toString.call(data.removeAttrId) === '[object Array]' ) { var index; for (index = 0; index < data.removeAttrId.length; ++index) { $(data.removeAttrId[index]).removeAttr(data.removeAttr[index]); } } else { $(data.removeAttrId).removeAttr(data.removeAttr); } } if (data.insertBefore != null && data.insertBefore !== 'undefined') $(data.insertBeforeId).before(data.insertBefore); if (data.insertPrepend != null && data.insertPrepend !== 'undefined') $(data.insertPrependId).prepend(data.insertPrepend); if (data.insertAppend != null && data.insertAppend !== 'undefined') $(data.insertAppendId).append(data.insertAppend); if (data.insertAfter != null && data.insertAfter !== 'undefined') $(data.insertAfterId).after(data.insertAfter); if (data.insert != null && data.insert !== 'undefined') $(data.insertId).empty().append(data.insert); if (data.fadeToId != null && data.fadeToId !== 'undefined' && data.fadeTo != null && data.fadeTo !== 'undefined') $(data.fadeToId).fadeTo('fast',data.fadeTo); if (data.resetForm != null && data.resetForm !== 'undefined') $(data.resetForm)[0].reset(); if (data.alert != null && data.alert !== 'undefined') alert(data.alert); if (data.moveToId != null && data.moveToId !== 'undefined') $('html, body').animate({ scrollTop: $(data.moveToId).offset().top + 30 }, 500); if (data.moveInId != null && data.moveInId !== 'undefined') { if (data.moveIn == null || data.moveIn === 'undefined') data.moveIn = 'html, body'; $(data.moveIn).animate({ scrollTop: $(data.moveInId).offset().top + 30 }, 500); } } }); return false; }); $('select.msformitem_ajax:not(.msformitem_ajax_initialized)').addClass('msformitem_ajax_initialized'); $('form.msform_ajax:not(.msform_ajax_initialized)').submit(function(){ dataString = $(this).serialize(); $.ajax({ type: 'POST', url: 'cgi/ajax.cernahruska.cz.msform.php', async: false, cache: false, data: dataString, dataType: 'json', success: function(data) { if (data.emptyId != null && data.emptyId !== 'undefined') { if (Object.prototype.toString.call(data.emptyId) === '[object Array]' ) { var index; for (index = 0; index < data.emptyId.length; ++index) { $(data.emptyId[index]).empty(); } } else { $(data.emptyId).empty(); } } if (data.replaceWith != null && data.replaceWith !== 'undefined') { if (Object.prototype.toString.call(data.replaceWith) === '[object Array]' ) { var index; for (index = 0; index < data.replaceWith.length; ++index) { $(data.replaceWithId[index]).replaceWith(data.replaceWith[index]); } } else { $(data.replaceWithId).replaceWith(data.replaceWith); } } if (data.changeVal != null && data.changeVal !== 'undefined') { if (Object.prototype.toString.call(data.changeVal) === '[object Array]' ) { var index; for (index = 0; index < data.changeVal.length; ++index) { $(data.changeValId[index]).val(data.changeVal[index]); } } else { $(data.changeValId).val(data.changeVal); } } if (data.addClass != null && data.addClass !== 'undefined') { if (Object.prototype.toString.call(data.addClass) === '[object Array]' ) { var index; for (index = 0; index < data.addClass.length; ++index) { $(data.addClassId[index]).addClass(data.addClass[index]); } } else { $(data.addClassId).addClass(data.addClass); } } if (data.removeClass != null && data.removeClass !== 'undefined') { if (Object.prototype.toString.call(data.removeClass) === '[object Array]' ) { var index; for (index = 0; index < data.removeClass.length; ++index) { $(data.removeClassId[index]).removeClass(data.removeClass[index]); } } else { $(data.removeClassId).removeClass(data.removeClass); } } if (data.fadeInId != null && data.fadeInId !== 'undefined') { if (Object.prototype.toString.call(data.fadeInId) === '[object Array]' ) { var index; for (index = 0; index < data.fadeInId.length; ++index) { $(data.fadeInId[index]).fadeTo('fast',1); } } else { $(data.fadeInId).fadeTo('fast',1); } } if (data.fadeOutId != null && data.fadeOutId !== 'undefined') { if (Object.prototype.toString.call(data.fadeOutId) === '[object Array]' ) { var index; for (index = 0; index < data.fadeOutId.length; ++index) { $(data.fadeOutId[index]).fadeTo('slow',0); } } else { $(data.fadeOutId).fadeTo('slow',0); } } if (data.showId != null && data.showId !== 'undefined') { if (Object.prototype.toString.call(data.showId) === '[object Array]' ) { var index; for (index = 0; index < data.showId.length; ++index) { $(data.showId[index]).show('slow'); } } else { $(data.showId).show('slow'); } } if (data.hideId != null && data.hideId !== 'undefined') { if (Object.prototype.toString.call(data.hideId) === '[object Array]' ) { var index; for (index = 0; index < data.hideId.length; ++index) { $(data.hideId[index]).hide('fast'); } } else { $(data.hideId).hide('fast'); } } if (data.propId != null && data.propId !== 'undefined') { if (Object.prototype.toString.call(data.propId) === '[object Array]' ) { var index; for (index = 0; index < data.propId.length; ++index) { if (data.propValue[index] == 'false') { $(data.propId[index]).prop(data.propName[index],false); } else if (data.propValue[index] == 'true') { $(data.propId[index]).prop(data.propName[index],true); } else { $(data.propId[index]).prop(data.propName[index],data.propValue[index]); } } } else { if (data.propValue == 'false') { $(data.propId).prop(data.propName,false); } else if (data.propValue == 'true') { $(data.propId).prop(data.propName,true); } else { $(data.propId).prop(data.propName,data.propValue); } } } if (data.attrId != null && data.attrId !== 'undefined') { if (Object.prototype.toString.call(data.attrId) === '[object Array]' ) { var index; for (index = 0; index < data.attrId.length; ++index) { if (data.attrValue[index] == 'false') { $(data.attrId[index]).attr(data.attrName[index],false); } else if (data.attrValue[index] == 'true') { $(data.attrId[index]).attr(data.attrName[index],true); } else { $(data.attrId[index]).attr(data.attrName[index],data.attrValue[index]); } } } else { if (data.attrValue == 'false') { $(data.attrId).attr(data.attrName,false); } else if (data.attrValue == 'true') { $(data.attrId).attr(data.attrName,true); } else { $(data.attrId).attr(data.attrName,data.attrValue); } } } if (data.removeAttrId != null && data.removeAttrId !== 'undefined') { if (Object.prototype.toString.call(data.removeAttrId) === '[object Array]' ) { var index; for (index = 0; index < data.removeAttrId.length; ++index) { $(data.removeAttrId[index]).removeAttr(data.removeAttr[index]); } } else { $(data.removeAttrId).removeAttr(data.removeAttr); } } if (data.insertBefore != null && data.insertBefore !== 'undefined') $(data.insertBeforeId).before(data.insertBefore); if (data.insertPrepend != null && data.insertPrepend !== 'undefined') $(data.insertPrependId).prepend(data.insertPrepend); if (data.insertAppend != null && data.insertAppend !== 'undefined') $(data.insertAppendId).append(data.insertAppend); if (data.insertAfter != null && data.insertAfter !== 'undefined') $(data.insertAfterId).after(data.insertAfter); if (data.insert != null && data.insert !== 'undefined') $(data.insertId).empty().append(data.insert); if (data.fadeToId != null && data.fadeToId !== 'undefined' && data.fadeTo != null && data.fadeTo !== 'undefined') $(data.fadeToId).fadeTo('fast',data.fadeTo); if (data.resetForm != null && data.resetForm !== 'undefined') $(data.resetForm)[0].reset(); if (data.alert != null && data.alert !== 'undefined') alert(data.alert); if (data.moveToId != null && data.moveToId !== 'undefined') $('html, body').animate({ scrollTop: $(data.moveToId).offset().top + 30 }, 500); if (data.moveInId != null && data.moveInId !== 'undefined') { if (data.moveIn == null || data.moveIn === 'undefined') data.moveIn = 'html, body'; $(data.moveIn).animate({ scrollTop: $(data.moveInId).offset().top + 30 }, 500); } } }); return false; }); $('form.msform_ajax:not(.msform_ajax_initialized)').addClass('msform_ajax_initialized'); }); });