function RightslinkPopUp(title, date, author, contentID)
	{	
		var url = "https://s100.copyright.com/servlet/DispatchServlet"; 
		var location = url 
			+ "?PublisherName=" + escape("Putman Media, Inc.")
			+ "&Publication=" + escape("Chemical Processing")
			+ "&Title=" + escape(title)
			+ "&PublicationDate=" + escape(date)
			+ "&Author=" + escape(author)
			+ "&Install=S"
			+ "&ContentID=" + escape(contentID);
		PopUp = window.open( location,  'Rightslink', 
			'location=no,toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=650,height=550');
	}

function OpenBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

var displayed;
displayed = '';
function toggle(divid){
	if(displayed != '') {
	  document.getElementById(displayed).style.display = 'none';
	}	
	if(displayed != divid){
		if(document.getElementById(divid).style.display == 'none'){
			document.getElementById(divid).style.display = 'block';
		}else{
			document.getElementById(divid).style.display = 'none';
		}
	}	
	displayed = divid;
}


// Top tabnav fix for IE6
var lastnavtab = "navtab2";
var ie6 = "";
function tabNavToggle(divid,disp,hover) {	
	// check to see if ie6 is being used
	var appVer = navigator.appVersion;
	appVer = appVer.split(';');
	if(appVer[1] == ' MSIE 6.0') {
		var ie6 = "yes";
	}	
	if (ie6 == "yes") {		
		if (disp != '') {		
			document.getElementById(lastnavtab+"a").style.backgroundPosition = "top right";
			document.getElementById(lastnavtab+"li").style.backgroundPosition = "top left";		
			if (divid != lastnavtab) {
				document.getElementById(lastnavtab).style.display = "none";
				lastnavtab = divid;
			}		
			if (disp == "block") {
				document.getElementById(divid+"a").style.backgroundPosition = "100% -42px";
				document.getElementById(divid+"li").style.backgroundPosition = "0% -42px";		
				document.getElementById(divid).style.display = disp;
			} else {
				document.getElementById(divid).style.display = disp;
			}
		}
		// if disp param is empty, there's no dropdown
		// for that li, so just change bg hover states.
		if (disp == '') {
			switch (hover) {
				case "on":
					document.getElementById(divid+"a").style.backgroundPosition = "100% -42px";
					document.getElementById(divid+"li").style.backgroundPosition = "0% -42px";
					break;
				case "off":
					document.getElementById(divid+"a").style.backgroundPosition = "top right";
					document.getElementById(divid+"li").style.backgroundPosition = "top left";
					break;
				default:
					return false;
			}		
		}		
	}	
}

// Content boxes
var lastcommunitytab = 'community1';
var lastmmediatab = 'mmedia1';
var lastrecenttab = 'recent1';
var lastviewedtab = 'viewed1';
var lastproductstab = 'products1';
var lasttopicstab = 'topics1';
var lastsubstab = 'subs1';
function toggleContent(box,idnum) {	
	var divid = box+idnum;
	switch (box){
  //community content box
	case "community":
		if (divid != lastcommunitytab) {
			document.getElementById(lastcommunitytab+"a").className = "";
			document.getElementById(lastcommunitytab).style.display = "none";
			document.getElementById(divid+"a").className = "on";
			document.getElementById(divid).style.display = "block";
			lastcommunitytab = divid;
		}
		break;
  //multimedia content box
	case "mmedia":
		if (divid != lastmmediatab) {
			document.getElementById(lastmmediatab+"a").className = "";
			document.getElementById(lastmmediatab).style.display = "none";
			document.getElementById(divid+"a").className = "on";
			document.getElementById(divid).style.display = "block";
			lastmmediatab = divid;
		}
		break;
  //topics content box
	case "topics":
		if (divid != lasttopicstab) {
			document.getElementById(lasttopicstab+"a").className = "";
			document.getElementById(lasttopicstab).style.display = "none";
			document.getElementById(divid+"a").className = "on";
			document.getElementById(divid).style.display = "block";
			lasttopicstab = divid;
		}
		break;
  //subscriptions content box
	case "subs":
		if (divid != lastsubstab) {
			document.getElementById(lastsubstab+"a").className = "";
			document.getElementById(lastsubstab).style.display = "none";
			document.getElementById(divid+"a").className = "on";
			document.getElementById(divid).style.display = "block";
			lastsubstab= divid;
		}
		break;
  //most recent content list
	case "recent":
		if (divid != lastrecenttab) {
			document.getElementById(lastrecenttab+"a").className = "";
			document.getElementById(lastrecenttab).style.display = "none";
			document.getElementById(divid+"a").className = "on";
			document.getElementById(divid).style.display = "block";
			lastrecenttab = divid;
		}
		break;
  //most viewed content list
	case "viewed":
		if (divid != lastviewedtab) {
			document.getElementById(lastviewedtab+"a").className = "";
			document.getElementById(lastviewedtab).style.display = "none";
			document.getElementById(divid+"a").className = "on";
			document.getElementById(divid).style.display = "block";
			lastviewedtab = divid;
		}
		break;
  //products content list
	case "products":
		if (divid != lastproductstab) {
			document.getElementById(lastproductstab+"a").className = "";
			document.getElementById(lastproductstab).style.display = "none";
			document.getElementById(divid+"a").className = "on";
			document.getElementById(divid).style.display = "block";
			lastproductstab = divid;
		}
		break;
	default:
		return false;
	}
}

// For jump menu selects within content boxes
lastblogtab = 'blog1';
lastvoicestab = 'voices1';
function rboxmidSelect(prefix,targ,selObj,restore){ //v3.0
	var selected = selObj.selectedIndex+1;
	var divid = prefix+selected;	
	switch (prefix){
  //blog select
	case "blog":
		document.getElementById(lastblogtab).style.display = "none";
		document.getElementById(divid).style.display = "block";
		lastblogtab = divid;
		break;
  //voices select
	case "voices":
		document.getElementById(lastvoicestab).style.display = "none";
		document.getElementById(divid).style.display = "block";
		lastvoicestab = divid;
		break;
	default:
		return false;
	}
}

/* Deal with IE problems on hover for left nav*/


startList = function() {

	startListLeft();
	startListTop();
}

startListLeft = function() {

if (document.all&&document.getElementById) {
navRoot = document.getElementById("leftnav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
 }
}

/* Deal with IE problems on hover for top nav*/
startListTop = function() {

if (document.all&&document.getElementById) {
navRoot = document.getElementById("topnav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
 }
}

//window.onload=startList;



// set up axel and ord for DART
var axel = Math.random() + "";
//var ord = axel * 1000000000000000000;
var ord = Math.floor(axel * 1000000000);

// hide/reveal tabs for knowledge centers
function tab1() {
	document.getElementById("tab1").style.display = "block";
	document.getElementById("tab2").style.display = "none";
	document.getElementById("tab3").style.display = "none";
	document.getElementById("tab4").style.display = "none";
}
function tab2() {
	document.getElementById("tab1").style.display = "none";
	document.getElementById("tab2").style.display = "block";
	document.getElementById("tab3").style.display = "none";
	document.getElementById("tab4").style.display = "none";
}
function tab3() {
	document.getElementById("tab1").style.display = "none";
	document.getElementById("tab2").style.display = "none";
	document.getElementById("tab3").style.display = "block";
	document.getElementById("tab4").style.display = "none";
}
function tab4() {
	document.getElementById("tab1").style.display = "none";
	document.getElementById("tab2").style.display = "none";
	document.getElementById("tab3").style.display = "none";
	document.getElementById("tab4").style.display = "block";
}
function setCookie(name, value, expiredays, path){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	var cookie_str = name+ "=" +escape(value)+
	((expiredays) ? ";expires="+exdate.toGMTString() : "")+
	((path) ? ";path="+path : "");
	document.cookie=cookie_str;
}
function getCookie( name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var ar_all_cookies = document.cookie.split( ';' );
	var ar_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < ar_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		ar_temp_cookie = ar_all_cookies[i].split( '=' );
		
		
		// and trim left/right whitespace while we're at it
		cookie_name = ar_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		// if the extracted name matches passed name
		if ( cookie_name == name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( ar_temp_cookie.length > 1 )
			{
				cookie_value = unescape( ar_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		ar_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}
function deleteCookie( name, path, domain ) {
	var cookie_str = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	( ( domain ) ? ";domain=" + domain : "" ) +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	if (getCookie( name )){
		document.cookie = cookie_str;
	}
}
function getDomainName(){
		return document.domain;
}
function getSiteInitials(){
		var domainName = getDomainName();
		var pos = domainName.indexOf("controlglobal");
		if (pos>-1){
			return 'cg';
		}
		var pos = domainName.indexOf("controldesign");
		if (pos>-1){
			return 'cd';
		}
		var pos = domainName.indexOf("chemicalprocessing");
		if (pos>-1){
			return 'cp';
		}
		var pos = domainName.indexOf("foodprocessing");
		if (pos>-1){
			return 'fp';
		}
		var pos = domainName.indexOf("pharmamanufacturing");
		if (pos>-1){
			return 'pm';
		}
		var pos = domainName.indexOf("plantservices");
		if (pos>-1){
			return 'ps';
		}
}

var lastkctab = 'kctab1';
function toggletabs(kind,num) {
	var divid = kind+num;
	if (divid != 'lastkctab') {
		document.getElementById(lastkctab+"a").className = "";
		document.getElementById(lastkctab+"li").className = "";
		document.getElementById(lastkctab).style.display = "none";		
		document.getElementById(divid+"a").className = "current";
		document.getElementById(divid+"li").className = "active";
		document.getElementById(divid).style.display = "block";
		lastkctab = divid;		
	}		
}

function refreshPopular() {
	(new Ajax()).doGet('/services/most_popular_processor.html');
}

function createCookie(name,value,days,host,path) {
	var expires = "";
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		expires = "; expires="+date.toGMTString();
	}
	
	var domain = '';
	if (host) {
		domain = "; domain="+host;
	}

	var folder = '';
	if (path) {
		folder = "; path="+path;
	}
	document.cookie = name+"="+value+expires+domain+folder;
}

function handle_validate_data(data)
{
	switch(data['status']) {
	case('success'):
		createCookie(data['name'], data['value'], 23, data['cookie_domain']);
		location.replace('/member/manage_account.html?q=user/' + data['uid'] + '/edit');
		break;
	case('expired'):
		param = '/member/register.php?status=expired';
		modalwindow();
		$('#modal_wrap').jqmShow();
		break;
	case('used'):
		param = '/member/login.php?status=used';
		modalwindow();
		$('#modal_wrap').jqmShow();
		break;
	}
}

// Modal functions
var fade_close=function(hash){ hash.w.fadeOut('350',function(){ hash.o.remove(); }); };
var fade_open=function(hash) { hash.w.fadeIn('350'); };

function modalwindow()
{
	$('#modal_wrap').jqm({
		ajax: param,
		ajaxText: '<img id="ajax_loading" src="http://www.controlglobal.com/images/user/ajax_loading.gif" height="100" width="100">',
		closeClass: 'modal_close',
		onHide: fade_close,
		onShow: fade_open,
		overlay: 80,
		overlayClass: 'modal_overlay',
		toTop: true,
		trigger: '.modal_trigger'
	});
}

// Manage Account -- focus form fields

var field = '';
var lasthash = '';

var onshow = function(){
		doshow();
};

function doshow() {
		if(field != '') {
				var selector = 'input#' + field;
				if(field == 'edit-pass-pass1') {
						var selector = 'input#' + field + ', input#edit-pass-pass2'; 
				}
				$(selector).addClass('highlight');
		}
		var focusid = field;
		if(focusid != '') {
				document.getElementById(focusid).focus();
		}
}

// initialize the variable everywhere
var put_registered = false;

