/*
 * Javascript functions to help Flash movies interact with the ShareThis API:
 * http://sharethis.com/publisher?type=stapi
 * 
 * Mark Celsor
 * mark@sharethis.com
 * 2008-04-10
 *

// Use this ActionScript on the frame where the button is instantiated:
getURL("javascript:var ShareObj = SHARETHIS.addEntry({ url:'http://sharethis.com/flash/#flash-page-c', title: 'Title Flash Page C'}, {button:false} );");

// Use this ActionScript to attach the sharing action to a button:
shareThis_btn.onRelease = function() {
	getURL("javascript:ShareThis_share();");
};

 */


/*
 * Create a sharelet that does not display a button,
 * and will generate a popup on share.
 */

var ShareObj=null;

function doShare(sub, ident, img) {
	ShareThis_clear();
	
	targetUrl = "http://FotoFlexer.com/Share/"+ident;
	//targetUrl = 'http://fotoflexer.com/view.php?a2='+ident;
	//alert(targetUrl);
	ShareObj = SHARETHIS.addEntry({ url:targetUrl, title: 'FotoFlexer Shared Photo', icon:img, summary: "This photo was made using FotoFlexer. Edit and share your own photos at <a href='http://fotoflexer.com'>FotoFlexer.com</a> for free. It's fast and easy, no registration required."}, {button:false});
 	
	ShareThis_share();

	
	

	

}







function _getWxH() {
     if (window.innerWidth) {
         return {
             width: window.innerWidth,
             height: window.innerHeight
         };
     } else if (document.documentElement.offsetWidth) {
         return {
             width: document.documentElement.offsetWidth,
             height: document.documentElement.offsetHeight
         };
     }
     return {width: 0, height: 0};
 }

function _getScrollXY() {
     var scrOfX = 0, scrOfY = 0;
     if(typeof(window.pageYOffset) == 'number') {
         //Netscape compliant
         scrOfY = window.pageYOffset;
         scrOfX = window.pageXOffset;
     } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
         //DOM compliant
         scrOfY = document.body.scrollTop;
         scrOfX = document.body.scrollLeft;
     } else if (document.documentElement
       && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
         //IE6 standards compliant mode
         scrOfY = document.documentElement.scrollTop;
         scrOfX = document.documentElement.scrollLeft;
     }
     return { width: scrOfX, height: scrOfY };
}

/*
 * Functions clears all sharlets.
 */

function ShareThis_clear(){
   SHARETHIS.sharelets = new Array;
}

/*
 * Functions called from flash to update elements
 * in the sharelet.
 */

function ShareThis_set(el, val){
    ShareObj.properties[el] = val;
}

/*
 * The share event executed from flash.
 */

function ShareThis_share(){

	var _dims = _getWxH();
	var _off = _getScrollXY();
	var _d = {};
	_d.top = (_dims.height / 2) - (440 / 2) | 0;
	_d.top = _d.top > 60 ? _d.top - 60 : 0;
	_d.top += _off.height;
	_d.left = (_dims.width / 2) - (360 / 2) | 0;
	_d.left = _d.left > 0 ? _d.left : 0;
	_d.left += _off.width;

	SHARETHIS.widget.left = _d.left;
	SHARETHIS.widget.top = _d.top;

	SHARETHIS.widget.hide();
	SHARETHIS.widget.show();
	var f = SHARETHIS.form(SHARETHIS.sharelets);
	document.body.appendChild(f);

	f.submit();

}