PGX.js.push('/_templates/root/scripts/root.js');

var PetClass = Class.create({
	
	init: function() {
		this.showContent();
		this.menu();
		
		var query = window.location.search.substring(1);
		if (query.indexOf('pgxURL=') == -1) {
			this.lightview();
		}
	},
	
	showContent: function() {
		if($('middle').innerHTML != '') {
			$('middle').setStyle( { display:'block' })
		}
		if($('bottom').innerHTML != '') {
			$('bottom').setStyle( { display:'block' })
		}
	},
	
	menu: function() {
		$$('[rel=menu]').each(function(menu) {
			if(menu.innerHTML == 'Home' || menu.innerHTML == 'home') {
				menu.up(0).className = 'li_menu_home';
			}
		});
	},
	
	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', {
				});
				element.next(0).update(image);
				element.next(0).show();
				
				var a = new Element('a', {
					'href': 'javascript:;',
					title: ' :: :: test'
				});
				a.onclick = function() {
					Impress.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('/');
							iLength = aUrl.length;
							sTitle = aUrl[iLength -1];
							delete aUrl[0];
							sURL = aUrl.join('/');
							url = PGX.Path + '_media' + sURL;
						}
					} catch(e) {}
					
					aTitle = sTitle.split('.');
					sTitle = aTitle[0].replace(/_/g, ' ');
					sTitle = sTitle.substr(0,1).toUpperCase() + sTitle.substr(1,sTitle.length);
					
					var a = new Element('a', {
						'href': url,
						'class': 'lightview',
						'rel': 'set[gallery]',
						'title':  sTitle
					});
					image.wrap(a);
				}
				element.show();
			
			}
			
		});
	},
	/*
	prodLightview: function() {
		aProd = $$('[rel="lightviewTitle"]');
		aProd.each(function(product) {			
			if(product.down(0).href) {
				product.down(0).addClassName('lightview');
				product.down(0).setAttribute('rel', 'set[product]');
			}
		})
	},
	*/
	
	youtube: function(id) {
		Lightview.show({
			href: '#' + id,
			rel: 'set[inline]',
			options: {
				width: 640,
				height: 390
			}
		});
	}
	
	
});

var Pet = new PetClass();

// Dom loaded
document.observe("dom:loaded", function() {
	Pet.init();													
});

_gaq.push(['_setAccount', 'UA-15163162-1'], ['_trackPageview']);

var addthis_config = addthis_config || {}; addthis_config.data_ga_property = 'UA-15163162-1'; addthis_config.data_ga_social = true;

PGX.js.push('/js/a1acb8aecc16aa6c12bafae9c25005961c10928b.js'); 
PGX.css.push('/_templates/root/styles/root.css'); 
PGX.track({"play.site":[],"play.site.config":[],"play.site.tdk":{"p":"10163","c":"10158","r":"796"},"play.site.content":{"p":"10163","c":"10158","r":"796"},"play.site.menu":{"p":"10163","c":"10158","r":"796"},"shared.google.analytics":{"p":"10163","c":"10158","r":"796"}});

