function HTTPObject() {
	var xmlhttp; try { xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");  } catch (e) { try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { xmlhttp=false; } } 
	if(!xmlhttp && typeof XMLHttpRequest !=undefined) { try { xmlhttp=new XMLHttpRequest(); } catch (e) { xmlhttp=false; } }
	if(!xmlhttp) { display_errmsg(e,"noajax"); return; } else { return xmlhttp; }
}

function $div(obj) {
   if(document.getElementById) {
        if(document.getElementById(obj)!=null) {
            return document.getElementById(obj)
        } else {
           return "";
       }
    } else if(document.all) {
        if(document.all[obj]!=null) {
            return document.all[obj]
        } else  {
          return "";
       }
    }
} 

function $DIV_BN(dn,s) { 
	var d = $div(dn); 
	(s=="b") ? ss="block" : ss="none"; 
	if(d!='') { 
		d.style.display=ss; 
	} 
}

function IsEmpty(obj, obj_type) {
	if (obj_type == "text" || obj_type == "password" || obj_type == "textarea" || obj_type == "file") {
	var objValue;
	objValue = obj.value.replace(/\s+$/,"");
	if (objValue.length == 0) {
		return true;
	} else {
		return false;
	}
	} else if (obj_type == "select" || obj_type == "select-one") {
		for (i=0; i < obj.length; i++) {
			if (obj.options[i].selected) {
				if(obj.options[i].value==" ") 
				{return true;obj.focus();} else {return false;}
				
				if(obj.options[i].value == "0") 
				{
					if(obj.options[i].selectedIndex == "0") 
					{return true;obj.focus();}
				} else {return false;}
			}			
		}
		return true;	
	} else if (obj_type == "radio" || obj_type == "checkbox") {
		if (!obj[0] && obj) {
			if (obj.checked) {
				return false;
			} else {
				return true;	
			}
		} else {
			for (i=0; i < obj.length; i++) {
				if (obj[i].checked) {
					return false;
				}
			}
			return true;
		}
	} else {
		return false;
	}
}

function ValidateEmail(Email) {
	var funRegExp = new RegExp("^([a-zA-Z0-9_\.\+\-])+@(([a-zA-Z0-9\-])+\.)+\.([a-zA-Z0-9]{2,6})+$");
	if (!Email.match(funRegExp)) { return false; }//if
	return true;
}
function LengthCheck(val, start, end){
	if(val.length >= start && val.length <= end){
		return true;
	}
	else{
		return false;
	}
	
}
function uncache(url) { var d=new Date(); return url+"&time="+d.getTime(); }

function IsNotnumber(obj) {
	var objValue;
	objValue = obj.value;
	if(isNaN(objValue)) {
			return true;
		} 
		else {
			return false;
		}
}
function replace_comment(type){
	var obj1 = document.getElementById('most_commenters');
	var obj2 = document.getElementById('most_visited');
	var obj3 = document.getElementById('most_comments');
	
	if(type == '1'){
		obj1.style.visibility = 'visible';
		obj1.style.display = 'inline';
		obj2.style.visibility = 'hidden';
		obj2.style.display = 'none';
		obj3.style.visibility = 'hidden';
		obj3.style.display = 'none';
	}
	else if(type == '2'){
		obj2.style.visibility = 'visible';
		obj2.style.display = 'inline';
		obj1.style.visibility = 'hidden';
		obj1.style.display = 'none';
		obj3.style.visibility = 'hidden';
		obj3.style.display = 'none';
	}
	else if(type == '3'){
		obj3.style.visibility = 'visible';
		obj3.style.display = 'inline';
		obj1.style.visibility = 'hidden';
		obj1.style.display = 'none';
		obj2.style.visibility = 'hidden';
		obj2.style.display = 'none';
	}
}
