// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function hideYouTubeText(recordId, videoConstant){
	if(document.getElementById('record_rp_type_' + recordId).value == videoConstant){
		document.getElementById('youTubeDiv_' + recordId).style.visibility = "visible";
	}else{
		document.getElementById('youTubeDiv_' + recordId).style.visibility = "hidden";
	}
}


function openModalWindowSlideshow(src, width, height, ticks) {
	var div = document.getElementById('modalWindowSlideshow');
	var bgDiv = document.getElementById('modalBackgroundDiv');
	
	var frame = document.getElementById('frameModalWindowSlideshow');
	frame.src = src + '?' + ticks;
	
	// Hide small video. ToDo: what if there are many videos?
	var movie = document.getElementById('youtube_movie_small')
	if (movie) {
		movie.style.visibility = 'hidden';
	}

	height += 32;  // add 2 lines

	div.style.left = (getWindowWidth() - width)/2 + "px";
	if (getScrollTop() + (getWindowHeight() - height)/2 > 0)
		div.style.top = getScrollTop() + (getWindowHeight() - height)/2 + "px";
	else
		div.style.top = "0px";
	div.style.height = height + "px";
	div.style.width = width + "px";

    div.style.display = "block";
    bgDiv.style.display = "block";
}

function closeModalWindowSlideshow() {
	var div = parent.document.getElementById('modalWindowSlideshow');
	var bgDiv = parent.document.getElementById('modalBackgroundDiv');

	// Blank and hide frame
	var frame = parent.document.getElementById('frameModalWindowSlideshow');
	frame.src = "";
	div.style.display = "none";
	bgDiv.style.display = "none";
	
	// Show small video. ToDo: what if there are many videos?
	var movie = parent.document.getElementById('youtube_movie_small')
	if (movie) {
		movie.style.visibility = 'visible';
	}
}

function openModalWindowVideo(src, width, height) {
	var div = document.getElementById('modalWindowVideo');
	var bgDiv = document.getElementById('modalBackgroundDiv');
	
	var frame = document.getElementById('frameModalWindowVideo');
	frame.src = src;
	
	// Hide small video. ToDo: what if there are many videos?
	var movie = document.getElementById('youtube_movie_small')
	if (movie) {
		movie.style.visibility = 'hidden';
	}
	
	div.style.left = (getWindowWidth() - width)/2 + "px";
	div.style.top = getScrollTop() + (getWindowHeight() - height)/2 + "px";
	div.style.height = height + "px";
	div.style.width = width + "px";
	
	div.style.display = "block";
	bgDiv.style.display = "block";
}

function closeModalWindowVideo() {
	var div = parent.document.getElementById('modalWindowVideo');
	var bgDiv = parent.document.getElementById('modalBackgroundDiv');

	// Blank and hide frame
	var frame = parent.document.getElementById('frameModalWindowVideo');
	frame.src = "";
	div.style.display = "none";
	bgDiv.style.display = "none";
	
	// Show small video. ToDo: what if there are many videos?
	var movie = parent.document.getElementById('youtube_movie_small')
	if (movie) {
		movie.style.visibility = 'visible';
	}
}

function centerContainer(height) {
	var div = parent.document.getElementById('modalWindowSlideshow');
	var bgDiv = parent.document.getElementById('modalBackgroundDiv');

	var divText = document.getElementById('containerText');
	var divImage = document.getElementById('containerImage');

	divImage.style.height = 535 + "px";
	div.style.height = height + divText.offsetHeight + "px";
}
