

/**
* site specification javascript document
*
* author: Gönczi Ákos
* site: http://www.sod.hu/
*
*/


window.addEvent('domready', function() {
	
	if( $('sharethis') ) {
		$('sharethisbox').set( 'style', 'display:block' );
		var sharethisbox = new Fx.Slide('sharethisbox', { transition: 'sine:out' } );
		sharethisbox.hide();
		$('sharethis').addEvent('click', function(e){
			sharethisbox.toggle();
			e.stop();
		});
	}
    
	if( $('sendthis') ) {
		$('sendthisbox').set( 'style', 'display:block' );
		var sendthisbox = new Fx.Slide('sendthisbox');
		sendthisbox.hide();
	    $('sendthis').addEvent('click', function(e){
	    	sendthisbox.toggle();
	    	e.stop();
	    });
    }
    
    if( $('signupBirthday') ) {
        var signupBirthday = new vlaDatePicker( 'signupBirthday', {
            separator: '-',
            prefillDate: false,
            format: 'y/m/d',
            openWith: 'togglePicker',
            defaultView: 'decade',
            startMonday: 'Monday',
            filePath: '/javascript/moocalendar/inc/',
            style: 'videoklinika',
            offset: { x: 1, y: 1 }
        });
    }
    

    
    // http://picasaweb.google.com/data/feed/base/user/goncziakos?alt=rss&kind=album&hl=hu
    // http://picasaweb.google.com/data/feed/base/user/goncziakos/albumid/5445934853432964977?alt=rss&kind=photo&hl=hu
    /*
    var mypicasawebalbum = new Request({
		url: '/getpicasawebalbum', 
		method: 'post', 
		data: {'url':'http://picasaweb.google.com/data/feed/base/user/goncziakos/albumid/5445934853432964977?alt=rss&kind=photo&hl=hu'}, 
		onSuccess: function( responseText, responseXML ) {

			var albumid = 'picasawebalbumcontaner';
			var length = responseXML.documentElement.childNodes[0].childNodes.length;
			var items = responseXML.documentElement.childNodes[0].childNodes

			var contaner = new Element( 'div', {'id':albumid,'style':'border:3px pink solid;margin:40px;padding:20px;text-align:center;'} );
			contaner.inject( $('wrapper'), 'top' );

			for( var n = 0; n < length; n = n + 1 ) {
				
				if( items[n].childNodes[8] ) {

					//console.log( n + ' - ' + items[n].childNodes[8].childNodes[0].attributes[0].value );
					
					var imgcol = new Element( 'a',{ 
						'style': 'display:inline-block;font-size:128px;height:auto;text-align:center;vertical-align:middle;width:1.1em;margin:2px;', 
						'href': items[n].childNodes[8].childNodes[0].attributes[0].value,
						'rel': 'lightbox[]'
					});

					new Element( 'img', {
						'alt': '', 
						'src' : items[n].childNodes[8].childNodes[5].attributes[0].value
					}).inject( imgcol );
					
					imgcol.inject( contaner );
				}
			}
			$$('a').filter(function(el) {
				return el.rel && el.rel.test(/^lightbox/i);
			}).slimbox({ overlayFadeDuration: 150, imageFadeDuration: 150, captionAnimationDuration: 150, resizeDuration: 150	}, null, function(el) {
				return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
			});

    	}
    }).send();
    */
    /*
    var SlideList = new Class({
    	initialize: function(menu, options) {
    		this.setOptions(this.getOptions(), options);
     
    		this.menu = $(menu), this.current = this.menu.getElement('li.current');
     
    		this.menu.getElements('li').each(function(item){
    			item.addEvent('mouseover', function(){ this.moveBg(item); }.bind(this));
    			item.addEvent('mouseout', function(){ this.moveBg(this.current); }.bind(this));
    			item.addEvent('click', function(event){ this.clickItem(event, item); }.bind(this));
    		}.bind(this));
     
    		this.back = new Element('li').addClass('background').adopt(new Element('div').addClass('left')).injectInside(this.menu);
    		this.back.fx = this.back.effect(this.options);
    		this.back.fx = new Fx.Morph(this.back,this.options); 
    		if(this.current) this.setCurrent(this.current);
    	},
     
    	setCurrent: function(el, effect){
    		this.back.setStyles({left: (el.offsetLeft)+'px', width: (el.offsetWidth)+'px'});
    		(effect) ? this.back.effect('opacity').set(0).start(1) : this.back.setOpacity(1);
    		this.current = el;
    	},
     
    	getOptions: function(){
    		return {
    			transition: Fx.Transitions.sineInOut,
    			duration: 500, wait: false,
    			onClick: Class.empty
    		};
    	},
     
    	clickItem: function(event, item) {
    		if(!this.current) this.setCurrent(item, true);
    		this.current = item;
    		this.options.onClick(new Event(event), item);
    	},
     
    	moveBg: function(to) {
    		if(!this.current) return;
    		this.back.fx.custom({
    			left: [this.back.offsetLeft, to.offsetLeft],
    			width: [this.back.offsetWidth, to.offsetWidth]
    		});
    	}
    });
     */
var SlideList = new Class({
    initialize: function(menu, options)
            {
            this.setOptions(this.getOptions(), options);
            this.menu = $(menu), this.current = this.menu.getElement('li.current');
            this.menu.getElements('li').each(function(item) {
                item.addEvent('mouseover', function() { this.moveBg(item); }.bind(this));
                item.addEvent('mouseout', function() { this.moveBg(this.current); }.bind(this));
                item.addEvent('mouseout', function() { this.moveBg.delay(1,this.current); }.bind(this));
                //item.addEvent('click', function(event) { this.clickItem(event,item); }.bind(this));
            }.bind(this));
            this.back = new Element('li').addClass('back').adopt(new Element('div').addClass('left')).injectInside(this.menu);
            //!this.back.fx = this.back.effects(this.options);
            //this.back.fx = this.back.set('tween',this.options);
            this.back.fx = new Fx.Morph(this.back,this.options);
            if(this.current) this.setCurrent(this.current);
    },

    setCurrent: function(el, effect) {
            this.back.setStyles({left: (el.offsetLeft)+'px', width: (el.offsetWidth)+'px'});
            (effect) ? this.back.effect('opacity').set(0).start(1) :this.back.setOpacity(1);
            this.current = el;
    },

    getOptions: function(){
            return {
                    transition: Fx.Transitions.sineInOut,
                    duration: 500, wait: false,
                    onClick: Class.empty
            };
    },

    clickItem: function(event, item) {
            if(!this.current) this.setCurrent(item, true);
            this.current = item;
            this.options.onClick(new Event(event), item);
    },

    moveBg: function(to) {
            this.timer = $clear(this.timer);
            if(!this.current) return;

            this.back.fx.start({
                    'left': [this.back.offsetLeft, to.offsetLeft],
                    'width': [this.back.offsetWidth, to.offsetWidth]
            });

			// $('myElement').tween('height', [20, 200]);
			//this.back.fx.tween('left', [this.back.offsetLeft, to.offsetLeft]);
			//this.back.fx.tween('width', [this.back.offsetWidth, to.offsetWidth]);
			/*this.back.fx.tween({
			left: [this.back.offsetLeft, to.offsetLeft],
			width: [this.back.offsetWidth, to.offsetWidth]
            });*/
            /*this.back.fx.custom({
                    left: [this.back.offsetLeft, to.offsetLeft],
                    width: [this.back.offsetWidth, to.offsetWidth]
            });*/
    }

});

    SlideList.implement(new Options);
    
    new SlideList( 'mainmenu', {
		transition: Fx.Transitions.backOut, 
		duration: 500, 
		onClick: function(ev, item) { 
    		ev.stop(); 
		}
    });


});




function printwindow() {
	bV = parseInt(navigator.appVersion)
	if (bV >= 4) { 
		window.print(); window.opener=self;
	}
}
function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}
function AddBookmark(title,url){
    if( !url)
    url = location.href;
    if( !title)
    title = document.title;
    // Firefox
    if (window.sidebar)
        window.sidebar.addPanel(title, url, "");
    // Opera
    else if(window.opera && window.print){
        var element = document.createElement('a');
        element.setAttribute('href',url);
        element.setAttribute('title',title);
        element.setAttribute('rel','sidebar');
        element.click();
    }
    // Internet Explorer
    else if(document.all)
        window.external.AddFavorite(url, title);
}

function setStartPage(e) {
    if (navigator.appName=="Netscape") {
        alert( 'Katt az "Eszközök -> Beállítésok" és ott "Kezdőlap -> Aktuális oldal használata".' );
    } else if (parseInt(navigator.appVersion)>3) {
        setHomePage( window.location.href );
    }
}


function urlDecode(str){
    str=str.replace(new RegExp('\\+','g'),' ');
    return unescape(str);
}

function urlEncode(str){
    str=escape(str);
    str=str.replace(new RegExp('\\+','g'),'%2B');
    return str.replace(new RegExp('%20','g'),'+');
}


