/* functions used in layers with TV Spots */
var $j = jQuery.noConflict();

var productGroups = {};


// =======================================================================
// =[ PRODUKTDATEN ]======================================================
// =======================================================================

// zu jedem Flash-Film existiert eine 'productGroup', die eine
// Liste der anzuzeigenden Produkte enthält.
/*productGroups['tunika'] = {
	// Id der Kategorie, die unter "hier gibt es noch mehr..." verlinkt wird.
	categoryId : '70914',
	products : [
		{ // artikel 1
			'prdName'	:	'Tunika',      // name des produktes
			'prdPreis'	:	'14,00',             // preis (Euro-Zeichen wird automatisch hinzugefügt)
			'prdBild'	:	'img/71715.jpg', // Pfad zu dem Produktbild
			'prdId'		:	'227958'             // Produkt-ID, wird für die Link-Erzeugung benötigt
		}, { // artikel 2
			'prdName'	:	'Kette',
			'prdPreis'	:	'5,00',
			'prdBild'	:	'img/7442693.jpg',
			'prdId'		:	'227788'
		}, { // artikel 3
			'prdName'	:	'Röhrenjeans',
			'prdPreis'	:	'15,00',
			'prdBild'	:	'img/71680.jpg',
			'prdId'		:	'227953'
		}, { // artikel 4
			'prdName'	:	'Kette',
			'prdPreis'	:	'5,00',
			'prdBild'	:	'img/7442695.jpg',
			'prdId'		:	'227784'
		}
	]
};*/
productGroups['jacke'] = {
	// Id der Kategorie, die unter "hier gibt es noch mehr..." verlinkt wird.
	categoryId : '70914',
	products : [
		{
			'prdName'	:	'Jacke',
			'prdPreis'	:	'19,80',
			'prdBild'	:	'img/7171613.jpg',
			'prdId'		:	'227758'
		}, {
			'prdName'	:	'T-Shirt',
			'prdPreis'	:	'6,00',
			'prdBild'	:	'img/71677.jpg',
			'prdId'		:	'227980'
		}, {
			'prdName'	:	'Tuch',
			'prdPreis'	:	'6,00',
			'prdBild'	:	'img/7606891.jpg',
			'prdId'		:	'227773'
		}, {
			'prdName'	:	'Tasche',
			'prdPreis'	:	'15,00',
			'prdBild'	:	'img/7362311.jpg',
			'prdId'		:	'227130'
		}
	]
};

productGroups['longshirt'] = {
	// Id der Kategorie, die unter "hier gibt es noch mehr..." verlinkt wird.
	categoryId : '70914',
	products : [
		{
			'prdName'	:	'Longshirt',
			'prdPreis'	:	'8,00',
			'prdBild'	:	'img/71710.jpg',
			'prdId'		:	'228005'
		}, {
			'prdName'	:	'Ketten',
			'prdPreis'	:	'3,00',
			'prdBild'	:	'img/7442690.jpg',
			'prdId'		:	'227794'
		}, {
			'prdName'	:	'Hose',
			'prdPreis'	:	'15,00',
			'prdBild'	:	'img/71709.jpg',
			'prdId'		:	'228000'
		}, {
			'prdName'	:	'Tuch',
			'prdPreis'	:	'6,00',
			'prdBild'	:	'img/7606892.jpg',
			'prdId'		:	'227775'
		}
	]
};

/*productGroups['strickjacke'] = {
	// Id der Kategorie, die unter "hier gibt es noch mehr..." verlinkt wird.
	categoryId : '70914',
	products : [
		{
			'prdName'	:	'Strickjacke',
			'prdPreis'	:	'12,00',
			'prdBild'	:	'img/71712.jpg',
			'prdId'		:	'228010'
		}, {
			'prdName'	:	'Longshirt',
			'prdPreis'	:	'7,00',
			'prdBild'	:	'img/71704.jpg',
			'prdId'		:	'227985'
		}, {
			'prdName'	:	'Jeans',
			'prdPreis'	:	'16,00',
			'prdBild'	:	'img/71707.jpg',
			'prdId'		:	'227995'
		}, {
			'prdName'	:	'Tasche',
			'prdPreis'	:	'15,00',
			'prdBild'	:	'img/75953.jpg',
			'prdId'		:	'229216'
		}
	]
};*/

productGroups['jeans-weste'] = {
	// Id der Kategorie, die unter "hier gibt es noch mehr..." verlinkt wird.
	categoryId : '70914',
	products : [
		{
			'prdName'	:	'Jeans-Weste',
			'prdPreis'	:	'9,00',
			'prdBild'	:	'img/71686.jpg',
			'prdId'		:	'228053'
		}, {
			'prdName'	:	'T-Shirt',
			'prdPreis'	:	'5,00',
			'prdBild'	:	'img/71687.jpg',
			'prdId'		:	'228048'
		}, {
			'prdName'	:	'Röhrenjeans',
			'prdPreis'	:	'15,00',
			'prdBild'	:	'img/71785.jpg',
			'prdId'		:	'228063'
		}, {
			'prdName'	:	'Hut',
			'prdPreis'	:	'7,00',
			'prdBild'	:	'img/7356591.jpg',
			'prdId'		:	'227769'
		}
	]
};

productGroups['blazer'] = {
	// Id der Kategorie, die unter "hier gibt es noch mehr..." verlinkt wird.
	categoryId : '70914',
	products : [
		{
			'prdName'	:	'Blazer',
			'prdPreis'	:	'15,00',
			'prdBild'	:	'img/71676.jpg',
			'prdId'		:	'228043'
		}, {
			'prdName'	:	'T-Shirt',
			'prdPreis'	:	'6,00',
			'prdBild'	:	'img/71678.jpg',
			'prdId'		:	'228028'
		}, {
			'prdName'	:	'Jeans',
			'prdPreis'	:	'15,00',
			'prdBild'	:	'img/71680.jpg',
			'prdId'		:	'227953'
		}, {
			'prdName'	:	'Ketten',
			'prdPreis'	:	'3,00',
			'prdBild'	:	'img/7442691.jpg',
			'prdId'		:	'227792'
		}
	]
};

productGroups['langarmshirt'] = {
	// Id der Kategorie, die unter "hier gibt es noch mehr..." verlinkt wird.
	categoryId : '70914',
	products : [
		{
			'prdName'	:	'Langarmshirt',
			'prdPreis'	:	'7,00',
			'prdBild'	:	'img/71683.jpg',
			'prdId'		:	'228023'
		}, {
			'prdName'	:	'Top',
			'prdPreis'	:	'4,00',
			'prdBild'	:	'img/71682.jpg',
			'prdId'		:	'228033'
		}, {
			'prdName'	:	'Jeans',
			'prdPreis'	:	'16,00',
			'prdBild'	:	'img/71681.jpg',
			'prdId'		:	'228038'
		}, {
			'prdName'	:	'Kette',
			'prdPreis'	:	'6,00',
			'prdBild'	:	'img/7442097.jpg',
			'prdId'		:	'227717'
		}
	]
};

productGroups['jacke2'] = {
	// Id der Kategorie, die unter "hier gibt es noch mehr..." verlinkt wird.
	categoryId : '70914',
	products : [
		{
			'prdName'	:	'Jacke',
			'prdPreis'	:	'18,00',
			'prdBild'	:	'img/71690.jpg',
			'prdId'		:	'228088'
		}, {
			'prdName'	:	'T-Shirt',
			'prdPreis'	:	'6,00',
			'prdBild'	:	'img/71678.jpg',
			'prdId'		:	'228028'
		}, {
			'prdName'	:	'Kappe',
			'prdPreis'	:	'5,00',
			'prdBild'	:	'img/7356592.jpg',
			'prdId'		:	'227771'
		}, {
			'prdName'	:	'Kette',
			'prdPreis'	:	'6,00',
			'prdBild'	:	'img/7442096.jpg',
			'prdId'		:	'227715'
		}
	]
};

videoLayer = function() {
	var prdList = "#prdList";
	var defaultTrailer = "jacke";
	$j(prdList).empty().html(newPrd(defaultTrailer));
	
	// link a whole block (e.g. li)
	var linkAllItems = $j(".modalWrap .linkAll");
	
	linkAllItems
	.css("cursor","pointer")
	.click(function(){
		window.location = $j(this).find("a:first").attr("href");
		return false;
	});
	
	// tags which inner tags should be decorated
	var decoTags = "p,a";
	linkAllItems.hover(
      function () {
        $j(this).find(decoTags).css("text-decoration","underline");
      },
      function () {
        $j(this).find(decoTags).css("text-decoration","none");
      }
    );

	$j("#videoList li a").click( function() {
		var playerIn = "#spotPlayer";
		var prdList = "#prdList";
		var curFilm = $j(this).attr("id");
		var playerPath = "flash/ef_videoplayer_v01.swf?videoPath=";
		var films = {
				//'tunika'		:	'Ef_Nr1.flv',
				'jacke'			:	'Ef_Nr2.flv',
				'longshirt'		:	'Ef_Nr3.flv',
				//'strickjacke'	:	'Ef_Nr4.flv',
				'jeans-weste'	:	'Ef_Nr5.flv',
				'blazer'		:	'Ef_Nr6.flv',
				'langarmshirt'	:	'Ef_Nr7.flv',
				'jacke2'		:	'Ef_Nr8.flv'
		};
		
		var flashPlayer = 	'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"'
						+	'		width="356" height="250" id="ef_videoplayer_v01" align="middle">'
						+	'	<param name="allowScriptAccess" value="sameDomain" />'
						+	'	<param name="allowFullScreen" value="false" />'
						+	'	<param name="movie" value="'+playerPath+films[curFilm]+'" />'
						+	'	<param name="quality" value="high" />'
						+	'	<param name="wmode" value="transparent" />'
						+	'	<embed src="'+playerPath+films[curFilm]+'" quality="high"'
						+	'			wmode="transparent" width="356" height="250"'
						+	'			name="ef_videoplayer_v01" align="middle"'
						+	'			allowScriptAccess="sameDomain" allowFullScreen="false"'
						+	'			type="application/x-shockwave-flash"'
						+	'			pluginspage="http://www.macromedia.com/go/getflashplayer" />'
						+	'</object>';
			
		$j("#videoList li a").removeClass("active");
		$j(this).addClass("active");
		
		$j(playerIn).empty().html(flashPlayer);
		$j(prdList).empty().html(newPrd(curFilm));
		
		return false;
	});
};

function newPrd(prdGroup) {
	var prdList = "";
	for(var i=0; i<productGroups[prdGroup].products.length; i++) {
		var tmp = productGroups[prdGroup].products[i];
		var url = 'http://www.ernstings-family.de/shop/servlet/efRedirect?productId='+tmp.prdId;
		prdList +=	"<li class='prd_ts linkAll'>"
				+	"	<div class='prd_ts_inner' id='prd_"+tmp.prdId+"'>"
				+	"		<a title='' href='"+url+"'>"
				+	"			<img alt='' src='"+tmp.prdBild+"'/>"
				+	"		</a>"
				+	"		<p class='ts_desc'>"
				+	"			<a href='"+url+"'>"
				+	"				<span class='ts_prd_price'>"+tmp.prdPreis+"</span><br/>"
				+	"				<strong class='ts_prd_name'>"+tmp.prdName+"</strong>"
				+	"			</a>"
				+	"		</p>"
				+	"	</div>"
				+	"	<div class='clear'><!-- --></div>"
				+	"</li>";
	}
	var catLink = "http://www.ernstings-family.de/shop/servlet/efRedirect?categoryId="+productGroups[prdGroup].categoryId;
	prdList +=	"<li class='prd_ts linkAll'>"
			+	"	<div class='prd_ts_inner moreGina'>"
			+	"		<a class='hide_text link_weiter' href='"+catLink+"'>"
			+	"			Hier gibt es noch mehr Pullover"
			+	"		</a>"
			+	"	</div>"
			+	"	<div class='clear'><!-- --></div>"
			+	"</li>"
	return prdList;
}
