/**
 * standard scripts in HTML head -> tags_htmlhead.tpl
 */
 
$(document).ready(function(){

	// ===== prettyPhoto ======
		$("a[rel^='prettyPhoto']").prettyPhoto({
			animation_speed: 'fast',		/* fast/slow/normal */
			opacity: 0.35,					/* Value between 0 and 1 */
			show_title: false,				/* true/false */
			allow_resize: true,				/* true/false */
			counter_separator_label: '/',	/* The separator for the gallery counter 1 "of" 2 */
			theme: 'pp_default',			/* pp_default / light_rounded / dark_rounded / light_square / dark_square / facebook */
			overlay_gallery: true,			/* If set to true, a gallery will overlay the fullscreen image on mouse over */
			deeplinking: false,				/* Allow prettyPhoto to update the url to enable deeplinking. */
			social_tools: ''				/* AZP: disable social sharing */
		});

	// ===== sweAccordion ======
		$(".sweAccordion").each(function(idx, oldRoot){
				$newRoot = $("<div class='sweAccordion'></div>");
				$(oldRoot).after($newRoot);
					
					$(oldRoot).find("tr:even").each(function(idx, childElm){
							$newRoot.append("<h3>" + $(childElm).html() + "</h3>");
							$newRoot.append("<div>" + $(childElm).next().find("td").html() + "</div>");
						});
						
					// remove original accordion table
					$(oldRoot).detach();
			});

		$(".sweAccordion").accordion({
				autoHeight: false,
				active: false,
				collapsible: true
			});

	// ===== sweTabs ======
		var cnt = 0;
		$(".sweTabs").each(function(idx, oldRoot){
			
			$newRoot = $("<div class='sweTabs'></div>");
			$(oldRoot).after($newRoot);
			
			// Tab-Header
			$newTabRoot = $("<ul></ul>");
			$newRoot.append($newTabRoot);
			
			var subcnt = cnt;
			$(oldRoot).find("tr:even").each(function(idx, childElm){
					$newTabRoot.append("<li><a href='#sweTabs-" + subcnt + "'>" + $(childElm).html() + "</a></li>");
					subcnt++;
				});
			
			// Tab-Content
			$newRoot.append($newTabRoot);
			subcnt = cnt;
			$(oldRoot).find("tr:even").each(function(idx, childElm){
					$newRoot.append("<div id='sweTabs-" + subcnt + "'>" + $(childElm).next().find("td").html() + "</div>");
					subcnt++;
				});
				
			// remove original accordion table
			$(oldRoot).detach();
			
			cnt = cnt + subcnt;
		});
		
		$(".sweTabs").tabs();
	
});
