/*  Start /_templates/roottemplate/scripts/roottemplate.js */

var ZodiacClass = Class.create({
	
	init: function() {
		
		var query = window.location.search.substring(1);
		if (query.indexOf('pgxURL=') == -1) {
			this.lightview();
			this.cufon();
		}
		
	},
	
	cufon: function() {
		PGX.cufon.replace('.menu_lnk_false', { fontFamily: 'junior_stinky', hover: true, textShadow: '#5d8911 0px 2px' } );
		PGX.cufon.replace('.menu_lnk_true', { fontFamily: 'junior_stinky', hover: true, textShadow: '#5d8911 0px 2px' } );
	},
	
	lightview: function() {
		$$('[rel="lightview"]').each(function(element) {
			element.hide();
			var url = element.next(0).innerHTML;
			
			if (url && url.indexOf('youtube') != -1) {
				
				var image = new Element('img', {
					'src': url,
					'border': '0',
					'width':'100%',
					'height':'100%',
					className:'media'
				});
				element.next(0).update(image);
				element.next(0).show();
				
				var a = new Element('a', {
					'href': 'javascript:;'
				});
				a.onclick = function() {
					Zodiac.youtube(element.down(0).id); return false;
				}
				image.wrap(a);
				
			} else {
			
				var image = element.down(0);
				if (image && image.src) {
					url = PGX.Prefix + PGX.Path + url;

					try {
						aUrl = url.split('{pgPrefix');
						if (aUrl[1]) {
							url = aUrl[1];
							aUrl = url.split('/');
							delete aUrl[0];
							url = aUrl.join('/');
							url = PGX.Path + '_media' + url;
						}
					} catch(e) {}
					
					var a = new Element('a', {
						'href': url,
						'class': 'lightview',
						'rel': 'set[gallery]'
					});
					image.wrap(a);
				}
				element.show();
			
			}
			
		});
	},
	
	youtube: function(id) {
		Lightview.show({
			href: '#' + id,
			rel: 'set[inline]',
			options: {
				width: 640,
				height: 390
			}
		});
	}
	
});

var Zodiac = new ZodiacClass();

document.observe("dom:loaded", function() {
	Zodiac.init();
});

/*  End /_templates/roottemplate/scripts/roottemplate.js */

