/**********************************************************************************************************************************************************
					 Facebook social network plugins						
					 http://developers.facebook.com/plugins					 
																			 
					 Lasantha Gamage										 
					 lasantha @zurigroup.com								 
					 06/06/2010												 	
***********************************************************************************************************************************************************/	


var Facebook = {};
Facebook.Like = function (url, width, ReturnText){
	
	if(!url){
		url = window.location.href;	
	}
	
	if (!width){
		width = 325;	
	}

	url = escape(url);
	
	if(Facebook.IsHttps()){
		fburl = "https://www.facebook.com/plugins/like.php?href="+url+"&layout=button_count&show-faces=false&width="+width+"&height=30&action=like&font=tahoma&colorscheme=light";
	}
	else{
		fburl = "http://www.facebook.com/plugins/like.php?href="+url+"&layout=button_count&show-faces=false&width="+width+"&height=30&action=like&font=tahoma&colorscheme=light";
	}
	
	output = '<iframe width="'+width+'" height="30" frameborder="0" scrolling="no" allowTransparency="true" src="'+fburl+'"></iframe>';
	if(ReturnText)
		return output;
	else
		document.write(output);
	
	
}

Facebook.IsHttps = function () {
	if (window.location.href.toLowerCase().indexOf('https') == 0 )
		return true;
	else
		return false;
}

Facebook.Share = function( url, ReturnText){
	if (!url){
		url = window.location.href;
	}
	
	if (Facebook.IsHttps()){
		imgurl = "https://www.spheresolutions.org/share.png";	
	}
	else{
		imgurl = "http://www.spheresolutions.org/share.png";		
	}
	
	url = escape(url);
	
	output = '<a target="_blank" href="http://www.facebook.com/sharer.php?u='+url+'"><img src="'+imgurl+'" border="0" /></a>';
	if(ReturnText)
		return output;
	else
		document.write(output);
}

Facebook.Likebox = function(pageid, option, ReturnText ){

	DefaltConfig = {width:292, height:180,connections:5,header:false,stream:false};

	
	if(option) {
		for (var o in option){
			DefaltConfig[o] = option[o];
		}
				
	}
	
	if (!option || !option['height']){
		tmpw = 105;
		
		if (DefaltConfig.header){
			tmpw += 25;				
		}
		
		if (DefaltConfig.stream){
			tmpw += 300;
		}
		
		tmpw += Math.ceil(DefaltConfig.connections/Math.floor(DefaltConfig.width/55))*75 + 10;
		
		DefaltConfig.height = tmpw;
	}
	
	if(Facebook.IsHttps()){
		fburl = "https://www.facebook.com/plugins/likebox.php";
	}
	else{
		fburl = "http://www.facebook.com/plugins/likebox.php";
	}
	
	output = '<iframe src="'+fburl+'?id='+pageid+'&amp;width='+DefaltConfig.width+'&amp;connections='+DefaltConfig.connections+'&amp;stream='+DefaltConfig.stream+'&amp;header='+DefaltConfig.header+'&amp;height='+DefaltConfig.height+'" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:'+DefaltConfig.width+'px; height:'+DefaltConfig.height+'px;" allowTransparency="true"></iframe>';
	if(ReturnText)
		return output;
	else
	document.write(output);
	
}

function Retweet(status,source,ReturnText){
	
	if (!status){
		status = document.title	+ ' - ' + window.location.href;
	}
	
	if(!source){
		source = "";	
	}
	
	if (Facebook.IsHttps()){
		imgurl = "https://www.spheresolutions.org/twitter.png";	
	}
	else{
		imgurl = "http://www.spheresolutions.org/twitter.png";		
	}
	
	output = '<a target="_blank" href="http://twitter.com/home?source='+source+'&status='+status+'"><img src="'+imgurl+'" border="0" /></a>';
	if(ReturnText)
		return output;
	else
	document.write(output);
}

