if (typeof window.addEventListener != 'undefined') {
	window.addEventListener('load', fncPageLoad, false);
}
else if (typeof document.addEventListener != 'undefined') {
	document.addEventListener('load', fncPageLoad, false);
}
else if (typeof window.attachEvent != 'undefined') {
	window.attachEvent('onload', fncPageLoad);
}
else {
	if(typeof window.onload == 'function') {
		var onload_existing = onload;
		window.onload = function() {
			onload_existing();
			fncPageLoad();
		};
	}
	else {
		window.onload = fncPageLoad;
	}
}

function fncPageLoad() {
  if (typeof(fncPageOnload) != "undefined") {
    fncPageOnload();
  }
}





function fncToggleSolutionDescription(intSolutionID) {
  if (document.getElementById('idSolutionDescriptionContent')) {
    if (document.getElementById('idSolutionDescriptionContent').style.display != "none") {
      fncFadeUp('idSolutionDescriptionContent');
      //document.getElementById('idSolutionDescriptionContent').style.display = "none";
      fncAddClass(document.getElementById('idSolutionDescriptionTrigger'),'clsHidden');
      document.getElementById('idSolutionDescriptionTrigger').innerHTML = document.getElementById('idSolutionDescriptionTrigger').innerHTML.replace("Hide","Show");
      fncSetCookie ('sintrohide_'+intSolutionID, '1', 'never', '/');
    }
    else {
      fncAppearDown('idSolutionDescriptionContent');
      //document.getElementById('idSolutionDescriptionContent').style.display = "block";
      fncRemoveClass(document.getElementById('idSolutionDescriptionTrigger'),'clsHidden');
      document.getElementById('idSolutionDescriptionTrigger').innerHTML = document.getElementById('idSolutionDescriptionTrigger').innerHTML.replace("Show","Hide");
      fncKillCookie ('sintrohide_'+intSolutionID, '/');
    }
  }
}


function fncToggleResourceMap() {
  if (document.getElementById('idRLResourceMap')) {
    if (document.getElementById('idRLResourceMap').style.display != "none") {
      fncFadeUp('idRLResourceMap');
    }
    else {
      fncAppearDown('idRLResourceMap');
    }
  }
}



function fncTrack(strWhatToTrack, strTrackAction, intItemID, strPartnerUserID, strPartnerID) {
  if (document.getElementById('idTracker')) {
    var dtNow = new Date();
    var dtStart = new Date(2000,0,1);
    var intDiffMS = dtNow-dtStart;
    intDiffMS = Math.round(intDiffMS/1000);
    
    var strTrackerURL = "/dyn/track.asp?wtt=" + strWhatToTrack + "&a=" + strTrackAction + "&id=" + intItemID + "&puid=" + strPartnerUserID + "&pid=" + strPartnerID;
    // alert(strTrackerURL);
    document.getElementById('idTracker').src = strTrackerURL;
  }
}



function fncEmbedVideo(strVideoURL, strVideoImage, strVideoContainerID, intWidth, intHeight) {
  if (document.getElementById(strVideoContainerID)) {
    var strElementName = strVideoContainerID + "Video";
    var strElementID = strVideoContainerID + "VideoID";
    //var intWidth = 240;
    //var intHeight = 180;
    var strIDToPlace = strVideoContainerID;
    var strPlayerCodebaseURL = "/includes/";
    var blnStartPlayingOnload = "false";
    
		var strEmbedHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+ intWidth + '" height="' + intHeight + '" id="' + strElementID + '" name="' + strElementName + '" wmode="transparent"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="' + strPlayerCodebaseURL + 'flvPlayer.swf?flvToPlay=' + strVideoURL + '&startImage=' + strVideoImage + '&hiddenGui=true&showScaleModes=false&smoothVideo=true&autoStart=' + blnStartPlayingOnload + '&allowFullScreen=false" /> <param name="loop" value="false" /> <param name="menu" value="false" /> <param name="quality" value="high" /> <param name="wmode" value="transparent" /> <param name="scale" value="snoscale" /> <param name="bgcolor" value="#000000" /> <embed src="' + strPlayerCodebaseURL + 'flvPlayer.swf?flvToPlay=' + strVideoURL + '&startImage=' + strVideoImage + '&hiddenGui=true&showScaleModes=false&smoothVideo=true&autoStart=' + blnStartPlayingOnload + '&allowFullScreen=false" loop="false" menu="false" quality="high" scale="noscale" width="' + intWidth + '" height="' + intHeight + '" name="' + strElementName + '" bgcolor="#000000" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object>';
    
    document.getElementById(strIDToPlace).innerHTML = strEmbedHTML;
    document.getElementById(strIDToPlace).style.display = "block";
  }
}


function fncToggleTab(strTabOpen, strTabClose) {
  document.getElementById('idTab'+strTabClose).className = "clsTab";
  document.getElementById('idTab'+strTabOpen).className = "clsTab clsTabSelected";
  document.getElementById('idTab' + strTabClose + 'Contents').style.display = "none";
  document.getElementById('idTab' + strTabOpen + 'Contents').style.display = "block";
}



function fncAppearDown(strID) {
  // for this to work strID must have INLINE display=none (not in CSS)
  if (document.getElementById(strID)) {
    new Effect.Appear(strID, {duration:0.5});
    new Effect.BlindDown(strID, {duration:0.5});
  }
}

function fncFadeUp(strID) {
  if (document.getElementById(strID)) {
    new Effect.BlindUp(strID, {duration:0.5});
    new Effect.Fade(strID, {duration:0.5});
  }
}


function fncRoundPanel(strID) {
  var oPanelDiv = $('idMainPanel');
  if (oPanelDiv) {
    var oRoundDiv = new Element('div');
    oRoundDiv.className = "clsMainPanelRoundTR";
    Element.insert( oPanelDiv, {'top':oRoundDiv} );
    var oRoundDiv = new Element('div');
    oRoundDiv.className = "clsMainPanelRoundTL";
    Element.insert( oPanelDiv, {'top':oRoundDiv} );
    var oRoundDiv = new Element('div');
    oRoundDiv.className = "clsMainPanelRoundBL";
    Element.insert( oPanelDiv, {'bottom':oRoundDiv} );
    var oRoundDiv = new Element('div');
    oRoundDiv.className = "clsMainPanelRoundBR";
    Element.insert( oPanelDiv, {'bottom':oRoundDiv} );
  }
}



function fncShowHelp(oSrc,strHelpMessage,intXOffset,intYOffset) {
  var intLeft = fncGetAbsoluteX(oSrc);
  var intTop = fncGetAbsoluteY(oSrc);
  if (document.getElementById("idHelpBox")) {
    document.getElementById("idHelpBox").style.display = "none";
    if (document.getElementById("idHelpBoxIframeContainer")) {
      document.getElementById("idHelpBoxIframeContainer").style.display = "none";
    } 
    document.getElementById("idHelpBox").style.top = (intTop+intYOffset) + "px";
    document.getElementById("idHelpBox").style.left = (intLeft+intXOffset) + "px";
    
    var strHelpHTML = '<div class="clsInner">' + unescape(strHelpMessage) + '</div><div class="clsClose"><a href="#" onclick="fncHideHelp(); return false;" title="Close this help window">close</a></div>';  
    
    document.getElementById("idHelpBox").innerHTML = strHelpHTML;
    document.getElementById("idHelpBox").style.display = "block";
    
    if (document.all) {
      var intWidth = fncGetWidth(document.getElementById("idHelpBox"));
      var intHeight = fncGetHeight(document.getElementById("idHelpBox"));
      document.getElementById("idHelpBoxIframe").style.width = intWidth + "px";
      document.getElementById("idHelpBoxIframe").style.height = intHeight + "px";
      document.getElementById("idHelpBoxIframeContainer").style.top = (intTop+intYOffset) + "px";
      document.getElementById("idHelpBoxIframeContainer").style.left = (intLeft+intXOffset) + "px";
      document.getElementById("idHelpBoxIframeContainer").style.width = intWidth + "px";
      document.getElementById("idHelpBoxIframeContainer").style.height = intHeight + "px";
      document.getElementById("idHelpBoxIframeContainer").style.display = "block";
    }
  } 
  return false;
}

function fncHideHelp() {
  if (document.getElementById("idHelpBox")) {
     document.getElementById("idHelpBox").style.display = "none";
     new Effect.BlindUp(document.getElementById('idHelpBox'), {duration:0.25});
	//$('#idHelpBox').slideUp();
  }
  if (document.getElementById("idHelpBoxIframeContainer")) {
    document.getElementById("idHelpBoxIframeContainer").style.display = "none";
  } 
}




function fncViewContent(oSrc, intContentID, blnAllowEdit) {
  var winContent = fncPopupPage("/admin/content-popup.asp?id=" + intContentID + "&blnAllowEdit=" + blnAllowEdit, 600, 400);
  return false;
}




function fncChkToggle(oChk,oChkboxes) {
  var oForm = oChk.form;
  var blnChecked = oChk.checked;
  if (typeof(oChkboxes) != "undefined") {
    for (var i=0;i<oChkboxes.length;i++) {
      oChkboxes[i].checked = blnChecked;
    }
  }
}

function fncWriteCalPopup(strTextboxID) {
  document.write('<img src="/images/_cal.gif" id="' + strTextboxID + 'Button" width="16" height="16" alt="Pop-up Calendar" border="0" tabindex="-1" style="margin-left:-11px;margin-right:10px;cursor:pointer;">');
  Calendar.setup({inputField:strTextboxID, ifFormat:"%m/%e/%Y", button:strTextboxID + "Button", weekNumbers:false, showOthers:true, step:1});
}


function fncRowHilite(oRow) {
  fncAddClass(oRow, "clsHover");
}

function fncRowUnHilite(oRow) {
  fncRemoveClass(oRow, "clsHover");
}


function fncPopupPage(strURL, intWidth, intHeight) {
  if (strURL.length > 0) {
    var winPopup = window.open(strURL, "winPopup", "width=" + intWidth + ",height=" + intHeight + ",menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");
  }
}


function fncExpandTextarea(strTextareaID) {
  var oElement = document.getElementById(strTextareaID);
  if (oElement) {
    if (oElement.rows) {
      oElement.rows = oElement.rows + 5;
    }
  }
}

function fncAddElement(oSrc, strValue) {
  var newdiv = document.createElement('div');
  newdiv.innerHTML = strValue;
  oSrc.appendChild(newdiv);
}

function fncReplaceElement(oSrc, strValue) {
  var newdiv = document.createElement('div');
  newdiv.innerHTML = strValue;
  oSrc.insertAdjacentElement("afterEnd",newdiv)
  //oSrc.appendChild(newdiv);
  fncRemoveElement(oSrc);
}

function fncRemoveElement(oSrc) {
  oSrc.parentNode.removeChild(oSrc);
}

function fncEscape(strSource) {
  var strEscaped = escape(strSource);
  strEscaped = strEscaped.replace(/\//g,"%2F");
  strEscaped = strEscaped.replace(/\?/g,"%3F");
  strEscaped = strEscaped.replace(/=/g,"%3D");
  strEscaped = strEscaped.replace(/&/g,"%26");
  strEscaped = strEscaped.replace(/@/g,"%40");
  return strEscaped;
} 


function fncToggleStyleCell(intStyle) {
  for (var i=1;i<=10;i++) {
    if (document.getElementById('idStyleCell' + i)) {
      if (intStyle == i) {
        fncAddClass(document.getElementById('idStyleCell' + i), "clsSelected");
      }
      else {
        fncRemoveClass(document.getElementById('idStyleCell' + i), "clsSelected");
      }
    }
  }
}


function fncLoopToggleSelects(blnMakeVisible) {
 if (document.body.innerHTML.length < 2000000) {
   var DocAll = document.getElementsByTagName("SELECT");
   for (index=0; index<DocAll.length; index++ ) {
     if (DocAll[index].tagName == "SELECT") {
      if (blnMakeVisible) {
        DocAll[index].style.visibility = "visible";
      }
      else {
        DocAll[index].style.visibility = "hidden";
      } 
     }
   }
 }
}



function fncAddClass(oElement, strClassName) {
  if (typeof(oElement) == "object" && strClassName.length > 0) {
    if (typeof(oElement.className) == "string") {  
      var strCurrentClassName = oElement.className;
      if (strCurrentClassName.indexOf(strClassName) < 0) {
        if (strCurrentClassName.length > 1) {
          strClassName = strCurrentClassName + " " + strClassName;
        }        
        oElement.className = strClassName;
      }
    }
  }
}

function fncRemoveClass(oElement, strClassName) {
  if (typeof(oElement) == "object" && strClassName.length > 0) {
    if (typeof(oElement.className) == "string") {  
      var strCurrentClassName = oElement.className;
      if (strCurrentClassName.indexOf(strClassName) >= 0) {
        strNewClassName = fncRemoveClassRecursive(" " + strCurrentClassName + " ", " " + strClassName + " ");
        if (strNewClassName.indexOf(" ") == 0) { strNewClassName = strNewClassName.substring(1); }
        if (strNewClassName.lastIndexOf(" ") == strNewClassName.length-1) { strNewClassName = strNewClassName.substring(0,strNewClassName.length-1); }
        oElement.className = strNewClassName;
      }
    }
  }
}

function fncRemoveClassRecursive(strSource, strSubstrToRemove) {
  var intIndex = strSource.indexOf(strSubstrToRemove);
  var strReturn = "";
  if (intIndex == -1) return strSource;
  strReturn += strSource.substring(0,intIndex) + " " + fncRemoveClassRecursive(strSource.substring(intIndex + strSubstrToRemove.length), strSubstrToRemove);
  return strReturn;
}



function fncSetState(strCountryID, strStateID) {
  var strCountry = "";
  if (document.getElementById(strCountryID)) {
    strCountry = document.getElementById(strCountryID).value;
    document.getElementById(strStateID + 'USA').style.display = "none";
    document.getElementById(strStateID + 'USA').disabled = true;
    document.getElementById(strStateID + 'CA').style.display = "none";
    document.getElementById(strStateID + 'CA').disabled = true;
    document.getElementById(strStateID + 'Other').style.display = "none";
    document.getElementById(strStateID + 'Other').disabled = true;
    
    if (strCountry == "Canada") {
      document.getElementById(strStateID + 'CA').style.display = "inline";
      document.getElementById(strStateID + 'CA').disabled = false;
    }
    else if (strCountry == "USA") {
      document.getElementById(strStateID + 'USA').style.display = "inline";
      document.getElementById(strStateID + 'USA').disabled = false;
    }
    else {
      document.getElementById(strStateID + 'Other').style.display = "inline";
      document.getElementById(strStateID + 'Other').disabled = false;
    }
  }
}


function fncGetAbsoluteX(oElement) {
  // Utility function to get the absolute X-coordinate of an object on the page
  if (typeof(oElement) == "string") {
    oElement = document.getElementById(oElement);
  }
  if (typeof(oElement) == "object") {
    var intCoords = {x: 0};
    while (oElement) {
      intCoords.x += oElement.offsetLeft;
      oElement = oElement.offsetParent;
    }
    return intCoords.x;
  }
}
function fncGetAbsoluteY(oElement) {
  // Utility function to get the absolute Y-coordinate of an object on the page
  if (typeof(oElement) == "string") {
    oElement = document.getElementById(oElement);
  }
  if (typeof(oElement) == "object") {
    var intCoords = {y: 0};
    while (oElement) {
      intCoords.y += oElement.offsetTop;
      oElement = oElement.offsetParent;
    }
    return intCoords.y;
  }
}

function fncGetWidth(oElement) {
  // Utility function to get the width of an object on the page
  if (typeof(oElement) == "string") {
    oElement = document.getElementById(oElement);
  }
  if (typeof(oElement) == "object") {
  	if (oElement.style.pixelWidth) {
  		return oElement.style.pixelWidth;
  	}
    if (oElement.style.width) {
        return oElement.style.width;
    } 
    return oElement.offsetWidth;
  }
}
function fncGetHeight(oElement) {
  // Utility function to get the height of an object on the page
  if (typeof(oElement) == "string") {
    oElement = document.getElementById(oElement);
  }
  if (typeof(oElement) == "object") {
  	if (oElement.style.pixelHeight) {
  		return oElement.style.pixelHeight;
  	}
    if (oElement.style.height) {
        return oElement.style.height;
    }
    return oElement.offsetHeight;
  }
}


/* BOUNCE FUNCTIONS */

function fncGetElement(id){
  if(document.getElementById){
    return document.getElementById(id);
  }
  else if(document.layers){
    return document.layers[id];
  }
  else if(document.all){
    return document.all[id];
  }
  else{
    return false;
  }
}

function fncGetElementStyle(id){
  if(document.getElementById){
    return document.getElementById(id).style;
  }
  else if(document.layers){
    return document.layers[id];
  }
  else if(document.all){
    return document.all[id].style;
  }
  else{
    return false;
  }
}//getElStyle

function fncGetScrollNN(){
  return window.pageYOffset;
}//fncGetScrollNN

function fncGetScrollHack(){
  //seems damn new browsers set one or the other, opposite stays 0
  //if this behavior changes will have to add more code forks
  //many set document.documentElement.scrollTop
  //NN sets window.document.body.scrollTop
  //and damn Opera sets both!!!!
  if(window.document.documentElement.scrollTop){
    return window.document.documentElement.scrollTop;
  }
  if(window.document.body.scrollTop){
    return window.document.body.scrollTop;
  }
  return 0;
}//fncGetScrollHack

function fncGetBrowserType(){
  if(typeof(document.documentElement)!="undefined") {
    if(typeof(document.documentElement.scrollTop)!="un defined") return 3;
  }
  //Don't test for document.body.scrollTop
  //WebTV has a static 0 but uses 'window.pageYOffset'!
  if(typeof(window.pageYOffset)!="undefined") return 1;
  return 0;
}//browserType

function fncJump(){
  var me=this;
  me.dyW=me.getD();
  me.hStyle.top=me.dyW+me.yOfs+me.units; //relocate
  setTimeout(me.id + "_x.sticky()",5);
}//fncJump

function fncBounce(){
  var me=this;
  me.dyW=me.getD();
  var t=me.dy;
  
  if(me.dyW!=me.dy){
    var pos=(me.dyW-me.dy) * .2;
    pos>0 ? pos=Math.ceil(pos) : pos=Math.floor(pos);
    me.dy+=pos;
    t=me.dy + me.yOfs;
    me.hStyle.top= t + me.units;
  }
  setTimeout(me.id + "_x.sticky()",5);
}//fncBounce

function fncMakeSticky(id,useBounce){
  var objSrc=fncGetElement(id);
  var bt=fncGetBrowserType();
  objSrc.getD = bt ? (bt>1 ? fncGetScrollHack : fncGetScrollNN ) : void(0);
  objSrc.units = bt>1 ? "px" : "";
  objSrc.hStyle=fncGetElementStyle(id); //handle to style
  //el's init yOfs
  objSrc.yOfs=(typeof(objSrc.pageY)=='number' ? objSrc.pageY : 0);
  //WebTV fix
  objSrc.yOfs+= (typeof(objSrc.offsetTop)=='number' ? objSrc.offsetTop: 0);
  objSrc.dy=0; //el's delta y init as zero
  objSrc.sticky=(useBounce ? fncBounce : fncJump ); //set sticky type
  window[objSrc.id+"_x"]=objSrc; //make a universal document handle
  objSrc.sticky();
}//makeSticky

/*
### HTML ###

<body onload="makeStick('theElementID',1)">

<div id="theElementID">This will now be sticky</div> ...

#########
If you leave off the 2nd parameter or set to '0' on fncMakeSticky() and the
element will jump to the scroll position similar to the CSS 'position:
fixed' or set to '1' to have the element 'slide' into position with a
dramatic bounce.

If you have several elements to make sticky then I suggest to make a
function like:

function bootstrap(){
fncMakeSticky('anElememnt');
fncMakeSticky('anotherElememnt');
fncMakeSticky('yetAnotherElememnt');
}    
*/



/* FORM FUNCTIONS */

function fncValidateAndSubmit(oForm) {
  if (fncValidateForm(oForm)) {
    oForm.submit();
  }
}

var blnDoFancyFields = true;
function fncValidateForm(oForm) {
	
	
  var strErrors = "";
  var oElements = oForm.elements;
  if (arguments.length >= 2) {
    if (arguments[1] == true) {
      blnDoFancyFields = true;
    }
  }
  for (var i=0;i<oElements.length;i++) {
    // Validate each element using the fncValidFormField function which will
    //   return any errors found.  
    strErrors = strErrors + fncValidFormField(oElements[i]);
  }
  
  if (strErrors.length > 0) {
    // Report any errors and return false
    alert("Please correct these errors before continuing: \n" + strErrors);
    return false;
  }
  else {
    // All elements have been validated, return true
    return true;
  }
}

function fncValidFormField(oElement) {
  // Returns error message if invalid
  // Form Elements can have the following additional attributes (which may lead to invalid XHTML)
  //   required - makes sure there is a value provided or selected
  //   validphone - ensures valid US/Canadian phone number
  //   validemail - ensures valid email address
  // Does not validate checkbox lists or radio buttons  *** Added checkbox and radio validation 2/24/10
  var strElementError = "";
  var strNiceName = oElement.name;
  var blnAllRequired = false;
  
  if (oElement.form) {
    if (oElement.form.getAttribute("required")) {
      blnAllRequired = true;
    }
  }
  
  if (typeof(blnDoFancyFields) == "undefined") {
    blnDoFancyFields = false;
  }
  if (arguments.length >= 2) {
    if (arguments[1] == true) {
      blnDoFancyFields = true;
    }
  }
  
  if (oElement.getAttribute("nicename")) {
    strNiceName = oElement.getAttribute("nicename");
  }
  
  if (!oElement.disabled && oElement.getAttribute("type") != "hidden") {
    
    // Validate Required Elements
    if (blnAllRequired || oElement.getAttribute("required")) {
      
	  // Check Radio Buttons and Checkboxes
	  if ( oElement.type == "radio" || oElement.type == "checkbox" ) {
		  
		  var isChecked = 0;
		  var temp_arr=document.getElementsByName(oElement.name);
		  var temp_arr_ln=temp_arr.length; 
		  for(var i=0;i<temp_arr_ln;i++){ 
			if(temp_arr[i].checked) {
			  isChecked = 1;	
			}
		  } 
		  if (isChecked == 0 ) {
			 strElementError = "Please select a " + strNiceName;
		  }
	  }
	  
      // Check Required Text Elements (Text, Textbox, Textarea)
      if ((oElement.type.indexOf("text") >= 0 || oElement.type.indexOf("password") >= 0) && oElement.value.length <= 0) {
        strElementError = "Please provide a response for " + strNiceName;
      }
      
      // Check Required Drop-Down Boxes
      if (oElement.type.indexOf("select") >= 0) {
        var intNumSelected = 0;
        for (var j=0;j<oElement.length;j++) {
          if (oElement[j].selected && oElement[j].value.length > 0) {
            intNumSelected++;
          }
        }
          
        if (intNumSelected == 0) {
          strElementError = "Please select a response for " + strNiceName;
        }
      }
    }
    
    // Validate Phone Number
    if (oElement.getAttribute("validphone") && oElement.value.length > 0) {
      if (!fncValidUSCanadaPhone(oElement.value)) {
        strElementError = "Please provide a valid " + strNiceName;
      }
    }
    
    // Validate Email Addresses
    if (oElement.getAttribute("validemail") && oElement.value.length > 0) {
      if (!fncValidEmail(oElement.value)) {
        strElementError = "Please provide a valid " + strNiceName;
      }
    }
    if (oElement.getAttribute("validintlphone") && oElement.value.length > 0) {
      if (!fncValidIntlPhone(oElement.value)) {
        strElementError = "Please provide a valid " + strNiceName;
      }
    }
  }
  
  if (strElementError.length > 0) {
    strElementError = "\n - " + strElementError; 
    if (blnDoFancyFields) { fncAddClass(oElement, "clsFormInputInvalid"); }
  }
  else {
    if (blnDoFancyFields) { fncRemoveClass(oElement, "clsFormInputInvalid"); }
  }
  return strElementError;
}

function fncValidEmail(strEmail) {
	strInvalidChars = " /:,;'";
	if (strEmail == "" ) {
		return false;
	}
	for ( i = 0; i<strInvalidChars.length;  i++) {
		chrBadChar=strInvalidChars.charAt(i);
		if (strEmail.indexOf(chrBadChar,0) > -1) {
			return false;
		}
	}
	intPos=strEmail.indexOf("@",1)
	if (intPos == -1 ) {
		return false;
	}
	if (strEmail.indexOf("@",intPos+1) > -1 ) {
		return false;
	}
	intPeriodPos=strEmail.indexOf(".",intPos)
	if (intPeriodPos == -1 ) {
		return false;
	}
	if (intPeriodPos+3 > strEmail.length ) {
		return false;
	}
	return true;
}

function fncValidUSCanadaPhone(strPhone) {
	if (strPhone.match(/\s*\(?\s*[2-9]\d{2}\s*\)?\s*([-.]?)\s*\d{3}\s*([-.]?)\s*\d{4}\s*/)) {
	  if (fncValidIntlPhone(strPhone)) {
		  return true;
	  }
	}
	return false;
}

function fncValidIntlPhone(strPhone) {
	strPhone = strPhone.replace(/[\s\(\)\-\.]/g,"");
	if (strPhone.length >= 10) {
	  return true;
	}
}



var tmrSessionExtend;

function fncSessionExtendPing() {
  var strURL = "/includes/ping.asp";
  xmlHttp=fncGetXmlHttpObject()
  if (xmlHttp==null) {
    // alert ("Browser does not support HTTP Request");
    return;
  } 
  xmlHttp.onreadystatechange = fncSessionExtendPingResponse;
  xmlHttp.open("GET", strURL, true);
  xmlHttp.send(null);
} 

function fncSessionExtendPingResponse() { 
  var intTimer = 18; // minutes until session extended
  clearTimeout(tmrSessionExtend);
  tmrSessionExtend = setTimeout("fncSessionExtendPing()",(intTimer*60*1000));
  var strResponse;
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
    var strResponse = xmlHttp.responseText;
    
  } 
} 

function fncGetXmlHttpObject() { 
  var objXMLHttp=null;
  if (window.XMLHttpRequest) {
    objXMLHttp=new XMLHttpRequest();
  }
  else if (window.ActiveXObject) {
    objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  return objXMLHttp;
} 



function fncSetCookie (name, value, exp, path) {
 /*
    INPUT
      name (string) - name of the cookie
      value (string) - value of the cookie
      exp (string) - default is "never"
                     if "never" it sets exp to "Thu, 7 Dec 2113 01:00:00 UTC"
                     if "exp" it sets exp to "Fri, 13 Apr 1970 01:00:00 UTC"
                     if int (ie "5", "20", "60000") it translates to int hours from now
                     if valid GMT date then it uses that as exp
                     else it defaults to 840 hours (5 weeks)
      path (string)
 */
  if(exp == "") {
    exp = "never";
  }
  if (typeof(exp) == 'string') {
    if (exp == 'never') { 
      var strExp = "Thu, 7 Dec 2113 01:00:00 UTC";
    }
    else if (exp == 'exp' || exp == 'now') { 
      var strExp = "Fri, 13 Apr 1970 01:00:00 UTC";
    }
  }
  else {
    if (Date.parse(exp)) {
     var strExp = exp;
    }
    else {
      exp = exp*1;
      if (isNaN(exp)) {
       var strExp = (new Date((new Date()).getTime() + 840*3600000)).toGMTString();
      }
      else {
       var strExp = (new Date((new Date()).getTime() + exp*3600000)).toGMTString();
      }
    }
  }
  if (typeof(strExp) == "undefined") {
    var strExp = (new Date((new Date()).getTime() + 840*3600000)).toGMTString();
  }
  document.cookie = name + '=' + escape(value) + ((strExp)?(';expires=' + strExp):'') + ((path)?';path=' + path:'');
}



function fncReadCookie(name) {
  var firstChar, lastChar;
  var theBigCookie = document.cookie;
  firstChar = theBigCookie.indexOf(name);
  if(firstChar != -1) {
    firstChar += name.length + 1;
    lastChar = theBigCookie.indexOf(';', firstChar);
    if(lastChar == -1) lastChar = theBigCookie.length;
    return unescape(theBigCookie.substring(firstChar, lastChar));
  }
  else {
    return false;
  }
}



function fncKillCookie(name, path) {
 /*
    REQUIRED MODULES
      "fncReadCookie" function
      "fncSetCookie" function
 */
  var value = fncReadCookie(name);
  if(value) {
    fncSetCookie(name, '', 'exp')    
  }
}



// used by dateAdd, dateDiff, datePart, weekdayName, and monthName
// note: less strict than VBScript's isDate, since JS allows invalid dates to overflow (e.g. Jan 32 transparently becomes Feb 1)
function isDate(p_Expression){
	return !isNaN(new Date(p_Expression));		// <<--- this needs checking
}


// REQUIRES: isDate()
function dateAdd(p_Interval, p_Number, p_Date){
	if(!isDate(p_Date)){return "invalid date: '" + p_Date + "'";}
	if(isNaN(p_Number)){return "invalid number: '" + p_Number + "'";}	

	p_Number = new Number(p_Number);
	var dt = new Date(p_Date);
	switch(p_Interval.toLowerCase()){
		case "yyyy": {// year
			dt.setFullYear(dt.getFullYear() + p_Number);
			break;
		}
		case "q": {		// quarter
			dt.setMonth(dt.getMonth() + (p_Number*3));
			break;
		}
		case "m": {		// month
			dt.setMonth(dt.getMonth() + p_Number);
			break;
		}
		case "y":		// day of year
		case "d":		// day
		case "w": {		// weekday
			dt.setDate(dt.getDate() + p_Number);
			break;
		}
		case "ww": {	// week of year
			dt.setDate(dt.getDate() + (p_Number*7));
			break;
		}
		case "h": {		// hour
			dt.setHours(dt.getHours() + p_Number);
			break;
		}
		case "n": {		// minute
			dt.setMinutes(dt.getMinutes() + p_Number);
			break;
		}
		case "s": {		// second
			dt.setSeconds(dt.getSeconds() + p_Number);
			break;
		}
		case "ms": {		// second
			dt.setMilliseconds(dt.getMilliseconds() + p_Number);
			break;
		}
		default: {
			return "invalid interval: '" + p_Interval + "'";
		}
	}
	return dt;
}



// REQUIRES: isDate()
// NOT SUPPORTED: firstdayofweek and firstweekofyear (defaults for both)
function dateDiff(p_Interval, p_Date1, p_Date2, p_firstdayofweek, p_firstweekofyear){
	if(!isDate(p_Date1)){return "invalid date: '" + p_Date1 + "'";}
	if(!isDate(p_Date2)){return "invalid date: '" + p_Date2 + "'";}
	var dt1 = new Date(p_Date1);
	var dt2 = new Date(p_Date2);

	// get ms between dates (UTC) and make into "difference" date
	var iDiffMS = dt2.valueOf() - dt1.valueOf();
	var dtDiff = new Date(iDiffMS);

	// calc various diffs
	var nYears  = dt2.getUTCFullYear() - dt1.getUTCFullYear();
	var nMonths = dt2.getUTCMonth() - dt1.getUTCMonth() + (nYears!=0 ? nYears*12 : 0);
	var nQuarters = parseInt(nMonths/3);	//<<-- different than VBScript, which watches rollover not completion
	
	var nMilliseconds = iDiffMS;
	var nSeconds = parseInt(iDiffMS/1000);
	var nMinutes = parseInt(nSeconds/60);
	var nHours = parseInt(nMinutes/60);
	var nDays  = parseInt(nHours/24);
	var nWeeks = parseInt(nDays/7);


	// return requested difference
	var iDiff = 0;		
	switch(p_Interval.toLowerCase()){
		case "yyyy": return nYears;
		case "q": return nQuarters;
		case "m": return nMonths;
		case "y": 		// day of year
		case "d": return nDays;
		case "w": return nDays;
		case "ww":return nWeeks;		// week of year	// <-- inaccurate, WW should count calendar weeks (# of sundays) between
		case "h": return nHours;
		case "n": return nMinutes;
		case "s": return nSeconds;
		case "ms":return nMilliseconds;	// millisecond	// <-- extension for JS, NOT available in VBScript
		default: return "invalid interval: '" + p_Interval + "'";
	}
}



// REQUIRES: isDate(), dateDiff()
// NOT SUPPORTED: firstdayofweek and firstweekofyear (does system default for both)
function datePart(p_Interval, p_Date, p_firstdayofweek, p_firstweekofyear){
	if(!isDate(p_Date)){return "invalid date: '" + p_Date + "'";}

	var dtPart = new Date(p_Date);
	switch(p_Interval.toLowerCase()){
		case "yyyy": return dtPart.getFullYear();
		case "q": return parseInt(dtPart.getMonth()/3)+1;
		case "m": return dtPart.getMonth()+1;
		case "y": return dateDiff("y", "1/1/" + dtPart.getFullYear(), dtPart);			// day of year
		case "d": return dtPart.getDate();
		case "w": return dtPart.getDay();	// weekday
		case "ww":return dateDiff("ww", "1/1/" + dtPart.getFullYear(), dtPart);		// week of year
		case "h": return dtPart.getHours();
		case "n": return dtPart.getMinutes();
		case "s": return dtPart.getSeconds();
		case "ms":return dtPart.getMilliseconds();	// millisecond	// <-- extension for JS, NOT available in VBScript
		default: return "invalid interval: '" + p_Interval + "'";
	}
}


// REQUIRES: isDate()
// NOT SUPPORTED: firstdayofweek (does system default)
function weekdayName(p_Date, p_abbreviate){
	if(!isDate(p_Date)){return "invalid date: '" + p_Date + "'";}
	var dt = new Date(p_Date);
	var retVal = dt.toString().split(' ')[0];
	var retVal = Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday')[dt.getDay()];
	if(p_abbreviate==true){retVal = retVal.substring(0, 3)}	// abbr to 1st 3 chars
	return retVal;
}
// REQUIRES: isDate()
function monthName(p_Date, p_abbreviate){
	if(!isDate(p_Date)){return "invalid date: '" + p_Date + "'";}
	var dt = new Date(p_Date);	
	var retVal = Array('January','February','March','April','May','June','July','August','September','October','November','December')[dt.getMonth()];
	if(p_abbreviate==true){retVal = retVal.substring(0, 3)}	// abbr to 1st 3 chars
	return retVal;
}



if (!document.all) {
HTMLElement.prototype.insertAdjacentElement=function(where,parsedNode){
switch(where){
case "beforeBegin":
this.parentNode.insertBefore(parsedNode,this);
break;
case "afterBegin":
this.insertBefore(parsedNode,this.firstChild);
break;
case "beforeEnd":
this.appendChild(parsedNode);
break;
case "afterEnd":
if(this.nextSibling)
this.parentNode.insertBefore(parsedNode,this.nextSibling);
else
this.parentNode.appendChild(parsedNode);
break;
}
}
HTMLElement.prototype.insertAdjacentHTML=function(where,htmlStr){
var r=this.ownerDocument.createRange();
r.setStartBefore(this);
var parsedHTML=r.createContextualFragment(htmlStr);
this.insertAdjacentElement(where,parsedHTML);
}
HTMLElement.prototype.insertAdjacentText=function(where,txtStr){
var parsedText=document.createTextNode(txtStr);
this.insertAdjacentElement(where,parsedText);
}
}


// ADDED MN 05/14/09 //

function htmlChange(which,tid,where){
	//document.getElementById("privacy").innerHTML = "<img src='/images/indicator_flower.gif' border=0/>";
	//pausecomp(5000);
	var ajaxRequest;  // The variable that makes Ajax possible!
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	//pausecomp(3000);
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			document.getElementById(where).innerHTML = ajaxRequest.responseText;
		}
	}
	ajaxRequest.open("GET", "ajax.asp?action="+which+"&id="+tid, true);
	ajaxRequest.send(null); 
} 

function fncToggleCheckBoxes(strForm, strField, blnCheck) {
	if(!document.forms[strForm]) { return; }
	var objCheckBoxes = document.forms[strForm].elements[strField];
	if(!objCheckBoxes) { return; }
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes) { objCheckBoxes.checked = blnCheck; }
	else {
		for(var i = 0; i < countCheckBoxes; i++) {
			objCheckBoxes[i].checked = blnCheck;
	  }
	}
}


function fncToggle_Img(obj,img) {
	var el = document.getElementById(obj);
	if ( el.style.display != "none" ) {
		fncFadeUp(obj);
		document.getElementById(img).src = "/images/plus.gif";
	}
	else {
		fncAppearDown(obj);
		document.getElementById(img).src = "/images/minus.gif";
	}
}

function toggleChildren(CatID){
	
	var objField = document.getElementById('blnYesNo_'+CatID);
	var objYes = document.getElementById('Yes_'+CatID);
	var objNo = document.getElementById('No_'+CatID);
	var objDate = document.getElementById('idDatePosted_'+CatID);
	
	if(objField.value == 'Yes'){ //setting to NO
		
		objField.value='No'; 
		objYes.setAttribute("class", "off_green");
		// for IE
		objYes.setAttribute("className", "off_green");
		objNo.setAttribute("class", "on_red");
		// for IE
		objNo.setAttribute("className", "on_red");
		objDate.disabled='disabled';
		
		// loop through children and grandchildren: 
		var strChildren = CatID+'_'+CatID+'_intChildID';
		for (var i = 0; i<document.formPartnerUser.elements.length; i++) {
			 if ((document.formPartnerUser.elements[i].name.indexOf(strChildren) > -1)) {
			 	childcatid = document.formPartnerUser.elements[i].value;
				document.getElementById('blnYesNo_'+childcatid).value='No';
				document.getElementById('idDatePosted_'+childcatid).disabled='disabled';
				document.getElementById('Yes_'+childcatid).setAttribute("class", "off_green");
				document.getElementById('Yes_'+childcatid).setAttribute("className", "off_green");
				document.getElementById('No_'+childcatid).setAttribute("class", "on_red");
				document.getElementById('No_'+childcatid).setAttribute("className", "on_red");
				
				for (var p = 0; p<document.formPartnerUser.elements.length; p++) {
				 	if ((document.formPartnerUser.elements[p].name.indexOf(childcatid+'_'+childcatid+'_intChildID') > -1)) {
					 	grandchildcatid = document.formPartnerUser.elements[p].value;
						document.getElementById('blnYesNo_'+grandchildcatid).value='No';
						document.getElementById('idDatePosted_'+grandchildcatid).disabled='disabled';
						document.getElementById('Yes_'+grandchildcatid).setAttribute("class", "off_green");
						document.getElementById('Yes_'+grandchildcatid).setAttribute("className", "off_green");
						document.getElementById('No_'+grandchildcatid).setAttribute("class", "on_red");
						document.getElementById('No_'+grandchildcatid).setAttribute("className", "on_red");
					 }
				}
			 }
		}
		
	}
	else { //setting to YES
		
		objField.value='Yes';
		objYes.setAttribute("class", "on_green");
		objYes.setAttribute("className", "on_green");
		objNo.setAttribute("class", "off_red");
		objNo.setAttribute("className", "off_red");
		objDate.disabled='';
		
		for (var p = 0; p<document.formPartnerUser.elements.length; p++) {
		 	if ((document.formPartnerUser.elements[p].name.indexOf(CatID+'_'+CatID+'_intParentID') > -1)) {
			 	parentid = document.formPartnerUser.elements[p].value;
				document.getElementById('blnYesNo_'+parentid).value='Yes';
				document.getElementById('idDatePosted_'+parentid).disabled='';
				document.getElementById('Yes_'+parentid).setAttribute("class", "on_green");
				document.getElementById('Yes_'+parentid).setAttribute("className", "on_green");
				document.getElementById('No_'+parentid).setAttribute("class", "off_red");
				document.getElementById('No_'+parentid).setAttribute("className", "off_red");
				
				for (var i = 0; i<document.formPartnerUser.elements.length; i++) {
					 if ((document.formPartnerUser.elements[i].name.indexOf(parentid+'_'+parentid+'_intParentID') > -1)) {
					 	grandparentcatid = document.formPartnerUser.elements[i].value;
						document.getElementById('blnYesNo_'+grandparentcatid).value='Yes';
						document.getElementById('idDatePosted_'+grandparentcatid).disabled='';
						document.getElementById('Yes_'+grandparentcatid).setAttribute("class", "on_green");
						document.getElementById('Yes_'+grandparentcatid).setAttribute("className", "on_green");
						document.getElementById('No_'+grandparentcatid).setAttribute("class", "off_red");
						document.getElementById('No_'+grandparentcatid).setAttribute("className", "off_red");
					}
				}
				
			 }
		}
		
	}
}



function toggleSolution(intSolutionID){
	
	var objField = document.getElementById('idSolutionYesNo_'+intSolutionID);
	var objYes = document.getElementById('idSolutionYes_'+intSolutionID);
	var objNo = document.getElementById('idSolutionNo_'+intSolutionID);
	
	if(objField.value == 'Yes'){ //setting to NO
	  
		fncFadeUp('SolutionCats_'+intSolutionID);
		document.getElementById('expCol_'+intSolutionID).src = "/images/plus.gif";
		
		objField.value='No'; 
		objYes.setAttribute("class", "off_green");
		// for IE
		objYes.setAttribute("className", "off_green");
		objNo.setAttribute("class", "on_red");
		// for IE
		objNo.setAttribute("className", "on_red");
		
	}
	else { //setting to YES
	  
		objField.value='Yes';
		objYes.setAttribute("class", "on_green");
		objYes.setAttribute("className", "on_green");
		objNo.setAttribute("class", "off_red");
		objNo.setAttribute("className", "off_red");
		
	}
}

function fncToggleDateFilter(strValue) {
  if (strValue=='dateadded' || strValue=='partneradded') {
      fncAppearDown('datefilter');
		}
   else {
			fncFadeUp('datefilter'); 
    }
}

// ADDED CG 03/11/10 //

  function fncSVRatingPreview(intResourceID, strSourceImgID, intRating) {
    var oImg = document.getElementById(strSourceImgID + "_" + intResourceID);
    oImg.src = "/images/star-red_group_" + intRating + "0.gif";
  }
  
  function fncSVRatingPreviewDefault(intResourceID, strSourceImgID, intRating) {
    var oImg = document.getElementById(strSourceImgID + "_" + intResourceID);
    oImg.src = "/images/star-gold_group_" + intRating + "0.gif";
  }
  
  function fncSVRatingSet(intResourceID, strSourceImgID, intRating, intTotalRating, intNumRatings) {
    intTotalRating=intTotalRating + intRating;
	intNumRatings = intNumRatings + 1;
	intNewAverage= Math.round(intTotalRating/intNumRatings);
	var oImg = document.getElementById(strSourceImgID + "_" + intResourceID);
    oImg.src = "/includes/rate.asp?v=" + intResourceID + "&r=" + intRating + "&datestamp=" + fncSVDateTimeNow();
    // add the datetime to prevent image caching by browser
	//alert("Total Rating: " + intTotalRating + "New Average rating: " + intNewAverage + " (" + intNumRatings + " votes) - /images/star-gold_group_" + intNewAverage + "0.gif");
   // oImg.useMap = "";
	//oImg.title = "Thanks for voting! New average rating: " + intNewAverage + " stars (" + intNumRatings + " votes)";
	//oImg.src = "/images/star-gold_group_" + intNewAverage + "0.gif";
	var RatingStarsSpan=document.getElementById("idRatingStars_RL_" + intResourceID);
	RatingStarsSpan.innerHTML="<img src='/images/star-gold_group_" + intNewAverage + "0.gif' title='Thanks for voting! New average rating: " + intNewAverage + " stars (" + intNumRatings + " votes)' /> (" + intNumRatings + " votes)";
	
  }

  
  function fncSVDateTimeNow() {
    var strDateTime = "";
    var dtNow = new Date();
    var dtStart = new Date(2000,0,1);
    var intDiffMS = dtNow-dtStart;
    intDiffMS = Math.round(intDiffMS/1000);
    strDateTime = intDiffMS;
    return strDateTime;
  }