/*
      ##### #     ##                                       ##           /##   	
   ######  /#    #### /                  #              /####         #/ ###  	
  /#   /  / ##    ###/                  ###     #      /  ###        ##   ### 	
 /    /  /  ##    # #                    #     ##         /##        ##       	
     /  /    ##   #                            ##        /  ##       ##       	
    ## ##    ##   #    /###     /###   ###   ########    /  ##       ######   	
    ## ##     ##  #   / ###  / / ###  / ### ########    /    ##      #####    	
    ## ##     ##  #  /   ###/ /   ###/   ##    ##       /    ##      ##       	
    ## ##      ## # ##    ## ##    ##    ##    ##      /      ##     ##       	
    ## ##      ## # ##    ## ##    ##    ##    ##      /########     ##       	
    #  ##       ### ##    ## ##    ##    ##    ##     /        ##    ##       	
       /        ### ##    ## ##    ##    ##    ##     #        ##    ##       	
   /##/          ## ##    ## ##    ##    ##    ##    /####      ##   ##       	
  /  #####           ######   ######     ### / ##   /   ####    ## / ##       	
 /     ##             ####     ####       ##/   ## /     ##      #/   ##.nl    	
 #                                                 #                          	
  ##                                                ##                        	
*/

window.addEvent('domready', function() {
	
	var pos = 0;
	var posMax = 3;
	
	var menus 		= $('menu'	).getElements('div[class=menuObj]');
	var splashes 	= $('splash').getElements('div[class=splashObj]');
	
	var myFx = new Fx.Slide('cont', {
		wrapper: 'contWrap',
		mode: 'vertical',
	    duration: 'short',
	    transition: Fx.Transitions.Quad.easeInOut
	}).slideIn();
	
	//myFx.show();
	
	
	
	splashes.each(function(item,index){
		if (pos != index) {
			item.fade('hide');
		} 
		item.addEvents({
            'click'  : function(e) {
            	var next = index + 1;
            	if (next > posMax) next = 0;
				pos = next;
            	item.fade('out');
            	var nextSlide = $('s' + next);
				nextSlide.fade('in');
				
				menus.each(function(item,index){
					if (pos != index) {
						item.setStyle('background-color','black');
					} else {
						item.setStyle('background-color','#222');
					}
            	});
            	
				
                openContent(pos);
                
            }
        });
        
	});
	/*
	var contFx = new Fx.Slide('cont', {
		mode:'vertical',
		onComplete: function() {
			$('cont').fade('in');
		}
	})
	*/
	
	menus.each(function(item,index){
		if (pos == index) {
			item.setStyle('background-color','#222');
		} 
		item.addEvents({
			'mouseover' : function(e) {
				if (pos != index) item.setStyle('background-color','#111');
			},
			'mouseout' : function(e) {
				if (pos != index) item.setStyle('background-color','black');
			},
            'click'  : function(e) {
            	var newpos = index;
            	menus.each(function(item,index){
					if (newpos != index) {
						item.setStyle('background-color','black');
					} else {
						item.setStyle('background-color','#222');
					}
            	});
            	var next = newpos;
				var currentSlide = $('s' + pos);
            	var nextSlide = $('s' + next);
            	currentSlide.fade('out');
				nextSlide.fade('in');
            	pos = next;
                openContent(pos);
            }
        });
        
	});
	
	
	
	
	
	
	var contentArray = new Array();
	contentArray[0] = "1.htm";
	contentArray[1] = "2.htm";
	contentArray[2] = "3.htm";
	contentArray[3] = "4.htm";
	
	
	openContent = function(link) {
        req.get('contents/' + contentArray[link]);
    };
    
	 req = new Request.HTML({
            update:$('cont'),
            evalScripts:true,
            evalResponse:true,
            noCache:true,
            onRequest: function() {
                $('cont').set('html','<div id="ajax_load"></div>');
            },
            onComplete: function() {
                myFx.hide().slideIn();
//                alert(myFx.open);
                
            }
    });
    







    
	

	(function(){openContent(pos);}).delay(1000);
     








    
	/*
	
	

	var allSubsHide = function() {
        menus.each(function(item, index){
            var submenu = $('submenu' + (index + 1));
            submenu.fade('hide');
            item.fade('show');
        });
    };


	
    menus.each(function(item, index){
        var submenu = $('submenu' + (index + 1));
        item.addEvents({
            'mouseover' : function(e) {
                allSubsHide();
                submenu.fade('show');
                item.fade('hide');
            },
            'mouseout'  : function(e) {
                
            }
        });
        submenu.addEvents({
            'mouseover' : function(e){
                submenu.fade('show');
                item.fade('hide');
            },
            'mouseout'  : function(e){
                submenu.fade('hide');
                item.fade('show');
            }
        });
        var submenuItems = submenu.getElements('div[class^=submenu_button]');
        submenuItems.each(function(button, bindex){
            if (bindex != 0) {
                button.addEvents({
                    'mouseover' : function(e){
                        submenu.fade('show');
                        item.fade('hide');
                        this.setStyle('color','#865F7F');
                    },
                    'mouseout'  : function(e){
                        this.setStyle('color','#BB484A');
                        e.stop();
                    },
                    'click'     : function(e){
                    	if (button.get('cid') == '1') {
	                    	if (button.get('lang') != lang) {
								window.location = "http://verloskundigenvida.nl/?l=" + button.get('lang');
	                    	} else {
		                        openContent('con.php?id=' + button.get('cid') + '&lang=' + lang);
	                    	}
                    	} else {
                    		if (button.get('cid') == 'form') {
		                        openContent('form.php?lang=' + lang);
                    		} else if (button.get('cid') == 'date') {
		                        openContent('date.php?lang=' + lang);
                    		} else {
		                        openContent('con.php?id=' + button.get('cid') + '&lang=' + lang);
                    		}
	                    }
	                    pageTracker._trackPageview(button.get('html'));
	                    submenu.fade('hide');
                        item.fade('show');
                    }
                });
            } else {
                button.setStyle('color','#865F7F');
                button.addEvents({
                    'mouseover' : function(e){
                        submenu.fade('show');
                        item.fade('hide');
                    }
                });
            }
        });
        
    });
    
    
    openContent = function(link) {
        req.get(link);
    };
    
    var fixWrapperHeight = function() {
        if ($('cont').getStyle('height').toInt() > 450) {
            var targetHeight = $('cont').getStyle('height').toInt() +220;
            $('wrapper').setStyle('height',targetHeight + 'px');
            $('wrapper').setStyle('margin-bottom',250 + 'px');
            $('longImageFill').setStyle('height',targetHeight + 'px');
        } else {
            $('wrapper').setStyle('height','600px');
            $('wrapper').setStyle('margin-bottom',50 + 'px');
            $('longImageFill').setStyle('height',1 + 'px');
        }
    }
    
	var obj = new Swiff('quote.swf', {
			width: 170,
			height: 400,    
			params: {
				bgcolor: '#ff3300'
			},
			container: $('quote')
    });
	showQuote = function(quote){
        Swiff.remote(obj.toElement(),'echoText',quote);
    }
    
    
    if (Browser.Plugins.Flash.version == '0') {
		$('quote').empty();	    
		showQuote = function(quote){
			$('quote').set('html','<i>'+quote+'</i>');
			$('quote').setStyle('font-family','Times');
			$('quote').setStyle('line-height','20px');
			$('quote').setStyle('font-size','16px');
			
		}
    }


    switchLongImage = function(link){
        var old_img = $('longImage').getStyle('background-image');
        var new_img = "url(" + link + ")";
        if (new_img != old_img) {
       		$('longImage').setStyle('background-image','url(' + link + ')');
	    }
        
    }
    
    req = new Request.HTML({
            update:$('cont'),
            evalScripts:true,
            evalResponse:true,
            noCache:true,
            onRequest: function() {
                $('cont').set('html','<div id="ajax_load"></div>');
            },
            onComplete: function() {
                fixWrapperHeight();
                $('cont').fade('in');
            }
    });
    (function(){openContent('con.php?id=1&lang='+lang);}).delay(1000);
           
    */
	
});

