

$(document).ready(function () {
	$.sifr({
		build: 436,
		version: 3,
		save: true,
		path: "/sifr/"
	});

	$('h1').sifr({
		font: 'Journal',
		size: 36,
		resizable: true
	});

	$('#search-box h2').sifr({
		font: 'Journal',
		size: 36,		
		resizable: true
	})



});

var maxWidth  = 250;
var maxHeight = 120;

function scaleImage(im) {

  if (typeof im.naturalHeight == 'undefined') im.naturalHeight = im.height;
  if (typeof im.naturalWidth == 'undefined') im.naturalWidth = im.width;
  
  if (im.naturalHeight > maxHeight) {

    im.height = maxHeight;
    im.style.maxHeight = im.naturalHeight + 'px';
    im.className = 'resized';
    im.title = 'Klik voor originele grootte';
    im.onclick = unscaleImage;

  }

	if (im.naturalWidth > maxWidth) {
	
		im.width = maxWidth;
		im.style.maxWidth = im.naturalWidth + 'px';
		im.className = 'resized';
		im.title = 'Klik voor originele grootte';
		im.onclick = unscaleImage;
	
	  }

}

function unscaleImage() {

  if (this.height == maxHeight) {
	if (this.naturalHeight < 468){
		this.height = this.naturalHeight;
		this.style.borderWidth = '0px';
		this.title = 'Klik om te verkleinen';
	}
	else{
		newWindow=window.open(this.src,'newWin','width='+this.naturalWidth+',height='+this.naturalHeight+',toolbar=no');
		newWindow.document.write('<html><head><title>'+this.alt+'(Large Image)<\/title><style>body{margin:0;}<\/style><\/head><body><img src="'+this.src+'" alt="'+this.alt+'"><\/body><\/html>');
		newWindow.focus();		
	}

  } else {
	
    this.height = maxHeight;
    this.style.borderWidth = '2px';
    this.title = 'Klik voor de orginele grootte';

  }

  if (this.width == maxWidth) {

    this.width = this.naturalWidth;
    this.style.borderWidth = '0px';
    this.title = 'Klik om te verkleinen';

  } else {

    this.width = maxWidth;
    this.style.borderWidth = '2px';
    this.title = 'Klik voor de orginele grootte';

  }

}



function outLinks(myURL1,myURL2,myURL3){
	linkTarget="_blank";
	for (var i=0; i<=(document.links.length-1); i++){
		if(document.links[i].href.indexOf(myURL1)>-1){
			isExternal=false;	
		}
		else if(document.links[i].href.indexOf(myURL2)>-1){
			isExternal=false;	
		}				
		else if(document.links[i].href.indexOf(myURL3)>-1){
			isExternal=false;	
		}
		else {
			isExternal=true;	
		}				

		if(isExternal){
			document.links[i].target = linkTarget;
		}
	}
}

//outLinks(document.domain,"www.bakkerswereld.nl");



function domResize() {
	if (navigator.userAgent.match(/Opera (\S+)/)) {
		var operaVersion = parseInt(navigator.userAgent.match(/Opera (\S+)/)[1]);
	}
	if (!document.getElementById||operaVersion <7) return;
	var imgarr=document.getElementsByTagName('img');	
	for (i=0;i<imgarr.length;i++){
				
		if (imgarr[i].className.indexOf('domresize')!=-1){
			imgarr[i].onload=function(){
				scaleImage(this);
			}
			scaleImage(imgarr[i]);
		}
	}
}
domResize();
