//class="exit" onclick="window.open(this.href);return false;"
function checkLinks() {
	var alinks,i;
	alinks = document.getElementsByTagName('a');
	for (i=0;i<alinks.length;i++) {
		islink = alinks[i].href;
		if (islink && islink.indexOf(window.location.hostname) == -1 && islink.indexOf('javascript:') == -1) {
				if (alinks[i].childNodes[0].nodeName != 'IMG') { //alinks[i].className='exit';
				}
				alinks[i].onclick=function() { return openlink(this); };
				
				if (!alinks[i].title) 
					alinks[i].title = 'open ' + alinks[i].href + ' in een nieuw venster';
		}
	}
}
function openlink(o) {
	var o;
	window.open(o.href);return false;
	
}



window.onload = function () {
	
	var stretchers = $$('a.stretcher');
	var stretch = $$('ul.stretch');
	var myAccordion = new Fx.Accordion(stretchers, stretch, {alwaysHide: true, start: 'all-closed'});
	initLightbox();
	
}

// bloggers
function initBloggers() {
	
	var els = $$('a.getBlogger');
	
	for (var i=0; i<els.length; i++){
			var el = els[i];
			el.onclick = function() { getBlogger(this.getAttribute('rel')); return false; }
	}
	
}
function getBlogger(id) {
	var url = '/city-adventures-getBlogger.php?id=' + id;	
	var xhr = new Ajax(url, {method: 'get', update: 'update',
					  onComplete: function() { var div_scroll1 = TextScroll('div_scroll1', 'scroll', 'scroll_up', 'scroll_down', 147); } 
			}).request();
		
	
}


// gives up and down scroll buttons to images, spans, ... named up_name, down_name, respectively.
// will keep the default scroll_box's style overflow if it encounters errors (so make overflow: auto;)

// usage: put this after the scrollbox div:  var div_scroll1 = new TextScroll('div_scroll1', 'scroll_box');
function TextScroll(scrollname, div_name,  up_name, down_name, h)
{
    this.div_name = div_name;
    this.name = scrollname;
    this.scrollCursor = 0;
    this.speed = 10;
    this.timeoutID = 0;
    this.div_obj = null;
    this.up_name = up_name;
    this.dn_name = down_name;
	this.h = h ? h : 320;
	this.scroller = 0;

{
        if (document.getElementById) {
            div_obj = $(this.div_name);
            if (div_obj) {
				// test scroll needed?
				div_obj.style.height = 'auto';
				div_obj.style.overflow = 'visible';
				
				
				if (div_obj.offsetHeight > this.h) { this.scroller = 1; }
				
                this.div_obj = div_obj;

				div_obj.style.height = this.h + 'px';
                div_obj.style.overflow = 'hidden';
            }
            div_up_obj = $(this.up_name);
            div_dn_obj = $(this.dn_name);
			
			if (!this.scroller && div_up_obj && div_dn_obj) {
				div_dn_obj.style.visibility = 'hidden';
				div_up_obj.style.visibility = 'hidden';
			} else if (this.scroller) {
				div_dn_obj.style.visibility = 'visible';
				div_up_obj.style.visibility = 'visible';	
			}
            if (div_up_obj && div_dn_obj) {
			
				
                div_up_obj.onmouseover = function () { eval (scrollname + ".scrollUp();"); };
                div_up_obj.onmouseout = function () { eval(scrollname + ".stopScroll();"); };

				div_dn_obj.onmouseover = function () { eval(scrollname + ".scrollDown();"); };
                div_dn_obj.onmouseout = function() { eval(scrollname + ".stopScroll();"); };
            }
        }
    }

this.stopScroll = function() {
        clearTimeout(this.timeoutID);
    }

this.scrollUp = function() {
        if (this.div_obj) {
            this.scrollCursor = (this.scrollCursor - this.speed) < 0 ? 0 : this.scrollCursor - this.speed;
            this.div_obj.scrollTop = this.scrollCursor;
            this.timeoutID = setTimeout(this.name + ".scrollUp()", 60);
        }
    }

this.scrollDown = function() {
        if (this.div_obj) {
            this.scrollCursor += this.speed;
            this.div_obj.scrollTop = this.scrollCursor;
            this.timeoutID = setTimeout(this.name + ".scrollDown()", 60);
        }
    }

this.resetScroll = function() {
        if (this.div_obj) {
            this.div_obj.scrollTop = 0;
            this.scrollCursor = 0;
        }
    }
}