/**
 * standard scripts in HTML head -> tags_htmlhead.tpl
 */
 
$(document).ready(function(){

	// ===== prettyPhoto ======
		$("a[rel^='prettyPhoto']").prettyPhoto({
			animationSpeed: 'normal',		/* fast/slow/normal */
			opacity: 0.35,					/* Value betwee 0 and 1 */
			showTitle: false,				/* true/false */
			allowresize: false,				/* true/false */
			counter_separator_label: '/',	/* The separator for the gallery counter 1 "of" 2 */
			theme: 'facebook',				/* light_rounded / dark_rounded / light_square / dark_square / facebook */
			callback: function(){}
		});

	// ===== 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,
				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();
	
});
