BASICS = {
		
	addComment: function(pid){
		
		 var _commentform = document.getElementById("addCommentP"+pid);
	     var _addcommentButton = document.getElementById("addComment"+pid);	
	     if (document.getElementById("pc"+pid)){
	     var _comments = document.getElementById("pc"+pid);
	     _comments.className = "in-active";	     
	     document.getElementById("linkComments"+pid).innerHTML = "Show Comments";
	     }
		 _class = _commentform.className;
	        if (_class == 'in-active') {
	            _class = "active";
	            _status = "Cancel Commenting";
	            
	           
	        } else {
	            _class = "in-active";
	            _status = "Add Comment";
	          
	        }
	        _commentform.className = _class;	
	        _addcommentButton.innerHTML = _status;
	   
	},
	
    toggleComments: function(pid,pcount) {
	
        var _comments = document.getElementById("pc"+pid);
        var _commentsButton = document.getElementById("linkComments"+pid);
        _class = _comments.className;
        _commentsButton.innerHTML = "hello";
       // alert(_class);
        if (_class == 'in-active') {
            _class = "active";
            _status = "Hide Comments";
        } else {
            _class = "in-active";
            _status = "Show Comments ("+pcount+")";
        }
        _comments.className = _class;
       // alert(_comments.innerHTML);
       // alert(_comments.className);
       _commentsButton.innerHTML = _status;
    },
    goLite: function(FRM,BTN){
       window.document.forms[FRM].elements[BTN].style.color = "#FFFFFF";
       window.document.forms[FRM].elements[BTN].style.backgroundColor = "#FF33FF";
    },
    goDim: function(FRM,BTN)
    {
       window.document.forms[FRM].elements[BTN].style.color = "";
       window.document.forms[FRM].elements[BTN].style.backgroundColor = "";
    },
    validateAddComment: function(pid){
    	var error = 0;
		author = document.getElementById("author"+pid).value;
		author = author.replace(/^\s+/,"");
		if(author.length < 1){
			alert("Please provide a name");
			document.getElementById("author"+pid).focus();
			return false;
			//error = 1;
		}
		// validate email
		email = document.getElementById("email"+pid).value;
		var whitespace=new String(" \t\n\r");
		email=email.replace(/^\s+/,"");
		var regEx=/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		if(regEx.test(email)==false||whitespace.indexOf(email.charAt(0))!=-1){
			alert('Please correct - invalid Email address!');
			document.getElementById("email"+pid).focus();
			return false;
			//error=1;
		}	
		// validate comments
		comment = document.getElementById("comment"+pid).value;
		comment = comment.replace(/^\s+/,"");
		if(comment.length < 1){
			alert("I thought you wanted to leave a comment, so please fill out the message box - thanks");
			return false;
			//error=1;
		}
		if (error != 1) {
			//alert("submit");
			//document.ac.action = "add.php";
			//document.ac.submit();			
		}
		else {
			//document.ac.action = "addcomment.php";
			///document.forms[0].submit();	
		}
		//document.ac.submit();
		return true;	
	},
	validateContactForm: function() {
		curName = document.getElementById("posName").value;
		curName = curName.replace(/^\s+/,"");
		if(curName.length < 1){
			alert("Please provide a name");
			document.getElementById("posName").focus();
			return false;
		}
		comment = document.getElementById("posText").value;
		comment = comment.replace(/^\s+/,"");
		if(comment.length < 1){
			alert("I thought you wanted to leave a comment, so please fill out the comment box - thanks");
			//document.getElementById("posText").focus();
			return false;
		}		
		return true;
		//document.forms[0].submit();	
	}
};

var asyncRequest = function() {
    function handleReadyState(o, callback) {
        if (o && o.readyState == 4 && o.status == 200) {
            if (callback) {
                callback(o);
            }
        }
    }
    var getXHR = function() {
        var http;
        try {
            http = new XMLHttpRequest;
            getXHR = function() {
                return new XMLHttpRequest;
            };
        } catch(e) {
            var msxml = ['MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP'];
            for (var i = 0, len = msxml.length; i < len; ++i) {
                try {
                    http = new ActiveXObject(msxml[i]);
                    getXHR = function() {
                        return new ActiveXObject(msxml[i]);
                    };
                    break;
                } catch(e) {}
            }
        }
        return http;
    };
    return function(method, uri, callback, postData) {
        var http = getXHR();
        http.open(method, uri, true);
        http.onreadystatechange = function() {
            handleReadyState(http, callback)
        };
        http.send(postData || null);
        return http;
    };
} ();
