/*
Project Name: der Hörverlag
Version: 1.0
Author: Design Aspekt (JB)
*/


function embedFlash(oTag) { 
	
	document.write(oTag);
}


$(document).ready(function () {

	$(".icon-settings-cart").fancybox();
	
});


function productAdded () {
	alert("Your product has been added to the cart");
}

/* Set up initial cookie, initial page header and buttons. */
$(function() {
	$("#colourSelection").show();
	
	$("#head").removeAttr("class");

	$("#head").addClass($.cookie("header-set"));
	
	if ($.cookie("header-set") == null) {

		$("#head").addClass("header-red");
	
	} else {
		//do nothing
	}
	
	
	// Colour picker buttons
	var btn_myskin = $("#btn-myskin");
	var btn_myskin2 = $("#btn-myskin2");
	var mySkin = $("#my-skin");

	btn_myskin.click(function() {
		mySkin.show();
	});
	
	btn_myskin2.click(function() {
		mySkin.show();
	});

	mySkin.click(function() {
		mySkin.hide();
	});

});


//Change header colour
function changeColour(colourID) {

	$("#head").removeAttr("class");
	
	//update cookie with header class chosne form the colour picker
	$.cookie("header-set", colourID, { path: '/', expires: 7 });
	
	//add header class from cookie
	$("#head").addClass($.cookie("header-set"));

}


// Slider knob
$(function() {

	$(".slider").mouseover(function() {
		$(this).removeClass("scroll_knob");
		$(this).addClass("scroll_knob_active");
	});


	$(".slider").mouseout(function() {
		$(this).removeClass("scroll_knob_active");
		$(this).addClass("scroll_knob");
	});
});


//move the link to a person in the middle of the div
$(function() {

	var pHeight = $(".peopledetail").height();
	var lHeight = $("#more").height();

	var addMargin = (pHeight - lHeight)/2;
	$("#more").css("margin-top", addMargin + "px");
});


//OS & Browser sniffer - Fix columns for safari on pc.
if($.client.os == "Windows" && $.client.browser == "Safari") {
	$( function() {
		$('.crosslink,.similar,.col3,.productthumb_large').css( 'width', '248px' );
		$('.pagination-wrapper-s,.pagination-wrapper-l').css( 'height', '25px' );
		$('.col2,.productthumb,.equal-box').css( 'width', '152px' );
		$('.people,.publications').css( 'width', '344px' );
		$('.col2,.col3').css( 'padding-right', '20px' );
		$('.news,.prod-list').css( 'width', '536px' );
		$('.recommend').css( 'width', '440px' );
		// needs to be after equal-box class.
		$('.productthumb_large').css( 'width', '248px' );
		$('#user-navi').css( 'width', '950px' );
		$('.special').css( 'width', '536px' );
		$('.boxmodule').css( 'width', '247px' );
		//$('.boxmodule').css( 'margin-right', '0px' );

	});
}


//OS & Browser sniffer - Fix columns for safari on mac.
if($.client.os == "Mac" && $.client.browser == "Safari") {
	$( function() {
		$('.crosslink,.similar,.col3,.productthumb_large').css( 'width', '248px' );
		$('.pagination-wrapper-s,.pagination-wrapper-l').css( 'height', '25px' );
		$('.productthumb,.equal-box').css( 'width', '152px' );
		$('.people,.publications').css( 'width', '344px' );
		$('.news,.prod-list').css( 'width', '536px' );
		$('.col3').css( 'padding-right', '20px' );
		$('.recommend').css( 'width', '440px' );
		// needs to be after equal-box class.
		$('.productthumb_large').css( 'width', '248px' );
		$('#user-navi').css( 'width', '950px' );
		$('.special').css( 'width', '536px' );
	});
}

//run equal heights function after all content has loaded.
$(window).load(function () {
	$(".modul-size").equalHeights();
});



// shows the subtext in the faq
var activeSubtext = null;
var activeListItem = null;

function showSubtext(layerId) {
	if (document.getElementById(layerId)) {
		selectedSubtext = document.getElementById(layerId);
		if (selectedSubtext.style.display == "block") {
			selectedSubtext.style.display = "none";
			activeSubtext = null;
		}
		else if (activeSubtext != selectedSubtext) {
			if (activeSubtext != null) {
				activeSubtext.style.display = "none";
			}
			selectedSubtext.style.display = "block";
			activeSubtext = selectedSubtext;
		}
	}
}



// adds or removes the background for the children section 
function setChildrenBg()
{
	$("body").addClass("bgChildren");
}

function setBg()
{
	$("body").removeClass("bgChildren");
}


/********************************************************************/
//COMMON FUNCTIONS
/********************************************************************/
var sImgPath = "web/pix/";

function initCaption() {
	if (aSlideTxt[0]) { writeCaption(aSlideTxt[0]); }
}

function writeCaption(txt) {
	if (document.getElementById("captionDiv")) {
		if (txt != "") { txt = txt + "<br /><br />"; }
		if (navigator.userAgent.indexOf("Safari") != -1) {
			txt = unescape(txt);
		}
		document.getElementById("captionDiv").innerHTML = txt;
	}
}

var activeSubtext = null;
var activeListItem = null;

function showSubtext(layerId) {
	if (document.getElementById(layerId)) {
		selectedSubtext = document.getElementById(layerId);
		if (selectedSubtext.style.display == "block") {
			selectedSubtext.style.display = "none";
			activeSubtext = null;
		}
		else if (activeSubtext != selectedSubtext) {
			if (activeSubtext != null) {
				activeSubtext.style.display = "none";
			}
			selectedSubtext.style.display = "block";
			activeSubtext = selectedSubtext;
		}
	}
}