var disDivision = false;
function changeDivision(){
	var arr = getPageSize();
	tip = document.getElementById('divisionmap');
	if(navigator.userAgent.indexOf("MSIE") >= 0){
		minuser = 460;
	}else{
		minuser = 468;
	}
	tip.style.left = ((arr[0]/2)-minuser)+'px';
	if(disDivision){
		tip.style.display = "none";
		disDivision = false;
	}else{
		tip.style.display = "block";
		disDivision = true;
	}
}
function openAd(id,sid,fksite,url){
	// Need to Ajax 
	var http = new XMLHttpObject();
	var params = "lid="+id+"&sid="+sid+"&site="+fksite;
	http.open("POST", "/xml/ad_banners/click.php", true);
	
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	
	http.send(params);
	
	window.open(url);
}
function openBanner(id,sid,url,fksite){
	// Need to Ajax 
	var http = new XMLHttpObject();
	var params = "lid="+id+"&sid="+sid+"&site="+fksite;
	http.open("POST", "/xml/ad_banners/clickad.php", true);
	
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	
	http.send(params);
	
	window.open(url);
}
function openUrl(url){
	// Need to Ajax 
	arrSize = getPageSize();
	oBody = document.getElementsByTagName('body')[0];
	oCont = document.createElement("div");
	oCont.setAttribute("id","browser_location");
	oDiv = document.createElement("div");
	oAnchor = document.createElement("a");
	oAnchor.appendChild(document.createTextNode("Return to the CME web site"));
	oAnchor.setAttribute("href","javascript:closeAd()");
	oDiv.appendChild(oAnchor);
	oCont.appendChild(oDiv);
	oFrame = document.createElement("iframe");
	oFrame.setAttribute("id","adframe");
	oFrame.setAttribute("src",url);
	oFrame.setAttribute("frameborder","0");
	oFrame.setAttribute("width","100%");
	oFrame.setAttribute("height",arrSize[1]+"px");
	oCont.appendChild(oFrame);
	oBody.appendChild(oCont);
}
function closeAd(){
	oDiv = document.getElementById('browser_location');
	if(oDiv != null) oDiv.parentNode.removeChild(oDiv);
}
function validateLogin(form){
	clearElements();
	addElement(form.name, "strUsername", "text", "Username", 1, 50, "");
	addElement(form.name, "strPassword", "text", "Password", 1, 50, "");
	return validateForm(form);
}
function validateComment(form){
	clearElements();
	addElement(form.name, "strContent", "text", "Content", 1, 5000, "");
	return validateForm(form);
}
function validateThread(form){
	clearElements();
	addElement(form.name, "strTitle", "text", "Title", 1, 200, "");
	addElement(form.name, "strBody", "text", "Content", 1, 5000, "");
	return validateForm(form);
}
function switchEvents(lid,id){
	window.location.href = "/?action=show&lid="+lid+"&comaction=category&cid="+id;	
}
