var baseURL="http://www.smatchfiles.de/stylepicker/",stylePicker=[],session=null;function importJS(a,c,b){var f=document.createElement("script");f.setAttribute("type","text/javascript");f.setAttribute("src",a);b&&wait_for_script_load(c,b);(a=document.getElementsByTagName("head")[0])?a.appendChild(f):document.body.appendChild(f)}function wait_for_script_load(a,c){var b=setInterval(function(){if(eval("typeof "+a)!="undefined"){clearInterval(b);c()}},50)} function updateButtonPosition(){jQuery.each(stylePicker,function(a,c){var b=c.picture;jQuery.each(c.snippet,function(g,l){var h=parseInt(l.id),k=parseInt(l.x),i=parseInt(l.y);k=b.offset().left+k;var j=b.offset().top+i;if(b.height()/2>i){i="box_smatch_oben.png";var m=117}else{i="box_smatch_unten.png";m=387}posYBox=j-m;jQuery("#button_"+h).css({top:j,left:k});jQuery("#productbox_"+h).css({top:posYBox,left:k});jQuery("#productbox_"+h+" ul").css({background:'transparent url("'+baseURL+"img/"+i+'") 20px no-repeat'})}); var f=b.offset().left+b.width()-135,d=b.offset().top+b.height()-30;jQuery("#smatch_howto_"+c.id).css({top:d,left:f});jQuery("#smatch_howto_hover_"+c.id).css({top:d-56,left:f})})} function getNextHighestZindex(a){var c=0,b=0,f=[];f=a?a.getElementsByTagName("*"):document.getElementsByTagName("*");for(a=0;a<f.length;a++){if(f[a].currentStyle)b=parseFloat(f[a].currentStyle.zIndex);else if(window.getComputedStyle)b=parseFloat(document.defaultView.getComputedStyle(f[a],null).getPropertyValue("z-index"));if(!isNaN(b)&&b>c)c=b}return c+1} function getSession(){jQuery(function(){jQuery.ajax({dataType:"jsonp",jsonp:"callback",url:baseURL+"ajax.php?action=getSession",success:function(a){session=a;startStylepicker();jQuery(".next, .prev").click(function(){jQuery("#stylepicker_box").html("");startStylepicker()})}})})} function startStylepicker(){jQuery(function(){var a=jQuery("img:visible"),c=getNextHighestZindex();jQuery("#stylepicker_box").length==0&&jQuery("body").append('<div id="stylepicker_box"></div>');jQuery.each(a,function(b){if(jQuery(a[b]).width()>150&&jQuery(a[b]).height()>100){var f=jQuery(a[b]);jQuery.ajax({dataType:"jsonp",jsonp:"callback",url:baseURL+"ajax.php?action=getSnippetData&url="+jQuery(f)[0].src+"&PHPSESSID="+session,success:function(d){if(d!=false&&d.snippet.length>0){var g="",l=d.button, h=d.logo,k=h.substring(0,h.lastIndexOf("."))+"_hover"+h.substring(h.lastIndexOf("."));jQuery.each(d.snippet,function(i,j){g=g+'<img src="'+l+'" class="smatch_button" id="button_'+j.id+'" />';g=g+'<div class="productcontainer" id="productbox_'+j.id+'"><span>'+d.text+"</span><ul>";j.products!==undefined&&jQuery.each(j.products,function(m,e){e.oldPrice=e.oldPrice?'<span style="color:red; text-decoration: line-through">'+e.oldPrice+"</span> ":"";clickoutURI=e.clickoutUri?e.clickoutUri:"http://www.smatch.com/"+ e.productId+"-?cid=stylepicker";if(e.brand!=null&&e.brand!=e.title.substr(0,e.brand.length))e.title=e.brand+" "+e.title;g=g+'<li><a href="'+clickoutURI+'" target="_blank"><img src="'+e.bigImageUrl+'" title="'+e.title+'"><br />'+e.title.substr(0,30)+"...";g=g+"<br />"+e.minPrice+"</a></li>"});g+="</ul></div>"});g=g+'<img src="'+h+'" id="smatch_howto_'+d.id+'" width="130" height="25" style="border:0; padding:0; z-index:'+c+';position: absolute;"/>';g=g+'<img src="'+k+'" id="smatch_howto_hover_'+d.id+ '" width="130" height="81" style="border:0; padding:0; z-index:'+c+';position: absolute; display:none;"/>';jQuery("#stylepicker_box").append(g);jQuery(".smatch_button").css({border:0,padding:0,"z-index":c,position:"absolute"});jQuery(".productcontainer").css({display:"none",position:"absolute","z-index":c+1,padding:0});jQuery(".productcontainer span").css({position:"absolute",top:27,left:60,color:"#7B7B7B","font-family":"Arial, sans-serif","font-size":"14px","font-weight":"bold","margin-left":10}); jQuery(".productcontainer ul").css({"background-repeat":"no-repeat","list-style-type":"none","padding-top":55,"padding-left":35,margin:0,width:350,height:460});jQuery(".productcontainer ul li").css({"float":"left",width:113,height:200,"text-align":"center",padding:0,"padding-left":35,"padding-right":20,"padding-bottom":5,margin:0,"font-family":"arial","font-size":11,"line-height":"120%"});jQuery(".productcontainer ul li a").css({color:"#7B7B7B","text-decoration":"none","font-weight":"normal",border:"none", padding:0});jQuery(".productcontainer ul li a img").css({padding:0,border:0,width:113,height:154,"padding-bottom":5});d.picture=f;stylePicker.push(d);updateButtonPosition();jQuery("#smatch_howto_"+d.id).bind("mouseenter",function(){jQuery(this).hide();jQuery("#smatch_howto_hover_"+d.id).show();jQuery("#smatch_howto_hover_"+d.id).bind("mouseleave",function(){jQuery(this).hide();jQuery("#smatch_howto_"+d.id).show()})});jQuery(".smatch_button").bind("mouseenter",function(){box="#productbox_"+jQuery(this).attr("id").split("_")[1]; jQuery(".productcontainer:not("+box+")").hide("fast");jQuery(box).show("fast")});jQuery(".productcontainer").bind("mouseleave",function(){var i=jQuery(this).attr("id").split("_")[1];jQuery("#productbox_"+i).hide("fast")})}}})}});jQuery(window).bind("resize",function(){setTimeout(updateButtonPosition,100)})})}window.jQuery?getSession():importJS(baseURL+"js/jquery.js","jQuery",function(){getSession()});