function rendermail(user, domain, classname, style){
  var1=user;
  var2=domain;
  var3=var1+'@'+var2;
  emailE=(var3);
  document.write ('<a class="'+ classname +'" style="'+style+'" href="mailto:' + emailE + '">' + emailE + '<\/a>');
}

function rendermailname(user, domain, classname, style, showname){
  var1=user;
  var2=domain;
  var3=var1+'@'+var2;
  emailE=(var3);
  showName = showname;
  
  if(showName==''){
    document.write ('<a class="'+ classname +'" style="'+style+'" href="mailto:' + emailE + '">' + emailE + '<\/a>');
  }else{
    document.write ('<a class="'+ classname +'" style="'+style+'" href="mailto:' + emailE + '">' + showName + '<\/a>');
  }
}

function StartClientMail(user, domain){
  var1=user;
  var2=domain;
  var3=var1+'@'+var2;
  emailE=(var3);
  document.location.href='mailto:' + emailE;
}

function onEnter( evt, frm ) {
	var keyCode = null;

	if( evt.which ) {
		keyCode = evt.which;
	} else if( evt.keyCode ) {
		keyCode = evt.keyCode;
	}
	if( 13 == keyCode ) {
		frm.btnEnter.click();
		return false;
	}
	return true;
}

function getPrintPage(){
	if(document.getElementById('AjrPrintContent') != null){
		var pageP = window.open('/print.asp','Print','width=680, height=650, resizable=1')
	}
}

function printPage(){

	window.document.title = window.opener.document.title;

	var sOut;
	sOut = '';

	if (window.opener.document.getElementById('AjrPrintContent')) {
	  sOut = sOut + window.opener.document.getElementById('AjrPrintContent').innerHTML;
	}

	if (window.opener.document.getElementById('AjrPrintContent2')) {
	  sOut = sOut + '<div style="margin-top: 30px;">' + window.opener.document.getElementById('AjrPrintContent2').innerHTML + '</div>';
	}

	document.getElementById('AjrPrintContent').innerHTML = sOut;
	document.body.style.backgroundImage='none';
	document.body.style.backgroundColor='#ffffff';

	window.print();
}

function makeRequest(url,type) {
    var httpRequest;
    if (window.XMLHttpRequest) { // Mozilla, Safari, ...
        httpRequest = new XMLHttpRequest();
        if (httpRequest.overrideMimeType) {
            httpRequest.overrideMimeType('text/xml');
            // See note below about this line
        }
    } 
    else if (window.ActiveXObject) { // IE
        try {
            httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (e) {
            try {
                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } 
            catch (e) {}
        }
    }
    if (!httpRequest) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }

	if(type!=''){
		httpRequest.onreadystatechange = function() { renderHtml(httpRequest,type); }
	}
	
    httpRequest.open('GET', url, true);
    httpRequest.send('');
}

function renderHtml(httpRequest,id) {
    if (httpRequest.readyState == 4) {
        if (httpRequest.status == 200) {
			document.getElementById(id).innerHTML=httpRequest.responseText;
        }
    }
}

function jsCharCounter(objToTest,intMaxLength,id){
	if (objToTest.value.length > intMaxLength){
		objToTest.value = objToTest.value.substring(0,intMaxLength);
		objToTest.focus();
	} else {
		document.getElementById(id).innerHTML = intMaxLength - objToTest.value.length
	}
}

function setSelectedIndex( me, valsearch )
{
  for (i = 0; i< me.options.length; i++)
  {
    if ( me.options[i].value == valsearch )
    {
	  me.options[i].selected = true;
    //me.options[i].style.backgroundColor = '#dddddd';
      break;
    }
  }
  return;
}

function CalculateChars( strId, sname, ivalue, obj )
{
  var strValue = document.getElementById( strId ).value;
  var strReplaceAllR = strValue.indexOf('\r');
  var strReplaceAllN = strValue.indexOf('\n');
  
  /*
  while(strReplaceAllR != -1) {
    strValue = strValue.replace('\r','');
    strReplaceAllR = strValue.indexOf('\r');
  }
  while(strReplaceAllN != -1) {
    strValue = strValue.replace('\n','');
    strReplaceAllN = strValue.indexOf('\n');
  }
  */
  
  document.getElementById( sname ).innerHTML = ( ivalue - strValue.length );
  
  var mlength = obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
  
  if( strValue.length > mlength )
    obj.value = strValue.substring( 0, mlength )
       
}