function checkXMLHTTP(xmlhttp) {
    xmlhttp = false;
    try {
        return xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        try {
            return xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (E) {
            xmlhttp = false;
        }
    }
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
        return xmlhttp = new XMLHttpRequest();
    }
}

function documentID(el) {
    return document.getElementById(el);
}




/*
 * @Function            : makegroupUrl 
 * @Used IN             : @function-'Self'       'front_end_resource/group/group.js'[@JS file],
 * @Description         : Make group URL using  group title
 * @Developed By        :afrin jahan noumen
 * @Start DateTime      : 10-02-2016 07:54 PM
 * @Status              : available      
 */
function  makegroupUrl(profileID) {
    if (profileID === '') {
        documentID('group_url').value = '';
    } else {
        profileID = profileID.replace(/  +/g, '');
        for (i = 0; profileID.length > i; i++) {
            if (profileID.charAt(i) === ' ') {
                profileID = profileID.replace(/ +/g, '-');
            }
            if (profileID.charAt(i) === '.') {
                profileID = profileID.replace(/\./g, '');
            }
            if (profileID.charAt(i) === '-') {
                profileID = profileID.replace(/--/g, '-');
            }
        }

        profileID = profileID.replace(/[&\/\\#@!^_=,+()$~%.'":*?<>{}]/g, '');
        if (profileID.charAt(profileID.length - 1) === '-') {
            profileID = setCharAt(profileID, profileID.length - 1, '');
        }
        profileID = profileID.toLowerCase();
        checkgroupURLExists(profileID, 1);
    }
    //checkJQueryValudation('group_url', 'input');
}





var checkgroupURLExistsURL;
function checkgroupURLExists(url, status) {
    var checkgroupURLExistsResponse;
   checkgroupURLExistsResponse = checkXMLHTTP(checkgroupURLExistsResponse);

    var formdata = new FormData();
    formdata.append("group_url", url);
    formdata.append("url_status", status);

   checkgroupURLExistsResponse.addEventListener("load", function () {

        if (status === 1) {
            documentID('group_url').value = checkgroupURLExistsResponse.responseText;
        } else {
            if (checkgroupURLExistsResponse.responseText === '1') {
                documentID('url_exist').value = 1;
                //checkJQueryValudation('group_url', 'input');
            } else if (checkgroupURLExistsResponse.responseText === '2') {
                documentID('url_exist').value = '';
                //checkJQueryValudation('group_url', 'input');
            }
        }

    }, false);
    checkgroupURLExistsResponse.open("POST", checkgroupURLExistsURL);
    checkgroupURLExistsResponse.send(formdata);
}


