﻿ $(document).ready(function() {
		$(".socializer").click(function (e) { 
			if(document.getElementById('containerx') == null){							 
				
				var top 	= $(".socializer").offset().top;
				var height	= $(".socializer").height();
				var left	= $(".socializer").offset().left;
				var pos 	= top+height+20;
				
				var div = document.createElement("div");
				$(div).hide();
				$(div).addClass("soc_container");
				//$(document.body).prepend(div);
				$('#content-header').after(div);
				var closeme = document.createElement('img');
				
				$(closeme).attr({ id: "close", src: "/images/close.gif"});
				$(closeme).addClass('close');
				$(div).append(closeme);
				
				$(closeme).click(function(){
					$(div).remove();
				})
				
				var title= $(".socializer").attr("title");
				var url  = document.location.href;  //$(".socializer").attr("alt");  --> use this if you wish to define an url in the alt tag 
				
				var name = document.createElement('h2');
				$(name).html('Mr. Rooter Plumbing');
				$(div).prepend(name);
				
				var left = document.createElement('div');
				$(left).addClass('soc_left');
				$(div).append(left);
				
				// del.icio.us
				var img = document.createElement('img');
				$(img).attr({ alt: 'send to delicious', src: "/images/delicious.png"  });
				$(left).append(img);
				
				var myLink = document.createElement('a');
				var hrefs = "http://del.icio.us/post?url=" + url;
				$(myLink).attr({ href: hrefs , title: 'send to del.icio.us' });
				$(myLink).html("del.icio.us");
				$(left).append(myLink);
				
				// digg
				var img = document.createElement('img');
				$(img).attr({ alt: 'send to digg', src: "/images/digg.png"  });
				$(left).append(img);
				
				var myLink = document.createElement('a');
				var hrefs = 'http://digg.com/submit?phase=2&url='+encodeURIComponent(url)+'&title='+title;
				$(myLink).attr({ href: hrefs , title: 'send to digg' });
				$(myLink).html("digg");
				$(left).append(myLink);
				
				// technorati
				var img = document.createElement('img');
				$(img).attr({ alt: 'send to technorati', src: "/images/technorati.png"  });
				$(left).append(img);
				
				var myLink = document.createElement('a');
				var hrefs =  'http://www.technorati.com/faves?add='+encodeURIComponent(url);
				$(myLink).attr({ href: hrefs , title: 'send to technorati' });
				$(myLink).html("technorati");
				$(left).append(myLink);
				
				// yahoo
				var img = document.createElement('img');
				$(img).attr({ alt: 'send to yahoo', src: "/images/im_yahoo.gif"  });
				$(left).append(img);
				
				var myLink = document.createElement('a');
				var hrefs =  'http://myweb2.search.yahoo.com/myresults/bookmarklet?u='+encodeURIComponent(url)+'&t='+title;
				$(myLink).attr({ href: hrefs , title: 'send to yahoo' });
				$(myLink).html("yahoo");
				$(left).append(myLink);
				
				// put in right container
				var right = document.createElement('div');
				$(right).addClass('soc_left');
				$(div).append(right);
				
				
				//facebook
				var img = document.createElement('img');
				$(img).attr({ alt: 'send to facebook', src: "/images/facebook.png"  });
				$(right).append(img);
				
				var myLink = document.createElement('a');
				var hrefs =  'http://www.facebook.com/sharer.php?u='+encodeURIComponent(url)+'&h='+title;
				$(myLink).attr({ href: hrefs , title: 'send to facebook' });
				$(myLink).html("facebook");
				$(right).append(myLink);				
				
				//stumbleupon
				var img = document.createElement('img');
				$(img).attr({ alt: 'send to ma.gnolia.com', src: "/images/stumbleupon.png"  });
				$(right).append(img);
				
				var myLink = document.createElement('a');
				var hrefs =  'http://www.stumbleupon.com/refer.php?url='+encodeURIComponent(url)+'&title='+title;
				$(myLink).attr({ href: hrefs , title: 'send to stumbleupon' });
				$(myLink).html("stumbleupon");
				$(right).append(myLink);
				
				//google
				var img = document.createElement('img');
				$(img).attr({ alt: 'send to google', src: "/images/google.png"  });
				$(right).append(img);
				
				var myLink = document.createElement('a');
				var hrefs =  'http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk='+encodeURIComponent(url)+'&title='+title;
				$(myLink).attr({ href: hrefs , title: 'send to google' });
				$(myLink).html("google");
				$(right).append(myLink);

				// ask
				var img = document.createElement('img');
				$(img).attr({ alt: 'send to ask.com', src: "/images/ask.png"  });
				$(right).append(img);
				
				var myLink = document.createElement('a');
				var hrefs =  'http://mystuff.ask.com/mysearch/QuickWebSave?v=1.2&t=webpages&title='+title+'&url='+encodeURIComponent(url);
				$(myLink).attr({ href: hrefs , title: 'send to ask' });
				$(myLink).html("ask");
				$(right).append(myLink);
				
//				$(".soc_container").css("visibility","visible");
				$(".soc_container").fadeIn(500);
					
				// ajax window	
				$('.soc_left a').bind("click",function(e){
					//e.preventDefault();
					var address 	= this;
					var scTop 		= $(window).scrollTop();
                    var width		= 0;									
					
					if(jQuery.browser.msie){
						width = document.body.clientWidth;
					}else{
						width	= window.innerWidth;
					}
				
					var left		= (width - 980) /2;
					//var wind 		= document.createElement("div");
			        var cssObj;
					
					if(jQuery.browser.msie){
						 cssObj = {
							top:0,
							width:'980px',
							position:'absolute',
							left: 0,
							border: '1px solid #ccc',
							visibility:'visible'
			
						 }
					}else{
						 cssObj = {
							top:scTop+20,
							width:'980px',
							position:'absolute',
							left: left + 'px'
			
						 }
					}
						
					//$(wind).css(cssObj);
					//$(wind).addClass('open_window');		
				
					var closeX = document.createElement('img');
					$(closeX).attr({ src:"/images/close.gif", position:'absolute',top:"0",right:"0" });
					$(closeX).addClass('close');
					
					$(closeX).click(function(){
						//$(wind).remove();											
					})
					
					//$(wind).prepend(closeX);
					//$(div).append(wind);
					
					var cssObj2 = {
        				width:'980px',
						height:'500px',
						border: 'none',
						position:'absolute',
						overflow:'auto',
						display:'block'
     				 }
					
					//var c	 = document.createElement('iframe');		
					//$(c).attr("src",this);
					//$(c).css(cssObj2);
					//$(wind).prepend(c);
					
	       })				
		}			
	})		
 })