var Linksharing = {
	imgUrl: 'http://www.facebook.com/sharer.php?u=',
	url: window.location.href,
	title: document.title,
	width : '150px',
	height : '55px',
	backColor: '#F1F1F1',
	border:'1px solid #dcdcdc',
	fontSize:'12px',
	fontColor: '#666666',
	fontFamily : 'Tahoma,Arial,Verdana',
	padding : '8px',
	paylasPaddingLeft: this.padding,
	textAlign : 'center',
	marginRight : '0px',
	paddingTop : '3px',
	is_firefox : (!document.all && document.getElementById),
	utf8:false,
	subdomain : null,
	domain : null,
	tema:1,
	charset : (document.characterSet) ? document.characterSet : document.charset,
	links:null,
	ekle:function(param){
		var re = /([^0-9])/gi;
			this.urlParser();
			this.url   = this.utf8Encode(this.url); 
		if(this.title == 'Undefined' || this.title.length < 3 )
		   this.title = 'Sembol';

	   if(this.is_firefox)
			this.marginRight = '0px';
		
		if( this.subdomain == 'www'){
			site = this.domain;
		}else{
			site = this.subdomain;
		}	
					
		if(!this.utf8)
			this.title = this.utf8Encode(this.title);
			
		this.links = 'http://www.facebook.com/sharer.php?u='+this.url+'&t='+this.title+'&site='+site;	
		
		if(this.tema === 1)
			this.tema1();
		else
			this.tema2();
		
	},
	tema1:function(){
		var html='<div style="width:'+this.width+';height:auto;">';
			
			
			html+='<a href="'+this.links+'&link=4&enc" target="_blank" title="facebook\'a ekle" >';
			html+='<img src="images/facebook.gif" alt="Facebook Profiline Ekle" style="margin:0 0 3px 0;border:none;"/><br />';
			html+='</a>';
	
			
			html+='</div>';	
			document.write(html);
	},
	tema2:function(){
		var html='<div style="width:135px;height:auto">';
		
			
			
			html+='<a href="'+this.links+'&link=4&enc" target="_blank" title="facebook\'a ekle" >';
			html+='<img src="images/facebook.gif" alt="Facebook Profiline Ekle"  style="margin:0px 2px 0px 0px;border:none;"/>';	
			html+='</a>';

			
			html+='</div>';	
			document.write(html);
	},
	utf8Encode : function (string) {  
		var unreserved = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_.~";
		var encoded = "";
		var decoded = string;
		
		for (var i = 0; i < decoded.length; i++ ) {
			  var ch = decoded.charAt(i);
		      if (unreserved.indexOf(ch) != -1) {
		        encoded = encoded + ch;
		      } else {
		       var charcode = decoded.charCodeAt(i);
		        if (charcode < 128) {
		          encoded = encoded + this.gethex(charcode);
		        }
		       if (charcode > 127 && charcode < 2048) {
		          encoded = encoded + this.gethex((charcode >> 6) | 0xC0);
				  encoded = encoded + this.gethex((charcode & 0x3F) | 0x80);
		        }
		        if (charcode > 2047 && charcode < 65536) {
		          encoded = encoded + this.gethex((charcode >> 12) | 0xE0);
		          encoded = encoded + this.gethex(((charcode >> 6) & 0x3F) | 0x80);
		          encoded = encoded + this.gethex((charcode & 0x3F) | 0x80);
		        }
		        if (charcode > 65535) {
		          encoded = encoded + this.gethex((charcode >> 18) | 0xF0);
		          encoded = encoded + this.gethex(((charcode >> 12) & 0x3F) | 0x80);
		          encoded = encoded + this.gethex(((charcode >> 6) & 0x3F) | 0x80);
		          encoded = encoded + this.gethex((charcode & 0x3F) | 0x80);
		        }
		      }
		}
		return encoded;
    },
	gethex : function(decimal){
		var hexchars = "0123456789ABCDEFabcdef";
	    return "%" + hexchars.charAt(decimal >> 4) + hexchars.charAt(decimal & 0xF);
	},
	urlParser : function (){
			var site 	   = this.url.match(/([a-zA-Z0-9]){1,}(.){1,1}/gi);
			this.subdomain = (site[1].substr( 0,site[1].indexOf(".") )).replace(/[0-9]/ig,"");
			this.domain	   = site[2].substr( 0,site[2].indexOf(".") );
	}
}
