$(document).ready(function() {
    if ($('#commercial').length) {
        $("div#menu_header li").hover(
          function () { $('#commercial').addClass('hidevideoclass');    }, 
          function () { $('#commercial').removeClass('hidevideoclass'); }
        );
    }
    $('li.noclick>a').click(function() { return false; });
    if ( $('#autotrackFrame').length ) {
            $('#autotrackFrame').append('<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script><script type="text/javascript">$(document).ready(function() { parent.setIframeHeight( $("table#pagina").height() ); });</script>');
    }
});

function setIframeHeight( newHeight ) {
	//alert(newHeight);
	if ($.browser.msie) {
		//$('#autotrackFrame').css('height', (newHeight + 500)+'px');
	} else {
		//$('#autotrackFrame').css('height', (newHeight + 500)+'px');	
	}
}
//pre-submit callback 
function showRequest(formData, jqForm, options) { 
    var queryString = $.param(formData);
    return true; 
} 
//post-submit callback 
function showResponse(responseText, statusText, xhr, $form)  { 
	//alert(responseText);
	if ( responseText != undefined ) {
		//disable button
		if ( responseText.indexOf('succesmelding') > -1 ) {
			if ($('input.verzendknop').length ) $('input.verzendknop').hide();
			if ($('input.verzenden').length ) $('input.verzenden').hide();
			if ($('input.verzendknopgroot').length ) $('input.verzendknopgroot').hide();
		}
		//show message
		$('#messageForm').html(responseText).addClass('successmsgForm');
		//show message
		$('#messageForm').show('fast'); 
    }
	return true; 
}

function displayBubble( className, innerText ) {
	//create bubble popups for each element with class "button"
	$('.'+className).CreateBubblePopup();
	//set customized mouseover event for each button
	$('.'+className).mouseover(function(){
		//get a reference to the object button
		var button = $(this);
		//show the bubble popup with new options
		button.ShowBubblePopup({
									innerHtml: innerText,
									innerHtmlStyle: { color:'#333333','text-align':'center' },
									themeName: 	'grey',
									themePath: 	'/addons/shared_addons/themes/residentie/css/jquery/jquerybubblepopup-theme'								 
							  });
	}); //end mouseover event
}
var newLink = "";
jQuery.fn.callbackSWFEndScriptCustom = function() {
    var myCommand = arguments[0];
    if ( myCommand == 'occasions' ) {
        $('#frontpage_bottom>div.html').prepend('<div id="clicktosubpage"><a href="'+newLink+'"><img src="/movies/occasions.jpg"/></a></div>');
    }
};


jQuery.fn.openPlaySwfMovie = function() {$('#commercial').empty();$('#commercial').flash({src: arguments[0],width: 600,height: 338, LOOP:"false"});return false;};

jQuery.fn.openPlaySwfMovie21 = function openPlaySwfMovie() {
    newLink = arguments[1];
        if ( $('#clicktosubpage').length  ) { $('#clicktosubpage').remove(); }
        $('#commercial').empty();
        $('#commercial').flashembed( { src: arguments[0],width: 600,height: 338, LOOP: 'false', allowscriptaccess: 'always',wmode: 'opaque' } , {  });
};
jQuery.fn.openPlaySwfMovie34 = function() {
        if ( $('#clicktosubpage').length  ) { $('#clicktosubpage').remove(); }
	$('#commercial').empty();
	var backlink = arguments[1];
        newLink = backlink;
	var movielink = arguments[0];
	if ( backlink == null ) {
		backlink="http://www.de-residentie.nl/";
	}
	$('#commercial').html("<a href=\""+movielink+"\" style=\"display: block; height: 338px;width: 600px;\" id=\"player\"></a>");
	flowplayer("player", "/movies/player/flowplayer-3.2.5.swf", {
		play:{ opacity:0 },
		loop: false,
		version: [9, 115],
		// older versions will see a custom message
                onLoad: function(clip) {
                    this.getPlugin("play").hide();
                    clip.update({ linkUrl: "" });
                },
		onFail: function()  {
			document.getElementById("info").innerHTML =
				"You need the latest Flash version to see MP4 movies. " +
				"Your version is " + this.getVersion();
		},
		plugins:  { 
			controls: null
			},
		clip: {
			//duration: 5,
			url: "http://www.de-residentie.nl"+movielink,
			onLoad: function(clip) {
                            this.getPlugin("play").hide();
                            clip.update({ linkUrl: "" });
                            //this.play();
			},
			onFinish: function(clip) {
				this.getPlugin("play").hide();
				clip.update({ linkUrl: backlink });
				this.unload();
			},
			autoPlay: true, 
			autoBuffering: true
		}
	});	
	return false;
};
jQuery.fn.openPlayFlvMovie = function() {
        if ( $('#clicktosubpage').length  ) { $('#clicktosubpage').remove(); }
	$('#commercial').empty();
	var backlink = arguments[1];
	if ( backlink == null ) {
		backlink="http://www.de-residentie.nl/";
	}
        newLink = backlink;
	$('#commercial').html("<a href=\""+arguments[0]+"\" style=\"display: block; height: 338px;width: 600px;\" id=\"player\"></a>");
	flowplayer("player", "/movies/player/flowplayer-3.2.5.swf", {
		play:{ opacity:0 },
		loop: false,
		version: [9, 115],
		// older versions will see a custom message
		onFail: function()  {
			document.getElementById("info").innerHTML =
				"You need the latest Flash version to see MP4 movies. " +
				"Your version is " + this.getVersion();
		},
		plugins:  { 
			controls: null 
			},
		clip: {
			//duration: 5,
			url: "http://www.de-residentie.nl"+arguments[0],
			onFinish: function(clip) {
				this.getPlugin("play").hide();
				clip.update({ linkUrl: backlink });
				this.unload();
			},
			autoPlay: true, 
			autoBuffering: true
		}
	});	
	return false;
};


jQuery.fn.openPlayFlvMovieNoClickRepeat = function() {
        if ( $('#clicktosubpage').length  ) { $('#clicktosubpage').remove(); }
	$('#commercial').empty();
        newLink = arguments[1];
	$('#commercial').html("<a href=\""+arguments[0]+"\" style=\"display: block; height: 338px;width: 600px;\" id=\"player\"></a>");
	flowplayer("player", "/movies/player/flowplayer-3.2.5.swf", {
		play:{ opacity:0 },
		loop: true,
		version: [9, 115],
		// older versions will see a custom message
		onFail: function()  {
			document.getElementById("info").innerHTML =
				"You need the latest Flash version to see MP4 movies. " +
				"Your version is " + this.getVersion();
		},
		plugins:  { 
			controls: null 
			},
		clip: {
			url: arguments[0],
			onFinish: function(clip) {
				this.play();
			},
                       // loop: true,
			autoPlay: true, 
			autoBuffering: true
		}
	});	
	return false;
};




function openPlaySwfMovieRepeat ( container, moviename, width, height, playercontrols ) {
        if ( $('#clicktosubpage').length  ) { $('#clicktosubpage').remove(); }
	$('#'+container).empty();
	$('#'+container).html("<a href=\""+moviename+"\" style=\"display: block; height: "+height+"px;width: "+width+"px;\" id=\"A"+container+"\"></a>");

	if ( playercontrols === "no" ) {
		flowplayer("A"+container, "/containerplayer/flowplayer-3.2.7.swf", {
			play:{ opacity:0 },
			loop: true,
			version: [9, 115],
			// older versions will see a custom message
			onFail: function()  { document.getElementById("info").innerHTML = "You need the latest Flash version to see MP4 movies. " + "Your version is " + this.getVersion();
			},
			plugins:  { 
				controls: null 
				},
			clip: {
				url: moviename,
				onFinish: function(clip) {
					this.play();
				},
                                
				autoPlay: true, 
				autoBuffering: true
			}
		});	
	} else {
		flowplayer("A"+container, moviename, {
			play:{ opacity:0 },
			loop: true,
			version: [9, 115],
			// older versions will see a custom message
			onFail: function()  { document.getElementById("info").innerHTML = "You need the latest Flash version to see MP4 movies. " + "Your version is " + this.getVersion(); },
			clip: {
				scaling: 'orig',
				allowscriptaccess: "always",
				forceStop: false,
				url: moviename,
				onFinish: function(clip) {
					this.play();
				},
				autoPlay: true, 
				autoBuffering: true
			}
		});	
	}
//	return false;
};


