var SiteClass = new Class({

	initialize: function(){
				//var Swis721ExEU = { src: 'public/flash/Swis721ExEU.swf' };
				var Swis721ExEU = { src: 'public/flash/Upper-WestSide.swf' };
				
				sIFR.useStyleCheck = true;
				sIFR.activate(Swis721ExEU);
				
				sIFR.replace(Swis721ExEU, {
					selector: 'h1.to_replace.black'
					,css: [
					  '.sIFR-root { font-size: 22px; color: #000000; }'
					],
					wmode: 'transparent'
				});	

				sIFR.replace(Swis721ExEU, {
					selector: 'h1.to_replace.white'
					,css: [
					  '.sIFR-root { font-size: 22px; color: #ffffff; }'
					],
					wmode: 'transparent'
				});
				
				hs.registerOverlay(
					{
						thumbnailId: null,
						overlayId: 'controlbar',
						position: 'top right',
						hideOnMouseOut: true
					}
				);
				
				
				hs.graphicsDir = 'public/images/highslide/graphics/';
				hs.outlineType = 'rounded-white';
				hs.align = 'center';
				hs.captionEval = 'this.thumb.title';
				
	}, // initialize

	
	domReady: function() {
		
		//this.activateInputs();
		//this.clearMenu();
		this.activateHighslide();
		this.activateGallery();
		
	}, // domReady

	activateGallery: function() {
		if($('budowa')) {
			$$('div#budowa div.gallery_box a.head').each(function(obj) {
				obj.onfocus = obj.blur;
				obj.onclick = function() {
					this.getParent().toggleClass('opened');
					/*
				 	var parent = this.getParent();
					$$('div#budowa div.gallery_box').each(function(div) {
						if(parent == div) div.addClass('opened');
							else div.removeClass('opened');
						
					});
					*/
				}
			});
		}
	}, //activateGallery
	
	activateHighslide: function() {
		
		var images = $$('a[rel=highslide]');
		for(var i=0; i < images.length; i++) {
			images[i].onclick = function() { return hs.expand(this); };
		}
		
	}, //activateHighslide	
	
	clearMenu: function() {
			$$('ul#menu a').each(function(obj) {
				obj.onfocus = obj.blur;
			});
	}, //clearMenu
	
	activateInputs: function() {
		$$('input[type=text],textarea').each(function(input){
			input.title = input.value;
			input.onfocus = function() { if(this.value == this.title) this.value = ''; if(window.ie6) this.addClass('focus'); }
			input.onblur = function() { if(this.value == '') this.value = this.title; if(window.ie6) this.removeClass('focus'); }
		});
	}, //activateInputs

	showMail: function(user, domain, contry, attr) {
		var start = "<a href=\"mailto:" + user + "@" + domain + "." + contry + "\"" + attr + ">";
		var end = "</a>";
		document.write(start + user + "@" + domain + "." + contry + end);
		return false;
	}, // showMail
	
	setZoom: function(img, dir, width, height, margin, zIndex, delay) {
		setTimeout(function() {
		if (img.dir==dir) {
		  img.style.width=width;
		  img.style.height=height;
		  img.style.margin=margin;
		  img.style.zIndex=zIndex;
		  img.parentNode.parentNode.style.zIndex=zIndex;
		}
	  }, delay);
	}, //setZoom	
	
	larger: function(img, width, height, side) {
	  img.dir='rtl';
	  now=parseInt(img.style.zIndex);
	  for (i=now+1; i<=10; i++) {
		w=(width*(10+i))/20+'px';
		h=(height*(10+i))/20+'px';
		//m=(-i)+'px 0 0 '+Math.round(-width*i/40)+'px';
		x=-Math.round(width*i*3/160);
		xside = x;
		if(side == 'r') xside = Math.round(xside/10);
		if(side == 'l') xside = Math.round(xside*2);
		m=(x)+'px 0 0 '+(xside)+'px';
		Site.setZoom(img, 'rtl', w, h, m, i, 20*(i-now));
	  }
	}, //larger	
	
	smaller: function(img, width, height, side) {
	  img.dir='ltr';
	  now=parseInt(img.style.zIndex);
	  for (i=now-1; i>=0; i--) {
		w=(width*(10+i))/20+'px';
		h=(height*(10+i))/20+'px';
		//m=(-i)+'px 0 0 '+Math.round(-width*i/40)+'px';
		x=-Math.round(width*i*3/160);
		xside = x;
		if(side == 'r') xside = Math.round(xside/10);
		if(side == 'l') xside = Math.round(xside*1.5);
		m=(x)+'px 0 0 '+(xside)+'px';
		Site.setZoom(img, 'ltr', w, h, m, i, 20*(now-i));
	  }
	} // smaller
	
});

var Site = new SiteClass();
window.addEvent('domready', function(){ Site.domReady(); });






