/* Last updated: Dec 2 2009 */
function bn_isNotEmpty(name) {
	return (name != null) && (name != "");
}
function bn_getOrderInfo() {
	if (typeof(bnOrderId) != "undefined" && bn_isNotEmpty(bnOrderId))
		baynote_tag.attrs.purchaseId = bnOrderId;
	if (typeof(bnOrderTotal) != "undefined" && bn_isNotEmpty(bnOrderTotal))
		baynote_tag.attrs.totalPurchases = parseFloat(bnOrderTotal);
	if (typeof(bnOrderDetails) != "undefined" && bn_isNotEmpty(bnOrderDetails))
		baynote_tag.attrs.purchaseDetails = bnOrderDetails;
}
function bn_getMediaInfo() {
	if (typeof(bnMediaDuration) != "undefined" && bn_isNotEmpty(bnMediaDuration)) {
		baynote_tag.attrs.expectedDuration = bnMediaDuration;
	}	
}
function bn_getAttrs(){
	/*alert('setAttrs');*/
	var metas = document.getElementsByTagName("meta");
	if (!metas) return;
	
	for (var i = 0; i < metas.length; i++) {
		if (!metas[i]) return;
			if (metas[i].name == "bn_channel") {
				var tempMetaContent = metas[i].content;
				if(bn_isNotEmpty(tempMetaContent)) {
					baynote_tag.docAttrs.channel = tempMetaContent;
				}
			} else if (metas[i].name == "bn_date") {
				var tempMetaContent = metas[i].content;
				if(bn_isNotEmpty(tempMetaContent)) {
					baynote_tag.docAttrs.date = tempMetaContent;
				}
			} else if (metas[i].name == "bn_headline") {
				var tempMetaContent = metas[i].content;
				if(bn_isNotEmpty(tempMetaContent)) {
					baynote_tag.docAttrs.headline = tempMetaContent;
				}
			} else if (metas[i].name == "bn_thumbnailURL") {
				var tempMetaContent = metas[i].content;
				if(bn_isNotEmpty(tempMetaContent)) {
					baynote_tag.docAttrs.thumbnailURL = tempMetaContent;
				}
			}else if (metas[i].name == "bn_summary") {
				var tempMetaContent = metas[i].content;
				if(bn_isNotEmpty(tempMetaContent)) {
					baynote_tag.docAttrs.summary = tempMetaContent;
				}
			}else if (metas[i].name == "bn_articleType") {
				var tempMetaContent = metas[i].content;
				if(bn_isNotEmpty(tempMetaContent)) {
					baynote_tag.docAttrs.articleType = tempMetaContent;
				}
			}else if (metas[i].name == "bn_canonical") {
				var tempMetaContent = metas[i].content;
				if(bn_isNotEmpty(tempMetaContent)) {
					baynote_tag.url = tempMetaContent;
				}
			}
			
	}

}
function bn_showObserver() {
	/* 1. set customer id */
	bn_customerId = "dennis";
	/* 2. set customer code */
	bn_code = "itpro";
	var bn_locHref = window.location.href;
	if (bn_locHref.indexOf("https://") == 0) {
		baynote_tag.server = "https://" + bn_customerId + "-" + bn_code + ".baynote.net";
	} else {
		baynote_tag.server = "http://" + bn_customerId + "-" + bn_code + ".baynote.net";
	}
	baynote_tag.customerId = bn_customerId;
	baynote_tag.code = bn_code;
	baynote_tag.type = "baynoteObserver";
	/* 3. set customer domain (optional) */
	baynote_globals.cookieDomain = "itpro.co.uk";
	/* 4. collect purchase info (optional) */ 
	bn_getOrderInfo();
	bn_getMediaInfo();
	bn_getAttrs();
	baynote_tag.show();
}
if (typeof(baynote_tag)!="undefined") {
	bn_showObserver();
}


