// ----------------------------------------------------------------------------------------------------
// UTILITY FUNCTIONS
// ----------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------
// GET OBJECTS, TAGS, CHILD OR PARENT ELEMENTS 

// get the object with the specified id
function getObject(id){
	if (document.getElementById){
		return document.getElementById(id);
	}
	else if (document.all){
		return  document.all[id];
	}
	else if (document.layers){
		return getObjectNN4(document, id);
	}
	else{
		return null;
	}
}

// helper function for getObject
// get object in Netscape 4
function getObjectNN4(obj,name){
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++){
		if (x[i].id == name)
			foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = getObjectNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}

// this replaces getElementsWithTagName
// works in IE4+, NS6+
function getTags(obj, tagName){
	// we can take in an id string or an object pointer
	// if it's a string, just use getObject on the id
	if (typeof(obj) == 'string') obj = getObject(obj);
	
	if (obj.getElementsByTagName){
		return obj.getElementsByTagName(tagName);
	}
	else if (document.all){
		if (tagName == "*"){
			return obj.all;
		}
		else{
			// IE4 (and maybe some other browsers) support this method
			// but tagname must be in uppercase
			tagName = tagName.toUpperCase();
			return obj.all.tags(tagName);
		}
	}
	else{
	// we can't get the tags, so we'll return nothing
	return null;
	}
}

// return the object's parent
// this does not work in NS 4.x
function getParent(obj){
	// we can take in an id string or an object pointer
	// if it's a string, just use getObject on the id
	if (typeof(obj) == 'string') obj = getObject(obj);
	
	if (obj.parentNode){
		return obj.parentNode;
	}
	else if (obj.parentElement){
		return obj.parentElement;
	}
	else if (obj.parentLayer){
		return obj.parentLayer;
	}
	else{
		// we can't get the parent, so return null
		return null;
	}
}

// get parent of a specific tag type
function getSpecParent(obj,parentTag) {
	if (typeof(obj) == 'string') obj = getObject(obj);
	
	var p = getParent(obj);
	var pTag = parentTag.toUpperCase();
	
	do {
		p = getParent(p);
	}
	while (p.nodeName != pTag);			
	
	return p;
}

// this is a more compatible version of element.childNodes
// works in IE4+, NS6+
// moz/opera count whitespace nodes, but IE does not
function getChildren(obj){
	// we can take in an id string or an object pointer
	// if it's a string, just use getObject on the id
	if (typeof(obj) == 'string') obj = getObject(obj);
	
	if (obj.childNodes){
		// for non IE browsers, we need to clean out the whitespace nodes
		// for consistency
		var nonWhitespace = new Array();
	
		for (var i = 0; i < obj.childNodes.length; i++){
			if (obj.childNodes[i].tagName != null && obj.childNodes[i].tagName != "!"){
				nonWhitespace[nonWhitespace.length] = obj.childNodes[i];
			}
		}
		return nonWhitespace;
	}
	else if (obj.children){	
		var nonWhitespace = new Array();
	
		// don't include comment tags (tags that have a tagName of !)
		for (var i = 0; i < obj.children.length; i++){
			if (obj.children[i].tagName != "!"){
				nonWhitespace[nonWhitespace.length] = obj.children[i];
			}
		}
		return nonWhitespace;
	}
	else if (obj.layers){
		return obj.layers;
	}
	else{
	// we can't get the tags, so we'll return nothing
	return null;
	}
}

// ----------------------------------------------------------------------------------------------------
// MANIPULATE STYLES, CLASSES

// set the style for an object
function setStyle(obj, styleTag, value){
	// we can take in an id string or an object pointer
	// if it's a string, just use getObject on the id
	if (typeof(obj) == 'string') obj = getObject(obj);
	
	// get the style object
	var style;
	if (document.getElementById){
		style = obj.style;
	}
	else if (document.all){
		style = obj.style;
	}
	else if (document.layers){
		style = obj;
	} 
	else{
		// we can't get the style, so return
		return false;
	}	
	// now, set the style
	style[styleTag] = value;
}

function setOpacity(obj,opVal){	
	if (typeof(obj) == 'string') obj = getObject(obj);		
	if (document.all) { // IE
		obj.style.filter = "alpha(opacity=" + opVal + ")"; 
	}	
	else if (document.doctype != null) {
		obj.style.MozOpacity = opVal / 100;  
	}
	else {		
		obj.style.opacity = opVal / 100;
	}	
}

// check to see if an element has a particular attribute value
function hasAttr(obj,attribute){
	if (typeof(obj) == 'string') obj = getObject(obj);
	var attr = false;
	if (obj.getAttribute(attribute) != null){
		attr = obj.getAttribute(attribute);
		return attr;
	}
}

// returns true if the object has the specified class
function hasClass(obj, className){
	// we can take in an id string or an object pointer
	// if it's a string, just use getObject on the id
	if (typeof(obj) == 'string') obj = getObject(obj);
	
	if (obj.className){
		var classes = obj.className.split(" ");
		for (var i = 0; i < classes.length; i++){
			if (classes[i]	== className){
				return true;
			}
		}
		return false;
	}
	else{
		return false;
	}
}

// add the CSS class to the object
function addClass(obj, className){
	// we can take in an id string or an object pointer
	// if it's a string, just use getObject on the id
	if (typeof(obj) == 'string') obj = getObject(obj);
	
	if (!hasClass(obj, className)){
		if (obj.className == null || obj.className == ""){
			obj.className = className;
		}
		else{
			// append this to the list of existing classes
			obj.className = obj.className + " " + className;
		}
	}
}

// remove the CSS class (if it exists)
function removeClass(obj, className){
	// we can take in an id string or an object pointer
	// if it's a string, just use getObject on the id
	if (typeof(obj) == 'string') obj = getObject(obj);
	
	var classes = obj.className.split(" ");
	var newClasses = new Array();
	
	for (var i = 0; i < classes.length; i++){
		if (classes[i]	!= className){
			newClasses[newClasses.length] = classes[i];
		}
	}
	
	var newClassString = newClasses.join(" ");
	obj.className = newClassString; 
}

// toggle the CSS class
// if its there, remove it
// if it isn't, add it
function toggleClass(obj, className){
	if (hasClass(obj, className)){
		removeClass(obj, className);
	}
	else{
		addClass(obj, className);
	}
}

// highlight a specific object in a group
function hiLite(obj,par,tag,className){
	if (typeof(obj) == 'string') obj = getObject(obj);
	if (typeof(par) == 'string') par = getObject(par);
	
	var c = getTags(par,tag);
	
	for(var i=0; i < c.length; i++){
		if(hasClass(c[i],className)){
			removeClass(c[i],className);
		}
		addClass(obj,className);
	}
}

// ----------------------------------------------------------------------------------------------------
// SHOW / HIDE OBJECTS

// show an element
// unless you specify a display type, the default of "block" is used
function show(obj, displayType){
	// we can take in an id string or an object pointer
	// if it's a string, just use getObject on the id
	if (typeof(obj) == 'string') obj = getObject(obj);
	
	if (document.layers){
		obj.visibility  = "show";
		if (displayType != null){
			obj.display = displayType;
		}
		else{
			obj.display = "block";
		}
	}
	else if (obj.style){
		obj.style.visibility  = "visible";
		if (displayType != null){
			obj.style.display = displayType;
		}
		else{
			obj.style.display = "block";
		}
	}
	else{
		return false;
	}
}

// hide all objects in a container
// then show the other one
function showOnly(obj){
	if (typeof(obj) == "string") obj = getObject(obj);
	show(obj);
	
	var container = getParent(obj);	
	var children = getChildren(container);
	
	for (var i = 0; i < children.length; i++){
		if (children[i] != obj){
			hide(children[i]);
		}
	}
}

// hide an object
// note that objects set display: none are inaccessible
// in the NN4.x DOM. If this matters, use hide instead
function hide(obj){
	// we can take in an id string or an object pointer
	// if it's a string, just use getObject on the id
	if (typeof(obj) == 'string') obj = getObject(obj);
	
	if (document.layers){
		obj.visibility  = "hidden";
		obj.display = "none";
	}
	else if (obj.style){
		obj.style.visibility  = "hidden";
		obj.style.display = "none";
	}
	else{
		return false;
	}
}

// hide the object by setting visibility: hidden
// objects hidden with this function will remain in
// the document flow
function hideVisibility(obj){
	// we can take in an id string or an object pointer
	// if it's a string, just use getObject on the id
	if (typeof(obj) == 'string') obj = getObject(obj);
	
	if (document.layers){
		obj.visibility  = "hidden";
	}
	else if (obj.style){
		obj.style.visibility  = "hidden";
	}
	else{
		return false;
	}
}

// ----------------------------------------------------------------------------------------------------
// GET DIMENSIONS AND POSITION

// get the document / body width
function getBodyWidth(){
	var x,y;
	
	if (document.getElementsByTagName){
		var bd = document.getElementsByTagName("body").item(0);
		x = getWidth(bd);
	}	
	return x;
}

function getBodyHeight(){
	var x,y;
	
	if (document.getElementsByTagName){
		var bd = document.getElementsByTagName("body").item(0);
		y = getHeight(bd);
	}	
	return y;
}

// get the browser width
function getScreenWidth(){
	var x,y;
	
	// all except Explorer
	if (self.innerHeight){
		x = self.innerWidth;
	}
	// Explorer 6 Strict Mode
	else if (document.documentElement && document.documentElement.clientHeight){
		x = document.documentElement.clientWidth;
	}
	// other Explorers
	else if (document.body){
		x = document.body.clientWidth;
	}
	return x;
}

// get the browser height
function getScreenHeight(){
	var x,y;
	
	// all except Explorer
	if (self.innerHeight){
		y = self.innerHeight;
	}
	// Explorer 6 Strict Mode
	else if (document.documentElement && document.documentElement.clientHeight){
		y = document.documentElement.clientHeight;
	}
	// other Explorers
	else if (document.body){
		y = document.body.clientHeight;
	}
	return y;
}

// get the vertical scroll
function getScrollTop(){
   var scrollTop = 0;
   if (self.pageYOffset){
      scrollTop = self.pageYOffset;
   }
   else if (document.documentElement && document.documentElement.scrollTop){
      scrollTop = document.documentElement.scrollTop;
   }
   else if (document.body){
      scrollTop = document.body.scrollTop;
   }
   return scrollTop;
}

// get the horizontal scroll
function getScrollLeft(){
   var scrollLeft = 0;
   if (self.pageXOffset){
      scrollLeft = self.pageXOffset;
   }
   else if (document.documentElement && document.documentElement.scrollLeft){
      scrollLeft = document.documentElement.scrollLeft;
   }
   else if (document.body){
      scrollLeft = document.body.scrollLeft;
   }
   return scrollLeft;
}

// get the height of an element
function getHeight(obj){
	if (typeof(obj) == 'string') obj = getObject(obj);		
	return obj.offsetHeight;
}

// get the width
function getWidth(obj){
	if (typeof(obj) == 'string') obj = getObject(obj);		
	return obj.offsetWidth;
}

// Returns the horizontal center coordinate. This is just the left scroll offset + browser width/2.
function getCenterX(){
	return ((getScrollLeft() + getScreenWidth())/2);
}

//  Returns the vertical center coordinate. This is just the top scroll offset + browser height/2.
function getCenterY(){
	return ((getScrollTop() + getScreenHeight())/2);
}

// will this object fit in the document horizontally?
function fitHorizontal(obj, xpos){
	return (xpos + getWidth(obj) <= getScreenWidth() + getScrollLeft() && xpos - getScrollLeft() >= 0);
}

function fitVertical(obj, ypos){
	return (ypos + getHeight(obj) <= getScreenHeight() + getScrollTop() && ypos - getScrollTop() >= 0);
}

// find the horizontal offset
function findPosX(obj){
	var left = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			left += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		left += obj.x;
	return left;
}

// find the vertical offset
function findPosY(obj){
	var top = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			top += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		top += obj.y;
	return top;
}

// resize object (stretch) functions
function stretchWidth(obj, offset){
	if (typeof(obj) == 'string') obj = getObject(obj);
	var w = getScreenWidth();
	obj.style.width = (w - offset) + "px";
}

function stretchHeight(obj, offset){
	if (typeof(obj) == 'string') obj = getObject(obj);
	var h = getScreenHeight();
	obj.style.height = (h - offset) + "px";
}


// ----------------------------------------------------------------------------------------------------
// WIDGETS -- SMALL, COMPOSITE FUNCTIONS
// ----------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------
// FORM ELEMENT FUNCTIONS

// check a specific checkbox
function setCheck(obj) {
	if (typeof(obj) == 'string') obj = getObject(obj);
	obj.checked = true;
}

// uncheck a specific checkbox
function undoCheck(obj) {
	if (typeof(obj) == 'string') obj = getObject(obj);
	obj.checked = false;
}

// check all in a group
function checkAll(obj) {
	if (typeof(obj) == 'string') obj = getObject(obj);
	
	//get checkboxes
	var checks = getTags(obj, 'input');
	
	for(var i=0; i<checks.length; i++) {
	checks[i].checked = true;
	}									
}

// uncheck all in a group
function checkNone(obj) {
	if (typeof(obj) == 'string') obj = getObject(obj);
	
	//get checkboxes
	var checks = getTags(obj, 'input');
	
	for(var i=0; i<checks.length; i++) {
	checks[i].checked = false;
	}								
}

// uncheck checked, check unchecked
function toggleChecked(obj) {
	if (typeof(obj) == 'string') obj = getObject(obj);
	
	//get checkboxes
	var checks = getTags(obj, 'input');
	
	for(var i=0; i<checks.length; i++) {
	if (checks[i].checked) {
		checks[i].checked = false;
		}
	else {
		checks[i].checked = true;
		}
	}									
}

// check a 'master' checkbox to enable / disable other checkboxes
function disableCheck(obj,chk){
	if (typeof(obj) == 'string') obj = getObject(obj);
	if (typeof(chk) == 'string') chk = getObject(chk);
	
	//get checkboxes
	var c = getTags(obj, 'input');	
	
	for(var i=0; i<c.length; i++){
		
		if (c[i] != chk){
			
			if (chk.checked){
				c[i].disabled = false;
			}
			else{
				c[i].disabled = true;
				c[i].checked = false;					
			}
		}	
	}				
}

// do a function onchange
// can be called from the value attribute assigned to <option> tags, but
// we should find a different way to call this in case it needs to be used for a real application
function doFunction(obj){
	if (typeof(obj) == 'string') obj = getObject(obj);
	var c = obj.options[obj.selectedIndex].value;
	if (c) setTimeout(c,0);
}

// faux select box
// this will update link text in a button-styled dropdown
function updateLink(obj,value){
	if (typeof(obj) == 'string') obj = getObject(obj);
	obj.innerHTML = '<span>' + value + '</span>';
}

// simple text replacement
function replaceText(obj,text) {
	if (typeof(obj) == 'string') obj = getObject(obj);
	obj.innerHTML = text;
}

// ----------------------------------------------------------------------------------------------------
// SPINDOWNS

function spindown(e, caller) {
	if (!caller) caller = this;
	
	// get the bottom element
	var bd = caller.id + "_body";
	var b = getObject(bd);
	var slct = getTags(b,'select');
	
	// if we have both the top and bottom
	// set the appropriate styles
	if (b != null) {
		if (hasClass(caller, "spdn_open")) {
			// close it
			hide(bd);
			removeClass(caller, "spdn_open");
			addClass(caller, "spdn_closed");
			if (slct != null){
				for(var z=0; z < slct.length; z++){
					hide(slct[z]);
				}
			}		
		}
		else {
			// open it
			if (b.nodeName == "TR"){
				showRow(bd);
			}
			else{
				show(bd);
			}					
			removeClass(caller, "spdn_closed");
			addClass(caller, "spdn_open");		
			if (slct != null){
				for(var z=0; z < slct.length; z++){
					show(slct[z]);
				}
			}			
		}
	}	
}

// control all spindowns within a specified container
// used for the accordion menu
function spindownOnly(e, caller) {
	if (!caller) caller = this;
	
	var p = getParent(caller);
	var c = getChildren(p);
	var b = getObject(caller.id + '_body');
	
	if (b != null){
		if (hasClass(caller,'spdn_closed')){	
			for (i = 0; i < c.length; i++){				
				if (hasClass(c[i],'spdn_open')){
					hide(c[i].id + '_body');
					removeClass(c[i],'spdn_open');
					addClass(c[i],'spdn_closed');
				}				
			}
			show(b);
			removeClass(caller,'spdn_closed');
			addClass(caller,'spdn_open');
		}
		else{
			hide(b)
			removeClass(caller,'spdn_open');
			addClass(caller,'spdn_closed');
		}
	}			
}

// to initialize spindowns onload
function setSpindown(obj) {
	if (typeof(obj) == "string") obj = getObject(obj);

	if (obj.captureEvents)
		obj.captureEvents(Event.CLICK);
	
	obj.onclick = spindown;
}

// ----------------------------------------------------------------------------------------------------
// TABS

// show the tab you've clicked
function showTab(e, caller){
	if (!caller) caller = this;	
	
	var par = getParent(caller);
	var tabs = getParent(par);
	var dv = getChildren(tabs);
	
	for (var i = 0; i < dv.length; i++) {
	
		if (hasClass(dv[i],'tabLinks')){		
			var lnk = getTags(dv[i],'a');	
			var div = getTags(dv[i],'div');
			
			// horizontal tab strip
			if (lnk != null){
				for (var j = 0; j < lnk.length; j++){
							
					// turn off the anchor linking so that it doesn't interfere
					lnk[j].href = 'javascript://';
					
					if (lnk[j].id != caller.id) { 
						removeClass(lnk[j],'tabLinkOn');
					}
					else { 
						addClass(lnk[j],'tabLinkOn'); 
					}
				}
			}
			
			// vertical tab strip w/ radios
			if (div != null){
				for (var k = 0; k < div.length; k++){
							
					// turn off the anchor linking so that it doesn't interfere
					div[k].href = 'javascript://';
					
					if (div[k].id != caller.id) { 
						removeClass(div[k],'tabLinkOn');
					}
					else { 
						addClass(div[k],'tabLinkOn'); 
					}
				}
			}
				
		}
		
		if (hasClass(dv[i],'tabContent')){			
			var tb = getChildren(dv[i]);
			for (var k = 0; k < tb.length; k++){				
				// make sure the divs not selected are hidden
				if (tb[k].id != caller.id + '_body') { hide(tb[k]); }				
				// show the div you selected
				else { 
					show(tb[k]);
					// custom check for screen height in PPC edit screens:
					if (getObject('editBody') != null){
						setStyle('editBody','height','auto');
					}		
				}					
			}	
		}
	}
}

// initialize tabs onload 
function setTabs(obj){
	if (typeof(obj) == "string") obj = getObject(obj);
	
	if (obj.addEventListener) {
		obj.addEventListener('click',showTab,false);							
	}
	else {
		obj.onclick = showTab;
	}
}

// ----------------------------------------------------------------------------------------------------
// XMLHttpRequest FUNCTIONS

var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/

if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { xmlhttp = new XMLHttpRequest(); }

function getMyHTML(serverPage, objID) {
	var obj = document.getElementById(objID); 
	
	xmlhttp.open("GET", serverPage); 
	xmlhttp.onreadystatechange = function(){ 
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { 
			obj.innerHTML = xmlhttp.responseText; 
			} 
	} 
	xmlhttp.send(null); 
} 

// swap content onchange using getMyHTML
// used briefly for AdoramaPix prototype -- not fully tested
function switchContent(obj){
	var d = document.forms[0].displaytype;
	var c = d.options[d.selectedIndex].value;
	if (c) getMyHTML(c,obj);
}

// ----------------------------------------------------------------------------------------------------
// POPUPS

// custom popup function - parameters passed in with link
function popup(alink, popup_width, popup_height, scrollbars, toolbars, resize){
	var url = alink.href;
	var name = alink.target;
	
	var popup_window = window.open(url,name,"toolbar="+toolbars+",directories="+toolbars+",status="+toolbars+",menubar="+toolbars+",location="+toolbars+",scrollbars="+scrollbars+",resizable="+resize+",width="+popup_width+",height="+popup_height);
	popup_window.focus();
}

// fixed popup function - parameters set in script which references popup()
function popupFixed(alink){
	var popup_window = popup(alink, 800, 650, 0, 0, 0); return false;
	popup_window.focus();			
}

// fixed popup function - parameters set in script which references popup()
function popupCalculator(alink){
	var popup_window = popup(alink, 800, 650, 1, 0, 1); return false;
	popup_window.focus();			
}

function popupSimple(url){
	var popup_window = window.open(url,'newWindow','width=400,height=300');
	// popup_window.focus();
}

/* highlight for consultant image map */
 
function highlightContact(id){
	if (typeof('contactReps') == 'string') obj = getObject('contactReps');
	var tr = getTags(obj,'tr');
	//alert(tr.length);

	for (var i = 0; i < tr.length; i++){
		if (hasClass(tr[i],'highlight')){
			removeClass(tr[i],'highlight');
		}
		addClass(id,'highlight');
	}
}


// ----------------------------------------------------------------------------------------------------
// IFRAME FUNCTIONS

// get to the iframes
function updateFrame(obj,url){
	if (typeof(obj) == 'string') obj = getObject(obj);
	//if (obj) obj.location.href = url;		
	if (obj) { obj.src = url; }
}

// ----------------------------------------------------------------------------------------------------
// TABLE FUNCTIONS - STRIPE, SHOW / HIDE COLUMNS
// see the SPINDOWN functions for showing / hiding rows

// Alternating table row colors
// modified by Shaun to change classes rather than colors
// modified by Maggie to use our core scripts
function stripe(){
	
	// the flag we'll use to keep track of whether the current row is odd or even
	var even = false;
	var evenStyle = 'even';
	var oddStyle = 'odd';
	
	var tb = getTags(document, 'tbody');
	
	for (var h = 0; h < tb.length; h++){
		// reset the even attribute
		even = false;
		
		if (hasClass(tb[h],'stripe')){
			// find all the tr elements... 
			var tr = getTags(tb[h], 'tr');
		
			// ... and iterate through them
			for (var i = 0; i < tr.length; i++){
				// avoid rows that have a class attribute
				// or backgroundColor style
				tr[i].className = even ? evenStyle : oddStyle;
		
				// flip from odd to even, or vice-versa
				even =  ! even;
			}		
		}			
	}
}

// hide column 
// not fully tested !!
function hideCol(obj){
	if (typeof(obj) == 'string') obj = getObject(obj);
	
	if (obj.nodeName == "TH"){
		var k = obj.id;
		var tr = getParent(obj);
		var hd = getParent(tr);
		var tb = getParent(hd);			
		var r = getTags(tb,'tr');
		
		hide(obj);
		
		for (var i = 0; i < r.length; i++){
			var d = getChildren(r[i]);				
			
			for (var x = 0; x < d.length; x++){
				if (d[x].getAttribute('headers') == k){
					hide(d[x]);
				}
			}
		}			
	}		
}

// show column
// not fully tested !!
function showCol(obj){
	if (typeof(obj) == 'string') obj = getObject(obj);
	
	if (obj.nodeName == "TH"){
		var k = obj.id;
		var tr = getParent(obj);
		var hd = getParent(tr);
		var tb = getParent(hd);			
		var r = getTags(tb,'tr');
		
		showCell(obj);
		
		for (var i = 0; i < r.length; i++){
			var d = getChildren(r[i]);				
			
			for (var x = 0; x < d.length; x++){
				if (d[x].getAttribute('headers') == k){
					showCell(d[x]);
				}
			}
		}			
	}		
}	

// show row
function showRow(obj){
	if (typeof(obj) == 'string') obj = getObject(obj);
	
	// only supported by IE 5-6
	if (typeof(document.all)=='object'){			
		show(obj);
	}
	else{
		setStyle(obj,'display','table-row');
		setStyle(obj,'visibility','visible');
	} 
}

// show a single cell
function showCell(obj){
	if (typeof(obj) == 'string') obj = getObject(obj);
	
	// only supported by IE 5-6
	if (typeof(document.all)=='object'){			
		show(obj);
	}
	else{
		setStyle(obj,'display','table-cell');
		setStyle(obj,'visibility','visible');
	} 
}

// get the column placement in the table (first column returns 0);
function getIndex(obj){
	if (typeof(obj) == 'string') obj = getObject(obj);
	return obj.cellIndex;
}

// ----------------------------------------------------------------------------------------------------
// ASSIGN EVENTS TO SPECIFIC OBJECTS

function assignClick(obj,fn) {
	if (typeof(obj) == 'string') obj = getObject(obj);	
		
	if (obj.addEventListener){
		obj.addEventListener('click',fn,false);
	}
	else{
		obj.onclick = fn;
	}							
}

function assignMouseover(obj,fn) {
	if (typeof(obj) == 'string') obj = getObject(obj);	
		
	if (obj.addEventListener){
		obj.addEventListener('mouseover',fn,false);
	}
	else{
		obj.onmouseover = fn;
	}							
}

// ----------------------------------------------------------------------------------------------------
// ANIMATION OJBECTS AND TRANSITIONS

function isNegative(num) {
	if (typeof(num) == 'number') {
		var ns = num.toString();
		if (ns.indexOf('-') != -1) { return true; }
		else { return false; }
	}
}

var effectCounter = 0;

function Effect(id,optParams) {
	if (id) {
		// get characteristics
		this.id = getObject(id);
		this.height = getHeight(id);
		this.width = getWidth(id);
		this.currXpos = findPosX(id);
		this.currYpos = findPosY(id);
		
		// set default values for optional parameters
		this.inc = 1;
		this.minht = 1;
		this.maxht = null;	
		this.distX = 0;		
		this.distY = 0;	
		
		// specify values parameters if they exist
		if (optParams) {
			this.params = optParams;
			
			if (this.params.increment) { 
				this.inc = this.params.increment; 
			}
			if (this.params.minHeight) { 
				this.minht = this.params.minHeight; 
			}
			if (this.params.maxHeight) { 
				this.maxht = this.params.maxHeight; 
			}			
			if (this.params.minWidth) { 
				this.minwd = this.params.minWidth; 
			}
			if (this.params.maxWidth) { 
				this.maxwd = this.params.maxWidth; 
			}			
			if (this.params.distanceX) {
				this.distX = this.params.distanceX;
			}
			if (this.params.distanceY) {
				this.distY = this.params.distanceY;
			}
		}
				
		// set methods
		this.show = function(){
			effectShow(this.id);
		}
		
		this.hide = function(){
			effectHide(this.id);
		}
		
		this.fadeIn = function() {		
			effectFadeIn(this.id,this.inc);
		}	
		
		this.fadeOut = function() {		
			effectFadeOut(this.id,this.inc);
		}			
		
		this.incHeight = function() {
			this.height = getHeight(id);
			effectIncHeight(this.id,this.inc,this.height,this.maxht);
		}
		
		this.decHeight = function() {
			this.height = getHeight(id);
			effectDecHeight(this.id,this.inc,this.height,this.minht);
		}
		
		this.incWidth = function() {	
			this.width = getWidth(id);	
			effectIncWidth(this.id,this.inc,this.width,this.maxwd);
		}
		
		this.decWidth = function() {
			this.width = getWidth(id);	
			effectDecWidth(this.id,this.inc,this.width,this.minwd);
		}		
		
		this.moveByX = function() {
			effectMoveByX(this.id,this.inc,this.distX);
		}
		
		this.moveByY = function() {
			effectMoveByY(this.id,this.inc,this.distY);
		}
		
		this.closeWidth = function() {
			effectCloseWidth(this.id,this.inc,this.width,this.minwd);
		}
	}
}

function effectShow(obj){
	if (typeof(obj) == 'string') obj = getObject(obj);
	show(obj);
}

function effectHide(obj){
	if (typeof(obj) == 'string') obj = getObject(obj);
	hide(obj);
}

function effectIncHeight(obj,increment,currht,maxht){
	if (typeof(obj) == 'string') obj = getObject(obj);
	
	var inc = increment;
	
	// get the object's content 
	var c = getChildren(obj);
	
	// if no max height specified, use the height of the object's content
	if (!maxht){ 
		var maxht = getHeight(c[0]); 
	}
	
	// after the animation begins, check to see if the remainder is smaller than the increment
	// if so, set the increment to 1px so that we match the max height exactly
	if ((maxht - currht) < inc){ inc = 1; }	

	if (currht < maxht){  // set the new height, and keep running the function
		var newht = currht += inc;
		setStyle(obj,'height',newht + 'px');
		setTimeout(function(){effectIncHeight(obj,inc,currht,maxht);},0);
	}
	else {
		doNextEffect(++effectCounter);
	}
}

function effectDecHeight(obj,increment,currht,minht){
	if (typeof(obj) == 'string') obj = getObject(obj);	
	
	var inc = increment;
	var minht = minht;
	
	// after the animation begins, check to see if the remainder is smaller than the increment
	// if so, set the increment to 1px so that we match the min height exactly
	if ((currht - minht) < inc){ inc = 1; }
	
	if (currht > minht){  // set the new height, and keep running the function
		var newht = currht -= inc;
		setStyle(obj,'height',newht + 'px');
		setTimeout(function(){effectDecHeight(obj,inc,currht,minht);},0);
	}
	else {
		doNextEffect(++effectCounter);
	}
}

function effectIncWidth(obj,increment,currwd,maxwd){
	if (typeof(obj) == 'string') obj = getObject(obj);
	
	var inc = increment;
	
	// get the object's content 
	var c = getChildren(obj);	
	
	// if no max height specified, use the height of the object's content
	if (!maxwd){ 
		var maxwd = getWidth(c[0]); 
	}
	else {
		var maxwd = maxwd;
	}
	
	// after the animation begins, check to see if the remainder is smaller than the increment
	// if so, set the increment to 1px so that we match the max height exactly
	if ((maxwd - currwd) < inc){ inc = 1; }	
	
	//alert(currwd+', '+maxwd);

	if (currwd < maxwd){  // set the new width, and keep running the function
		
		var newwd = currwd += inc;
		setStyle(obj,'width',newwd + 'px');
		setTimeout(function(){effectIncWidth(obj,inc,currwd,maxwd);},0);
	}
	else {
		doNextEffect(++effectCounter);
	}
}

function effectDecWidth(obj,increment,currwd,minwd){
	if (typeof(obj) == 'string') obj = getObject(obj);

	var inc = increment;
	var minwd = minwd;
	
	// after the animation begins, check to see if the remainder is smaller than the increment
	// if so, set the increment to 1px so that we match the min height exactly
	if ((currwd - minwd) < inc){ inc = 1; }
	
	if (currwd > minwd){  // set the new width, and keep running the function
		var newwd = currwd -= inc;
		setStyle(obj,'width',newwd + 'px');
		setTimeout(function(){effectDecWidth(obj,inc,currwd,minwd);},0);
	}
	else {
		doNextEffect(++effectCounter);
	}
}

function effectFadeIn(obj,increment,newOp){
	if (typeof(obj) == 'string') obj = getObject(obj);
	
	// make sure you're not using Opera, which doesn't support opacity
	if (!window.opera) {
	
		var maxOpacity = 99;	
		
		if (!newOp) { var currOp = 1; }		
		else { currOp = newOp; }
		
		var inc = increment;
		if ((maxOpacity - currOp) < inc){ inc = 1; }
		
		if (currOp < maxOpacity) {
			var opVal = currOp += inc;
			setOpacity(obj,opVal);
			setTimeout(function(){effectFadeIn(obj,inc,currOp);},0);
		}
	}
}

function effectFadeOut(obj,increment,newOp){
	if (typeof(obj) == 'string') obj = getObject(obj);
	
	// make sure you're not using Opera, which doesn't support opacity
	if (!window.opera) {
	
		var minOpacity = 1;
		
		if (!newOp) { var currOp = 99; }		
		else { currOp = newOp; }
		
		var inc = increment;
		if ((currOp - minOpacity) < inc){ inc = 1; }
		
		if (currOp > minOpacity) {
			var opVal = currOp -= inc;
			setOpacity(obj,opVal);
			setTimeout(function(){effectFadeOut(obj,inc,currOp);},0);
		}
	}
}

function effectMoveByX(obj,increment,distanceX,currX,loop) {
	if (typeof(obj) == 'string') obj = getObject(obj);	
	
	var inc = increment;
	var dX = distanceX;
	var currX;
	var newX;
	
	if (!loop) {
		currX = 0;		
	}
	else {
		currX = currX;
	}
	
	if (isNegative(dX)) {
		if (currX > dX) {
			newX = currX - inc;
			obj.style.left = newX + 'px';
			setTimeout(function(){effectMoveByX(obj,inc,dX,newX,true);},0);
		}		
	}
	else {		
		if (currX < dX) {
			newX = currX + inc;
			obj.style.left = newX + 'px';
			setTimeout(function(){effectMoveByX(obj,inc,dX,newX,true);},0);
		}
	}
}

function effectMoveByY(obj,increment,distanceY,currY,loop) {
	if (typeof(obj) == 'string') obj = getObject(obj);	
	
	var inc = increment;
	var dY = distanceY;
	var currY;
	var newY;
	
	if (!loop) {
		currY = 0;
	}
	else {
		currY = currY;
	}	
	
	if (isNegative(dY)) {
		if (currY > dY) {
			newY = currY - inc;
			obj.style.top = newY + 'px';
			setTimeout(function(){effectMoveByY(obj,inc,dY,newY,true);},0);
		}
	}
	else {		
		if (currY < dY) {
			newY = currY + inc;
			obj.style.top = newY + 'px';
			setTimeout(function(){effectMoveByY(obj,inc,dY,newY,true);},0);
		}	
	}
}

function effectCloseWidth(obj,increment,width,minwd) {
	if (typeof(obj) == 'string') obj = getObject(obj);
	
	var inc = increment;
	var halfInc = inc/2;
	var width = width;
	var center = width/2;
	var minwd = minwd;
	
	var c = getChildren(obj);
	if (c.length > 0) {
		for (var i = 0; i < c.length; i++) {
			hide(c[i]);
		}
	}
	
	effectMoveByX(obj,halfInc,center);	
	effectDecWidth(obj,inc,width,minwd);
}

// CGF - FCS scripts

/* domReady function */
/*
 * (c)2006 Dean Edwards/Matthias Miller/John Resig
 * Special thanks to Dan Webb's domready.js Prototype extension
 * and Simon Willison's addLoadEvent
 *
 * For more info, see:
 * http://dean.edwards.name/weblog/2006/06/again/
 * http://www.vivabit.com/bollocks/2006/06/21/a-dom-ready-extension-for-prototype
 * http://simon.incutio.com/archive/2004/05/26/addLoadEvent
 * 
 * Thrown together by Jesse Skinner (http://www.thefutureoftheweb.com/)
 *
 *
 * To use: call addDOMLoadEvent one or more times with functions, ie:
 *
 *    function something() {
 *       // do something
 *    }
 *    addDOMLoadEvent(something);
 *
 *    addDOMLoadEvent(function() {
 *        // do other stuff
 *    });
 *
 */
 
function addDOMLoadEvent(func) {
   if (!window.__load_events) {
      var init = function () {
          // quit if this function has already been called
          if (arguments.callee.done) return;
      
          // flag this function so we don't do the same thing twice
          arguments.callee.done = true;
      
          // kill the timer
          if (window.__load_timer) {
              clearInterval(window.__load_timer);
              window.__load_timer = null;
          }
          
          // execute each function in the stack in the order they were added
          for (var i=0;i < window.__load_events.length;i++) {
              window.__load_events[i]();
          }
          window.__load_events = null;

          // clean up the __ie_onload event
          /*@cc_on @*/
          /*@if (@_win32)
              document.getElementById("__ie_onload").onreadystatechange = "";
          /*@end @*/
      };
   
      // for Mozilla/Opera9
      if (document.addEventListener) {
          document.addEventListener("DOMContentLoaded", init, false);
      }
      
      // for Internet Explorer
      /*@cc_on @*/
      /*@if (@_win32)
          document.write("<scr"+"ipt id=__ie_onload defer src=javascript:void(0)><\/scr"+"ipt>");
          var script = document.getElementById("__ie_onload");
          script.onreadystatechange = function() {
              if (this.readyState == "complete") {
                  init(); // call the onload handler
              }
          };
      /*@end @*/
      
      // for Safari
      if (/WebKit/i.test(navigator.userAgent)) { // sniff
          window.__load_timer = setInterval(function() {
              if (/loaded|complete/.test(document.readyState)) {
                  init(); // call the onload handler
              }
          }, 10);
      }
      
      // for other browsers
      window.onload = init;
      
      // create event function stack
      window.__load_events = [];
   }
   
   // add function to event stack
   window.__load_events.push(func);
}

//cookie functions
function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}


function ReadCookie(cookieName) {
 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 if (ind==-1 || cookieName=="") return ""; 
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length; 
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}


/* This function is used to delete cookies */
function deleteCookie(name,path,domain) {
  if (ReadCookie(name)) {
     document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function largeType() {
	var body = getTags(document,'body');
	body[0].style.fontSize = '15px';
	hide('fontsizeLarge');
	show('fontsizeSmall');
	deleteCookie('fontSize')
	SetCookie('fontSize', '15px');
}

function smallType() {
	var body = getTags(document,'body');
	body[0].style.fontSize = '12px';
	show('fontsizeLarge');
	hide('fontsizeSmall');
	deleteCookie('fontSize')
	SetCookie('fontSize', '12px');
}

//check for text cookie
function checkText(){
	var textCheck = ReadCookie('fontSize');
	if(textCheck){
		if(textCheck == '15px'){
			largeType();
		}
		else{
			smallType();
		}
	}
}
//call checkText function on dom ready
addDOMLoadEvent(checkText);


// add event listener to tabs on daf investment options page to show / hide detail content
function setInfoBlocks() {
	if (getObject('infoDetailContainer')) {	
		var links = getTags('infoDetailContainer','a');	
		for (var i = 0; i < links.length; i++) {	
			if (hasClass(links[i],'infoBtn') || hasClass(links[i],'infoBtnLrg')) {		
				if (links[i].addEventListener){
					links[i].addEventListener('click',showInfoBlock,false);
				}
				else{
					links[i].onclick = showInfoBlock;
				}	
			}
		}	
	}
}
//call setInfoBlocks function on dom ready
addDOMLoadEvent(setInfoBlocks); 

function showInfoBlock(e,caller) {
	if (!caller) caller = this;	

	var par = getParent(caller);
	var boxId = par.id;
	var detailId = boxId + 'Details';
	var container = getObject('infoDetailContainer');
	var blocks = getChildren(container);
	
	if (blocks != null) {
		for (var i = 0; i < blocks.length; i++) {
			if (hasClass(blocks[i],'infoBlockDetails')) {
				addClass(blocks[i],'hideBox');
			}
			if (hasClass(blocks[i],'infoBtnBox')) {
				if (hasClass(blocks[i],'infoBlockOn')) {
					removeClass(blocks[i],'infoBlockOn');
				}
				if (hasClass(blocks[i],'infoBlockOnLrg')) {
					removeClass(blocks[i],'infoBlockOnLrg');
				}				
			}
		}
	}
	
	caller.blur();
	addClass(container,'infoBlockBorder');
	
	// update button so that it looks like a tab
	if (boxId == 'infoBtn3'){
		addClass(par,'infoBlockOnLrg');
	}
	else {
		addClass(par,'infoBlockOn');
	}	
	
	// show detail content by removing the 'hideBox' class
	if (hasClass(detailId,'hideBox')) {
		removeClass(detailId,'hideBox');
	}
	
	var st = getScrollTop();
	if (st < 150) {
		scrollTo(0,150);
	}	
}


// show dhtml popups
function showPopup(hrefVal) {

	var b = getObject('popupBox');
	var c = getObject('content');
	var f = getObject('popupFrame');
	
	if (b != null && c != null && f != null) {
		showInfo(b,c,'popup','persist'); 
		updateFrame(f,hrefVal); 
	}
}


//add elements to the popupElements Div (if applicable)
function addPopupElements(){
	if(getObject('popupElements')){
		getObject('popupElements').innerHTML = '<div class=\"popup\" id=\"popupBox\"><div class=\"popupContent\"><iframe src=\"blank.shtml\" name=\"popupFrame\" id=\"popupFrame\" frameborder=\"0\"></iframe></div></div><div id=\"clearScreen\">&#160;</div><iframe src=\"blank.shtml\" frameborder=\"0\" scrolling=\"no\" id=\"ghost\" name=\"ghost\"></iframe>';
	}
}
//call addPopupElements function on dom ready
//addDOMLoadEvent(addPopupElements); 


function LeaveCGF(param_href, param_width, param_height, param_hasScroll, param_toolbars, param_resize) {
        
		if (confirm('You are about to leave the Fidelity Charitable Gift Fund website for a website that is unaffiliated with the Gift Fund. The Gift Fund has not been involved with the preparation of the content supplied at the unaffiliated site and does not guarantee or assume any responsibility for its content.'))
	       window.open(param_href,"","toolbar="+param_toolbars+",directories=0,status=0,menubar=0,location=0,scrollbars="+param_hasScroll+",resizable="+param_resize+",width="+param_width+",height="+param_height);
       else
	       return false;
}


function searchEvents(){
	if(getObject('globalSearch')){	
		//clear search text on focus
		var searchTxt = getObject('searchTxt');
		searchTxt.onfocus = function(){
			if(this.value == 'Search...'){
				this.value = '';
			}
		}	
		searchTxt.onblur = function(){
			if(this.value == ''){
				this.value = 'Search...';
			}
		}	
	}
}
//call searchBtnHover function on dom ready
addDOMLoadEvent(searchEvents); 


// add rollover state for all green form submit buttons
function addButtonRollover() {
	var buttons = getTags(document,'button');
	var btnClass;
	
	if (buttons != null) {
		for (var i = 0; i < buttons.length; i++) {
			if (hasClass(buttons[i],'btnGreen30')){
				btnClass = 'btnGreen30hover';
			}
			if (hasClass(buttons[i],'btnGreen80')){
				btnClass = 'btnGreen80hover';
			}
			if (hasClass(buttons[i],'btnGreen120')){
				btnClass = 'btnGreen120hover';
			}
			if (hasClass(buttons[i],'btnGreen170')){
				btnClass = 'btnGreen170hover';
			}			
						
			var overFn = function() { addClass(this,btnClass); }
			var outFn = function() { removeClass(this,btnClass); }
				
			if (buttons[i].addEventListener){
				buttons[i].addEventListener('mouseover',overFn,false);
				buttons[i].addEventListener('mouseout',outFn,false);
			}
			else{
				buttons[i].onmouseover = overFn;
				buttons[i].onmouseout = outFn;
			}			
		}
	}	
}
// call rollover on dom ready
addDOMLoadEvent(addButtonRollover);

/* metrics tracking - cookie and random number generat0r added 4/25/07 */
/*
 * New Code
 */
/*
 * Random number generator
 *
 */	
function generateRandomNumber(){

	var randomNumber = Math.random() * Math.pow(10, 20) 
						+ Math.random() * Math.pow(10, 20) 
						+ Math.random() * Math.pow(10, 20) 
						+ Math.random() * Math.pow(10, 20);

	return randomNumber;
}

/*
 * Random name with FCS_ identifier to identity 
 * non-authenticated, public site, visitos
 *
 */	
function generateName(){
	var name = "_CGF";
	return name;
}


/*
 * Following are cookie maintenance js functions
 * performing CREATE, READ & DELETE cookie functions
 *
 */	



/*
 * CREATE cookie function creates a cookie
 * based on name, value, days params,
 * each value can be manupilated per needs,
 * name is to identify each cookie,
 * value is to track number of visits,
 * days is to expire cookie after so and so days,
 * Note: days with -1 immediately deletes given cookie.
 *
 */	

var expiryDate=new Date();
expiryDate.setYear(expiryDate.getFullYear()+1000);


function createCookie(name,value,cookieExpiryDate) {
	if (cookieExpiryDate) {
		var expires = "; expires="+cookieExpiryDate.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires;
}


/*
 * READ cookie function reads the cookie list
 * if empty cookie list adds FCS cookie
 * if non-empty cookie list searches for FCS cookie
 * if non found creates new FCS cookie,
 * else updates FCS cookie with new value 
 * which is no of visits to the given page
 * Note: days with -1 immediately deletes given cookie.
 *
 */	

function readCookie() {
      var name="CGF";
	var isCreateCookie = false;
	var ca = document.cookie.split(';');
	var cookieText=document.cookie;
	if(ca!=null&&ca!=" "&&ca.length>0&&navigator.cookieEnabled){
		//alert(ca);
		if (cookieText.indexOf(name) != -1){
		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(name) != -1){
				var currentCookie = ca[i];
				//needed else swaps name for value
				if(currentCookie.indexOf("=")!=-1){
					var currentCookieName= currentCookie.substring(0,currentCookie.indexOf("="));
					//var currentCookieValue=currentCookie.substring(currentCookie.indexOf("=")+1,currentCookie.length);
					//currentCookieValue=Number(currentCookieValue)+1;
					//eraseCookie(currentCookieName);
					//createCookie(currentCookieName,currentCookieValue,expiryDate);
					//alert("Hello "+currentCookieName+"!!! thanks for visiting us again.");
					return;
				}else{
					var currentCookieName= currentCookie.substring(0,currentCookie.indexOf("="));
					var currentCookieValue=currentCookie.substring(currentCookie.indexOf("=")+1,currentCookie.length);
					eraseCookie(currentCookieName);
				}
			}else{
				isCreateCookie = true;
			}
		}

		}else{
			isCreateCookie = true;
		}

	}else if(ca==" "){
		//alert("Hello new user with no cookies");
		createCookie(generateName(),generateRandomNumber(),expiryDate);
		if(location.port!=null||location.port!=''){
			//location.href=location.protocol+"..//"+location.hostname+":"+location.port+"./"+location.pathname;
			location.href=location.protocol+"..//"+location.hostname+location.pathname;
			//alert("Am I right "+location.href);
		}else{
			location.href=location.protocol+"..//"+location.hostname+location.pathname;
			//alert("Am I right "+location.href);
		} 
		//return ;
	}

	if(isCreateCookie){
		//alert("Hello new user with cookies");
		createCookie(generateName(),generateRandomNumber(),expiryDate);
		if(location.port!=null||location.port!=''){
			//location.href=location.protocol+"..//"+location.hostname+":"+location.port+"./"+location.pathname;
			location.href=location.protocol+"..//"+location.hostname+location.pathname;
			//alert("Am I right "+location.href);
		}else{
			location.href=location.protocol+"..//"+location.hostname+location.pathname;
			//alert("Am I right "+location.href);
		} 
		//return ;
	} 

	//return ;
}


/*
 * DELETE cookie function deletes the FCS cookie. 
 * This function is written only for maintenance
 * only, we are not using this function currently,
 * but if there is need its available.
 *
 */	


function eraseCookie(name) {	
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		if(ca[i].indexOf(name)!=-1){
			var currentCookie = ca[i];
			if(currentCookie.indexOf("=")!=-1){
				var currentCookieName= currentCookie.substring(0,currentCookie.indexOf("="));
				var currentCookieValue=currentCookie.substring(currentCookie.indexOf("="),currentCookie.length);
				var expires = "; expires=-1";
				document.cookie = currentCookieName+"="+currentCookieValue+expires;
			}
		} 
	}	
}


/*

Work with Events

*/
	
	function addEvent(obj, evType, fn){
		if (obj.addEventListener){
			obj.addEventListener(evType, fn, true);
			return true;
		} else if (obj.attachEvent){
			var r = obj.attachEvent("on"+evType, fn);
			return r;
		} else {
			return false;
		}
	}

//Web meterics project code end



/*

Work with Events

*/	
	function addEvent(obj, evType, fn){
		if (obj.addEventListener){
			obj.addEventListener(evType, fn, true);
			return true;
		} else if (obj.attachEvent){
			var r = obj.attachEvent("on"+evType, fn);
			return r;
		} else {
			return false;
		}
	}

/* end of metrics tracking */
 
 
