var basketagain=false;
var iconset = ["home", "newspaper", "pencil", "quill", "image", "camera", "music", "play", "film", "camera2", "bullhorn", "connection", "podcast", "book", "file", "stack", "tag", "cart", "coin", "credit", "phone", "envelope", "pushpin", "location", "location2", "clock", "alarm", "bell", "calendar", "bubble", "user", "users", "busy", "binoculars", "key", "lock", "unlocked", "cog", "wand", "stats", "bars", "trophy", "glass", "mug", "food", "fire", "remove", "airplane", "truck", "road", "lightning", "list", "menu", "globe", "earth", "flag", "attachment", "eye", "bookmark", "star", "star2", "star3", "heart", "heart2", "happy", "smiley", "tongue", "sad", "wink", "grin", "cool", "angry", "evil", "shocked", "confused", "neutral", "wondering", "warning", "notification", "question", "info", "close", "minus", "plus", "filter", "google", "googleplus", "facebook", "instagram", "twitter", "feed", "youtube", "vimeo", "flickr", "picassa", "yahoo", "apple", "android", "skype", "linkedin", "delicious", "pinterest", "foursquare", "paypal"];
var killsearchitems=false;
var theopenid=false;
///////////////////////////////////////
// //
// Helpers //
// //
///////////////////////////////////////
function inArray(needle, haystack) {
var length = haystack.length;
for(var i = 0; i < length; i++) {
if(haystack[i] == needle) return true;
}
return false;
}
function reHighliteListItem(id){
$("#thissearchitemimg"+id).css("border", "0px");
}
function scrollToItem(id){
if($("#thissearchitem"+id).offset()!=undefined){
var tx=$("#thissearchitem"+id).offset().top;
tx=tx-150;
$('html, body').animate({scrollTop: tx+"px"},'slow');
$("#thissearchitemimg"+id).css("border", "10px solid #c38d4d");
window.setTimeout("reHighliteListItem('"+id+"')", 3500);
}
}
/*
String.prototype.parseURL = function() {
return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&~\?\/.=]+/g, function(url) {
return ""+url+" ";
});
};
function startHashtag(tag){
if(cpage!="news"){
showPlaceSearch();
showAllOptions();
$("#sotext").val(tag);
sotext=encodeURIComponent($("#sotext").val());
peoplepage=1;
getCheckins();
$('#resetoptions').slideDown('slow', function(){});
$('#checkinoptions').addClass('bgreddark');
}else{
$("#feedq").val(tag);
whatfeed='everyone';
$('.whatfeed').removeClass('bggreen');
$('#whatfeed'+whatfeed).addClass('bggreen');
setNewsMenu('Newsfeed');
}
}
String.prototype.parseHashtag = function() {
return this.replace(/[#]+[A-Za-z0-9-_]+/g, function(t) {
var tag = t.replace("#","");
return "#"+tag+" ";
});
};
String.prototype.parseAts = function() {
return this.replace(/[@]+[A-Za-z0-9-_]+/g, function(t) {
var tag = t.replace("@","")
return "@"+tag+" ";
});
};
String.prototype.parseExc = function() {
return this.replace(/[!]+[A-Za-z0-9-_]+/g, function(t) {
var tag = t.replace("!","")
return "!"+tag+" ";
});
};
*/
function linkify(inputText) {
var replacedText, replacePattern1, replacePattern2, replacePattern3;
//URLs starting with http://, https://, or ftp://
replacePattern1 = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;
replacedText = inputText.replace(replacePattern1, '$1 ');
//URLs starting with "www." (without // before it, or it'd re-link the ones done above).
replacePattern2 = /(^|[^\/])(www\.[\S]+(\b|$))/gim;
replacedText = replacedText.replace(replacePattern2, '$1$2 ');
//Change email addresses to mailto:: links.
replacePattern3 = /(([a-zA-Z0-9\-\_\.])+@[a-zA-Z\_\-]+?(\.[a-zA-Z]{2,6})+)/gim;
replacedText = replacedText.replace(replacePattern3, '$1 ');
return replacedText;
}
///////////////////////////////////////
// //
// Videos //
// //
///////////////////////////////////////
function checkIfInstaVideo(val, url, imgurl, replaceat, rep){
var myurl="https://api.instagram.com/v1/media/"+val['media_id']+"?client_id=c1e113e25b9f40ff894733726e433358";
$.ajax({
url: myurl,
type: 'GET',
dataType: 'jsonp',
success: function(data) {
if(rep && data['data']['type']=="video"){
var w=$('#'+replaceat).width();
var h=$('#'+replaceat).height()+100;
var turl=url+"embed/";
$("#"+replaceat).html("
");
}
if(data['data']['type']=="video" && !rep){
$("#"+replaceat).css('display', 'block');
}
},
error: function(XHR, textStatus, errorThrown){
}
});
}
function getIstaIMGfromURL(url, imgurl, replaceat, rep){
var myurl="http://api.instagram.com/oembed?url="+encodeURIComponent(url);
$.ajax({
url: myurl,
type: 'GET',
dataType: 'jsonp',
success: function(data) {
checkIfInstaVideo(data, url, imgurl, replaceat, rep)
},
error: function(XHR, textStatus, errorThrown){
}
});
}
//VIDEO
function getVideo(url, imgurl, replaceat, rep){
var w=$('#theimage_'+replaceat).width();
var h=$('#theimage_'+replaceat).height();
var l = getHostname(url);
var isvideo=false;
var turl=false;
if(l!="instagram.com" && l!="instagr.am" && l!="www.instagr.am" && l!="www.instagram.com" ){
if(l=="vine.co"){
turl=url+"/card";
}
if(l=="youtube.com" || l=="youtu.be" || l=="www.youtube.com" || l=="www.youtu.be"){
if(imgurl!=""){
var params=imgurl.split("/");
var param="";
for(var i=0; i");
}
if(turl && !rep){
$("#"+replaceat).css('display', 'block');
}
return turl;
}else{
getIstaIMGfromURL(url, imgurl, replaceat, rep);
}
setDim();
setTimeout(function(){ setDim(); }, 1000);
setTimeout(function(){ setDim(); }, 3000);
}
///////////////////////////////////////
// //
// Timestamps //
// //
///////////////////////////////////////
function relative_time_twitter(dateString) {
var rightNow = new Date(),
then = new Date(dateString),
diff = rightNow - then,
second = 1000,
minute = second * 60,
hour = minute * 60,
day = hour * 24,
week = day * 7;
// return blank string if unknown
if (isNaN(diff) || diff < 0) {
return dateString;
}
// within 2 seconds
if (diff < second * 2) {
return "right now";
}
if (diff < minute) {
return Math.floor(diff / second) + " seconds ago";
}
if (diff < minute * 2) {
return "about 1 minute ago";
}
if (diff < hour) {
return Math.floor(diff / minute) + " minutes ago";
}
if (diff < hour * 2) {
return "about 1 hour ago";
}
if (diff < day) {
return Math.floor(diff / hour) + " hours ago";
}
if (diff > day && diff < day * 2) {
return "yesterday";
}
if (diff < day * 365) {
return Math.floor(diff / day) + " days ago";
}
else {
return "over a year ago";
};
}
function updateTimeStr(){
$('span').each( function( idx )
{
// try to get an existing attribute
var stnid = $(this).attr( 'timestr' );
// check whether we got a valid attribute
if ( stnid && stnid != 'undefined' && stnid != null && stnid!=''){
var newago=relative_time_twitter(stnid);
this.innerHTML=newago;
}
}
);
}
function focusAtEnd(el) {
el.focus();
var s = el.value;
el.value = '';
el.value = s;
}
///////////////////////////////////////
// //
// Socialize //
// //
///////////////////////////////////////
function startShare(){
$('#sharebuttons').fadeIn('slow', function(){});
}
function hideShare(){
$('#sharebuttons').fadeOut('slow', function(){});
}
function startTwitterRE(thisid, thisintent, thisto){
var TwReWinURL='https://twitter.com/intent/'+thisintent+'?'+thisto+'='+thisid+'&via=s42at';
TwReWin = window.open(TwReWinURL, "TwReWin1", "width=550,height=350,left=100;top=100;toolbar=yes,scrollbars=yes,resizable=no,location=no");
TwReWin.focus();
}
function shareIt(on, code){
var dir="verlag";
if(on=="Twitter"){
var url="https://bachem.de/"+dir+"/"+code;
var popurl="https://twitter.com/intent/tweet?&url="+url;
wintw = window.open( popurl , "wintwl", "width=600,height=400,left=100;top=100,toolbar=no,scrollbars=yes,resizable=no,location=no");
wintw.focus();
}
if(on=="Facebook"){
var headredicerct=encodeURIComponent("http://bachem.de/cb.php");
var url=encodeURIComponent("https://bachem.de/"+dir+"/"+code);
var quote=encodeURIComponent("Bachem Verlag");
var popurl="https://www.facebook.com/dialog/feed?app_id=670050973094871"e="+quote+"&display=popup&link="+url+"&redirect_uri="+headredicerct;
winfb = window.open( popurl , "winfbl", "width=600,height=400,left=100;top=100,toolbar=no,scrollbars=yes,resizable=no,location=no");
winfb.focus();
}
if(on=="Google"){
var url=encodeURIComponent("https://bachem.de/"+dir+"/"+code);
var popurl="https://plus.google.com/share?url="+url;
wingo = window.open( popurl , "wingol", "width=500,height=500,left=100;top=100,toolbar=no,scrollbars=yes,resizable=no,location=no");
wingo.focus();
}
}
function emailIt(code, title, imgurl){
window.location='mailto:?subject='+title+'&body=https://bachem.de/'+code;
}
function displayRemoveConnection(val){
if(val){
$('#connextion'+val).slideUp('slow', function(){});
}
}
function removeConnection(id){
x_removeConnection(id, displayRemoveConnection);
}
///////////////////////////////////////
// //
// URL //
// //
///////////////////////////////////////
var getHostname = function(href) {
var l = document.createElement("a");
l.href = href;
return l.hostname;
};
function setURL(u, t){
if(t!=""){
document.title="Bachem Verlag | "+t;
}else{
document.title="Bachem Verlag";
}
var url="https://bachem.de/verlag/"+u
var stateObj = { foo: "bachemneu" };
history.pushState(stateObj, "bachemneu", url);
}
///////////////////////////////////////
// //
// Navigation //
// //
///////////////////////////////////////
function hideFrameLoader(){
$('#frameloader').css('display', 'none');
}
function getStoryLayer(url){
$('#frameloader').css('display', 'block');
$('body').css('overflow', 'hidden');
$('#frameloader').css('overflow-y', 'hidden');
$('#frameloader').css('display', 'block');
$('#theframe').attr('src', String(url));
}
function closeWelcomeMenu(){
$('#jpbachemlogo').animate({"height": "80px"},300, function(){});
$('#closewelcomemenubutton').fadeOut('slow', function(){});
$('#welcomemenubutton').fadeIn('slow', function(){});
}
function showWelcomeMenu(){
$('#jpbachemlogo').animate({"height": "355px"},300, function(){});
$('#welcomemenubutton').fadeOut('slow', function(){});
$('#closewelcomemenubutton').fadeIn('slow', function(){});
}
function getForeignPage(page){
if(page=="verlag"){
top.location.href="https://bachem.de/verlag/";
}
if ( navigator.userAgent.match( /(iPhone|iPod|iPad|Android|BlackBerry|webOS)/i ) ){
}else{
$('#closewelcomemenubutton').fadeOut('slow', function(){});
$('#welcometext').fadeOut('slow', function(){});
$("#jpbachemlogo").css("text-align", "left");
$('#jpbachemlogo').animate({"height": "80px"},300, function(){});
$('#jpbachemlogo').animate({"top": "0px"},300, function(){});
$('#jpbachemlogo').animate({"margin-left": "100px"},600, function(){});
$('#jpbachemlogo').animate({"left": "0px"},300, function(){
$('#jpbachemlogo').animate({"margin-left": "0px"},300, function(){});
$('#jpbachemlogo').animate({"width": "100%"},300, function(){
$('#framecan').fadeIn('fast', function(){});
$('#welcomemenubutton').fadeIn('fast', function(){});
if(page=="poly"){
getStoryLayer("http://www.polivox.de");
}
if(page=="kirche"){
getStoryLayer("http://www.kirchenzeitung-koeln.de");
}
if(page=="ferien"){
getStoryLayer("http://ferienstrassen.info");
}
if(page=="immo"){
getStoryLayer("https://bachem.de/immobilien/");
}
});
});
}
}
///////////////////////////////////////
// //
// Basket //
// //
///////////////////////////////////////
var basketcount=0;
function reDisplaySubmitOrder(){
closeBasket();
}
function displaySubmitOrder(){
hideOrderForm();
$("#basketcount").html("");
$("#basketcount").fadeOut("fast");
$("#basketdata").html("Vielen Dank für Ihre Bestellung! Ihnen wurde eine Auftragsbestätigung per Email zugesand. ");
window.setTimeout("reDisplaySubmitOrder()", 3500);
}
function submitOrder(){
var theorder = new Object;
theorder['customer']= new Object;
theorder['customer']['firstname']=encodeURIComponent($("#order_firstname").val());
theorder['customer']['lastname']=encodeURIComponent($("#order_lastname").val());
theorder['customer']['company']=encodeURIComponent($("#order_company").val());
theorder['customer']['street']=encodeURIComponent($("#order_street").val());
theorder['customer']['zip']=encodeURIComponent($("#order_zip").val());
theorder['customer']['city']=encodeURIComponent($("#order_city").val());
theorder['customer']['country']=encodeURIComponent($("#order_country").val());
theorder['customer']['email']=encodeURIComponent($("#order_email").val());
theorder['order']= new Object;
theorder['order']['subtotal']=encodeURIComponent($("#subtotal").html());
theorder['order']['shippingselect']=encodeURIComponent($("#shippingselect").val());
theorder['order']['shipping']=encodeURIComponent($("#shipping").html());
theorder['order']['ordertotal']=encodeURIComponent($("#ordertotal").html());
theorder['order']['message']=encodeURIComponent($("#order_message").val());
theorder['orderitems']= new Array;
for(i=0; i < basketcount; i++){
theorder['orderitems'][i] = new Object;
theorder['orderitems'][i]['id']=encodeURIComponent($("#basketid"+i).val());
theorder['orderitems'][i]['quantity']=encodeURIComponent($("#quantity"+i).val());
}
var data_to_send = JSON.stringify(theorder);
x_submitOrder(data_to_send, displaySubmitOrder);
}
function checkOrderForm(){
$(".orderin").css("border-color", "#d1d1d1");
var s=$("#order_firstname").val();
if(s==""){
$("#order_firstname").css("border-color", "#ff0000");
focusAtEnd($("#order_firstname"));
return false;
}
var s=$("#order_lastname").val();
if(s==""){
$("#order_lastname").css("border-color", "#ff0000");
focusAtEnd($("#order_lastname"));
return false;
}
var s=$("#order_street").val();
if(s==""){
$("#order_street").css("border-color", "#ff0000");
focusAtEnd($("#order_street"));
return false;
}
var s=$("#order_zip").val();
if(s==""){
$("#order_zip").css("border-color", "#ff0000");
focusAtEnd($("#order_zip"));
return false;
}
var s=$("#order_city").val();
if(s==""){
$("#order_city").css("border-color", "#ff0000");
focusAtEnd($("#order_city"));
return false;
}
var s=$("#order_country").val();
if(s==""){
$("#order_country").css("border-color", "#ff0000");
focusAtEnd($("#order_country"));
return false;
}
var s=$("#order_email").val();
var validemail=checkmail(s);
if(!validemail){
$("#order_email").css("border-color", "#ff0000");
focusAtEnd($("#order_email"));
return false;
}
var c=$("#agbcheck").attr("class");
if(c=="icon-checkbox-unchecked"){
alert('Stimmen Sie bitte noch unseren AGB zu! Danke!');
return false;
}
submitOrder();
}
function setAGBCheck(){
var c=$("#agbcheck").attr("class");
$("#agbcheck").removeClass("icon-checkbox-unchecked");
$("#agbcheck").removeClass("icon-checkbox-checked");
if(c=="icon-checkbox-unchecked"){
$("#agbcheck").addClass("icon-checkbox-checked");
}else{
$("#agbcheck").addClass("icon-checkbox-unchecked")
}
}
function showShippingInfos(){
var s=$("#shippingselect").val();
if(s=="EU"){
$('#sinfoseu').slideDown('slow', function(){});
}
if(s=="WO"){
$('#sinfoswo').slideDown('slow', function(){});
$('#sinfoseu').slideDown('slow', function(){});
}
}
function setShipping(){
var ordertotal=$("#subtotal").html();
ordertotal=parseFloat(ordertotal.replace(/,/g, '.'));
var s=$("#shippingselect").val();
if(s=="DE"){
$("#shipping").html("0,00");
$('#showshippinginfoslink').slideUp('slow', function(){});
$("#shippingtherms").html("Versandbedingungen");
}
if(s=="EU"){
//$("#shipping").html("8,60");
//ordertotal=ordertotal+8.6;
$("#shipping").html("9,00");
ordertotal=ordertotal+9;
$('#showshippinginfoslink').slideDown('slow', function(){});
$("#shippingtherms").html("Versandbedingungen Ausland");
}
if(s=="WO"){
//$("#shipping").html("12,90");
//ordertotal=ordertotal+12.9;
$("#shipping").html("9,00");
ordertotal=ordertotal+9;
$('#showshippinginfoslink').slideDown('slow', function(){});
$("#shippingtherms").html("Versandbedingungen Ausland");
}
$('#sinfoswo').slideUp('slow', function(){});
$('#sinfoseu').slideUp('slow', function(){});
ordertotal=ordertotal.toFixed(2);
ordertotal=ordertotal.replace(/\./g, ',');
$("#ordertotal").html(ordertotal);
}
function closeBasket(){
$('#topcats').slideDown('slow', function(){});
$('#outputtop').slideDown('slow', function(){});
killsearchitems=false;
$('#searcharea').fadeIn('slow', function(){});
$('#basket').fadeOut('slow', function(){});
$('#closebasketlink').fadeOut('slow', function(){});
$('#orderaddress').slideUp('slow', function(){});
$("#totalamount").html("");
$('body').css('overflow', 'auto');
}
function prepairOrderForm(){
$('.minorder').css('min-height', 'auto');
$('.minorder').animate({"height": "150px"},300, function(){});
$('.minorder').animate({"width": "150px"},300, function(){});
$('.leftorder').css('float', 'left');
$('.leftorder').animate({"margin-top": "-15px"},300, function(){});
$('.leftorder').animate({"margin-left": "15px"},300, function(){});
$('.minorder').animate({"margin-right": "50px"},300, function(){});
$("#totalamount").html("");
$('#orderaddress').slideDown('slow', function(){});
}
function hideOrderForm(){
$('.minorder').css('width', 'auto');
$('.minorder').css('height', 'auto');
$('.minorder').animate({"min-height": "300px"},300, function(){});
$('.minodercan').css('width', '300px');
$('.leftorder').css('float', 'none');
$('.leftorder').animate({"margin-top": "10px"},300, function(){});
$('.leftorder').animate({"margin-left": "0px"},300, function(){});
$('.minorder').animate({"margin-right": "0px"},300, function(){});
$("#totalamount").html("");
$('#orderaddress').slideUp('slow', function(){});
}
function calcQuantityPrice(id){
var returnamount=0;
var price=$("#price"+id).val();
price=parseFloat(price.replace(/,/g, '.'));
var quantity=$("#quantity"+id).val();
var amount=price*quantity;
returnamount=amount;
amount=amount.toFixed(2);
amount=amount.replace(/\./g, ',');
if(amount!="NaN" && amount!="0,00" ){
$("#amount"+id).html(amount+" €");
}else{
returnamount=0;
$("#amount"+id).html("");
$("#quantity"+id).val("");
}
return returnamount;
}
function calcAllAmounts (){
hideOrderForm();
var total=0;
var ordertotal=0;
for(i=0;i Jetzt bestellen [ "+total+" € ] ");
$("#subtotal").html(total);
$("#ordertotal").html(ordertotal);
}else{
$("#totalamount").html("");
$("#subtotal").html("");
$("#ordertotal").html("");
}
}
function dispplaySetNewBasketAmount(val){
}
function setNewBasketAmount(i, id){
var value=$("#quantity"+i).val();
x_setNewBasketAmount(id, value, dispplaySetNewBasketAmount);
}
function displayGetBasket(val){
basketcount=0;
$("#basketdata").html("");
if(val){
for(var i in val['item']){
$("#basketdata").append("Einzelpreis "+val['item'][i]['price']+" €
");
basketcount++;
}
$('#removeallfrombasket').slideDown('slow');
}else{
$("#basketdata").html("Der Warenkorb ist leer. ");
$('#removeallfrombasket').slideUp('slow');
}
calcAllAmounts();
if(basketcount>0){
$("#basketcount").html(basketcount);
$('#basketcount').slideDown('slow');
}else{
$('#basketcount').slideUp('slow');
}
}
function showBasket(){
$('#searcharea').fadeOut('slow', function(){});
$('#basket').fadeIn('slow', function(){});
$('#closebasketlink').fadeIn('slow', function(){});
$('#oneitem').fadeOut('slow', function(){});
$('#closeoneitemlink').fadeOut('slow', function(){});
x_getBasket(displayGetBasket);
$('body').css('overflow', 'hidden');
}
function displayAddToBasket(val){
if(val){
$("#book_view_basket_"+val['id']).html(" Im Warenkorb · Jetzt bestellen... ");
if(val['basketc']!=0){
//$("#basketlink").html(" "+val['basketc']);
}else{
//$("#basketlink").html(" ");
}
showBasket();
}
}
function addToBasket(id){
x_addToBasket(id, displayAddToBasket);
}
function displayRemoveFromBasket(val){
$('#basketelement'+val).slideUp('slow', function(){
x_getBasket(displayGetBasket);
});
}
function removeFromBasket(id){
x_removeFromBasket(id, displayRemoveFromBasket);
}
function displayRemoveAllFromBasket(val){
if(val){
$("#basketdata").html("Der Warenkorb ist leer. ");
$('#removeallfrombasket').slideUp('slow');
$('#basketcount').slideUp('slow');
}
}
function removeAllFromBasket(){
x_removeAllFromBasket(displayRemoveAllFromBasket);
}
///////////////////////////////////////
// //
// Items //
// //
///////////////////////////////////////
function makeStoryView(val){
if(val['pubpress']==0){
$("#theitemsories").append("");
}else{
$("#theitempresssories").append("");
}
if(val['icon']!=""){
if(val['url']!=""){
$("#story_view_icon_"+val['id']).html(" ");
}else{
$("#story_view_icon_"+val['id']).html(" ");
}
}else{
$("#story_view_icon_"+val['id']).css('display', 'none');
}
if(val['url']!=""){
if(val['title']!=""){
$("#story_view_title_"+val['id']).html(""+val['title']+" ");
}
if(val['imgurl']!=""){
if(val['file']==""){
$("#story_view_image_"+val['id']).html(" ");
}
if(val['file']=="png"){
$("#story_view_image_"+val['id']).html(" ");
}
if(val['file']=="pdf"){
$("#story_view_image_"+val['id']).html(" ");
}
if(val['file']=="doc"){
$("#story_view_image_"+val['id']).html(" ");
}
if(val['file']!="doc" && val['file']!="pdf" && val['file']!="" && val['file']!="png"){
$("#story_view_image_"+val['id']).html(" ");
}
}
}else{
if(val['title']!=""){
$("#story_view_title_"+val['id']).html(""+val['title']+"");
}
if(val['imgurl']!=""){
if(val['file']==""){
$("#story_view_image_"+val['id']).html("");
}
if(val['file']=="png"){
$("#story_view_image_"+val['id']).html(" ");
}
if(val['file']=="pdf"){
$("#story_view_image_"+val['id']).html(" ");
}
if(val['file']=="doc"){
$("#story_view_image_"+val['id']).html(" ");
}
if(val['file']!="doc" && val['file']!="pdf" && val['file']!="" && val['file']!="png"){
$("#story_view_image_"+val['id']).html(" ");
}
}
}
if(val['text']!=""){
$("#story_view_text_"+val['id']).html(""+val['text']+"");
}
if(val['url']!="" && val['imgurl']!=""){
$('#story_view_image_loaded'+val['id']).imagesLoaded( function() {
var imgLoad=getVideo(val['url'], val['imgurl'], "story_view_image_"+val['id'], true);
});
}
var l = getHostname(val['url']);
if(l=="player.vimeo.com"){
var imgLoad=getVideo(val['url'], "", "story_view_image_"+val['id'], true);
}
if(cpage=="oneitem"){
showPressStories();
}
}
function displaySaveInfoMail(val){
if(val){
$("#infomailstatus").html("Ihre Email-Adresse wurde eingetragen. Vielen Dank für Ihr Interesse!
");
$("#infomailinput").slideUp('fast');
$("#infomailbutton").slideUp('fast');
}else{
$("#infomailstatus").html("Ihre Email-Adresse wurde bereits eingetragen
");
}
}
function checkInfoMail(itemid){
$("#infomailstatus").html("");
var email=$("#infomail").val();
if (!email.match(/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i)){
$("#infomailstatus").html("Ungültige Email
");
} else {
email=encodeURIComponent(email);
x_saveInfoMail(itemid, email, displaySaveInfoMail);
}
}
function makeBookView(val){
$("#theitemdata").append("");
$("#book_view_title_"+val['id']).html(val['title']);
$("#book_view_subtitle_"+val['id']).html(val['subtitle']);
$("#book_view_publisher_"+val['id']).html(val['publisher']);
$("#book_view_edition_"+val['id']).html(val['edition']);
$("#book_view_isbn_"+val['id']).html(val['isbn']);
$("#book_view_shareit_"+val['id']).html("");
if(val['price']!=""){
$("#book_view_price_"+val['id']).html(val['price']+" €");
if(val['ca']!=""){
$("#book_view_price_"+val['id']).html(val['ca']+" "+$("#book_view_price_"+val['id']).html());
}
}
if(val['price']!="" && val['status']!=0 && val['status']!=1 && val['status']!=4 ){
if(val['inbasket']){
$("#book_view_basket_"+val['id']).html(" Im Warenkorb · Jetzt bestellen... ");
}else{
$("#book_view_basket_"+val['id']).html(" In den Warenkorb ");
$("#book_view_basket_"+val['id']).append("Innerhalb Deutschlands übernehmen wir für Sie die Versandkosten!
");
}
}
if(val['status']==4){
$("#book_view_basket_"+val['id']).html(""+val['title']+" ist leider z.Zt. vergriffen. ");
}
if(val['status']==1){
if(val['publicationday']!=""){
$("#book_view_basket_"+val['id']).html("Vorschau Voraussichtlich ab "+val['publicationday']+" erhältlich.");
}else{
$("#book_view_basket_"+val['id']).html("Vorschau ");
}
/*
$("#book_view_basket_"+val['id']).append(" Tragen Sie hier Ihre Email-Adresse ein. Wir informieren Sie, sobald der Titel verfügbar ist.
");
*/
}
if(val['status']==3){
$("#book_view_price_"+val['id']).append(" ANGEBOT ");
}
if(val['status']==5){
$("#book_view_price_"+val['id']).append(" NEU ");
}
$("#book_view_description_"+val['id']).html(val['description']);
if(val['imgurl']!=""){
$("#book_view_image_"+val['id']).html("");
}
if(val['tags']!=""){
var arr = val['tags'].split(' ');
for(var i in arr){
if( arr[i] != "" ){
//$("#book_view_tags_"+val['id']).html($("#book_view_tags_"+val['id']).html()+""+arr[i]+" ");
$("#theitemtags").append("");
}
}
}
if(!val['quizdata']){
setURL(val['id'], val['title']);
}else{
$("#book_view_shareit_"+val['id']).html("");
setURL(val['quizdata']['id'], val['quizdata']['title']);
}
}
function makeAppView(val){
$("#theitemdata").append("");
$("#app_view_frame_"+val['id']).html("");
var winh=$(document).height();
winh=winh-130;
$("#appviewframe").css("height", winh+"px");
setURL(val['id'], val['title']);
}
function makePeopleView(val){
$("#theitemdata").append("");
$("#people_view_name_"+val['id']).html(val['subtitle']+" "+val['title']);
$("#people_view_description_"+val['id']).html(val['description']);
if(val['imgurl']!=""){
$("#people_view_image_"+val['id']).html("");
}
if(val['tags']!=""){
var arr = val['tags'].split(' ');
for(var i in arr){
if( arr[i] != "" ){
$("#people_view_tags_"+val['id']).html($("#people_view_tags_"+val['id']).html()+""+arr[i]+" ");
}
}
}
setURL(val['id'], val['subtitle']+" "+val['title']);
}
function makeAuthorsBooksView(val){
if(val){
$("#theitemrelateddataicon").html("
");
for(var i in val){
if(val[i]['status']!=0){
$("#theitemrelateddata").append(""+val[i]['title']+"
"+val[i]['description']+"
");
}
}
$("#theitemrelateddata").append("
");
}
}
function makeBooksAuthorsView(val){
if(val){
$("#theitemrelateddataicon").html("
");
for(var i in val){
$("#theitemrelateddata").append(""+val[i]['subtitle']+" "+val[i]['title']+"
"+val[i]['description']+"
");
}
$("#theitemrelateddata").append("
");
}
}
function makeItemView(val){
if(val['data']['type']=="au" || val['data']['type']=="il" || val['data']['type']=="fo" || val['data']['type']=="mi" || val['data']['type']=="he"){
makePeopleView(val['data']);
if(val['data']['type']!="mi"){
makeAuthorsBooksView(val['books']);
}
} else {
if(val['data']['type']=="ap"){
makeAppView(val['data']);
}else{
makeBookView(val['data']);
makeBooksAuthorsView(val['contris']);
}
}
}
function hidePressStories(){
$('#theitempresssories').slideUp('fast', function(){});
$('#closepresslink').slideUp('fast', function(){});
$('#presslink').fadeIn('fast', function(){});
}
function showPressStories(){
$('#theitempresssories').slideDown('slow', function(){});
$('#closepresslink').slideDown('fast', function(){});
$('#presslink').fadeOut('fast', function(){});
}
function displayGetItemStories(val){
$("#theitemsories").html("");
$("#theitempresssories").html("");
hidePressStories();
var haspress=false;
if(val){
for(var i in val){
makeStoryView(val[i]);
if(val[i]['pubpress']==1){
haspress=true;
}
}
}
if(haspress){
$('#presslink').fadeIn('fast', function(){});
}else{
$('#presslink').fadeOut('fast', function(){});
}
}
function getItemStories(id){
x_getItemStories(id, displayGetItemStories)
}
function displayGetOneSearchItem(val){
if(val){
$("#outputtop").css("display", "none");
$("#theitemtags").html("");
$("#theitemdata").html("");
if(val['stories']){
displayGetItemStories(val['stories']);
}
if(val['data']){
makeItemView(val);
}
$('#oneitem').fadeIn('slow', function(){});
$('#closeoneitemlink').fadeIn('slow', function(){});
$("#outputtop").css("margin-top", "80px");
$(".toptopmenu").css('background', '#FFFFFF');
$("#oneitem").scrollTop(0);
$(window).scrollTop(0);
$("body,html,document").scrollTop(0);
if(val['data']['quizdata']){
makeQuiz(val['data']['quizdata'], val['data']);
}
if(navigator.userAgent.match(/(iPod|iPhone|iPad|Android)/)) {
}else{
$("#outputtop").css("display", "block");
}
}
}
function getOneSearchItem(id){
theopenid=id;
$("#theitemsories").html("");
$("#theitempresssories").html("");
hidePressStories();
$('#presslink').fadeOut('fast', function(){});
$("#theitemdata").html("");
$("#theitemrelateddata").html("");
$("#theitemrelateddataicon").html("");
$('#searcharea').fadeOut('slow', function(){});
$('#basket').fadeOut('slow', function(){});
$('#closebasketlink').fadeOut('slow', function(){});
$("#theitemdata").html(" ");
$('#oneitem').fadeIn('slow', function(){});
$(' body').css('overflow', 'hidden');
setItemsMargins();
x_getOneSearchItem(id, displayGetOneSearchItem);
}
function setItemsMargins(){
var w=$(window).width();
$('.outputtopitem').css("margin", "90px");
$(".oneitem").css("padding-left", "20%");
$(".oneitem").css("padding-right", "20%");
if( w < 481){
$('.outputtopitem').css("margin", "auto");
$('.outputtopitem').css("margin-top", "170px");
$('.outputtopitem').css("height", "455px");
$(".oneitem").css("padding-left", "10px");
$(".oneitem").css("padding-right", "10px");
}
}
function closeOneSearchItem(){
$("#outputtop").css("display", "block");
$(".oneitem").css("padding-left", "20%");
$(".oneitem").css("padding-right", "20%");
$(".oneiteminner").css("padding-top", "50px");
$("#outputtop").css("margin-top", "30px");
$('#searcharea').fadeIn('slow', function(){});
$('#oneitem').fadeOut('slow', function(){
});
$('#closeoneitemlink').fadeOut('slow', function(){ setItemsMargins();});
setURL("", "");
if(basketagain){
showBasket();
}
basketagain=false;
$('body').css('overflow', 'auto');
scrollToItem(theopenid);
theopenid=false;
setDim();
setTimeout(function(){ setDim(); }, 1000);
}
///////////////////////////////////////
// //
// Tags / Search //
// //
///////////////////////////////////////
function setTag(tag){
catbooks=1;
catpeople=1;
catnews=1;
$('.tc').removeClass("icon-checkmark");
$('.tc').removeClass("icon-checkbox-unchecked");
$('.tc').removeClass("icon-checkbox-checked");
$('.tc').addClass("icon-checkmark");
if(theopenid){
closeOneSearchItem();
}
$("#q").val(tag);
searchItems("new");
$(window).scrollTop(0);
catbooks=0;
catpeople=0;
catnews=0;
}
function startNewSearch(){
catbooks=1;
catpeople=1;
catnews=1;
$('.tc').removeClass("icon-checkmark");
$('.tc').removeClass("icon-checkbox-unchecked");
$('.tc').removeClass("icon-checkbox-checked");
$('.tc').addClass("icon-checkmark");
if(theopenid){
closeOneSearchItem();
}
searchItems("new");
$(window).scrollTop(0);
catbooks=0;
catpeople=0;
catnews=0;
}
var ti;
function displaySearchItems(val){
var hasstillitems=0;
if(cpage==1){
$("#outputtop").html("");
if(val['tags']){
$("#tagcan").html("");
}
}
if(val){
for(var i in val['item']){
ti=i;
var xlink=" href='#' onclick='getOneSearchItem("+val['item'][i]['id']+");' ";
if(val['item'][i]['type']=="io"){
if(!val['item'][i]['hasstories']){
xlink=" href='#' onclick='setTag(\""+val['item'][i]['tags'][0]+"\");return false;' ";
}
}
if(val['item'][i]['link']!=""){
xlink=" href='"+val['item'][i]['link']+"' target='_blank' ";
}
if(val['item'][i]['type']=="au" || val['item'][i]['type']=="il" || val['item'][i]['type']=="fo" || val['item'][i]['type']=="mi" || val['item'][i]['type']=="he"){
var overclass="outputtopitemoverlaypeople";
}else{
var overclass="outputtopitemoverlay";
}
$("#outputtop").append("
");
var ticon="";
if(val['item'][i]['type']=="au" || val['item'][i]['type']=="il" || val['item'][i]['type']=="fo" || val['item'][i]['type']=="mi"){
ticon="
";
}
if(val['item'][i]['type']=="bo"){
ticon="
";
}
if(val['item'][i]['type']=="ap"){
ticon="
";
}
if(val['item'][i]['type']=="hb"){
ticon="
";
}
if(val['item'][i]['type']=="ne"){
ticon="
";
}
if(val['item'][i]['type']=="co"){
ticon="
";
}
if(val['item'][i]['type']=="he"){
ticon="
";
}
if(val['item'][i]['type']=="qu"){
ticon="
";
}
if(val['item'][i]['type']=="io"){
ticon="
";
}
var inf="";
if(val['item'][i]['status']==5){
inf="
[ NEU ]
";
}
if(val['item'][i]['status']==1){
inf="
[ VORSCHAU ]
";
}
if(val['item'][i]['status']==3){
inf="
[ ANGEBOT ]
";
}
if(val['item'][i]['status']==4){
inf="
[ Vergriffen ]
";
}
if(val['item'][i]['type']=="au" || val['item'][i]['type']=="il" || val['item'][i]['type']=="fo" || val['item'][i]['type']=="mi" || val['item'][i]['type']=="he"){
$("#outputitemtitle"+val['item'][i]['id']).html(ticon+val['item'][i]['subtitle']+" "+val['item'][i]['title']+inf);
}else{
$("#outputitemtitle"+val['item'][i]['id']).html(ticon+val['item'][i]['title']+inf);
}
var regex = /
/gi;
//val['item'][i]['description']=val['item'][i]['description'].replace(regex, " ")
$("#outputtopitemoverlayinner"+val['item'][i]['id']).html("
"+val['item'][i]['description']+"
");
for(var p in val['item'][i]['tags']){
$("#thisitemtags"+val['item'][i]['id']).html($("#thisitemtags"+val['item'][i]['id']).html()+"
"+val['item'][i]['tags'][p]+" ");
}
if(val['item'][i]['description']==""){
$("#outputtopitemoverlay"+val['item'][i]['id']).css('display', 'none');
}
if(val['item'][i]['type']=="au" || val['item'][i]['type']=="il" || val['item'][i]['type']=="fo" || val['item'][i]['type']=="mi" || val['item'][i]['type']=="he"){
var x=val['item'][i]['id'];
var w=$(window).width();
var lastmargin=90;
if( w < 481){
lastmargin=5;
}
//$('.outputtopitem').css("margin", lastmargin+"px");
//$('#outputtopitemoverlay'+x).css("margin-top","-70px");
$('#outputtopitemoverlay'+x).animate({"margin-top": "-70px"},2000, function(){});
$('.outputtopitem').css("margin-top","170px");
/*
(function(x) {
var w=$(window).width();
var lastmargin=90;
if( w < 481){
lastmargin=5;
}
$('.outputtopitem').animate({"margin": lastmargin+"px"},0,
function(){
$('#outputtopitemoverlay'+x).animate({"margin-top": "-70px"},0, function(){});
//if( w > 481){
$('.outputtopitem').animate({"margin-top": "170px"},0, function(){});
//}
}
);
})(x);
*/
}else{
var x=val['item'][i]['id'];
var w=$(window).width();
var lastmargin=90;
if( w < 481){
lastmargin=5;
}
//$('.outputtopitem').css("margin", lastmargin+"px");
//$('#outputtopitemoverlay'+x).css("margin-top", "-130px");
$('#outputtopitemoverlay'+x).animate({"margin-top": "-130px"},2000, function(){});
if( w < 481){
var mh=180;
if(x!=1070){
$('#outputtopitem_'+x).css("margin-top", mh+"px");
}
}
/*
(function(x) {
var w=$(window).width();
var lastmargin=90;
if( w < 481){
lastmargin=5;
}
$('.outputtopitem').animate({"margin": lastmargin+"px"},0,
function(){
$('#outputtopitemoverlay'+x).animate({"margin-top": "-130px"},0, function(){});
if( w < 481){
var mh=180;
if(x!=1070){
$('#outputtopitem_'+x).animate({"margin-top": mh+"px"},0, function(){});
}
}
}
);
})(x);
*/
}
if(cpage==1){
$('.outputtop').fadeIn(2000);
}
if(val['item'][i]['status']==5){
$("#au"+val['item'][i]['id']).html('Neu');
$("#au"+val['item'][i]['id']).css('background', '#BB0000');
$("#au"+val['item'][i]['id']).css('color', '#FFFFFF');
$("#au"+val['item'][i]['id']).css('margin-left', '117px');
$("#au"+val['item'][i]['id']).css('width', '66px');
$("#au"+val['item'][i]['id']).css('display', 'block');
}
if(val['item'][i]['status']==3){
$("#au"+val['item'][i]['id']).html('Angebot');
$("#au"+val['item'][i]['id']).css('background', '#BCCB00');
$("#au"+val['item'][i]['id']).css('color', '#FFFFFF');
$("#au"+val['item'][i]['id']).css('margin-left', '80px');
$("#au"+val['item'][i]['id']).css('width', '140px');
$("#au"+val['item'][i]['id']).css('display', 'block');
}
hasstillitems++;
}
if(cpage==1){
var lasttag = new Array;
for(var i in val['tags']){
var isin=inArray(val['tags'][i]['tag'], lasttag);
if(!isin){
$("#tagcan").append("
"+val['tags'][i]['tag']+" ");
}
lasttag.push(val['tags'][i]['tag']);
}
}
}else{
if(cpage==1){
$("#outputtop").html("
Keine Ergebnisse ");
}
}
cpage++;
if(hasstillitems==0){
cpage=false;
}
killsearchitems=false;
setDim();
setTimeout(function(){ setDim(); }, 1000);
}
function searchItems(ntb){
$('#topcats').slideDown('slow', function(){});
$('#outputtop').slideDown('slow', function(){});
if(!killsearchitems){
killsearchitems=true;
if(ntb=="new"){
cpage=1;
$("#outputtop").html("
");
}
if(cpage){
if(cpage==1){
//$('.outputtop').css('display', 'none');
}
var q=encodeURIComponent($("#q").val());
x_searchItems(q, catbooks, catpeople, catnews, cpage, displaySearchItems);
}
}
}
///////////////////////////////////////
// //
// TopCats //
// //
///////////////////////////////////////
function setTopCats(cat){
$('.tc').removeClass("icon-checkmark");
$('.tc').removeClass("icon-checkbox-unchecked");
$('.tc').removeClass("icon-checkbox-checked");
$('.tc').addClass("icon-checkbox-unchecked");
if(cat=="news"){
if(catnews==1){
catnews=0;
}else{
catnews=1;
}
}
if(catnews==1){
$('#topcat_news').removeClass("icon-checkbox-unchecked");
$('#topcat_news').addClass("icon-checkbox-checked");
}
if(cat=="people"){
if(catpeople==1){
catpeople=0;
}else{
catpeople=1;
}
}
if(catpeople==1){
$('#topcat_people').removeClass("icon-checkbox-unchecked");
$('#topcat_people').addClass("icon-checkbox-checked");
}
if(cat=="books"){
if(catbooks==1){
catbooks=0;
}else{
catbooks=1;
}
}
if(catbooks==1){
$('#topcat_books').removeClass("icon-checkbox-unchecked");
$('#topcat_books').addClass("icon-checkbox-checked");
}
if((catbooks==1 && catpeople==1 && catnews==1) || (catbooks==0 && catpeople==0 && catnews==0)){
catbooks=0;
catpeople=0;
catnews=0;
$('.tc').removeClass("icon-checkmark");
$('.tc').removeClass("icon-checkbox-unchecked");
$('.tc').removeClass("icon-checkbox-checked");
$('.tc').addClass("icon-checkmark");
}
$("#q").val("");
searchItems("new");
}
function scrollToTop(){
$('html, body').animate({scrollTop: "0px"}, 'slow');
}