GEL.widget.ShareThis= function(element,options){ 
	var _superC= GEL.widget.ShareThis.superclass.constructor, 
		options= options || {}; 
	_superC.apply(this, arguments); 
	var 
		_controllers= { 
			shareon : ["sharelinks", "mouseover", ShowController],
			shareoff : ["sharelinks", "mouseout", ShowController],
			tracklink: ["sharethis", "click", GEL.util.LinkTrackController],
			sharethis: ["sharethis", "click", GEL.util.ShareThisControl.ShareController]
		}, 
		_location= 'location' in options ? 
			options.location : (GEL.thepage.pageinfo.url.location ? 
				GEL.thepage.pageinfo.url.location : (function(){ 
					var _l= window.location; 
					return _l.protocol + '//' + 
						_l.hostname + _l.pathname + _l.search 
				})()
			),
		_hideDelay= 'hidedelay' in options ? 
			options.hidedelay :  300,
		_showDelay= 'showdelay' in options ? 
			options.showdelay : 100,
		_status= 'status' in options ? 
			options.status :  "Reading",
		_picsrc= 'picsrc' in options ? 
			options.picsrc :  GEL.ement("photosrc").element.src
	; 
	for(var _k in _controllers) 
		this.config.controllers.push(_controllers[_k]); 
	this.init= function(){ 
		this.initClassControllers(); 	
	} 
	this.getLocation= function(_l){ 
		return _location; 
	}
	this.setLocation= function(_l){ 
		_location= _l; 
	} 
	this.getstatus= function(_s){ 
		return _status; 
	}
	this.getpicsrc= function(){ 
		return _picsrc; 
	}
	this.setpicsrc= function(_ps){ 
		_picsrc= _ps; 
	} 
		
	function ShowController(widget){ 
		var _gel= GEL.ement(widget.element), _ul, _showT= 0,_hideT; 
		_ul= GEL.ement(_gel.$(".bkhidden")[0]); 
		this.eventHandler= function(widgetEvent){ 
			if(widgetEvent.domEvent.domevent.type === 'mouseover') {
				clearTimeout(_hideT); 
				_showT= setTimeout(	
					function(){ _ul.css({visibility: "visible"}); }, 
					_showDelay
				); 
			}else{	
				clearTimeout(_showT); 
				_hideT= setTimeout(
					function(){ 
						_ul.css({visibility: "hidden"}); 
					}, 
					_hideDelay
				); 
			}
		}
	}
}
GEL.extend (GEL.widget.ShareThis, GEL.widget.Base); 
(function(){ 
var _SNINFO= {
	print: { 
		makeurl: function(w){ 
			var _l= GEL.thepage.pageinfo.articleprinturl;
			return _l;
		},
		height: 600,
		width: 800
	},
	email: { 
		makeurl:function(w){ 
			var 
				_i= GEL.thepage.pageinfo,
				_l= _i.articleemailurl
			;
			_l += "&"; 
			_l += GEL.objectUtil.join({
					GPUBDATE: _i.date.isopuddate, 
					GCATID: _i.categoryid, 
					GARTNO: _i.key, 
					GTITLE: _i.title
				}, "=", "&"
			); 
			return _l;
		}, 
		height: 300,
		width: 400
	},
	printpic: { 
		makeurl: function(w){ 
			var _l= w.getLocation();
			_l += (_l.indexOf("?") >= 0 )? '&':'?';
			_l +='template=printphoto&src='+w.getpicsrc();
			
			return _l;
		},
		height: 600,
		width: 800
	},
	emailpic: { 
		makeurl:function(w){ 
			var _i= GEL.thepage.pageinfo,
				_l= w.getLocation();
			_l += _l.indexOf("?") >= 0 ? "&" : "?"; 
			_l += "template=XsendmailpopupPic";
			_l += "&GTITLE="+_i.title
			
			return _l;
		}, 
		height: 300,
		width: 400
	},
	facebookpic: {
		makeurl: function(w){
			var _l = w.getLocation()
				_i= GEL.thepage.pageinfo;
			_l += _l.indexOf("?") >= 0 ? "" : "?"; 
			if(_i.type != 'gallery'){
				_l += "&gthumbnaillink="+encodeURIComponent(w.getpicsrc().replace(/\//g,"slash_replace"));
				_l += "&gthumbnaillink="+encodeURIComponent(w.getpicsrc());
			}
			return "http://www.facebook.com/sharer.php?u=" +  
				encodeURIComponent(_l);
		},
		height: 436,
		width: 626
	},
	facebook: {
		makeurl: function(w){ 
			return "http://www.facebook.com/sharer.php?u=" +  
				encodeURIComponent(w.getLocation());
		},
		height: 436,
		width: 626
	},
	digg: {
		makeurl: function(w){ 
			var _i= GEL.thepage.pageinfo; 
			return "http://digg.com/submit?phase=2&url=" + 
				encodeURIComponent(w.getLocation()) + 
				"&title=" + encodeURIComponent(_i.title);
		},
		height: false,
		width: false
	},
	delicious: {
		makeurl: function(w){ 
			var _i= GEL.thepage.pageinfo; 
			return "http://del.icio.us/post?v=2&url=" + 
				encodeURIComponent(w.getLocation()) + 
				"&title=" + encodeURIComponent(_i.title);
		},
		height: false,
		width: false
	},
	reddit: {
		makeurl: function(w){ 
			var _i= GEL.thepage.pageinfo; 
			return "http://reddit.com/submit?url=" + 
				encodeURIComponent(w.getLocation()) + 
				"&title=" + encodeURIComponent(_i.title);
		},
		height: false,
		width: false
	},
	newsvine: {
		makeurl: function(w){ 
			var _i= GEL.thepage.pageinfo; 
			return "http://www.newsvine.com/_tools/seed&save?u=" + 
				encodeURIComponent(w.getLocation()) + 
				"&T=" + encodeURIComponent(_i.title);
		},
		height: false,
		width: false
	},
	twitter: {
		makeurl: function(w){ 
		var _s = w.getstatus();
			return "http://twitter.com/home?status="+_s+":"+ "%20" + 
				encodeURIComponent(w.getLocation());
		},
		height: false,
		width: false
	},
	fark: {
		makeurl: function(w){ 
		var _i= GEL.thepage.pageinfo;
			return "http://www.fark.com/cgi/farkit.pl?u=" + 
				encodeURIComponent(w.getLocation()) + 
				"&h=" + encodeURIComponent(_i.title);
		},
		height: false,
		width: false
	},
	whatsthis: {
		makeurl: function(){ return "/apps/pbcs.dll/section?category=socialbookmarkshelp"}, 
		height: 200,
		width: 200
	}
};
GEL.namespace("util.ShareThisControl"); 
GEL.util.ShareThisControl.ShareController= function(widget){ 
	this.eventHandler= function(widgetEvent){ 
		var 
			_a= GEL.thepage.pageinfo,
			_atobj= null,  
			_opt= "menubars=0,scrollbars=1,resizable=1",
			_url= '', 
			_classArray= widgetEvent.sourceEl.className.split(/\s+/)
		;
		for(var i=0;i<_classArray.length;i++) { 
			if(_classArray[i] in _SNINFO) {
				_atobj= _SNINFO[_classArray[i]]; 
			}
		}
		if(!_atobj) return; 
		_url= _atobj.makeurl(widget); 
		if(_atobj.height) 
			_opt += ",height="+_atobj.height; 
		if(_atobj.width)
			_opt += ",width=" + _atobj.width; 

		if(_atobj.height || _atobj.width )
			window.open(_url,"ShowProdWindow",_opt); 
		else 
			window.open(_url);
	}
}
})(); 

GEL.widget.PictopiaWidget = function(element, options) {
	var _superC= GEL.widget.PictopiaWidget.superclass.constructor;
	_superC.apply(this, arguments);
	
	this.config.controllers = [
		["purchase", "click", PTController]
	];
	
	this.init = function() {
		this.initClassControllers();
	}
	
	function PTController(widget) {
		this.eventHandler = function(widgetEvent) {
			var _info = GEL.thepage.pageinfo,
				_classArray= widgetEvent.sourceEl.className.split(/\s+/),
				_id = _classArray[1],
				_t = _info.title;
				
				if ( typeof(_id)!='undefined' ) {
					_i = _info.pic[_id].id,
					_l = _info.pic[_id].link,
					_c = _info.pic[_id].caption;
				} else {
					_i = _info.pic.id,
					_l = _info.pic.link,
					_c = _info.pic.caption;
				}
	
			goPtp(_i, _t, _l, _c);
		}
	}
	
	function goPtp(artNo, title, imageUrl, caption) {   
		if (imageUrl.match(/\&Ref=/i)) {
			var ref = imageUrl.replace(/.*\&Ref=/,'');
	      	ref = ref.replace(/\&.*/, '');
			artNo += '-' + ref;
		}
		var loc = "http://pictopia.com/perl/ptp?provider_id=" + GEL.thepage.pageinfo.pic.ptpid
			+ "&photo_name="+ artNo
            + "&title=" + title
			+ "&embedded=y"
			+ "&thumbnail_url=" + escape(imageUrl)
			+ "&m_caption="+ caption;
    	var  PictopiaWin = window.open(loc, 'ptp');
     	PictopiaWin.focus();
	}
}
GEL.extend(GEL.widget.PictopiaWidget, GEL.widget.Base);

GEL.widget.TopixWidget = function(element, options) {
	var _superC= GEL.widget.TopixWidget.superclass.constructor;
	_superC.apply(this, arguments);
	
	this.init = function(scriptfrag) {
		topix_headlines(scriptfrag);
	}
	
	function topix_headlines(scriptfrag) {
		var ph_container_id = "topix_ph_flexible";
		scriptfrag(ph_container_id);
	}
}
GEL.extend(GEL.widget.TopixWidget, GEL.widget.Base);

GEL.widget.FontSizeWidget = function(element, options) {
	var _superC= GEL.widget.FontSizeWidget.superclass.constructor;
	_superC.apply(this, arguments);
		
	this.config.controllers = [ 
		["increase-font", "click", IncreaseFontController],
		["decrease-font", "click", DecreaseFontController]
	]; 

	this.init = function() {
		this.initClassControllers();
	}
	
	function IncreaseFontController(widget) {
		this.eventHandler = function(widgetEvent) {
			increaseFontSize(widget);
		}
	}
	function DecreaseFontController(widget) {
	this.eventHandler = function(widgetEvent) {
			decreaseFontSize();
		}
	}
	
	var min=8;
	var max=18;
	function increaseFontSize() {
		GEL.ement("article-bodytext").foreach("P", function(){ 
			if(GEL.ement(this).getElement().style.fontSize) {
				var s = parseInt(GEL.ement(this).getElement().style.fontSize.replace("px",""));
			} else {
				var s = 12;
			}
			if(s!=max) {
				s += 1;
			}
			GEL.ement(this).css({ fontSize: s+"px" });
		} )		
	}
	function decreaseFontSize() {
		GEL.ement("article-bodytext").foreach("P", function(){ 
			if(GEL.ement(this).getElement().style.fontSize) {
				var s = parseInt(GEL.ement(this).getElement().style.fontSize.replace("px",""));
			} else {
				var s = 12;
			}
			if(s!=min) {
				s -= 1;
			}
			GEL.ement(this).css({ fontSize: s+"px" });
		} ) 		
	}
}
GEL.extend(GEL.widget.FontSizeWidget, GEL.widget.Base);