function RightslinkPopUp(title, date, author, contentID)
	{	
		var url = "https://s100.copyright.com/servlet/DispatchServlet"; 
		var location = url 
			+ "?PublisherName=" + escape("Putman Media, Inc.")
			+ "&Publication=" + escape("Food 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;
}

/* 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;

function autorefresh_ad(id) {
  var dc_tile=0;
  dc_tile++;
  top.frames[id].location.replace("http://ad.doubleclick.net/adi/"+dart_site_name+"/"+dart_zone_name+";dcopt="+dcopt[id]+";rb="+dart_roadblock+";"+pos[id]+"sz="+size[id]+";tile="+tile[id]+";kw="+dart_keywords+";ord=' + ord + '?");
}

var lasttab = 'tab1';
var lastpoptab = 'tabpop1';
function toggletabs(box,idnum) {	
	var divid = box+idnum;
	switch (box){
  //top right column box
	case "tab":
		if (divid != lasttab) {
      document.getElementById(lasttab+"a").className = "";
      document.getElementById(lasttab+"li").className = "";
      document.getElementById(lasttab).style.display = "none";
      document.getElementById(divid+"a").className = "current";
      document.getElementById(divid+"li").className = "active";
      document.getElementById(divid).style.display = "block";
			lasttab = divid;
		}
		break;
  //most popular box
	case "tabpop":
		if (divid != lastpoptab) {
      document.getElementById(lastpoptab+"a").className = "";
      document.getElementById(lastpoptab+"li").className = "";
      document.getElementById(lastpoptab).style.display = "none";
      document.getElementById(divid+"a").className = "current";
      document.getElementById(divid+"li").className = "active";
      document.getElementById(divid).style.display = "block";
			lastpoptab = divid;
		}
		break;
	default:
		return false;
	}
}

// For jump menu selects within sections
lastdept = 'dept1';
function inputSelect(prefix,targ,selObj,restore){
  var selected = selObj.selectedIndex+1;
  var divid = prefix+selected;	
  document.getElementById(lastdept).style.display = "none";
  document.getElementById(divid).style.display = "block";
  lastdept = divid;
}

// Topnav hover fix (IE6)
var lastnavtab = "navtab2";
var ie6 = "";
function tabNavToggle(divid,number,display,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") {
  	var current_tab = divid+number;
  	var tab_to_right = divid+(parseInt(number)+1);
  	var tab_to_right_exists = document.getElementById(String(tab_to_right)+"li");
  	if(display != ''){
  		document.getElementById(lastnavtab+"a").style.backgroundPosition = "100% 0";  // right top
  		document.getElementById(lastnavtab+"li").style.backgroundPosition = "0 0";  // left top
	  	if(tab_to_right_exists){
  		  document.getElementById(tab_to_right+"li").style.backgroundPosition = "0 -42px";  // left middle
  		}
  		if(divid != lastnavtab){
  		  document.getElementById(lastnavtab).style.display = "none";
	  	  document.getElementById(current_tab+"li").style.backgroundPosition = "0 -42px";  // left middle
	  	  lastnavtab = current_tab;
	  	}
  		if (display == "block"){
  		  document.getElementById(current_tab+"a").style.backgroundPosition = "100% -42px";  // right middle
	  	  document.getElementById(current_tab+"li").style.backgroundPosition = "0 -84px";  // left bottom
	  	  if(tab_to_right_exists){
	  	    document.getElementById(tab_to_right+"li").style.backgroundPosition = "0 0";  // left top
	  	  }
	  	  document.getElementById(current_tab).style.display = display;
  		} else {
  		  document.getElementById(current_tab).style.display = display;
  		}
  	}
  	if(display == ''){
  	  switch(hover){
	  	  case "on":
	  	    document.getElementById(current_tab+"a").style.backgroundPosition = "100% -42px";  // right middle
	  	    document.getElementById(current_tab+"li").style.backgroundPosition = "0 -84px";  // left bottom
	  	    if(tab_to_right_exists){
	  	      document.getElementById(tab_to_right+"li").style.backgroundPosition = "0 0";  // left top
  		    }
	  	    break;
	  	  case "off":
  		    document.getElementById(current_tab+"a").style.backgroundPosition = "100% 0";  // right top
	  	    document.getElementById(current_tab+"li").style.backgroundPosition = "0 -42px";  // left middle
	  	    if(tab_to_right_exists){
	  	      document.getElementById(tab_to_right+"li").style.backgroundPosition = "0 -42px";  // left middle
	  	    }
	  	    break;
	  	  default:
	  	    return false;
	    }
  	}	
	}
}

var last_kctab = 'kctab1';
function kctabs(box,idnum) {	
  var divid = box+idnum;
    if (divid != last_kctab) {
      document.getElementById(last_kctab+"li").className = "";
      document.getElementById(last_kctab).style.display = "none";
      document.getElementById(divid+"li").className = "current";
      document.getElementById(divid).style.display = "block";
      last_kctab = 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';
		break;
	case('used'):
		param = '/member/login.php?status=used';
		break;
	}
	modalwindow();
	$('#modal_wrap').jqmShow();
}

// 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.foodprocessing.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();
		}
}