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

var AllVacClass = Class.create({
	
	init: function() {
		
		var query = window.location.search.substring(1);
		if (query.indexOf('pgxURL=') == -1) {
			this.flash();
			this.prodLightview();
			this.lightview();
			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(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) {
			iWidth = flash.down(0).next(2).innerHTML;
			iHeight = flash.down(0).next(3).innerHTML;
			
			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)

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

/*  Start /_templates/contact/contact.js */

function setCheckValue(element) {	
	hidelement = $(element).id+'_hid';
	if($(element).status == true) {
		$(hidelement).value = 'ja';
	}else{
		$(hidelement).value = 'nee';
	}
}

/*  End /_templates/contact/contact.js */

