/*
YUI based image gallery
(c) tobi flüter (tflueter@brainpool.de)
*/


//var imagePath = "/media/images/dummys/gallery/640x360/";
//var thumbPath = "/media/images/dummys/gallery/94x53/";
var name_of_inner_arrow_left = "inner_arrow_left";
var name_of_inner_arrow_right = "inner_arrow_right";
var adbreaker = 4;

var currentContentId = "";

//please don't edit anything after this line
var current_gallery_idx = 1; 
var clickcounter = 0;
//var avtRand = rand(3, 5);
var avtRand = 7;
function setImageValues(new_array){ images = new_array; }



//main content panel
function refreshPanel(contentId, gotoContentId, galleryId) {
	clickcounter++;
	if (clickcounter > avtRand) {
		location.href = '/bilder/galerie/index.html?galleryId='+galleryId+'&contentId='+gotoContentId+'&a=1';
		clickcounter = 0;
		//avtRand = rand(4, 6);
	} else {
		//ajax("", "/includes/php/inc/image_panel2.inc.php", "&contentType=image&contentId="+gotoContentId+"&galleryId="+galleryId, "image_panel");
		//ajax("", "ajax.php", "getSuggestInfo&contentType=image&contentId="+gotoContentId, "ajax_suggest_container");
		//ajax("", "ajax.php", "getBookmarkInfo&contentType=image&contentId="+gotoContentId, "ajax_container_bookmark");
		//ajax("", "ajax.php", "getVoting&contentType=image&contentId="+gotoContentId, "ajax_container_voting");

		//manchmal kommt voting-ajax-request nicht hinterher... das muss ncoh gefixt werden
		//setTimeout('ajax("", "ajax.php", "getVoting&contentType=image&contentId="+' + gotoContentId + ', "ajax_container_voting");', 100);	
		//ajax("", "ajax.php", "getGalleryFunctions&contentType=image&contentId="+gotoContentId, "ajax_container_function_panel");
		
		//ajax("", "ajax.php", "getComments&contentType=image&contentId="+gotoContentId, "comments");
		//ajax("", "ajax.php", "addTag&contentType=image&contentId=" +gotoContentId, "ajax_container_addtag");
		//ajax("", "ajax.php", "refreshImageTitle&contentType=image&contentId=" +gotoContentId, "gallery_image_infos");
		
		
		StartAjaxHTTP("/includes/php/inc/image_panel.inc.php?contentType=image&contentId="+gotoContentId+"&galleryId="+galleryId, "image_panel");
		StartAjaxHTTP("/includes/php/ajax.php?action=getGalleryFunctions&contentType=image&contentId="+gotoContentId, "ajax_container_function_panel");
		StartAjaxHTTP("/includes/php/ajax.php?action=getComments&contentType=image&contentId="+gotoContentId, "comments");
		StartAjaxHTTP("/includes/php/ajax.php?action=addTag&contentType=image&contentId=" +gotoContentId, "ajax_container_addtag");
		StartAjaxHTTP("/includes/php/ajax.php?action=addTag&contentType=gallery&contentId=" +galleryId, "ajax_container_addtag_gallery");
		StartAjaxHTTP("/includes/php/ajax.php?action=refreshImageTitle&contentType=image&contentId=" +gotoContentId, "gallery_image_infos");
		generatePI(gotoContentId, galleryId);
		currentContentId = gotoContentId;
	}
}


function generatePI(contentId, galleryId)
{
	var ivwPixel = new Image();
	ivwPixel.src = "http://pro7.ivwbox.de/cgi-bin/ivw/CP/1521usfoGALE;/sendungen/usfo/bilder/galerie/index.html?galleryId="+galleryId+"&contentId="+contentId+"&" + Math.random().toString();
}


//comments
function refreshComments(contentId){
	//YAHOO.log('BildId:'+images[current_gallery_idx]['id'], 'warn');
	ajax("", "ajax.php", "getComments&contentType=image&contentId="+contentId, "comments");
}


function addNewTag(){
	ajax("", "ajax.php", "addTag&tags=" + document.getElementById("newtag").value + "&contentType=image&contentId=" + currentContentId, "ajax_container_addtag");
}


//xxxxxxxxxxxxxxxxxxx Fade in and out any element like the inner arrows
function showElement(duration, divid){
	var opacity_values = {
		opacity: { to: 0.8 }
	};
	opacity_obj = new YAHOO.util.Anim(divid, opacity_values, duration, YAHOO.util.Easing.easeBoth);
	opacity_obj.animate();
}

function hideElement(duration, divid){
	var opacity_values = {
		opacity: { to: 0 }
	};
	opacity_obj = new YAHOO.util.Anim(divid, opacity_values, duration, YAHOO.util.Easing.easeBoth);
	opacity_obj.animate();
}


//xxxxxxxxxxxxxxxxxxx MagicDiv displayed after 4 mousecl icks.
function showRectangleDiv(){
	document.getElementById('avt_container').style.display = "block";
	document.getElementById('avt_functions').style.display = "block";
	document.getElementById('image_container').style.display = "none";
	document.getElementById('image_functions').style.display = "none";
}


function hideRectangleDiv(){
	document.getElementById('image_container').style.display = "block";
	document.getElementById('image_functions').style.display = "block";
	document.getElementById('avt_container').style.display = "none";
	document.getElementById('avt_functions').style.display = "none";
}
//	<a href="javascript:showRectangleDiv();">Werbung</a> | <a href="javascript:hideRectangleDiv();">Bild</a>


//xxxxxxxxxxxxxxxxxxx InfoBox: Forwarding....
function showInfobox(){
	var infobox_values = {
		height: { to: 30 },
		width: { to: 300 },
		opacity: { to: 0.8 }
	};
	opacity_obj = new YAHOO.util.Anim('overlay_infobox', infobox_values, 0.5, YAHOO.util.Easing.easeBoth);
	opacity_obj.animate();
}

function hideInfobox(){
	var infobox_values = {
		height: { to: 0 },
		width: { to: 0 },
		opacity: { to: 0 }
	};
	opacity_obj = new YAHOO.util.Anim('overlay_infobox', infobox_values, 0.5, YAHOO.util.Easing.easeBoth);
	opacity_obj.animate();
}


function rand(rangeFrom, rangeTo){
	return rangeFrom + Math.round((rangeTo-rangeFrom)*Math.random());
}

