// Popup
function popUp (thisURL) { 
	if (document.getElementById) { 
	    // Set the width of your shared popup window here
		var winheight = 600;
		var winwidth = 800;
		width = parseInt(winwidth) + 20;
		height = parseInt(winheight) + 20;
		newwin = window.open(thisURL.href, "popUp", "resizable=yes,width="+width+",height="+height+",scrollbars=yes,location=yes");
		newwin.focus();
		return false; 
	} else { 
		return true; 
	} 
}

// This script adds the popup functionality to all links with a class of popup
function popLinks(){
	if (!document.getElementsByTagName) return null;
	var anchors = document.getElementsByTagName("a");
	for(var i=0; i < anchors.length; i++){
		var a = anchors[i];
		var thisclass = a.className;
		if ((thisclass.indexOf("popup") != -1)) { 
			//a.setAttribute("title", a.title + " - This link will open in a new window.");  
		  	a.onclick = function() { return popUp(this); }
		}
	  }
}

window.onload = function(){
  popLinks();
}

// Popup - Live Chat
function popChat (thisURL) { 
	if (document.getElementById) { 
	    // Set the width of your shared popup window here
		var winheight = 450;
		var winwidth = 420;
		width = parseInt(winwidth) + 15;
		height = parseInt(winheight) + 15;
		newwin = window.open(thisURL, "popChat", "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+width+",height="+height);
		newwin.focus();
		return; 
	} else { 
		return true; 
	} 
}


// fieldname, warningname, remainingname, maxchars
function CheckFieldLength(fn,wn,rn,mc) {
  var len = fn.value.length;
  if (len > mc) {
    fn.value = fn.value.substring(0,mc);
    len = mc;
  }
  document.getElementById(wn).innerHTML = len;
  document.getElementById(rn).innerHTML = mc - len;
}


