// Shop CBN Javascript Function Library

// dependencies: jquery library

try {


// wait until loaded
$(document).ready(function() {

	String.prototype.cbn_trim = function() { return this.replace(/^\s+|\s+$/g, ''); }

	var cbn_VideoCount; 
	var cbn_VideoPair; 
	var cbn_VideoList; 	
	var cbn_VideoArray;
	var cbn_Video; 
	var cbn_SKU;

	// determine products that have video clips
	cbn_VideoList = "																								\
		Couragous DVD 	 					| 2253_Courfaith 		|	/mp4/Courageous_Trailer_WS				,	\
		Couragous DVD 	 					| 2253_Courmen	 		|	/mp4/Courageous_Trailer_WS				,	\
		The Secret Kingdom 					| 2253_MFPM042308001	|	/mp4/SK3v2_WS							,	\
		Paula Deen's Southern Cooking Bible | 9781416564072			|	/mp4/PaulaDeen_101411_WS				,	\
		The Tehran Initiative 				| 9781414319353			|	/mp4/EST155_JoelRosenberg_101811_WS		,	\
		A Simple Book of Financial Wisdom	| 9781936214457			|	/mp4/JGA66_DannyKofke_101711_WS			,	\
		Wheat Belly							| 9781609611545			|	/mp4/SUS213_DrWilliamDavis_101711_WS	,	\
		Diabetes Without Drugs				| 2253_9781605296753	|	/mp4/SUS204_SuzyCohen_080311_WS			,	\
		One Song at a Time					| 0669447002161   		|	/mp4/SUE261_JamieGrace_113011_WS		,	\
		The Gift of Rest					| 9781451606171   		|	/mp4/JWA189_SenJoeLieberman_120211_WS	,	\
		Socrates in the City				| 9780525952558   		|	/mp4/SUK53_EricMetaxas_120211_WS		,	\
		The Jesus Mission					| 9780307730497   		|	/mp4/SUE256_StevenScott_111411_WS		,	\
		Sacred Acre							| 9780310332190	    	|	/mp4/TB80v4_WS			                ,	\
		Dadgum That's Good					| 9780578059549     	|	/mp4/SUE255_JohnMcLemore_111611_WS		,	\
		Paper Angels						| 9781451606195       	|	/mp4/SUA23_JimmyWayne_111711v3_WS		,	\
		Coming Back Stronger				| 9781414339443   		|	/vod/SB102v3_WS                 		,	\
		Bonhoeffer: Pastor...(paperback)	| 9781595552464			|	/vod/AR76v4_WS							,	\
		Bonhoeffer: Pastor...(hardcover)	| 9781595551382			|	/vod/AR76v4_WS							,	\
		Defender of Faith					| 9780310725404			|	/mp4/SB121v2_WS							,	\
		You Lost Me							| 9780801013140			|	/mp4/JGA68_DavidKinnaman_111111_WS		,	\
		The Journey							| 0815674010008			|	/mp4/SUB107_AndraeCrouch_111111_WS		,	\
		Heart Improvement					| 0703132300726			|	/mp4/JimLabriola_110411_WS				,	\
		Advent Booklet						| 2253_CBNBTAB			|	/mp4/ADVENT01v1_WS						,	\
		Raising Bully-Proof Kids			| 9780800788131			|	/mp4/JRC6_PaulCoughlin_081911_WS		,	\
		Lioness Arising						| 9780307457790			|	/mp4/SUE249_LisaBevere_091211_WS		,	\
		Simply Done, Well Done				| 9780470615331			|	/mp4/AaronMcCargo_110111_WS				,	\
		My Family Table						| 9781449407872			|	/mp4/LWS36v1_WS							,	\
		A Marriage Carol					| 9780802402646			|	/mp4/GaryChapman_121211_WS				,	\
		Joy- An Irish Christmas 			| 0804879252924			|	/mp4/MUS51v1_WS							,	\
		Stories ...Songs of Christmas 		| 0310239265			|	/vod/SP89v1_WS							,	\
		Stories ...Traditions of Christmas 	| 0310248809			|	/vod/SP89v1_WS							,	\
		Nearing Home 						| 9780849948329			|	/mp4/SUS217_FranklinGraham_121611_WS	,	\
		Making Men 							| 2253_9780615544397	|	/mp4/JGA69_ChuckHolton_120911_WS		,	\
		As Good as She Imagained 			| 9781617950124			|	/mp4/JGA70_RoxannaGreen_010612_WS		,	\
		Alzheimer's Disease:...Cure? 		| 2253_02936			|	/mp4/LJO190v1_WS						,	\
		The Harbinger 						| 2253_86108			|	/mp4/SUB109_JonathanCahn_010312_WS		,	\
		The Fasting Edge Journal 			| 9781616388508			|	/mp4/SUS218_JentezenFranklin_010512_WS	,	\
		Skinny Chicks Eat Real Food 		| 2253_9781609613082	|	/mp4/SUE259_ChristineAvanti_010412_WS	,	\
		Winning the Food Fight				| 9780830761227			|	/mp4/SUK54_SteveWillis_011112_WS		,	\
		Memoirs of a Terrorist				| 9781416577805			|	/vod/AL32v1_WS							,	\
		What Your Doctor May Not... 		| 9781609412548			|	/mp4/SUE267_MarkHouston_020812_WS   	,	\
		America the Beautiful		 		| 9780310330714			|	/mp4/SUB110_BenCarson_021312_WS   		,   \
		The Essential Guide to Healing 		| 9780800795191			|	/mp4/BillJohnson_021412_WS   			,	\
		The Vow						 		| 9781433675799			|	/mp4/SUE268_KimKrickettCarpenter_021512_WS   		\
	";


	// create an array of all products
	cbn_VideoArray = cbn_VideoList.split(",");
	// loop through to determine if one of these products are being viewed
	for ( cbn_VideoCount=0; cbn_VideoCount < cbn_VideoArray.length; cbn_VideoCount++) {
		cbn_VideoPair = cbn_VideoArray[cbn_VideoCount].split("|");
		if (cbn_VideoPair.length == 3) {
			cbn_SKU = cbn_VideoPair[1].cbn_trim().toLowerCase();
			cbn_Video = cbn_VideoPair[2].cbn_trim().toLowerCase();
			if (location.href.toLowerCase().indexOf("sku=" + cbn_SKU) > 0) {
					// add video
					$("#G-detailheaders").prepend('<a name="video"></a>');
					$("#G-detaildescription").prepend('<div style="float: right; padding: 20px 0px 10px 10px; text-align: center;"><embed src="http://dl2.cbn.com/cbnplayer/cbnPlayer.swf?s=' + cbn_Video + '" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="374" height="306"></embed></div>');
					$("#G-detaildescription").append('<div style="text-align: center; padding-top: 10px"><a href="_additem.asp?product_id=' + cbn_SKU + '&amp;product_qty=1"><img src="http://shop.cbn.com/images/Detail_AddToCart.gif" alt="Add Item To Cart" align="center" border="0"></a></div>');
					// move to video if requested
					if (location.href.toLowerCase().indexOf("#video") > 0) {
						location.href = location.href; //.replace("#video","#v-anchor");
					}
					// exit loop
					cbn_VideoCount = cbn_VideoArray.length;
		    }
		}	
	}

})


} 
catch (err) { }







