function scale_thumbs(){$("img.thumb-product").each(function(){var img_width_max=150;var img_height_max=150;var img_width=$(this).width();var img_height=$(this).height();if(img_width>img_height&&img_width>img_width_max){$(this).width(img_width_max);}
else{if(img_height>img_height_max){$(this).height(img_height_max);}}});}
this.bestPriceToolTip=function(){xOffsetBp=10;yOffsetBp=20;$(".bpv img").hover(function(e){$("body").append('<div id="tooltip"><div id="title">Preisvergleich?</div>'+
'Der Preis dieses Angebots wurde mit Hilfe eines Online Preisvergleichs getestet. Das Ergebnis entspricht dem besten Preis den wir bei unserer Recherche finden konnten. So könnt Ihr Euch ganz sicher sein auch wirklich ein Schnäppchen zu machen.'+
'</div>');$("#tooltip")
.css("top",(e.pageY-xOffsetBp)+"px")
.css("left",(e.pageX+yOffsetBp)+"px")
.fadeIn("fast");},function(e){$("#tooltip").remove();})
$(".bpv").mousemove(function(e){$("#tooltip")
.css("top",(e.pageY-xOffsetBp)+"px")
.css("left",(e.pageX+yOffsetBp)+"px");});}
$(document).ready(function(){scale_thumbs();bestPriceToolTip();if($.support.leadingWhitespace){}
startCoundownTimer();});function showSubDeals(el){foo=el;if($(el).hasClass('closed')){var id=$(el).attr('id');id=id.replace(/subDealsButton_/,'');modifyOfferBackground(id);modifyOfferMoredeals(id);$(el).text('» Deals schließen');$('#subDealsWrapper_'+id).slideDown(function(){$(el).removeClass('closed').addClass('open');});}else if($(el).hasClass('open')){var id=$(el).attr('id');id=id.replace(/subDealsButton_/,'');var subDealsNumber=$(el).siblings('input').val();$(el).text('» Weitere Deals ('+subDealsNumber+')');$('#subDealsWrapper_'+id).slideUp(function(){$(el).removeClass('open').addClass('closed');modifySubDeal('offer_main_center_slide',id);modifySubDeal('offer_main_left_moredeals',id);});}}
function showReplyBox(element,iDepth,iID,parentID,commentID){$('#replycomment_box').find(".writecomment_center").removeClass("writecomment_center1 writecomment_center2 writecomment_center3").addClass("writecomment_center"+iDepth);$('#replycomment_box').find(".writecomment_middle").removeClass("writecomment_middle1 writecomment_middle2 writecomment_middle3").addClass("writecomment_middle"+iDepth);$('.form_replycomment_box').children('.hidden_repy_comment').remove(':hidden');$('.form_replycomment_box').append('<input class="hidden_repy_comment" type="hidden" name="commentid" value="'+commentID+'">');if(iDepth>=2){$('.form_replycomment_box').append('<input class="hidden_repy_comment" type="hidden" name="parentid" value="'+iID+'">');}
else{$('.form_replycomment_box').append('<input class="hidden_repy_comment" type="hidden" name="parentid" value="'+parentID+'">');}
$('.form_replycomment_box').append('<input class="hidden_repy_comment" type="hidden" name="id" value="'+iID+'">');$("#"+element).hide();$("#"+element).insertAfter('#comment_box_'+iDepth+'_'+iID);$("#"+element).slideDown('slow');}
function modifySubDeal(element,id){if($('#'+element+'_'+id).hasClass('slide_on')){$('#'+element+'_'+id).removeClass('slide_on').addClass('slide_off');}
else if($('#'+element+'_'+id).hasClass('slide_off')){$('#'+element+'_'+id).removeClass('slide_off').addClass('slide_on');}}
function modifyOfferBackground(id){if($('#offer_main_center_slide_'+id).hasClass('slide_on')){$('#offer_main_center_slide_'+id).removeClass('slide_on').addClass('slide_off');}
else if($('#offer_main_center_slide_'+id).hasClass('slide_off')){$('#offer_main_center_slide_'+id).removeClass('slide_off').addClass('slide_on');}}
function modifyOfferMoredeals(id){if($('#offer_main_left_moredeals_'+id).hasClass('slide_on')){$('#offer_main_left_moredeals_'+id).removeClass('slide_on').addClass('slide_off');}
else if($('#offer_main_left_moredeals_'+id).hasClass('slide_off')){$('#offer_main_left_moredeals_'+id).removeClass('slide_off').addClass('slide_on');}}
function startCoundownTimer(){var currentSeconds=new Date().getSeconds();var offsetSeconds=60-currentSeconds;window.setTimeout('countdownTimer()',(offsetSeconds*1000));}
function countdownTimer(){$('.time_number').each(function(i,el){var hours=$(el).text().match(/^ *[0-9]+/);hours=parseInt(hours);var mins=$(el).text().match(/[0-9]+Min$/);mins=parseInt(mins);if(mins>0){mins--;}else{if(hours>0){hours--;mins=59;}}
var newText=hours+'Std '+mins+'Min';$(el).text(newText);});window.setTimeout('countdownTimer()',60000);}
this.infoToolTip=function(){xOffsetInfo=-150;yOffsetInfo=-100;$("#deal_main_right_info_button").hover(function(e){$("#infoTooltip").show();$("#infoTooltip")
.css("top",(e.pageY+yOffsetInfo)+"px")
.css("left",(e.pageX+xOffsetInfo)+"px")
.fadeIn("fast");},function(e){$("#infoTooltip").hide();})
$("#deal_main_right_info_button").mousemove(function(e){$("#infoTooltip")
.css("top",(e.pageY+yOffsetInfo)+"px")
.css("left",(e.pageX+xOffsetInfo)+"px");});}
$(document).ready(function(){infoToolTip();});$(document).ready(function(){$('#newsbox_navi_news').click(function(){if(!$('#newsbox_navi_news').hasClass('active')){$('#newsbox_navi_news').addClass('active');$('#newsbox_navi_deals').removeClass('active');$('#newsbox_news_wrapper').show();$('#newsbox_deals_wrapper').hide();}});$('#newsbox_navi_deals').click(function(){if(!$('#newsbox_navi_deals').hasClass('active')){$('#newsbox_navi_news').removeClass('active');$('#newsbox_navi_deals').addClass('active');$('#newsbox_news_wrapper').hide();$('#newsbox_deals_wrapper').show();}});});$(document).ready(function(){var $dd=$('.select_shop_form');if($dd.length>0){var $options=$('option',$dd);var arrVals=[];$options.each(function(){arrVals.push({val:$(this).val(),text:$(this).text()});});arrVals.sort(function(a,b){return a.text==b.text?0:a.text<b.text?-1:1;});for(var i=0;i<arrVals.length;i++){$($options[i]).val(arrVals[i].val).text(arrVals[i].text);}
$("#shop_select").prepend($('<option/>').attr('value','0').text('Alle Shops'));$('#shop_select').val(getUrlVars()["shop_select"]);}});function getUrlVars()
{var vars=[],hash;var hashes=window.location.href.slice(window.location.href.indexOf('?')+1).split('&');for(var i=0;i<hashes.length;i++)
{hash=hashes[i].split('=');vars.push(hash[0]);vars[hash[0]]=hash[1];}
return vars;}
