//////////////////////////////////////////////////////////////////////////
// $RCSfile: sisby.js,v $
// $Source: /home/cvs/ihk4/scandio-cms/website-sisby/src/js/sisby.js,v $
// $Date: 2010-03-02 11:49:40 $
// $Revision: 1.16 $
// $Author: mkalmes $
//////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////
// renders all "table" rows (build with DIVs.keyval) in even/odd style
//
$(document).ready(function()
{
	$("div.keyval:even").addClass("odd");
});
//////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////
// activate prettyPhoto popup/layer functionality for a href with rel='prettyPhoto'
//
$(document).ready(function(){
	$("a[rel^='prettyPhoto']").prettyPhoto({
		showTitle: false
	});
});
//////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////
//urlencodes all links to "warenkorbPut.js" aka class="merkliste"
//
function urlencodeMerkliste()
{
	var href = $(".merkliste").attr("href");
	if( typeof href != "undefined" )
	{
		var url = href.substring(0,href.indexOf("?")+1);
		var req = href.substring(href.indexOf("?")+1,href.length);
		req = escape(req).replace(/%3D/g,"=").replace(/%26/g,"&");
		url = url + req;
		$(".merkliste").attr("href", url );
	}	
}
//////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////
// gemeinde_infobox click heads
// changed 17.12.2009:ischwarzer -- only one item can be open
$(function() {
	$(".clickable").click(function() {
		if($(this).hasClass("active")) { // click on open item
		 		$(this).toggleClass("active");
				$(this).next().toggle();
		} else { // click on closed item
		 	// find open item and close it
			var elemToHide = $(".active");
			elemToHide.toggleClass("active");
			elemToHide.next().toggle();
			// open clicked item
			$(this).toggleClass("active");
			$(this).next().toggle();
		}
	});
});

function clickable_toggle(obj)
{
		if($(obj).hasClass("active")) { // click on open item
		 		$(obj).toggleClass("active");
				$(obj).next().toggle();
		} else { // click on closed item
		 	// find open item and close it
			var elemToHide = $(".active");
			elemToHide.toggleClass("active");
			elemToHide.next().toggle();
			// open clicked item
			$(obj).toggleClass("active");
			$(obj).next().toggle();
		}
}

// global var to activate accoridion rollover by request
var g_accOpen_GPIB = -1;
var g_accOpen_GPC = -1;

function jsSet_accOpen_GPIB( acc )
{
	g_accOpen_GPIB = acc;
}
function jsSet_accOpen_GPC( acc )
{
	g_accOpen_GPC = acc;
}

function jsLoadGemeindeprofilInfobox(url, accOpen)
{
	var selector = "#content";
	var jQueryLoad = url + " " + selector;
	// alert(jQueryLoad);
	g_accOpen_GPIB = -1;
	if( typeof accOpen != "undefined" )
	{
		g_accOpen_GPIB = accOpen;
	}
	
	$("#infobox").load(jQueryLoad, '', jqueryCallbackDoAccordion_GemeindeprofilInfobox );
}						

// callback if the page has been laoded successfully
function jqueryCallbackDoAccordion_GemeindeprofilInfobox() 
{
	$("#jsContent").accordion({
		active: g_accOpen_GPIB, // collapse all due to expand the further information tab inside template "deckblatt_profil.jsp"
		header: '.acc-head',
		autoHeight: false,
		collapsible: true
	});
}

function jqueryCallbackDoAccordion_GemeindeprofilContent() 
{
	$("#gemeindedetail").accordion({
		active: g_accOpen_GPC,
		header: '.acc-head',
		autoHeight: false,
		collapsible: true
	});
}

function jqueryCallbackDoAccordion_Gemeindeprofil() 
{
	jqueryCallbackDoAccordion_GemeindeprofilInfobox();
	jqueryCallbackDoAccordion_GemeindeprofilContent();

	$(document).ready(function()
	{
		if ($("#div_loader").length)
		{
			$("#div_loader").hide();
		}
	});
}
//////////////////////////////////////////////////////////////////////////

function resetForm(id) 
{
	$('#'+id).each(function(){
	        this.reset();
	});
}