
(function(){var MY_NAME="snowflake.js";var IS_DEBUG=false;var IMAGE_INFO={url:"snow.png",w:72,h:18};var REQUIRES=["http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"];var PRODUCT_PREFIX="sam_test_";var _c=window.console;var trace=function(msg){if(!IS_DEBUG)return;if(!_c)return;_c.log(msg);};var load_script=function(src,on_load){var js=document.createElement('script');js.src=src;var done=false;js.onload=js.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){done=true;on_load();}};var head=document.getElementsByTagName("head")[0]||document.documentElement;head.appendChild(js);};var is_ready=false;var wait_ready_function=null;var load_requires=function(){is_ready=false;var count=REQUIRES.length;var loaded=0;var f;f=function(){load_script(REQUIRES.shift(),function(){if(REQUIRES.length==0){is_ready=true;if(!wait_ready_function)return;wait_ready_function();wait_ready_function=null;}else{f();}});};f();};var get_script_base_url=function(script_url){var scripts=document.getElementsByTagName("script");for(var i=0;i<scripts.length;i++){var sc=scripts[i];if(!sc.src||''==sc.src){continue;}
var pos=sc.src.lastIndexOf("/"+script_url);if(-1==pos){continue;}
return sc.src.substring(0,pos+1);}};var create_node_iterator=function(root){var result={};var node_stack=[{node:root,index:0}];result.next=function(){while(0!=node_stack.length){var current_node=node_stack[node_stack.length-1];var children=current_node.node.childNodes;if(children.length>current_node.index){var next_node=children[current_node.index];if(1==next_node.nodeType){node_stack.push({node:next_node,index:0});}
current_node.index++;return next_node;}else{node_stack.pop();}}
return null;};return result;};var async=function(f){var iid=setInterval(function(){clearInterval(iid);f();},1);};var word_class_name=PRODUCT_PREFIX+"word";var get_id_suffix=function(){if(!window[PRODUCT_PREFIX+"id_seed"]){window[PRODUCT_PREFIX+"id_seed"]=0;}else{window[PRODUCT_PREFIX+"id_seed"]=window[PRODUCT_PREFIX+"id_seed"]+1;}
return window[PRODUCT_PREFIX+"id_seed"];};var h=IMAGE_INFO.h;var w=h;var count=IMAGE_INFO.w/w;var wnd;var doc;var wnd_h;var wnd_w;var doc_h;var doc_left;var doc_top;var show=function(){if(!wnd){wnd=$(window);doc=$(document);var f=function(){wnd_h=wnd.height();wnd_w=wnd.width();doc_h=doc.height();doc_left=doc.scrollLeft();doc_top=doc.scrollTop();};wnd.resize(f);wnd.scroll(f);f();}
var backgroundPosition=Math.floor(Math.random()*count)*w*-1;var opacity=0.2;var move_to_y=Math.min(doc_top+wnd_h-h+200,doc_h-h);for(var i=0;i<3+Math.floor(Math.random()*4);i++){var speed=25+Math.floor(Math.random()*5);var y=doc_top-w-10*Math.floor(Math.random()*5);var duration=(move_to_y-y)*speed;var x=doc_left+Math.floor(Math.random()*wnd_w);var move_to_x=10*(5+Math.floor(Math.random()*10));if(Math.floor(Math.random()*2)==0){move_to_x=x-move_to_x;}else{move_to_x=x+move_to_x;}
var flake=document.createElement("div");flake=$(flake).css("position","absolute").css("overflow","hidden").css("width",w+"px").css("height",h+"px").css("left",x+"px").css("top",y+"px").css("background-image","url("+IMAGE_INFO.url+")").css("background-position",backgroundPosition+"px").appendTo("body").animate({top:move_to_y+"px",left:move_to_x+"px",opacity:opacity},{duration:duration,complete:function(){$(this).remove();}});}};var init=function(){IMAGE_INFO.url=get_script_base_url(MY_NAME)+IMAGE_INFO.url;trace(IMAGE_INFO.url);var f=function(){var iid=setInterval(function(){show();},5000);show();};if(is_ready){f();}else{wait_ready_function=f;}};load_requires();init();})();
