var baseURL="http://www.smatchfiles.de/stylepicker/",stylePicker=[],session=null;function importJS(a,d,b){var e=document.createElement("script");e.setAttribute("type","text/javascript");e.setAttribute("src",a);b&&wait_for_script_load(d,b);(a=document.getElementsByTagName("head")[0])?a.appendChild(e):document.body.appendChild(e)}function wait_for_script_load(a,d){var b=setInterval(function(){if(eval("typeof "+a)!="undefined"){clearInterval(b);d()}},50)} function updateButtonPosition(){jQuery.each(stylePicker,function(a,d){var b=d.picture;jQuery.each(d.snippet,function(f,c){f=parseInt(c.id);var i=parseInt(c.x),h=parseInt(c.y);c=b.offset().left+i;i=b.offset().top+h;if(b.height()/2>h){h="box_smatch_oben.png";var j=i-102}else{h="box_smatch_unten.png";j=i-372}jQuery("#button_"+f).css({top:i,left:c});jQuery("#productbox_"+f).css({top:j,left:c});jQuery("#productbox_"+f+" ul").css({"background-image":"url("+baseURL+"img/"+h+")"})});a=b.offset().left+b.width()- 135;var e=b.offset().top+b.height()-30;jQuery("#smatch_howto_"+d.id).css({top:e,left:a});jQuery("#smatch_howto_hover_"+d.id).css({top:e-56,left:a})})} function getNextHighestZindex(a){var d=0,b=0,e=Array();e=a?a.getElementsByTagName("*"):document.getElementsByTagName("*");for(a=0;a<e.length;a++){if(e[a].currentStyle)b=parseFloat(e[a].currentStyle.zIndex);else if(window.getComputedStyle)b=parseFloat(document.defaultView.getComputedStyle(e[a],null).getPropertyValue("z-index"));if(!isNaN(b)&&b>d)d=b}return d+1} function getSession(){jQuery(function(){jQuery.ajax({dataType:"jsonp",jsonp:"callback",url:baseURL+"ajax.php?action=getSession",success:function(a){session=a;startStylepicker()}})})} function startStylepicker(){$(function(){var a=$("img:visible"),d=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 e=jQuery(a[b]);jQuery.ajax({dataType:"jsonp",jsonp:"callback",url:baseURL+"ajax.php?action=getSnippetData&url="+$(e)[0].src+"&PHPSESSID="+session,success:function(f){if(f!=false&&f.snippet.length>0){var c="",i=f.button;jQuery.each(f.snippet, function(h,j){c=c+'<img src="'+i+'" class="smatch_button" id="button_'+j.id+'" />';c=c+'<div class="productcontainer" id="productbox_'+j.id+'"><ul>';j.products!==undefined&&jQuery.each(j.products,function(k,g){if(g.brand==null)g.brand="<br />";g.oldPrice=g.oldPrice?'<span style="color:red; text-decoration: line-through">'+g.oldPrice+"</span> ":"";c=g.clickoutUri?c+'<li><a href="'+g.clickoutUri+'" target="_blank"><img src="'+g.bigImageUrl+'">'+g.minPrice+"<br />"+g.brand+"</a></li>":c+'<li><a href="http://www.smatch.com/'+g.productId+'-?cid=stylepicker" target="_blank"><img src="'+g.bigImageUrl+'">'+g.minPrice+"<br />"+g.brand+"</a></li>"}); c+="</ul></div>"});c=c+'<img src="'+baseURL+'img/howto.png" id="smatch_howto_'+f.id+'" style="border:0; padding:0; z-index:'+d+';position: absolute;"/>';c=c+'<img src="'+baseURL+'img/howto_hover.png" id="smatch_howto_hover_'+f.id+'" style="border:0; padding:0; z-index:'+d+';position: absolute; display:none;"/>';$("#stylepicker_box").append(c);jQuery(".smatch_button").css({border:0,padding:0,"z-index":d,position:"absolute"});jQuery(".productcontainer").css({"padding-left":20,display:"none",position:"absolute", "z-index":d+1});jQuery(".productcontainer ul").css({"background-repeat":"no-repeat","list-style-type":"none","padding-top":25,"padding-left":25,margin:0,width:340,height:460});jQuery(".productcontainer ul li").css({"float":"left",width:113,"text-align":"center","padding-left":35,"padding-bottom":10,margin:0,"font-family":"arial","font-size":12,color:"black"});jQuery(".productcontainer ul li a").css({color:"black","text-decoration":"none","font-weight":"bold",border:"none"});jQuery(".productcontainer ul li a img").css({padding:0, border:0});f.picture=e;stylePicker.push(f);updateButtonPosition();$("#smatch_howto_"+f.id).bind("mouseenter",function(){$(this).hide();$("#smatch_howto_hover_"+f.id).show();$("#smatch_howto_hover_"+f.id).bind("mouseleave",function(){$(this).hide();$("#smatch_howto_"+f.id).show()})});$(".smatch_button").bind("mouseenter",function(){box="#productbox_"+$(this).attr("id").split("_")[1];$(".productcontainer:not("+box+")").hide("fast");$(box).show("fast")});$(".productcontainer").bind("mouseleave",function(){var h= $(this).attr("id").split("_")[1];$("#productbox_"+h).hide("fast")});typeof stylepicker_expose!="undefined"&&e.bind("mouseenter",function(){$(this).expose({api:true,color:"#000000",opacity:0.6,onBeforeClose:function(){if($(".productcontainer:visible").length>0)return false}}).load()})}}})}});$(window).bind("resize",function(){setTimeout(updateButtonPosition,100)})});$(".next, .prev").click(function(){$("#stylepicker_box").html("");startStylepicker()})} window.jQuery?getSession():importJS(baseURL+"js/jquery.js","jQuery",function(){getSession()});