﻿/* Renders an email address from FCK function call */
function mt(name,domain,subject,body) {
  var mailto = 'mailto:' + name + '@' + domain;
  if(subject!='') {
    mailto += '?subject=' + subject;
    if(body!='') {
        mailto += '&body=' + body;
    }
  } else {
    if(body!='') {
        mailto += '?body=' + body;
    }
  }
  location.href = mailto;
}

function writeAdminEmail() {
    var strEmail = ('admin' + '@' + 'namfs' + '.org');
    document.write('<a href="mailto:' + strEmail + '?Subject=Website Inquiry">' + strEmail + '</a>');
}

function IsElementSelected(id) {
    var el = document.getElementById(id);
    var sel = false;
    var inputs = el.getElementsByTagName('input');
    for(i=0;i<inputs.length;i++){
        if(inputs[i].checked){
            sel = true;
        }
    }
    return sel;
}

function Trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function LTrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}

function RTrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

function getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}

function setCookie(c_name, value, expiredays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = c_name + "=" + escape(value) +
((expiredays == null) ? "" : ";expires=" + exdate.toUTCString());
}

function swapConfImg(intImg) {
    var getnewimg = getCookie('img1');
    if (getnewimg == null || getnewimg == "") getnewimg = 1;

    var img1 = document.getElementById('NAMFSConfImage');
    img1.src = '/Portals/0/Images/Home_Page/home_' + getnewimg + '.jpg';

    if (getnewimg < intImg) {
        setCookie('img1', parseInt(getnewimg) + 1, 365);
    } else {
        setCookie('img1', 1, 365);
    }
}
