(function($){var cache=[];$.preloadImages=function(){var args_len=arguments.length;for(var i=args_len;i--;){var cacheImage=document.createElement('img');cacheImage.src=arguments[i];cache.push(cacheImage);}}})(jQuery);(function($){$.fn.popupBanner=function(userOptions){var options={pageId:'home',show:1,imageURL:'http://templatehelp.com/codes/popup/images/preload-template.png',destURL:'http://store.templatemonster.com/?aff=admin',headerDestURL:'/templates/',headerURL:'http://templatehelp.com/codes/popup/images/top.png',headerHoverURL:'http://templatehelp.com/codes/popup/images/top_hover.png',footerDestURL:'http://www.templatetuning.com/?aff=admin',footerURL:'http://templatehelp.com/codes/popup/images/bottom.png',footerHoverURL:'http://templatehelp.com/codes/popup/images/bottom_hover.png',isHeader:1,isFooter:1,isClose:1,isRollUp:0,customCode:'',templateType:0,marginTop:0,aff:'admin',banner_width:-1,banner_height:-1,showTime:15}
$.extend(options,userOptions);banner_hover=0;if(options.isHeader)
$.preloadImages(options.headerURL,options.headerHoverURL);if(options.isFooter)
$.preloadImages(options.footerURL,options.footerHoverURL);function hide_banner(is_stop){if(!is_stop&&banner_hover)
return false;if(is_stop)
$p_b.stop();if(typeof($c_b)!="undefined"){$c_b.remove();$c_t.remove();var top=-$banner_height;$p_b.animate({top:top+"px"},500,function(){$p_b.remove();});}
if(typeof($r_u_b)!="undefined"){var top=$p_b.offset().top<0?options.marginTop:-$banner_height+23+options.marginTop;if(top<0){$('#roll_up_button').addClass('down');}else{$('#roll_up_button').removeClass('down');}
$p_b.animate({top:top+"px"},500);}}
function show_banner(options,cookie_arr,cookie_str){if(options.customCode==''){var header=options.isHeader?'<a class="banner_link" id="popup_banner_top" href="'+options.headerDestURL+'">'+'<img src="'+options.headerURL+'"/></a><a id="close_button"></a>':'';var center='<a class="banner_link" href="'+options.destURL+'" id="banner_link_center">'+'<img id="img_popup" src="'+options.imageURL+'"/></a>';var footer=options.isFooter?'<a class="banner_link" id="popup_banner_bottom" href="'+options.footerDestURL+'">'+'<img src="'+options.footerURL+'"/></a><a id="roll_up_button"></a>':'';options.customCode=header+center+footer;}
var banner_hidden=false;if(cookie_arr.length){if(options.show==1)
banner_hidden=true;else if(in_array(options.pageId,cookie_arr)){banner_hidden=true;}}
if(!banner_hidden){cookie_arr[cookie_arr.length]=options.pageId;cookie_str=implode(';',cookie_arr);var tomorrow=new Date();tomorrow.setDate(tomorrow.getDate()+1);tomorrow=new Date(tomorrow.getFullYear(),tomorrow.getMonth(),tomorrow.getDate(),0,0,0,0);cookie("popup_banner",Base64.encode(cookie_str),{path:"/",expires:tomorrow});}
$.preloadImages(options.imageURL);banner=new Image();$(banner).load(function(){$p_b=$obj;$p_b.addClass('popup_banner');$p_b.addClass('iePNG');$p_b.html(options.customCode);$p_b.after('<a id="close_button"></a><div id="close_text"></div>');$pbt=$('#popup_banner_top');$pbb=$('#popup_banner_bottom');$banner_height=options.banner_height>0?options.banner_height:$p_b.height();$banner_width=options.banner_width>0?options.banner_width:$p_b.width();$p_b.css('width',$banner_width+'px');if(options.isFooter&&options.isRollUp){var roll_up_top=$banner_height-13;var roll_up_ml=$banner_width/2-10;$r_u_b=$('#roll_up_button');$r_u_b.css({opacity:0.75,top:roll_up_top+"px",marginLeft:roll_up_ml+"px"}).fadeIn('fast');$r_u_b.hover(function(){$r_u_b.css('opacity',1);},function(){$r_u_b.css('opacity',0.75);});$r_u_b.click(function(){hide_banner(1);});var top=banner_hidden?-$banner_height+23+options.marginTop:options.marginTop;if(top<0){$('#roll_up_button').addClass('down');}else{$('#roll_up_button').removeClass('down');}
$p_b.animate({top:top+"px"},500);}else if(options.isHeader&&options.isClose&&!banner_hidden){$c_b=$('#close_button');$c_t=$('#close_text');$c_b.fadeIn('fast');$c_b.hover(function(){$c_t.show();$c_b.css('opacity',1);},function(){$c_t.hide();$c_b.css('opacity',0.75);});$c_b.mousemove(function(e){$c_t.css({left:e.pageX+10,top:e.pageY-10});});$c_b.click(function(){hide_banner(1);});var close_ml=$banner_width/2-24;$c_b.css({opacity:0.75,marginLeft:close_ml+"px"});$p_b.animate({top:options.marginTop+"px"},500);}
$p_b.hover(function(){banner_hover=1;});$pbt.hover(function(){$('img',this).attr('src',options.headerHoverURL);},function(){$('img',this).attr('src',options.headerURL);});$pbb.hover(function(){$('img',this).attr('src',options.footerHoverURL);},function(){$('img',this).attr('src',options.footerURL);});if(options.isRollUp){$pbb.removeAttr("href");$pbb.click(function(){$r_u_b.click();return false;});}
$img_popup=$('#img_popup');$('#banner_link_center').hover(function(){$('#opacity').remove();$('img',this).before('<div id="opacity"></div>');var $height=$img_popup.height();var $width=$img_popup.width();var $left=$img_popup.width()/2;$('#opacity').css({left:$left+"px"}).height($height).stop().animate({width:$width+"px",left:"6px"},150);},function(){var $left=$img_popup.width()/2;$('#opacity').stop().animate({width:"0px",left:$left+"px"},150,function(){$(this).remove();});});if(options.showTime){$p_b.animate({height:$banner_height},options.showTime*1000,function(){hide_banner(0);});}}).attr('src',options.imageURL);}
$obj=$(this);cookie_str=cookie("popup_banner");cookie_arr=cookie_str?explode(";",Base64.decode(cookie_str)):new Array();if(!cookie_arr.length||options.show==2||(options.isFooter&&options.isRollUp)){if(!in_array(options.pageId,cookie_arr)||(options.isFooter&&options.isRollUp)){if(options.templateType&&options.customCode==''){$.getJSON("/get_url",{url:'http://templatehelp.com/codes/edu_banner.php?type='+options.templateType+'&mask=http://store.templatemonster.com/%type%/%id%.html'},function(data){if(data.error==0){options.imageURL=data.imageURL;options.destURL=data.destURL+'?aff='+options.aff;if(options.banner_height>0){options.banner_height+=data.image_height;options.banner_width=data.image_width;}}
show_banner(options,cookie_arr,cookie_str);});}else{show_banner(options,cookie_arr,cookie_str);}}}
$('.banner_link').click(function(){_gaq.push(['_trackEvent','popup_banner',$(this).attr('href')]);});};})(jQuery);
