function isFloat(value){
    if(parseFloat(value)==value-0.0)
        return true;
    return false;
}

function isIEBrowser() {

if (navigator.appVersion.indexOf("MSIE")!=-1)
            {
                return true;
                }

return false;
}

/**
* Creates an xml http object.
*/
function getXmlHttpObject() {
    
    var xml = null;
    
    try {
        xml = new ActiveXObject("Msxml2.XMLHTTP");
        
    } catch (e) {
    
    try {
        xml = new ActiveXObject("Microsoft.XMLHTTP");   
    } catch (d) {
    
}

}

if (xml == null) {
    
    xml = new XMLHttpRequest();
}

return xml;
}

/**
* sends an ajax xml request.
*/
function sendAJAXRquest(xmlHttpObject, url, getOrPost, responseMethodName, parametersForPost ) {
    
    if (xmlHttpObject == null || xmlHttpObject == undefined) {
        alert('XML Http object must be provided');
        return;
    }
    xmlHttpObject.onreadystatechange=responseMethodName; 
    xmlHttpObject.open(getOrPost,url,true);
    xmlHttpObject.send(parametersForPost);
}

/**
* The following function parse xml string and returns a document object.
* Please note that the following code has been obtained from the following 
* url: http://www.webreference.com/programming/javascript/definitive2/2.html
*/
function getDocumentObjectFromString(xmlString) {
    
    
    if (document.implementation && document.implementation.createDocument) { 
        //  alert(1);
        // Mozilla, Firefox, and related browsers 
        return (new DOMParser()).parseFromString(xmlString, "application/xhtml+xml"); 
    } 
    else if (typeof ActiveXObject != undefined) { 
        //    alert(2);
        // Internet Explorer. 
        // var doc = XML.newDocument();  // Create an empty document 
        var doc = new ActiveXObject("Microsoft.XMLDOM"); 
        doc.async = false;
        doc.loadXML(xmlString);            // Parse text into it 
        //var pi = doc.createProcessingInstruction("xml"," version='1.0' encoding='UTF-8'");
        //doc.appendChild(pi);
        
        return doc;                   // Return it 
    } 
    else { 
        //   alert(3);
        // As a last resort, try loading the document from a data: URL 
        // This is supposed to work in Safari. Thanks to Manos Batsis and 
        // his Sarissa library (sarissa.sourceforge.net) for this technique. 
        var url = "data:text/xml;charset=utf-8," + encodeURIComponent(xmlString); 
        var request = new XMLHttpRequest(); 
        request.open("GET", url, false); 
        request.send(null); 
        return request.responseXML; 
    } 
}

/**
* The following function returns an empty document object if arguments are not
* provided.
* Please note that the following code has been obtained from the following 
* url: http://www.webreference.com/programming/javascript/definitive2/2.html
*/
function getNewDocumentObject(rootTagName, namespaceURL) { 
    
    
    if (!rootTagName) rootTagName = ""; 
    if (!namespaceURL) namespaceURL = ""; 
    if (document.implementation && document.implementation.createDocument) { 
        // This is the W3C standard way to do it 
        return document.implementation.createDocument(namespaceURL, rootTagName, null); 
    } 
    else { // This is the IE way to do it 
        // Create an empty document as an ActiveX object 
        // If there is no root element, this is all we have to do 
        
        
        //var doc = new ActiveXObject("MSXML2.DOMDocument"); 
        var doc = new ActiveXObject("Microsoft.XMLDOM"); 
        // If there is a root tag, initialize the document 
        if (rootTagName) { 
            // Look for a namespace prefix 
            var prefix = ""; 
            var tagname = rootTagName; 
            var p = rootTagName.indexOf(':'); 
            if (p != -1) { 
                prefix = rootTagName.substring(0, p); 
                tagname = rootTagName.substring(p+1); 
            } 
            // If we have a namespace, we must have a namespace prefix 
            // If we don't have a namespace, we discard any prefix 
            if (namespaceURL) { 
                if (!prefix) prefix = "a0"; // What Firefox uses 
            } 
            else prefix = ""; 
            // Create the root element (with optional namespace) as a 
            // string of text 
            var text = "<" + (prefix?(prefix+":"):"") +  tagname + 
            (namespaceURL 
                ?(" xmlns:" + prefix + '="' + namespaceURL +'"') 
                :"") + 
            "/>"; 
            // And parse that text into the empty document 
            doc.loadXML(text); 
        } 
        return doc; 
    }
}

function getStringFromDocumentObject(doc) {
    
    /*/// Mozilla
    
    var serializer = new XMLSerializer();
    var output = serializer.serializeToString(doc);
    alert("dfldl\n"+output)
    */
    ///IE
    //alert(doc.xml);
    
    if (document.implementation && document.implementation.createDocument) {
        
        var serializer = new XMLSerializer();
        var output = serializer.serializeToString(doc);
        return output;
    } else {
    return doc.xml;
}
}

function validateEmail(id)
{

    var x = document.getElementById(id).value;
    
    var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (filter.test(x))
        {
            //alert('YES! Correct email address');
            return true;
            
        }
        else
        {
            alert('Incorrect Email Address');
            document.getElementById('userid2').focus();
            return false;
        }
}
        
        function validatePassword(pwd){
            var x = pwd;
            if(x.length < 6)
                {
                    alert('Minimum Password length is 6 characters');
                    document.getElementById('password2').focus();;
                    return false;
                }
                return true;
            }
            
            function containCharectar(value){
                
            }
            
            function containNumber(value){
                
            }
            
            function isValidEmailAddr(email)
            {
                
                
                var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
                if (filter.test(email))
                    {
                        //alert('YES! Correct email address');
                        return true;
                        
                    }
                    else
                        {   
                            
                            return false;
                        }
                    }
                    //Kashif Nov 2,2007
                    /*
                    * Please note that the following code of functions  
                    * getSelectedRadio()
                    * getSelectedRadioValue()
                    * getSelectedCheckbox()
                    * getSelectedCheckboxValue()
                    * has been obtained from the following 
                    * http://www.breakingpar.com/bkp/home.nsf/0/CA99375CC06FB52687256AFB0013E5E9
                    * 
                    */
                    function getSelectedRadio(buttonGroup) {
                        // returns the array number of the selected radio button or -1 if no button is selected
                        if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
                            for (var i=0; i<buttonGroup.length; i++) {
                                if (buttonGroup[i].checked) {
                                    return i
                                }
                            }
                        } else {
                        if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
                    }
                    // if we get to this point, no radio button is selected
                    return -1;
                } // Ends the "getSelectedRadio" function
                
                function getSelectedRadioValue(buttonGroup) {
                    // returns the value of the selected radio button or "" if no button is selected
                    var i = getSelectedRadio(buttonGroup);
                    if (i == -1) {
                        return "";
                    } else {
                    if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
                        return buttonGroup[i].value;
                    } else { // The button group is just the one button, and it is checked
                    return buttonGroup.value;
                }
            }
        } // Ends the "getSelectedRadioValue" function
        
        function getSelectedCheckbox(buttonGroup) {
            // Go through all the check boxes. return an array of all the ones
            // that are selected (their position numbers). if no boxes were checked,
            // returned array will be empty (length will be zero)
            var retArr = new Array();
            var lastElement = 0;
            if (buttonGroup[0]) { // if the button group is an array (one check box is not an array)
                for (var i=0; i<buttonGroup.length; i++) {
                    if (buttonGroup[i].checked) {
                        retArr.length = lastElement;
                        retArr[lastElement] = i;
                        lastElement++;
                    }
                }
            } else { // There is only one check box (it's not an array)
            if (buttonGroup.checked) { // if the one check box is checked
                retArr.length = lastElement;
                retArr[lastElement] = 0; // return zero as the only array value
            }
        }
        return retArr;
    } // Ends the "getSelectedCheckbox" function
    
    function getSelectedCheckboxValue(buttonGroup) {
        // return an array of values selected in the check box group. if no boxes
        // were checked, returned array will be empty (length will be zero)
        var retArr = new Array(); // set up empty array for the return values
        var selectedItems = getSelectedCheckbox(buttonGroup);
        if (selectedItems.length != 0) { // if there was something selected
            retArr.length = selectedItems.length;
            for (var i=0; i<selectedItems.length; i++) {
                if (buttonGroup[selectedItems[i]]) { // Make sure it's an array
                    retArr[i] = buttonGroup[selectedItems[i]].value;
                } else { // It's not an array (there's just one check box and it's selected)
                retArr[i] = buttonGroup.value;// return that value
            }
        }
    }
    return retArr;
} // Ends the "getSelectedCheckBoxValue" function
//End Kashif

//check for integer
function isInteger(value){
    if(parseInt(value)==value-0)
        return true;
    return false;
}

function putFocusIntoTextField(fieldId) {
    
    document.getElementById(fieldId).focus();
}


 function validate_Date(id)
{
    var today = new Date();

    var temp = new Array();
    temp = document.getElementById(id).value.split("-");
    var day = temp[0];
    var month = temp[1]-1;
    var year = temp[2];

    var inputDate = new Date(year,month,day);

    if(inputDate > today)
    {
        document.getElementById(id).value = "";
        return false;
    }

    return true;
}

function validateInviteEmail(emailAdress)
{

    var x = emailAdress;
    
    var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (filter.test(x))
        {
            //alert('YES! Correct email address');
            return true;
            
        }
        else
        {
            alert('Incorrect Email Address');
            return false;
        }
}

function isNegative(integer)
{
    if(integer < 0)
        return true;
    else
        return false;
}
   

