function printStackTrace(b){var c=(b&&b.e)?b.e:null;var e=b?!!b.guess:true;var d=new printStackTrace.implementation();var a=d.run(c);return(e)?d.guessFunctions(a):a}printStackTrace.implementation=function(){};printStackTrace.implementation.prototype={run:function(a){a=a||(function(){try{var c=__undef__<<1}catch(d){return d}})();var b=this._mode||this.mode(a);if(b==="other"){return this.other(arguments.callee)}else{return this[b](a)}},mode:function(a){if(a["arguments"]){return(this._mode="chrome")}else{if(window.opera&&a.stacktrace){return(this._mode="opera10")}else{if(a.stack){return(this._mode="firefox")}else{if(window.opera&&!("stacktrace" in a)){return(this._mode="opera")}}}}return(this._mode="other")},instrumentFunction:function(a,b,c){a=a||window;a["_old"+b]=a[b];a[b]=function(){c.call(this,printStackTrace());return a["_old"+b].apply(this,arguments)};a[b]._instrumented=true},deinstrumentFunction:function(a,b){if(a[b].constructor===Function&&a[b]._instrumented&&a["_old"+b].constructor===Function){a[b]=a["_old"+b]}},chrome:function(a){return a.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@").split("\n")},firefox:function(a){return a.stack.replace(/(?:\n@:0)?\s+$/m,"").replace(/^\(/gm,"{anonymous}(").split("\n")},opera10:function(g){var k=g.stacktrace;var m=k.split("\n"),a="{anonymous}",h=/.*line (\d+), column (\d+) in ((<anonymous function\:?\s*(\S+))|([^\(]+)\([^\)]*\))(?: in )?(.*)\s*$/i,d,c,f;for(d=2,c=0,f=m.length;d<f-2;d++){if(h.test(m[d])){var l=RegExp.$6+":"+RegExp.$1+":"+RegExp.$2;var b=RegExp.$3;b=b.replace(/<anonymous function\:?\s?(\S+)?>/g,a);m[c++]=b+"@"+l}}m.splice(c,m.length-c);return m},opera:function(h){var c=h.message.split("\n"),b="{anonymous}",g=/Line\s+(\d+).*script\s+(http\S+)(?:.*in\s+function\s+(\S+))?/i,f,d,a;for(f=4,d=0,a=c.length;f<a;f+=2){if(g.test(c[f])){c[d++]=(RegExp.$3?RegExp.$3+"()@"+RegExp.$2+RegExp.$1:b+"()@"+RegExp.$2+":"+RegExp.$1)+" -- "+c[f+1].replace(/^\s+/,"")}}c.splice(d,c.length-d);return c},other:function(h){var b="{anonymous}",g=/function\s*([\w\-$]+)?\s*\(/i,a=[],d=0,e,c;var f=10;while(h&&a.length<f){e=g.test(h.toString())?RegExp.$1||b:b;c=Array.prototype.slice.call(h["arguments"]);a[d++]=e+"("+this.stringifyArguments(c)+")";h=h.caller}return a},stringifyArguments:function(b){for(var c=0;c<b.length;++c){var a=b[c];if(a===undefined){b[c]="undefined"}else{if(a===null){b[c]="null"}else{if(a.constructor){if(a.constructor===Array){if(a.length<3){b[c]="["+this.stringifyArguments(a)+"]"}else{b[c]="["+this.stringifyArguments(Array.prototype.slice.call(a,0,1))+"..."+this.stringifyArguments(Array.prototype.slice.call(a,-1))+"]"}}else{if(a.constructor===Object){b[c]="#object"}else{if(a.constructor===Function){b[c]="#function"}else{if(a.constructor===String){b[c]='"'+a+'"'}}}}}}}}return b.join(",")},sourceCache:{},ajax:function(a){var b=this.createXMLHTTPObject();if(!b){return}b.open("GET",a,false);b.setRequestHeader("User-Agent","XMLHTTP/1.0");b.send("");return b.responseText},createXMLHTTPObject:function(){var c,a=[function(){return new XMLHttpRequest()},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}];for(var b=0;b<a.length;b++){try{c=a[b]();this.createXMLHTTPObject=a[b];return c}catch(d){}}},isSameDomain:function(a){return a.indexOf(location.hostname)!==-1},getSource:function(a){if(!(a in this.sourceCache)){this.sourceCache[a]=this.ajax(a).split("\n")}return this.sourceCache[a]},guessFunctions:function(b){for(var d=0;d<b.length;++d){var h=/\{anonymous\}\(.*\)@(\w+:\/\/([\-\w\.]+)+(:\d+)?[^:]+):(\d+):?(\d+)?/;var g=b[d],a=h.exec(g);if(a){var c=a[1],f=a[4];if(c&&this.isSameDomain(c)&&f){var e=this.guessFunctionName(c,f);b[d]=g.replace("{anonymous}",e)}}}return b},guessFunctionName:function(a,c){try{return this.guessFunctionNameFromLines(c,this.getSource(a))}catch(b){return"getSource failed with url: "+a+", exception: "+b.toString()}},guessFunctionNameFromLines:function(h,f){var c=/function ([^(]*)\(([^)]*)\)/;var g=/['"]?([0-9A-Za-z_]+)['"]?\s*[:=]\s*(function|eval|new Function)/;var b="",d=10;for(var e=0;e<d;++e){b=f[h-e]+b;if(b!==undefined){var a=g.exec(b);if(a&&a[1]){return a[1]}else{a=c.exec(b);if(a&&a[1]){return a[1]}}}}return"(?)"}};

var trace = printStackTrace();

var errordialog=function(emsg, url, linenumber){
	var msg = "<strong>Foutmelding:</strong> Er is een fout opgetreden, ("+ emsg +": " + linenumber +"). De beheerder is op de hoogte gebracht.";
	$('body').append("<div id='errordl' class='errordialog'><div>"+msg+"</div></div>");
	$('#errordl').slideDown('fast');
	var stack = trace.join(' -> ');
	senderror(emsg,linenumber,url,stack);
}

function senderror(msg,linenumber,url,stack){
	/*VERZAMEL DATA*/
	var e = "ERROR: "+msg+"\n\r";
	e += "URL: "+url+"\n\r";
	e += "LINE: "+linenumber+"\n\r";
	e += "STACK: "+stack+"\n\r\n\r";
	
	e += "Browser CodeName: " + navigator.appCodeName + "\n\r";
	e += "Browser Name: " + navigator.appName + "\n\r";
	e += "Browser Version: " + navigator.appVersion + "\n\r";
	e += "Cookies Enabled: " + navigator.cookieEnabled + "\n\r";
	e += "Platform: " + navigator.platform + "</p>";
	e += "User-agent header: " + navigator.userAgent + "\n\r";	
	
	
	/*PUSH*/
	var data = "{data: \""+e+"\"}";	

	$.postJSON("/json/errorhandler",{
			"var":e,
			format: "json"
	});	

}

jQuery.extend({
	postJSON: function( url, data, callback) {
	return jQuery.post(url, data, callback, "json");
	}
});

jQuery.cookie = function (key, value, options) {
    
	//usage example
	//$.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });

	
    if (arguments.length > 1 && String(value) !== "[object Object]") {
        options = jQuery.extend({}, options);

        if (value === null || value === undefined) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }
        
        value = String(value);
        
        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? value : encodeURIComponent(value),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};




window.onerror=function(msg, url, linenumber){
	return errordialog(msg, url, linenumber);
}


function init(m){
	initcufon(m);	
	setblurs();
	getcolomns();
}

function initcufon(model){

	if(model == 'home'){	
		Cufon.replace(['h1:not(.clean)'], {
			hover: true		
		});			
	}
	
	//general
	Cufon.replace(['span:not(.clean)'], {
		hover: true		
	});

	Cufon.replace(['.shadow'], {
		textShadow: '1px 1px #304364',	
		color: '-linear-gradient(#FFE66F, #FED300)',	
		hover: true		
	});	

	Cufon.replace(['.ticketbutton a'], {
		color: '-linear-gradient(#004471, #003153)',	
		hover: true		
	});	
		
}


function formsubmit(f){
	$('#'+f).submit();
}

function setblurs(){
	
	$('#searchinput').focus(function() {
	  if(this.value == 'Zoekwoord'){
		$('#searchinput').attr('value','');
	  }
	});
		
	$('#searchinput').blur(function() {
	  if(this.value == ''){
		$('#searchinput').attr('value','Zoekwoord');
	  }
	});
		
	$('#email').focus(function() {
	  if(this.value == 'E-mailadres'){
		$('#email').attr('value','');
	  }
	});
	
	$('#email').blur(function() {
	  if(this.value == ''){
		$('#email').attr('value','E-mailadres');
	  }
	});	
	
} 

function getcolomns(){
	//opmaat maken van alle bouw blokken		
	var coll = $('.infoleft').height();
	var colm = $('.infocontent .contentplacement').height();
	var colr = $('.inforight').height();
	
	
	var mt = 0;
	if(mt < coll){
		mt = coll
	}
	
	if(coll < colm){
		mt = colm+200;
	}

	if(colm < colr){
		mt = colr
	}	
	
	
	var nh = mt+"px"; //css formattering	
	$('.infoleft').css('height',nh);
	$('.infocontent').css('height',nh);
	//$('.infocontent .contentplacement').css('height',nh);
	$('.inforight').css('height',nh);
	$('.info').css('height',nh);	
	 
	setTimeout('getcolomns()', 300);
	
}
 
function checkcontentcol(){
	var colm = $('.infocontent').height();
	
	if(colm == contheight){
		setTimeout('checkcontentcol()', 1000);	
	}
	else{
		getcolomns();
	}
	
	
}


function submitcartpage(url,trigger){	
	
	if(document.getElementById('submitformulier') == null){
		window.location = url;
	}
	else{
		document.getElementById('submitformulier').action = document.getElementById('submitformulier').action+"&t="+trigger;
		document.submitformulier.submit();
		return false;
	}	
}


function betaal(){
	document.submitbetaal.submit();
	return false;	
}

function winPopup(sURL, sWinName, iWidth, iHeight) {var f="scrollbars=yes,resizable=yes,width=" + iWidth + ",height=" + iHeight + ",top=" + ((screen.height-iHeight)/2) + ",left=" + ((screen.width-iWidth)/2);window.open(sURL,sWinName,f);}

function addtonewsletter(){
	var url = "http://s.mc1.nl/s.asp?q=2029542C52544F554D5649354133&l=100&email="+$('#emailletter').attr('value');
	winPopup(url,'SubScreen',740,680);
}

