var addthis_config = {
	data_track_clickback: true,
	ui_offset_top: 0,
	ui_offset_left: -114,
	services_compact: 'email, print, facebook, twitter, delicious, digg',
	services_expanded: 'email, print, facebook, twitter, delicious, digg'
	//,services_exclude: 'print'
};

//***************************************
// FOR JW FLV PLAYER
	// some variables to save
	var currentPosition;
	var currentVolume;
	var currentItem;
	var swfObjsLoaded = false;
	var tmrPrototype;

	// these functions are caught by the JavascriptView object of the player.
	function sendEvent(typ,prm) { thisMovie("mpl").sendEvent(typ,prm); };
	function getUpdate(typ,pr1,pr2,pid) {

	if(typ == "time") { currentPosition = pr1; }
		var id = document.getElementById(typ);
		id.innerHTML = typ+ ": "+Math.round(pr1);
	};

	function thisMovie(movieName) {
		if(navigator.appName.indexOf("Microsoft") != -1) {
			return window[movieName];
		} else {
			return document[movieName];
		}
	};

//***************************************

	var playaId = "";

	function writeVideoObject(id, pic, flv, width, height, autostart){
		playaId = id;
		var file = flv;
		var basePath = '/business/toughbook/';
		if(flv.startsWith('./video/')) file = basePath + flv.substring(2);
		if(flv.startsWith('video/')) file = basePath + flv;

		with(new SWFObject('/business/toughbook/flvplayer/flvplayer.swf?preventCache=' + (new Date().valueOf()),id,width,height,'7')){
			addVariable('file',file);
			addVariable('image',pic);
			addVariable("javascriptid","_" + id);
			addVariable('height',height);
			addVariable('width',width);
			addVariable('displaywidth',width);
			addVariable('displayheight',height);
			addVariable('showvolume','true');
			//addVariable('enablejs','true'); //ENABLING THIS SEEMS TO CAUSE PROBLEMS IN IE
			addVariable('useaudio','false');
			addVariable('usecaptions','false');
			addVariable('usekeys','false');
			if (autostart) {
				addVariable('autostart',autostart);
			} else {
				addVariable('autostart','true');
			}
			addVariable("overstretch","fit");
			addParam('allowscriptaccess','always');
			addParam('allowfullscreen','true');
			addParam('wmode','transparent');

			addVariable('usefullscreen','false');
			addVariable('showdigits','false');

			//$(id).style.background= 'none';
			write(id);
		}

		// INVOKE COREMETRICS
		if(typeof(invokeCMPageView)=='function') invokeCMPageView(flv);
	}
	
	/*  JW PLAYER 5.3
	function writeVideoObject(id, pic, flv, width, height, autostart){
		playaId = id;
		var file = flv;
		var basePath = '/business/toughbook/';
		if(flv.startsWith('./video/')) file = basePath + flv.substring(2);
		if(flv.startsWith('video/')) file = basePath + flv;

		//skin: "/jwplayer/glow.zip",
		//sharing: "none",
		//
		
		jwplayer(id).setup({
			flashplayer: "/business/toughbook/flvplayer/flvplayer.swf",
			image: pic,
			dock: "true",
			playlist: "none",
			fullscreen: "false",
			controlbar: "over",
			'controlbar.idlehide': "true",
			file: flv,
			height: height,
			width: width
		});

		// INVOKE COREMETRICS
		if(typeof(invokeCMPageView)=='function') invokeCMPageView(flv);
	}
	*/

	function blueDotClick_video(elt, id, pic, flv, width, height){
		if((typeof $$)=='function'){
			var current_dot = elt.down('img[type="widget_dot"],img.widget_dot');

			var container = elt.up('div.slides_small');
			if(container&&current_dot){
				var dots = container.select('img[type="widget_dot"],img.widget_dot');
				dots.each(function(dot){
					dot.src = '/business/toughbook/img/dot_off.gif';
				});
				current_dot.src = '/business/toughbook/img/dot_on.gif';
			}
		}
		writeVideoObject(id, pic, flv, width, height);
	}

	function addVideo(evt){
		var id, pic, flv, width, height;
		var srcElt = (window.event)?window.event.srcElement:Event.element(evt);
		id = srcElt.parentNode.id;
		pic = srcElt.getAttribute('img');
		flv = srcElt.getAttribute('url');
		width = srcElt.getAttribute('vidwidth');
		height = srcElt.getAttribute('vidheight');
		writeVideoObject(id, pic, flv, width, height);
	}

	function addVideos(){
		if(swfObjsLoaded) return;
		var intVideos = 0;
		var videoDivs = $$('.swfObj');
		videoDivs.each(
			function (item){
				intVideos++;
				var url = item.getAttribute('url');
				var img = item.getAttribute('img');
				var _width = item.getAttribute('vidwidth');
				var _height = item.getAttribute('vidheight');
				var _margin = item.getAttribute('margin');

				if(item.id=='') item.id = 'swfObj' + intVideos;

				item.style.background= 'url(/business/toughbook/img/video-loading-bg.gif) center no-repeat';
				item.innerHTML = '';

				//ADDED TO SUPPORT WRITING STATIC IMG WHEN FLASH V7 or GREATER ISN"T INSTALLED
				if (FlashDetect.versionAtLeast(8) == true){
					// CREATE PREVIEW IMAGE
					var imgPreview = document.createElement('img');
					imgPreview.setAttribute('src',img);
					imgPreview.setAttribute('width',_width);
					imgPreview.setAttribute('height',_height);
					imgPreview.setAttribute('id','swfObjImg'+intVideos);
					item.appendChild(imgPreview);
					//imgPreview = $('swfObjImg'+intVideos);
					imgPreview.style.width = _width + 'px';
					imgPreview.style.height = _height + 'px';
					imgPreview.style.cursor = 'pointer';
					imgPreview.setAttribute('img',img);
					imgPreview.setAttribute('url',url);
					imgPreview.setAttribute('vidwidth',_width);
					imgPreview.setAttribute('vidheight',_height);
					imgPreview.onclick = addVideo;
				} else {
					// CREATE MESSAGE IMAGE FOR USER TO DOWNLOAD FLASH
					var ancPreview = document.createElement('a');
					ancPreview.setAttribute('href','http://www.adobe.com/products/flashplayer/');
					ancPreview.setAttribute('target','_blank');
					//ancPreview.setAttribute('href','javascript:showRedirectBox(\'http://reviews.cnet.com/laptops/panasonic-toughbook-cf-52/4505-3121_7-32476019.html?ar=o\',null,\'getFlash\')');

					item.appendChild(ancPreview);
					var imgPreview = document.createElement('img');
					imgPreview.setAttribute('src','/business/toughbook/img/vid-no-flash-player.gif');
					imgPreview.setAttribute('width','220');
					imgPreview.setAttribute('height','164');
					imgPreview.style.border = 'solid 1px black';
					ancPreview.appendChild(imgPreview);
				};
			}
		);
	}

	function addFlashBanners(){
		var intBanners = 0;
		var bannerDivs = $$('.swfBanner');
		bannerDivs.each(
			function (item){
				intBanners++;

				if (FlashDetect.versionAtLeast(8) == true){
					var url = item.getAttribute('url');
					var width = item.getAttribute('bnrwidth');
					var height = item.getAttribute('bnrheight');
					if(item.id=='') item.id = 'swfBanner' + intBanners;
					var wmode = "";
					if (item.getAttribute('wmode')){
							wmode = item.getAttribute('wmode');
					} else {
						wmode='transparent';
					};
					writeFlashObject(item,url,width,height,wmode);
				} else {
					// CREATE MESSAGE IMAGE FOR USER TO DOWNLOAD FLASH
					var divPreview = document.createElement('div');
					divPreview.setAttribute('width',item.getAttribute('bnrwidth'));
					divPreview.setAttribute('height',item.getAttribute('bnrheight'));
					divPreview.style.border = 'solid 1px black';
					divPreview.style.backgroundColor = 'white';
					item.appendChild(divPreview);
					var ancPreview = document.createElement('a');
					ancPreview.setAttribute('href','http://www.adobe.com/products/flashplayer/');
					divPreview.appendChild(ancPreview);
					var imgPreview = document.createElement('img');
					if (parseFloat(item.getAttribute('bnrwidth')) < 151){
						imgPreview.setAttribute('src','/business/toughbook/img/vid-no-flash-player-rhp.gif');
						imgPreview.setAttribute('width','150');
						imgPreview.setAttribute('height','90');
						var topBottomMargin = (item.getAttribute('bnrheight') - 90) / 2
						imgPreview.style.marginTop = topBottomMargin;
						imgPreview.style.marginBottom = topBottomMargin;
					} else {
						imgPreview.setAttribute('src','/business/toughbook/img/vid-no-flash-player.gif');
						imgPreview.setAttribute('width','220');
						imgPreview.setAttribute('height','164');
						imgPreview.style.marginLeft = (item.getAttribute('bnrwidth') / 2) - 102;
						imgPreview.style.marginTop = item.getAttribute('bnrheight') / 2;
					}
					ancPreview.appendChild(imgPreview);
					//item.style.border = "solid 1px black";
				}
			}
		);
	}



function writeFlashObject(srcElement,url,width,height,wmode){
	var div = srcElement.parentNode;
	if(typeof(srcElement)=='string') srcElement = $(srcElement);
	var ret = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\""+width+"\" height=\""+height+"\"><param name=\"movie\" value=\""+url+"\"><param name=\"quality\" value=\"high\"><param name=\"wmode\" value=\""+wmode+"\"><embed src=\""+url+"\" width=\""+width+"\" height=\""+height+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" wmode=\""+wmode+"\" type=\"application/x-shockwave-flash\"></embed></object>";
	srcElement.innerHTML = ret;
}


// NEW PRODUCTS SECTION FUNCTIONS

function writeProductVideo(elt, id, pic, flv, width, height, vidDownloadPath, vidDownloadTypeAndSize){
	var download_link = $('vidSubLinks');

	writeVideoObject(id, pic, flv, width, height);

	$$(".vidInList").each(function(elmt){elmt.removeClassName('vidSelected');});
	Element.up(elt,'div').addClassName('vidSelected');

	// KICK OUT COREMETRICS PAGEVIEWS
	if(typeof toughbook_model=='string'){
		var pageId, categoryId
		categoryId = 'Toughbook Products Sub'; //cmCategoryId
		pageId = 'Toughbook Videos '+toughbook_model;
		var video_title_span = Element.down(elt,'span.vidListName');
		var video_title;
		if(video_title_span){
			video_title = (video_title_span.textContent||video_title_span.innerText);
			if(video_title.indexOf('[')>-1) video_title = video_title.substr(0,video_title.indexOf('[')).strip();
			if(pageId&&categoryId) cmCreatePageviewTag(cm_sanitize(pageId + ' ' + video_title),categoryId);
		}
	}

	if (vidDownloadPath == '' || vidDownloadTypeAndSize == ''){
		if(download_link) download_link.style.display = 'none';
	} else {
		if(download_link) download_link.style.display = 'block';
		if ($('vidDownloadLinkHref')) $('vidDownloadLinkHref').href = vidDownloadPath;
		if ($('vidDownloadLinkSize')) $('vidDownloadLinkSize').innerHTML = vidDownloadTypeAndSize;
	}
}

function writeProductVideoYoutube(elt,video_elt,url,width,height){
	writeFlashObject(video_elt,url,width,height,'opaque');
	var download_link = $('vidSubLinks');
	if(download_link) download_link.style.display = 'none';

	$$(".vidInList").each(function(elmt){elmt.removeClassName('vidSelected');});
	Element.up(elt,'div').addClassName('vidSelected');

}
function cm_sanitize(value){
	value = value.replaceAll('/',' ');
	value = value.replaceAll('-','');
	value = value.replaceAll(',',' ');
	value = value.replaceAll('  ',' ');
	value = value.replaceAll('\\(',' ');
	value = value.replaceAll('\\)',' ');
	value = value.replaceAll('  ',' ');
	return value;
}

Event.observe(window,'load',function(){
	addVideos();
	addFlashBanners();

	// FOR ANY PAGE WITH A FILTER DROPDOWN, PERFORM RE-FILTER
	filter();

	// PREVENT JUMP LINK FUNCTIONALITY ON CURRENT/SELECTED LHC LINK
	$$('#left_nav a.exact').each(function(anchor){
		anchor.observe('click',function(evt){
			evt.preventDefault();
		});
	});

	// FORCE WIDTH OF PANASONIC GLOBAL HEADER
	var panasonic_header = $$('#form1 > table')[0];
	if(panasonic_header) panasonic_header.style.width = '984px';

},false);

document.observe('dom:loaded',function(){
	unfocusLinks();

	// CLEAR SOLUTION FLOATING
	var solutions = $$('.solution');
	if(solutions){
		solutions.each(function(solution){
			var div = new Element('div');
			div.style.clear = 'both';
			div.style.height = div.style.width = '0px';
			solution.appendChild(div);
		});
	}
},false);


var last_sol;
//NOT SURE IF THIS FUNCTION IS USED ANY MORE IN LIEU OF filterSelection() in expandCollapse.js
// A: Yes, it is in product case studies pages at least
function filter(dropdown){
	if(!dropdown) dropdown = $('dd');
	if(!dropdown) return;

	var sol = dropdown.value;
	if(sol==last_sol){
		return;
	}else{
		last_sol = sol;
	}
	var solutions = $$(".solution");
	var closers = $$(".closer");
	var first_index = -1;
	var num_shown = 0;
	var first_sol;
	solutions.each(function(solution,index){
		solution.removeClassName('first');
		solution.style.display = 'block';
		if(sol=='all'){
		    //var h2Sol = solution.down('h2');
		    //if(h2Sol){if(!h2Sol.hasClassName('catHeader')) alert(h2Sol.innerHTML); h2Sol.addClassName('catHeader');}

			if(first_index==-1){
				first_index = 0;
				first_sol = solution;
				closers.each(function(item){item.style.display = 'block';})
				first_sol.style.borderTop='none';
			} else {
				// SHOW ONLY IF FAQs-TYPE INTERFACE
				if(closers&&closers.length) solution.style.borderTop='solid 1px';
			}
			num_shown++;
		}else if(solution.hasClassName(sol)){
			if(first_index==-1){
				first_index = index;
				first_sol = solution;
				closers.each(function(item){item.style.display = 'block';})
				//first_sol.removeClassName('catHeader');
				first_sol.style.borderTop='none';
			} else {
				// SHOW ONLY IF FAQs-TYPE INTERFACE
				if(closers&&closers.length) solution.style.borderTop='solid 1px';
			}
			num_shown++;
		}else{
			solution.style.display = 'none';
		}
	});
	//if (num_shown > 1) {
		//alert(first_index);
		if(solutions[first_index]) solutions[first_index].addClassName('firstly');
	//}

	var collapse_buttons = $$('.collapseBtn');
	collapse_buttons.each(
		function(item){
			item.style.display = (num_shown<=1)?'none':'block';
		}
	);

	if(first_sol){
		var collapse_btn = first_sol.down('.collapseBtn');
		var collapse = first_sol.down('.collapse');
		if(typeof toggleElement == 'function') if(collapse){toggleElement(collapse.getAttribute('id'),collapse_btn.getAttribute('btn_index'))};
	}

	if(num_shown>1) {
		if(typeof collapseAllElements == 'function') collapseAllElements(-1);
	}
}

function getInnerText(elt) {
	return (elt.textContent||elt.innerText);
}

function filterVids() {
	var sol = $('ddv').value;
	var vids = $$("div#vidsList div.vidInList");
	vids.each(function(vid){
		if(sol=='all'){
			vid.style.display = 'block';
		} else if(vid.hasClassName(sol)){
			vid.style.display = 'block';
		} else {
			vid.style.display = 'none';
		}
	});
}

/* CAN DELETE THIS I THINK -GN 2/5/10
function subcontentShow(whatToShow, whichAnchor){

	$$(".visib").each(function(elmt){
		elmt.removeClassName('visib');
	});
	$(whatToShow).addClassName('visib');

	$$('a.activ').each(function(elt){
		elt.removeClassName('activ');
	});
	Element.addClassName(whichAnchor,'activ');

	if ($('subContentFAQs')) hideFaqsDiv();

	// KICK OUT COREMETRICS PAGEVIEWS
	var pageId, categoryId;
	categoryId = 'Toughbook Products Sub'; //cmCategoryId
	if(typeof toughbook_model=='string'){
		switch(whatToShow){
			case 'subContentProductImages':
				pageId = 'Toughbook Prod Img '+toughbook_model;
			break;
			case 'subContentApplicationImages':
				pageId = 'Toughbook App Img '+toughbook_model;
			break;
			case 'subContentNewsReviews':
				pageId = 'Toughbook News Reviews '+toughbook_model;
			break;
			case 'subContentReviews':
				pageId = 'Toughbook Reviews '+toughbook_model;
			break;
			case 'subContentNews':
				pageId = 'Toughbook News '+toughbook_model;
			break;
			case 'subContentSpec':
				pageId = 'Toughbook Specs '+toughbook_model;
			break;
			case 'subContentIntel':
				pageId = 'Toughbook Intel '+toughbook_model;
			break;
			case 'subContentGobi':
				pageId = 'Toughbook Gobi '+toughbook_model;
			break;
			case 'subContentROI':
				pageId = 'Toughbook ROI '+toughbook_model;
			break;
			case 'subContentAwards':
				pageId = 'Toughbook Awards '+toughbook_model;
			break;
		}
		if(pageId&&categoryId) cmCreatePageviewTag(cm_sanitize(pageId),categoryId);
	}
}
*/

// Make all doc links target new windows
function unfocusLinks(){
	for(var i=0;i<document.links.length;i++){
		var lnk = document.links[i];
		lnk.onfocus = function(){this.blur();};
	}
}


/***
*  Javascript trim, ltrim, rtrim
*  http://www.webtoolkit.info/
***/

function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

/***
*  FROM http://www.quirksmode.org/js/cookies.html
***/

function createCookie(name,value,minutes) {
	if (minutes) {
		var date = new Date();
		date.setTime(date.getTime()+(minutes*60*1000)); //when was days was (days*24*60*60*1000)
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1000);
}


Event.observe(window,'load',function(){
	// /* SOLUTIONS */ HIDE HORIZONTAL RULE UNDER LAST ARTICLE
	var selector = '.articleBlock hr.clearboth';
	var filter_section = window.details.queryString()['filter_section'];
	if(filter_section) selector = '.articleBlock.'+filter_section+' hr.clearboth';
	var HRs = $$(selector);
	if(HRs.length) HRs[HRs.length-1].style.visibility = 'hidden';

	// HIDE HORIZONTAL RULE UNDER LAST ARTICLE - PRODUCT SECTIONS
	if(typeof _filter_section=='string'&&_filter_section){
		$$('.subContent').each(function(div){
			var HRs = div.select('.articleBlock.'+_filter_section+' hr.clearboth');
			if(HRs.length) HRs[HRs.length-1].style.visibility = 'hidden';
		});
	}

	// RHC NEW PRODUCTS PROMO
	var rhp_featured_products = $('rhp_featured_products');
	if(rhp_featured_products){
		if (sRightNavVersion=='WirelessSprintHome') {

			writeFlashObject(rhp_featured_products,'/business/toughbook/flash/rc-feature-Sprint.swf','150','95','transparent');

		
		/*
		} else if (sRightNavVersion=='Events'){

				$('rhp_featured_products').innerHTML = '<a href="http://www.gartner.com/technology/symposium/orlando/index.jsp" target="_blank"><img src="/business/toughbook/img/rhc-events.gif" style="margin-top:32px;#margin-top:20px;border:solid 1px #ccc;"></a>';
				if(window.details.ieVersion()>-1){
					$('rhp_featured_products').style.height="60px";
				} else {
					$('rhp_featured_products').style.height="70px";
				}
		*/

		} else {

			//JPL CONCISE CODE FOR USE WHEN ONLY 2 CASES ARE NEEDED, FOR MORE, USE THE BELOW MORE VERBOSE SCRIPT
			/*
			var path = '/business/toughbook/flash/'+((sRightNavVersion=='Federal')?'rc-feature-fed.swf':'rc-feature-main.swf');
			writeFlashObject(rhp_featured_products,path,'150','95','transparent');
			*/

			var path;
			if (sRightNavVersion=='Reseller'){
				path = '/business/toughbook/flash/rhc-featured-reseller.swf';
			} else if ((sRightNavVersion!='SupportUnauthenticated') && (sRightNavVersion.substr(0,7) == 'Support')){
				path = '/business/toughbook/flash/rc-feature-support.swf';
			} else {
				path = '/business/toughbook/flash/rhc-featured-product.swf';
			}
			writeFlashObject(rhp_featured_products,path,'150','95','transparent');
		}
		// MONITOR ANY NEW LINKS CREATED BY THIS FEATURED PROMO BLOCK
		monitorCMLinks();
	}
});

function invokeClickManageConversionEvent(event_id,category){
/*
	Example:
	    Description: Wireless Contact
	    Tag Format : <img width='1' height='1' style='visibility:hidden' src='[ Protocol (http|https) ]://www.clickmanage.com/events/conversionevent.aspx?ca=10623&ci=12284&cv=[ Optional conversion value ]'>
	    Known URLs :
*/
	if(event_id){
		var img = new Image();
		img.src = window.location.protocol + '//www.clickmanage.com/events/conversionevent.aspx?ca=10623&ci=' + event_id;
		img.style.visibility = 'hidden';
		img.style.position = 'absolute';
		document.body.appendChild(img);
	}

	//if(event_id=='12288'){
	if(category=='live chat - contact form'){
		if(!event_id){
			var contact_form_chat_click_manage_ids = [
			    ['telecom-computer-contact.asp', '12738'],
			    ['federal-government-computer-contact.asp', '12739'],
			    ['field-service-contact.asp', '12740'],
			    ['financial-computer-contact.asp', '12741'],
			    ['healthcare-computer-contact.asp', '12745'],
			    ['insurance-computer-contact.asp', '12747'],
			    ['oil-gas-computers.asp', '12748'],
			    ['proservices-laptop-contact.asp', '12749'],
			    ['public-sector-computer-contact.asp', '12750'],
			    ['reseller-partner-program-contact.asp', '12751'],
			    ['retail-hospitality-computer-contact.asp', '12752'],
			    ['why-toughbook-roi-evaluator-demo.asp', '12753'],
			    ['supply-chain-contact.asp', '12754'],
			    ['utilities-contact.asp', '12755'],
			    ['wireless-computer-contact.asp', '12756']
			];

			for(var i=0;i<contact_form_chat_click_manage_ids.length;i++){
				if(window.location.href.toLowerCase().indexOf(contact_form_chat_click_manage_ids[i][0])>-1){
					invokeClickManageConversionEvent(contact_form_chat_click_manage_ids[i][1],'live chat - contact form');
					return;
				}
			}
		}
	}

	if(category&&category.indexOf('live chat')>-1){
		// INVOKE CONVERSION EVENT TAG
		var cm_id = 'Live Chat';
		if((typeof cmPageId)=='string'&&cmPageId) cm_id += ' ' + cmPageId;
		cmCreateConversionEventTag(cm_id,'2','TOUGHBOOK CONVERSION EVENTS','1');
	}

	if(window.location.host.indexOf('panasonic')==-1) alert('ClickManage ' + event_id);
}

function invoke_clickmanage_conversion_event_generic(account_id,conversion_id){
/*
Example:
    Description: Education - Request Interactive Brochure
    Tag Format : <img width='1' height='1' style='visibility:hidden' src='[ Protocol (http|https) ]://www.clickmanage.com/events/conversionevent.aspx?ca=10756&ci=12284&cv=[ Optional conversion value ]'>
    Known URLs :
*/
	var img = new Image();
	img.src = window.location.protocol + '//www.clickmanage.com/events/conversionevent.aspx?ca='+account_id+'&ci=' + conversion_id;
	img.style.visibility = 'hidden';
	img.style.position = 'absolute';
	document.body.appendChild(img);
}

function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}
function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}
function eraseCookie(name) {
    createCookie(name, "", -1);
}

// GLOBAL NAV
function global_nav_init(){

	$$('#navmain a').each(function(menu_bar_item){

		var section = $('masthead').getAttribute('section');
		var menu_name = menu_bar_item.getAttribute('menu');
		var menu = $$('.subnav[menu="'+menu_name+'"]')[0];
		var menu_bar_item_image = menu_bar_item.down('img');
		var subnav_shadow = $('subnav_shadow');

		var preceding_divisor = menu_bar_item.previous('img.divisor');
		var following_divisor = menu_bar_item.next('img.divisor');

		// ACTIVATE ACTIVE SECTION (MAKE GREY ON PAGE LOAD FOR MENU ITEM OF SECTION WE'RE IN)
		if (menu_name == section) {
			if(menu_bar_item_image.src.contains('-over.gif')) menu_bar_item_image.src = menu_bar_item_image.src.replace('-over.gif','.gif');
			menu_bar_item_image.src = menu_bar_item_image.src.replace('.gif','-on.gif');
			if (preceding_divisor) preceding_divisor.src = "./img/navmain-divisor-on.gif"
			if (following_divisor) following_divisor.src = "./img/navmain-divisor-on.gif"
		}

		menu_bar_item.setAttribute('default_image',menu_bar_item_image.src);
		if(preceding_divisor) preceding_divisor.setAttribute('default_image',preceding_divisor.src);
		if(following_divisor) following_divisor.setAttribute('default_image',following_divisor.src);

		// DYNAMICALLY POSITION MENU
		if(menu){
			//it's minus one to compensate for the divisor pixel,btw, except on business
			if (menu_bar_item.positionedOffset()[0] == 0){
				menu.style.left = menu_bar_item.positionedOffset()[0] + 'px';
			} else {
				menu.style.left = menu_bar_item.positionedOffset()[0]-1 + 'px';
			}
			menu.menu_bar_item = menu_bar_item;
		}

		// MENU BAR ITEM

		menu_bar_item.highlight = function(){
			menu_bar_item.setAttribute('active','true');

			// 2) swap main nav image to over state
			if(menu_bar_item_image.src.contains('-on.gif')){
				menu_bar_item_image.src = menu_bar_item_image.src.replace('-on.gif','-over.gif');
			} else if (!menu_bar_item_image.src.contains('-over.gif')){
				menu_bar_item_image.src = menu_bar_item_image.src.replace('.gif','-over.gif');
			}

			if(preceding_divisor) preceding_divisor.src = preceding_divisor.getAttribute('default_image').replace('.gif','-over.gif');
			if(following_divisor) following_divisor.src = following_divisor.getAttribute('default_image').replace('.gif','-over.gif');
		}

		menu_bar_item.unhighlight = function(){
			menu_bar_item.setAttribute('active','false');
			menu_bar_item_image.src = menu_bar_item.getAttribute('default_image');
			if(preceding_divisor) preceding_divisor.src = preceding_divisor.getAttribute('default_image');
			if(following_divisor) following_divisor.src = following_divisor.getAttribute('default_image');
		}

		menu_bar_item.observe('mouseover',function(){
			menu_bar_item.addClassName('hover');
			menu_bar_item.highlight();
			if(menu) menu.display.defer();
		});

		menu_bar_item.observe('mouseout',function(){
			menu_bar_item.removeClassName('hover');
			hideSubnavs.defer();
			if(!menu) menu_bar_item.unhighlight();
		});

		// MENU
		if(menu){
			menu.observe('mouseover',function(){
				menu.addClassName('hover');
			});
			menu.observe('mouseout',function(){
				menu.removeClassName('hover');
				hideSubnavs.defer(); // ALLOW TIME FOR MOUSEOVER EVENT, THEN CHECK TO SEE IF STILL HOVERED OVER
			});
			menu.display = function(){
				menu.addClassName('shown');
				if(window.details.ieVersion()==-1||window.details.ieVersion()>6){
					subnav_shadow.setStyle({
						width:menu.clientWidth + 'px',
						height:menu.clientHeight + 'px',
						left:(menu.positionedOffset()[0] + 10) + 'px',
						top:(menu.positionedOffset()[1] + 10) + 'px',
						visibility:'visible'
					});
				}
				menu.menu_bar_item.highlight();
			}
			menu.undisplay = function(force_close){
				if(force_close||menu.getStyle('display')=='block'&&!menu.down('.hover')){
					menu.removeClassName('shown');
					subnav_shadow.style.visibility = 'hidden';
					menu.menu_bar_item.unhighlight();
				}
			}
		}

	});

	$$('div.subnav a.tiered').each(function(tiered_parent){
		var tier_menu_name = tiered_parent.getAttribute('menu');
		var tier_menu = $$('.tier3nav[menu="'+tier_menu_name+'"]')[0];
		var tier_shadow = $('tiered_subnav_shadow');

		// TIER PARENT ITEM
		tiered_parent.observe('mouseover',function(){
			clear_hovered_menu_items();
			tiered_parent.addClassName('hover');
			tiered_parent.setAttribute('hover','true');
			if(tier_menu){
				tier_menu.style.left = '377px';//(window.details.ieVersion()==-1) ? '377px' : '375px';
				tier_menu.style.top = tiered_parent.positionedOffset()[1] + 30 +'px';
				tier_menu.display.defer();
			}
		});
		tiered_parent.observe('mouseout',function(){
			if(!tier_menu.hasClassName('shown')) tiered_parent.removeClassName('hover');

			tiered_parent.removeAttribute('hover');
			clear_hovered_menu_items();
		});

		// TIER 3 MENU
		if(tier_menu){
			tier_menu.menu_bar_item = tiered_parent.up('.subnav').menu_bar_item;

			tier_menu.observe('mouseover',function(){
				tier_menu.addClassName('hover');
				clear_hovered_menu_items();
				tiered_parent.addClassName('hover');
			});
			tier_menu.observe('mouseout',function(){
				tier_menu.removeClassName('hover');
				tiered_parent.removeClassName('hover');
				tiered_parent.removeAttribute('hover');
				hideSubnavs.defer();
			});
			tier_menu.display = function(){
				tier_menu.addClassName('shown');
				(function(){
					clear_hovered_menu_items();
					tiered_parent.addClassName('hover');
				}).defer();
				if(window.details.ieVersion()==-1||window.details.ieVersion()>6){
					tier_shadow.setStyle({
						width:tier_menu.clientWidth + 'px',
						height:tier_menu.clientHeight + 'px',
						left:(tier_menu.positionedOffset()[0] + 10) + 'px',
						top:(tier_menu.positionedOffset()[1] + 9) + 'px',
						visibility:'visible'
					});
				}
			}
			tier_menu.undisplay = function(){
				if(tier_menu.getStyle('display')=='block'){
					tier_menu.removeClassName('shown');
					tier_shadow.style.visibility = 'hidden';
				}
			}
		}
	});
}

function clear_hovered_menu_items(){
	var hovered_menu_items = $$('a.tiered.hover');
	hovered_menu_items.each(function(item){
		if(item.getAttribute('hover')!='true') item.removeClassName('hover');
	});
}

function hideSubnavs(){
	$$('.tier3nav:not(.hover)').each(function(item){
		item.undisplay();
	});
	$$('.subnav a.tiered.hover').each(function(anchor){
		var menu_name = anchor.getAttribute('menu');
		if(!$$('.tier3nav.shown[menu="'+menu_name+'"]').length){
			anchor.removeClassName('hover');
		}
	});
	$$('.subnav.shown:not(.hover)').each(function(subnav){
		subnav.undisplay();
	});
}
// END GLOBAL NAV

function changeOpacity(elt, value){
	$(elt).style.opacity = value / 100;
	$(elt).style.filter = 'alpha(opacity=' + value + ')';
}
//USE TO INITIALIZE A SCRIPT TAG FOR JSONP CALL
function initJSONP(url) {
    // create script tag
    var script = document.createElement("script");
    script.setAttribute("type", "text/javascript");

    // append timestamp to avoid browser caching
    url += (url.indexOf("?") == -1 ? "?" : "&buster") + (new Date().getTime());

    // set script source to the service that responds with thepadded JSON data
    script.setAttribute("src", url);

    // insert script tag
    document.body.appendChild(script);

    // remove script tag by timeout (remove responsibility from callback)
    setTimeout(function() {
        document.body.removeChild(script);
    }, 2000);
}
