//###############################################################################
//Version 1.0
// History
// 2008/12/15 Version 1 show and hide Content Divs
//                      paging for marginal Div, Robert Kunde
//################################################################################

//show Box
function showBox(selector){
	if(document.getElementById(selector)){
		  document.getElementById(selector).style.display="block";
	}
}
//show Box position=relative top=0
function showBoxPosRelTop0(selector){
	if(document.getElementById(selector)){
		  document.getElementById(selector).style.position="relative";
		  document.getElementById(selector).style.top="0";
	}
}
//show Box with Flash if isFlash
function showBoxFlash(selector){
	if (isFlash(6)){
		if(document.getElementById(selector)){
			  document.getElementById(selector).style.position="relative";
			  document.getElementById(selector).style.top="0";
		}
	}
}

//function urlcopy
function urlcopy(){
	$('#footerServiceFunction').show();
	$('#jqmWindowUrlCopy').jqm({overlay: 1});
	$('.jqModal').click(function(){
		$('#urlCopyInput').html("<input id='urlCopyUrl' name='urlCopyUrl' style='padding:2px;font-size:70%;width:430px;color:#2A3C48;background-color:#C3D9E7;border:none;' type='text' value='" + window.location.href + "'/>");
		if (navigator.appName == "Microsoft Internet Explorer"){
			$(".jqmWindowUrlCopy").css("margin-top", "-85px")
			$('#urlCopyText').html("Diese Url wurde in die Zwischenablage kopiert.");
			window.clipboardData.setData("Text",window.location.href);
		} else {
			$('#urlCopyText').html("Sie können jetzt diese Url kopieren.");
			document.getElementById("urlCopyUrl").select();
		}
	});
}

//
//News Fader
//

//hide Content News Divs by ID, add show Link
function hideContentNewsDiv(inId,buttonTextAdd,buttonTextSub){
  $("#textBox" + inId).addClass("jsDisplayNone");
  $("#button" + inId).append("<div class='buttonLink add'><a href='#' id='"+inId+"_link' onclick='handleContentNewsDivs(\""+inId+"\",\""+buttonTextAdd+"\",\""+buttonTextSub+"\");return false'></a></div>");
  $("#"+ inId +"_link").text(buttonTextAdd);

}

//show Content News Div if disabled, otherwise hide it
function handleContentNewsDivs(inId,buttonTextAdd,buttonTextSub){
  //only when visible
  if($("#textBox"+ inId).is(":visible")){
    $("#textBox" + inId).removeClass("jsDisplayBlock");
    $("#textBox" + inId).addClass("jsDisplayNone");
    $("#"+ inId +"_link").parent().removeClass("sub");
    $("#"+ inId +"_link").parent().addClass("add");
    $("#"+ inId +"_link").text(buttonTextAdd);
  }
  else{
    $("#textBox" + inId).removeClass("jsDisplayNone");
    $("#textBox" + inId).addClass("jsDisplayBlock");
    $("#"+ inId +"_link").parent().removeClass("add");
    $("#"+ inId +"_link").parent().addClass("sub");
    $("#"+ inId +"_link").text(buttonTextSub);
  }
}

//
//Marginal Paging
//

//init marginal Divs for Paging Box
function marginalDivs(inId, menuId){

  //add Box to Paging
  addItemToPagingMenu(inId, menuId);
  $("#" + inId).css("display", "none");
  $("#" + menuId).parent().parent().children(".pagingContent").find(".pagingContentItem:first").css("display", "block");
  $("#" + menuId + "_list li:first a").addClass("active");
}

//render Menu for Paging
function renderPagingMenu(menuId){
  counter = 1;
  $("#" + menuId).html(''
    + '<div class="pagingBox">'
    + '<ul id="'+ menuId +'_list">'
    + '</ul>'
    + '<div class="clear"></div>'
    + '</div>'
    );
$("#" + menuId).parent().parent().css("display", "none");
}

//add li item in Paging Menu
function addItemToPagingMenu(inId, menuId){
  $("#" + menuId + "_list").append("<li id=\""+ inId +"_listEntry\"><a href=\"#\" onclick=\"showMarginalDiv('"+ inId +"','"+ menuId +"');return false;\">"+ counter +"</a></li>");
  counter = counter + 1;
$("#" + menuId).parent().parent().css("display", "block");
}

//show Box by ID
//hide all other in List
function showMarginalDiv(inId, menuId){
  $("#" + menuId).parent().parent().children(".pagingContent").find(".pagingContentItem").css("display", "none");
  $("#" + inId).css("display", "block");
  $("#" + menuId + "_list li a").removeClass("active");
  $("#" + inId + "_listEntry a").addClass("active");

}

//show all Marginal Box Items in List
function showAllMarginalDivs(menuId){
  $("#" + menuId + "_showAll").click(function(){

      $("#" + menuId + "_list li a").removeClass("active");
      $("#" + menuId + "_showAll").text("schließen");
      $("#" + menuId + "_showAll").addClass("active");

      $("#" + menuId).parent().children(".pagingContent").find(".pagingContentItem").css("display", "block");

      $("#" + menuId + "_showAll").unbind("click");
      $("#" + menuId + "_showAll").click(function(){

          $("#" + menuId + "_showAll").unbind("click");
          firstItem = $("#" + menuId + "_list li:first").attr("id");
          firstItem = firstItem.replace("_listEntry","");
          showMarginalDiv(firstItem, menuId);
          $("#" + menuId + "_showAll").text("Alle zeigen");
          $("#" + menuId + "_showAll").removeClass("active");
      });
  });
}