/****************************************************************************

   Copyright (c) Crusader Ltd
   
   webmaster[at]crusaderltd.com

   File:          cl.js
   Author:        Stephen Last
   Creation Date: 01/08/2008

****************************************************************************/

/////////////////////////////////////////////////////////
// Add load events
/////////////////////////////////////////////////////////
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function () {
			oldonload();
			func();
		}
	}
}

/////////////////////////////////////////////////////////
// Q and A - Show/Hide
// -------------------
// Loop through all anchors's looking for a class that 
// starts with 'answer_cat_'. Then grab the class name
// and use it to find the div in question. Then we 
// swap the display property between 'none' and 'block'
/////////////////////////////////////////////////////////
function cl_showHide() {
	var a = document.getElementsByTagName("a");
	for(var i=0;i<a.length;i++) {
		var a_class = a[i].className
		if ((a_class.indexOf('answer_cat_')!=-1) || (a_class.indexOf('answer_pro_')!=-1)) {
			a[i].a_class = a_class;
			a[i].onclick = function() {
				var div = document.getElementById(this.a_class);
				if (div.style.display=='none') { div.style.display='block'; } else { div.style.display='none'; }
				return false;
			}
		}
	}
}
addLoadEvent(cl_showHide);

/////////////////////////////////////////////////////////
// Blogs Hover
// -----------
// Set the hover for the blogs section, would normally
// use CSS for this stuff but I don't want to change the 
// h3 and p to spans (no nesting block within inline!).
/////////////////////////////////////////////////////////
function cl_blogs() {
	var div = document.getElementsByTagName("div");
	for(var i=0;i<div.length;i++) {
		var div_class = div[i].className
		if (div_class.indexOf('highlight')!=-1) {
			div[i].thediv = div[i];
			div[i].a = div[i].getElementsByTagName("a")[0];
			div[i].href = div[i].getElementsByTagName("a")[0].getAttribute('href');
			// On click
			div[i].onclick = function() {
				document.location=""+this.href+"";
			}
			// On mouse over
			div[i].onmouseover = function() {
				this.thediv.style.backgroundColor='#f2f2f2';
				this.thediv.style.cursor='pointer';
				this.a.style.color='#444';
			}
			// On mouse out
			div[i].onmouseout = function() {
				this.thediv.style.backgroundColor='#fff';
				this.a.style.color='#888';
			}
		}
	}
}
addLoadEvent(cl_blogs);

/////////////////////////////////////////////////////////
// Clickable boxes
// ---------------
// make the entire box clickable where the class is
// either 'class_box' or 'feat_box'
/////////////////////////////////////////////////////////
function cl_clickableBox() {
	var div = document.getElementsByTagName("div");
	for(var i=0;i<div.length;i++) {
		var div_class = div[i].className
		if ((div_class.indexOf('class_box')!=-1) || (div_class.indexOf('feat_box')!=-1)) {
			var div_id = div[i].getAttribute("id");
			var a = document.getElementById(div_id.replace("box","boxlink"));
			div[i].href = a;
			div[i].onclick = function() {
				document.location=""+this.href+"";
			}
		}
	}
}
addLoadEvent(cl_clickableBox);

/////////////////////////////////////////////////////////
// Popup window
// ------------
// Simply add class="popup" to any anchor tag
/////////////////////////////////////////////////////////
function cl_popup() {
	var a = document.getElementsByTagName("a");
	for(var i=0;i<a.length;i++) {
		var a_class = a[i].className
		if (a_class.indexOf('popup')!=-1) {
			a[i].href = a[i].getAttribute('href');
			a[i].onclick = function() {
				window.open(this.href,"","scrollbars=yes,width=600,height=400,resizable=yes,status=yes");
				return false;
			}
		}
	}
}
addLoadEvent(cl_popup);

/////////////////////////////////////////////////////////
// Convert e-mail address (anti-spam)
/////////////////////////////////////////////////////////
function convertEmail() {
	var a = document.getElementsByTagName("a");
	if (a) {
		for (var i=0; i<a.length; i++) {
			var href = a[i].getAttribute("href");
			if (href) {
				if (href.indexOf("mailto:")!=-1) {
					var new_mail = href;
					new_mail = new_mail.replace("-at-","@");
					new_mail = new_mail.replace("-dot-",".");
					new_mail = new_mail.replace("-dot-",".");
					a[i].setAttribute("href",new_mail);
					a[i].childNodes[0].nodeValue = new_mail.replace("mailto:","");
				}
			}
		}
	}
}
addLoadEvent(convertEmail);

/////////////////////////////////////////////////////////
// From old file - main.js
/////////////////////////////////////////////////////////
function PopUp(theURL,winName,features) {
	window.open(theURL,winName,features);
}
function ToggleItem(myItem) {
	if (myItem.style.visibility != 'hidden') {
		HideItem(myItem);
	} else {
		ShowItem(myItem);
	}
	return false;
}
function ShowItem(myItem) {
	myItem.style.visibility = 'visible';
	myItem.style.display = '';
}
function HideItem(myItem) {
	myItem.style.visibility = 'hidden';
	myItem.style.display = 'none';
}
var state = 'none';

function showhide(layer_ref) {
	if (state == 'block') {
	state = 'none';
	}
	else {
	state = 'block';
	}
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
	eval( "document.all." + layer_ref + ".style.display = state");
	}
	if (document.layers) { //IS NETSCAPE 4 or below
	document.layers[layer_ref].display = state;
	}
	if (document.getElementById &&!document.all) {
	hza = document.getElementById(layer_ref);
	hza.style.display = state;
	}
} 

/////////////////////////////////////////////////////////
// From old file - options.js
/////////////////////////////////////////////////////////
function goInStock(id) {
	var outOfStock = document.getElementById('outofstockline' + id);
	var inStock = document.getElementById('addtobasketline' + id);
	var outOfStockMessage = document.getElementById('outofstockmessage' + id);
	outOfStock.style.display = 'none';
	outOfStock.style.visibility = 'hidden';
	outOfStockMessage.style.display = 'none';
	outOfStockMessage.style.visibility = 'hidden';
	inStock.style.display = '';
	inStock.style.visibility = 'visible';
	
}
function goOutOfStock(id) {
	var outOfStock = document.getElementById('outofstockline' + id);
	var inStock = document.getElementById('addtobasketline' + id);
	var outOfStockMessage = document.getElementById('outofstockmessage' + id);
	inStock.style.display = 'none';
	inStock.style.visibility = 'hidden';
	outOfStockMessage.style.display = '';
	outOfStockMessage.style.visibility = 'visible';
	outOfStock.style.display = '';
	outOfStock.style.visibility = 'visible';
}
				
function ExtractNum(stringNo) {
	//We're doing string functions to make sure that we're getting the price after "(+" of each option labels
	stringNo = stringNo.slice(stringNo.lastIndexOf("(+"),stringNo.length);
	var parsedNo = ""; 
	for(var n=0; n<stringNo.length; n++) 
	{
		var i = stringNo.substring(n,n+1); 
		if(i=="1"||i=="2"||i=="3"||i=="4"||i=="5"||i=="6"||i=="7"||i=="8"||i=="9"||i=="0"||i==".")
		parsedNo += i; 
	} 
	if (parsedNo.length > 0) { 
	return parsedNo;} else {return 0;}
}
function checkStock(id,outOfStockItems) {
	// Build up out options selections
	var txtPrice = document.getElementById('txtPrice' + id);
	var origPrice = document.getElementById('origPrice' + id);
	var txtPriceEx = document.getElementById('txtPriceEx' +id);
	var selections = new Array();
	var selectionCount = 0;
	var numOptionsTotal = 0;
	for (i=0;i<document.getElementById('options' + id).elements.length;i++) {
		var element = document.getElementById('options' + id).elements[i];
		if(element.name.substring(0,6)=='OPT_ID') {
			switch(element.type)
			{
				case 'checkbox':
					// is this checkbox selected?
					if(element.checked == true) {
						// use this ID
						selections[selectionCount]=element.value;
						selectionCount++;
												
						// find all labels
						var labels = document.getElementsByTagName('label');
						// loop through all label elements
							for (var m = 0; m < labels.length; m++) {
								var label = labels[m];
								var labelFor = label.htmlFor;					
								if (labelFor == element.id) {
										numOptionsTotal = numOptionsTotal + parseFloat(ExtractNum(label.innerHTML));
								}							
							}
					} else {
						// otherwise we have to get out the nocheckvalue
						var nocheck = document.getElementById('options' + id).elements['NOCHECK_' + element.name]
						selections[selectionCount]=nocheck.value;
						selectionCount++;
					}
					break;
					
				case 'radio':
					if(element.checked == true) {
						selections[selectionCount]=element.value;
						selectionCount++;
						// find all labels
						var labels = document.getElementsByTagName('label');
						// loop through all label elements
							for (var m = 0; m < labels.length; m++) {
								var label = labels[m];
								var labelFor = label.htmlFor;					
								if (labelFor == element.id) {
										numOptionsTotal = numOptionsTotal + parseFloat(ExtractNum(label.innerHTML));
								}							
							}
					}
					break;
					
				case 'select-one':
					var Index = element.selectedIndex;
					selections[selectionCount]=element.value;
					selectionCount++;
					numOptionsTotal = numOptionsTotal + parseFloat(ExtractNum(element.options[Index].text));
					break;

				default:
					break;
					
			}
			
		}

	}
	
	txtPrice.value=( parseFloat(origPrice.value) +  parseFloat(numOptionsTotal)).toFixed(2);
	if (txtPriceEx != null){
		var numTax = document.getElementById('numTax' + id);
		txtPriceEx.value = (txtPrice.value * numTax.value).toFixed(2);
	}
	
	selections = (selections.sort());
	var selection = selections.join('-');
	var isOutOfStock = false;
	
	// Does this combination exist in out outofstock array?
	for(i=0; i<outOfStockItems.length; i++) {
		if(outOfStockItems[i]==selection) {
			isOutOfStock = true;
			break;
		}
	}
	
	if(isOutOfStock) {
		goOutOfStock(id);
	} else {
		goInStock(id);
	}
}

/*	SWFObject v2.2 <http://code.google.com/p/swfobject/> 
	is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
*/
var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();

/**
 * jQuery lightBox plugin
 * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
 * and adapted to me for use like a plugin from jQuery.
 * @name jquery-lightbox-0.5.js
 * @author Leandro Vieira Pinho - http://leandrovieira.com
 * @version 0.5
 * @date April 11, 2008
 * @category jQuery plugin
 * @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)
 * @license CCAttribution-ShareAlike 2.5 Brazil - http://creativecommons.org/licenses/by-sa/2.5/br/deed.en_US
 * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
 */
(function($){$.fn.lightBox=function(settings){settings=jQuery.extend({overlayBgColor:'#000',overlayOpacity:0.8,fixedNavigation:false,imageLoading:'images/lightbox-ico-loading.gif',imageBtnPrev:'images/lightbox-btn-prev.gif',imageBtnNext:'images/lightbox-btn-next.gif',imageBtnClose:'images/lightbox-btn-close.gif',imageBlank:'images/lightbox-blank.gif',containerBorderSize:10,containerResizeSpeed:400,txtImage:'Image',txtOf:'of',keyToClose:'c',keyToPrev:'p',keyToNext:'n',imageArray:[],activeImage:0},settings);var jQueryMatchedObj=this;function _initialize(){_start(this,jQueryMatchedObj);return false;}
function _start(objClicked,jQueryMatchedObj){$('embed, object, select').css({'visibility':'hidden'});_set_interface();settings.imageArray.length=0;settings.activeImage=0;if(jQueryMatchedObj.length==1){settings.imageArray.push(new Array(objClicked.getAttribute('href'),objClicked.getAttribute('title')));}else{for(var i=0;i<jQueryMatchedObj.length;i++){settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),jQueryMatchedObj[i].getAttribute('title')));}}
while(settings.imageArray[settings.activeImage][0]!=objClicked.getAttribute('href')){settings.activeImage++;}
_set_image_to_view();}
function _set_interface(){$('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="'+settings.imageLoading+'"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="'+settings.imageBtnClose+'"></a></div></div></div></div>');var arrPageSizes=___getPageSize();$('#jquery-overlay').css({backgroundColor:settings.overlayBgColor,opacity:settings.overlayOpacity,width:arrPageSizes[0],height:arrPageSizes[1]}).fadeIn();var arrPageScroll=___getPageScroll();$('#jquery-lightbox').css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:arrPageScroll[0]}).show();$('#jquery-overlay,#jquery-lightbox').click(function(){_finish();});$('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function(){_finish();return false;});$(window).resize(function(){var arrPageSizes=___getPageSize();$('#jquery-overlay').css({width:arrPageSizes[0],height:arrPageSizes[1]});var arrPageScroll=___getPageScroll();$('#jquery-lightbox').css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:arrPageScroll[0]});});}
function _set_image_to_view(){$('#lightbox-loading').show();if(settings.fixedNavigation){$('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();}else{$('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();}
var objImagePreloader=new Image();objImagePreloader.onload=function(){$('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]);_resize_container_image_box(objImagePreloader.width,objImagePreloader.height);objImagePreloader.onload=function(){};};objImagePreloader.src=settings.imageArray[settings.activeImage][0];};function _resize_container_image_box(intImageWidth,intImageHeight){var intCurrentWidth=$('#lightbox-container-image-box').width();var intCurrentHeight=$('#lightbox-container-image-box').height();var intWidth=(intImageWidth+(settings.containerBorderSize*2));var intHeight=(intImageHeight+(settings.containerBorderSize*2));var intDiffW=intCurrentWidth-intWidth;var intDiffH=intCurrentHeight-intHeight;$('#lightbox-container-image-box').animate({width:intWidth,height:intHeight},settings.containerResizeSpeed,function(){_show_image();});if((intDiffW==0)&&(intDiffH==0)){if($.browser.msie){___pause(250);}else{___pause(100);}}
$('#lightbox-container-image-data-box').css({width:intImageWidth});$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({height:intImageHeight+(settings.containerBorderSize*2)});};function _show_image(){$('#lightbox-loading').hide();$('#lightbox-image').fadeIn(function(){_show_image_data();_set_navigation();});_preload_neighbor_images();};function _show_image_data(){$('#lightbox-container-image-data-box').slideDown('fast');$('#lightbox-image-details-caption').hide();if(settings.imageArray[settings.activeImage][1]){$('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();}
if(settings.imageArray.length>1){$('#lightbox-image-details-currentNumber').html(settings.txtImage+' '+(settings.activeImage+1)+' '+settings.txtOf+' '+settings.imageArray.length).show();}}
function _set_navigation(){$('#lightbox-nav').show();$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({'background':'transparent url('+settings.imageBlank+') no-repeat'});if(settings.activeImage!=0){if(settings.fixedNavigation){$('#lightbox-nav-btnPrev').css({'background':'url('+settings.imageBtnPrev+') left 15% no-repeat'}).unbind().bind('click',function(){settings.activeImage=settings.activeImage-1;_set_image_to_view();return false;});}else{$('#lightbox-nav-btnPrev').unbind().hover(function(){$(this).css({'background':'url('+settings.imageBtnPrev+') left 15% no-repeat'});},function(){$(this).css({'background':'transparent url('+settings.imageBlank+') no-repeat'});}).show().bind('click',function(){settings.activeImage=settings.activeImage-1;_set_image_to_view();return false;});}}
if(settings.activeImage!=(settings.imageArray.length-1)){if(settings.fixedNavigation){$('#lightbox-nav-btnNext').css({'background':'url('+settings.imageBtnNext+') right 15% no-repeat'}).unbind().bind('click',function(){settings.activeImage=settings.activeImage+1;_set_image_to_view();return false;});}else{$('#lightbox-nav-btnNext').unbind().hover(function(){$(this).css({'background':'url('+settings.imageBtnNext+') right 15% no-repeat'});},function(){$(this).css({'background':'transparent url('+settings.imageBlank+') no-repeat'});}).show().bind('click',function(){settings.activeImage=settings.activeImage+1;_set_image_to_view();return false;});}}
_enable_keyboard_navigation();}
function _enable_keyboard_navigation(){$(document).keydown(function(objEvent){_keyboard_action(objEvent);});}
function _disable_keyboard_navigation(){$(document).unbind();}
function _keyboard_action(objEvent){if(objEvent==null){keycode=event.keyCode;escapeKey=27;}else{keycode=objEvent.keyCode;escapeKey=objEvent.DOM_VK_ESCAPE;}
key=String.fromCharCode(keycode).toLowerCase();if((key==settings.keyToClose)||(key=='x')||(keycode==escapeKey)){_finish();}
if((key==settings.keyToPrev)||(keycode==37)){if(settings.activeImage!=0){settings.activeImage=settings.activeImage-1;_set_image_to_view();_disable_keyboard_navigation();}}
if((key==settings.keyToNext)||(keycode==39)){if(settings.activeImage!=(settings.imageArray.length-1)){settings.activeImage=settings.activeImage+1;_set_image_to_view();_disable_keyboard_navigation();}}}
function _preload_neighbor_images(){if((settings.imageArray.length-1)>settings.activeImage){objNext=new Image();objNext.src=settings.imageArray[settings.activeImage+1][0];}
if(settings.activeImage>0){objPrev=new Image();objPrev.src=settings.imageArray[settings.activeImage-1][0];}}

function _finish(){$('#jquery-lightbox').remove();$('#jquery-overlay').fadeOut(function(){$('#jquery-overlay').remove();});$('embed, object, select').css({'visibility':'visible'});}
function ___getPageSize(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=window.innerWidth+window.scrollMaxX;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;}
var windowWidth,windowHeight;if(self.innerHeight){if(document.documentElement.clientWidth){windowWidth=document.documentElement.clientWidth;}else{windowWidth=self.innerWidth;}
windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}
if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;}
if(xScroll<windowWidth){pageWidth=xScroll;}else{pageWidth=windowWidth;}
arrayPageSize=new Array(pageWidth,pageHeight,windowWidth,windowHeight);return arrayPageSize;};function ___getPageScroll(){var xScroll,yScroll;if(self.pageYOffset){yScroll=self.pageYOffset;xScroll=self.pageXOffset;}else if(document.documentElement&&document.documentElement.scrollTop){yScroll=document.documentElement.scrollTop;xScroll=document.documentElement.scrollLeft;}else if(document.body){yScroll=document.body.scrollTop;xScroll=document.body.scrollLeft;}
arrayPageScroll=new Array(xScroll,yScroll);return arrayPageScroll;};function ___pause(ms){var date=new Date();curDate=null;do{var curDate=new Date();}
while(curDate-date<ms);};return this.unbind('click').click(_initialize);};})(jQuery);

/////////////////////////////////////////////////////////
// When the document is ready, do these!
/////////////////////////////////////////////////////////
$(document).ready(function() {
	
	if ($("a.lightbox").length) { cl_lightbox(); }
	if ($("#customer_wrap").length) { cl_emailreminder(); }
	if ($("#related_scroll").length) { var related = new cl_scroll(); related.init(); }
	if ($(".stock").length) { cl_stockmoreinfo(); }
	if ($("#prodvid").length) { cl_prodvids(); }
	if ($("#fb_bar").length) { fbBar(); }
	if ($(".prodscroll").length) { cl_prodcroll(); }
	if ($(".checkout").length) { checkoutJS(); }
	if ($("#siteseal").length) { godaddySeal(); }
	
});

/////////////////////////////////////////////////////////
// New window for go daddy
/////////////////////////////////////////////////////////
function godaddySeal() {
	$("#siteseal a").bind("click",function(e){
		var href = $(this).attr("href");
		newwindow = window.open(href,'name','height=360,width=540');
		e.preventDefault();
	});
}

/////////////////////////////////////////////////////////
// 
/////////////////////////////////////////////////////////
function checkoutJS() {
	if(document.getElementById('strSameShippingAsBilling').checked==true) {
		HideItem(document.getElementById('shippingdetails'));
	}
}

/////////////////////////////////////////////////////////
// Facebook bar
/////////////////////////////////////////////////////////
function fbBar() {
	
	var fb_page = $("#fb_url").text();
	if (fb_page) {
		var txt_open = "<span>To see our latest products and deals, click here then '<strong>like</strong>' our page on Facebook!</span>";
		var txt_close = "^^ Close ^^";
		var html = $("<p>"+txt_open+"</p>");
		var content = $('<div id="fb_likeus"></div>');
		var iframe = $('<iframe src="https://www.facebook.com/plugins/likebox.php?href='+fb_page+'&amp;width=600&amp;colorscheme=light&amp;show_faces=false&amp;stream=false&amp;header=false&amp;height=70" scrolling="no" frameborder="0" allowTransparency="true"></iframe>');
		
		$("#fb_bar").append(html);
		$("#fb_bar p").fadeIn(300).bind("click",function(){
			var height = $("#fb_bar").height();
			if (height > 50) {
				$("#fb_likeus").fadeOut(250,function(){
					$("#fb_bar").animate({ height:'-=150' },100,function(){
						$("#fb_bar p").html(txt_open);
					});
				});
			} else {
				$("#fb_bar").animate({ height:'+=150' },200,function(){
					$(this).prepend(content);
					$("#fb_bar p").html(txt_close);
					$("#fb_likeus").fadeIn(200,function(){
						$(this).prepend(iframe);
					});
				});
			}
		});
	}
}

/////////////////////////////////////////////////////////
// Product videos
/////////////////////////////////////////////////////////
function cl_prodvids() {
	
	var vidfld = $("#vidfld").text();
	var shopfld = $("#shopfld").text();
	var plcode = $("#prodvid").attr("rel");
	var vidcolours = $("#vidcolours").text();
	
	if (vidcolours) {
		// From config setting (CL_VideoColours)
		arr = vidcolours.split("|");
		cl_darkcolor = arr[0];
		cl_brightcolor = arr[1];
	} else {
		// Fallback colours (gifts)
		cl_darkcolor = "621a21";
		cl_brightcolor = "953a43";
	}
	
	var flashvarsVideo = {
		source: shopfld + "uploads/videos_products/" + plcode + ".flv",
		type: "video",
		streamtype: "file",
		server: "",//Used for rtmp streams
		duration: "52",
		poster: vidfld + "bg.jpg",
		autostart: "false",
		logo: vidfld + "logo.png",
		logoposition: "top left",
		logoalpha: "100",
		logowidth: "50",
		logolink: "http://www.crusadergifts.co.uk",
		hardwarescaling: "false",
		darkcolor: cl_darkcolor,
		brightcolor: cl_brightcolor,
		controlcolor: "ffffff",
		hovercolor: "000000"
	};
	var flashvarsAudio = {};
	var params = {
		menu: "false",
		scale: "noScale",
		allowFullscreen: "true",
		allowScriptAccess: "always",
		bgcolor: "#ffffff",
		quality: "high",
		wmode: "opaque"
	};
	var attributes = {
		id:"prodvid"
	};
	swfobject.embedSWF(vidfld + "JarisFLVPlayer.swf", "prodvid", "635px", "360px", "10.0.0", vidfld + "expressInstall.swf", flashvarsVideo, params, attributes);

}

/////////////////////////////////////////////////////////
// Stock status extra info
/////////////////////////////////////////////////////////
function cl_stockmoreinfo() {
	var lnk = $("<a href='#' id='stockmore_lnk'>Tell Me More &raquo;</a>");
	$(".stock .msg").append(lnk);
	$("#stockmore_txt").hide();
	$("#stockmore_lnk").bind("click",function(e){
		var display = $("#stockmore_txt").css("display");
		if (display=="none") { $("#stockmore_txt").slideDown(200); }
		if (display!="none") { $("#stockmore_txt").slideUp(100); }
		e.preventDefault();
	});
}

/////////////////////////////////////////////////////////
// Customer / Login / E-Mail reminder
/////////////////////////////////////////////////////////
function cl_emailreminder() {
	$("#emailreminder").hide();
	if ($("#emailreminder .errors").length) {
		$("#emailreminder").fadeIn(300,function(){ $("#strEmailAddressReminder").focus(); });
	}
	var lnk = $("<p><a href='#' id='forgot_pass_lnk'>Forgot Password?</a></p>");
	$("#forgot_pass_placeholder").append(lnk);
	$("#forgot_pass_lnk").bind("click",function(e){
		var display = $("#emailreminder").css("display");
		if (display!='none') { $("#emailreminder").fadeOut(200); }
		if (display=='none') { $("#emailreminder").fadeIn(300,function(){ $("#strEmailAddressReminder").focus(); }); }
		e.preventDefault();
	});
}

/////////////////////////////////////////////////////////
// Crusader lightbox (jquery plugin)
/////////////////////////////////////////////////////////
function cl_lightbox() {
	var shopfld = $("#shopfld").text();
	$("a.lightbox").lightBox({
		overlayBgColor: '#000',
		overlayOpacity: 0.5,
		imageLoading: shopfld + 'images/lightbox-loading.gif',
		imageBtnClose: shopfld + 'images/lightbox-close.gif',
		imageBtnPrev: shopfld + 'images/lightbox-prev.gif',
		imageBtnNext: shopfld + 'images/lightbox-next.gif',
		containerResizeSpeed: 350
	});
	$("a.lightbox").mouseover(function(){ $("span.hover",this).css("display","block"); });
	$("a.lightbox").mouseout(function(){ $("span.hover",this).css("display","none"); });
}

/////////////////////////////////////////////////////////
// Related products (scrollable)
/////////////////////////////////////////////////////////
function cl_scroll() {
	var inview = 4;    // Number of products in viewable area
	var speed = 200;   // Scroll speed in milliseconds
	var width = 150;   // Width of one product
	var jump = width;  // Jump distance for products
	var currslot = 1;  // Current slide position
	this.init = function() {
		var prods = $("#related_count").text();
		var maxright = (width*prods)-(width*inview)
		dots();
		$('#related_scroll #move_left').mouseup(function(event) {
			event.preventDefault();
			if (leftpx()<0) {
				currslot--;
				$('#related_scroll #scrollable ul').animate({ left: '+='+jump }, speed);
				dots();
			}
		});
		$('#related_scroll #move_right').mouseup(function(event) {
			event.preventDefault();
			if (leftpx()>(-maxright)) {
				currslot++;
				$('#related_scroll #scrollable ul').animate({ left: '-='+jump }, speed);
				dots();
			}
		});
		$('#related_scroll #move_left').click(function(event) { event.preventDefault(); });
		$('#related_scroll #move_right').click(function(event) { event.preventDefault(); });
		// If we don't need to scroll
		if (prods<=inview) {
			$("#related_dots").css("display","none");
			$("#related_scroll #move_left").css("visibility","hidden");
			$("#related_scroll #move_right").css("visibility","hidden");
		}
	}
	function dots() {
		var dots = $("#related_dots").html().split(" ");
		var new_dots = "";
		for(i=1; i<dots.length; i++) {
			if (i==currslot || i==currslot+1 || i==currslot+2 || i==currslot+3) {
				new_dots += "<span>&bull;</span> ";
			} else {
				new_dots += "&bull; ";
			}
		}
		$("#related_dots").html(new_dots);
	}
	function leftpx() {
		var pos = $('#related_scroll #scrollable ul').position();
		return pos.left; // -40 to take into account the left arrow button
	}	
}

/////////////////////////////////////////////////////////
// Prod scroll
/////////////////////////////////////////////////////////
function cl_prodcroll() {
	
	$(".prodscroll").each(function(i){
		
		var inview = 4;          // Number of products in viewable area
		var speed = 500;         // Scroll speed in milliseconds
		var width = 150;         // Width of one product
		var jump = width*inview; // Jump distance for products
		var page = 1;            // Page number
		
		var count = $(".prods ul li",this).length;  // Number of products
		var prods = $(".prod_count",this).text();   // Max number of products
		var maxright = (width*count)-(width*inview) // Max right pixel count
		
		$('.prods ul',this).css("width",(count*width)); // Set ul pixel width
		dots(page,this); // Do the dots
		
		var prodscroll = this;
		var prodscroll_outer = $(this).parent();
		
		// Move previous
		$(".move_prev a",prodscroll_outer).bind("mouseup",function(e){
			e.preventDefault();
			
			var thisdiv = $(this).parent().parent().parent();
			var ul = $('.prods ul',thisdiv);
			
			if (pos(thisdiv)<0) {
				$(ul).animate({ left: '+='+jump }, speed, "swing", function(){
					page--;
					dots(page,thisdiv);
					arr(page,thisdiv);
					$(ul).stop();
				});
			}
			
		});
		// Move next
		$(".move_next a",prodscroll_outer).bind("mouseup",function(e){
			e.preventDefault();
			
			var thisdiv = $(this).parent().parent().parent();
			var ul = $('.prods ul',thisdiv);
			
			if (pos(thisdiv)>(-maxright)) {
				$(ul).animate({ left: '-='+jump }, speed, "swing", function(){
					page++;
					dots(page,thisdiv);
					arr(page,thisdiv);
					$(ul).stop();
				});
			}
			
		});
		// Disable click and dblclick
		$('.move_prev a',prodscroll_outer).bind("click dblclick",function(e){
			e.preventDefault();
		});
		$('.move_next a',prodscroll_outer).bind("click dblclick",function(e){
			e.preventDefault();
		});
		// Page dots
		function dots(p,thisdiv) {
			$("p.dots",thisdiv).html("");
			for (i=0;i<=count-1;i++) {
				if ((i+1 > (p-1)*inview) && (i+1 <= p*inview)) {
					$("p.dots",thisdiv).append("<span>&bull;</span> ");
				} else {
					$("p.dots",thisdiv).append("&bull; ");
				}
			}
		}
		// Arrows on or off
		function arr(p,thisdiv) {
			if (p==1) { $(".move_prev a",thisdiv).addClass("off"); } else { $(".move_prev a",thisdiv).removeClass("off"); }
			if (pos(thisdiv)>(-maxright)) { $(".move_next a",thisdiv).removeClass("off"); } else { $(".move_next a",thisdiv).addClass("off"); }
		}
		// Get the left position
		function pos(thisdiv) {
			var ul = $('.prods ul',thisdiv);
			return $(ul).position().left;
		}
	});
}





