PGX.js.push('http://www.tiypg.com/_pgx/shared/lightview/2.5.2/lightview.js');

var _class=Class.create({initialize:function(){typeof Lightview!="undefined"&&this.loaded();document.observe("lightview:loaded",this.loaded.bind(this))},loaded:function(){PGL.lightview=this.lightview},lightview:function(a){a=Object.extend({href:"#_lvajaxelement"},Object.clone(a));a.options=Object.extend({width:400,height:300},Object.clone(a.options));if(a.youtube){a.options.width=640;a.options.height=385;a.href="#_lvajaxelement";a.rel="set[inline]";if(typeof a.options.closeButton!="undefined"&&a.options.closeButton==
false)a.rel="inline"}if(a.href=="#_lvajaxelement"){var b=new Element("div",{id:"_lvajaxelement",style:"width:"+a.options.width+"px; height:"+a.options.height+"px; overflow:hidden;"});$("lightviewError").insert(b);a.youtube&&b.pgx("shared.youtube",{video:a.youtube,autoplay:true})}document.observe("lightview:hidden",function(){document.stopObserving("lightview:hidden");$("_lvajaxelement")&&$("_lvajaxelement").destroy()});Lightview.show(a);return a.href=="#_lvajaxelement"?b:Lightview[Lightview._contentPosition]}});
new _class;Element.addMethods({lightview:function(a,b){b=Object.clone(b);b.href="#"+$(a).identify();if(!b.rel){b.rel="set[inline]";if(b.options&&typeof b.options.closeButton!="undefined"&&b.options.closeButton==false)b.rel="inline"}return PGL.lightview(b)}});

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

var AllVacClass = Class.create({
	
	init: function() {
		
		var query = window.location.search.substring(1);
		if (typeof pgiEdit == 'undefined') {
			this.flash();
			this.prodLightview();
			this.setLastProductStyle();
		}
		
	},
	
	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': '220',
					'height':'132',
					className:'media'
				});
				element.next(0).update(image);
				element.next(0).show();
				
				var a = new Element('a', {
					'href': 'javascript:;'
				});
				a.onclick = function() {
					AllVac.youtube(element.down(0).id); return false;
				}
				image.wrap(a);
				
			} else {
			
				var image = element.down(0);
				if (image && image.src) {
					url = 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();
			
			}
			
		});
	},
	
	prodLightview: function() {
		
		aProd = $$('[rel="prodlightview"]');
		aProd.each(function(product) {
			if(typeof product.down(0).href != 'undefined') {
//												console.log(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
			}
		});
	},
	
	setLastProductStyle: function() {
		aProd = $$('.product_ov');
		iCount = aProd.length-1;
		aProd.each(function(product, index) {
			if(iCount == index) {
				product.addClassName('product_last');
			}
		});
	},
	
	flash: function() {
		
		aFlash = $$('.flash');
		aFlash.each(function(flash) {
			
			var iWidth = flash.down('#fWidth').innerHTML.replace('<br>', '').replace('<BR>', '');
			var iHeight = flash.down('#fHeight').innerHTML.replace('<br>', '').replace('<BR>', '');
			
			if(iWidth == '' || iWidth == 'Text' || iWidth == '0') {
				iWidth = '100%';
			}else{
				iWidth = iWidth + 'px';
			}
			
			if(iHeight == '' || iHeight == 'Text2' || iHeight == '0') {
				iHeight = '100%';
			}else{
				iHeight = iHeight + 'px';
			}			
			
			flash.setStyle({
				width:iWidth,
				height:iHeight
			});
			
			flash.update(flash.down(0).innerHTML);
		});
	},
	
	toggleSubmenu:function(element, action) {
		if($(element).down(0).innerHTML != '') {
			if(action == true){
				$(element).down(0).show();
			}else{
				$(element).down(0).hide();
			}
		}
	}
	
});

var AllVac = new AllVacClass();

document.observe("dom:loaded", function() {
	AllVac.init();
});
//swfobject.addDomLoadEvent(init)

swfobject.switchOffAutoHideShow();
swfobject.registerObject("_170bf9d8", "9.0.0");

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

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

PGX.js.push('/js/a1acb8aecc16aa6c12bafae9c25005961c10928b.js'); PGX.js.push('http://www.tiypg.com/_pgx/shared/lightview/2.5.2/scripts/lightview.js'); 
PGX.css.push('http://www.tiypg.com/_pgx/shared/lightview/2.5.2/styles/lightview.css'); PGX.css.push('/_templates/root/styles/root.css'); 
PGX.track({"shared.lightview":[],"play.site":[],"play.site.config":[],"play.site.tdk":{"p":"7659","c":"7649","r":"5888"},"play.site.content":{"p":"7659","c":"7649","r":"5888"},"play.site.menu":{"p":"7659","c":"7649","r":"5888"},"shared.google.analytics":{"p":"7659","c":"7649","r":"5888"}});

