// JavaScript Document
function popup_win(file,name,width,height,scrollb){
	newWindow=window.open(file,name,'width='+width+',height='+height+',directories=no,location=no,menubar=no,scrollbars='+(scrollb===true?'yes':'no')+',status=no,toolbar=no,resizable=no,left=0,top=0,screenx=50,screeny=50');
	newWindow.focus();
	return false;
}
function addEvent(obj,evType,fn,useCapture){
	useCapture=(!useCapture)?'false':useCapture;
	if(obj.addEventListener){
		obj.addEventListener(evType,fn,useCapture);
		return true;
	}else if(obj.attachEvent){
		var r=obj.attachEvent("on"+evType.toString(),fn);
		return r;
	}
}
function cancelEvent(evt){
	evt=(evt)?evt:window.event;
	evt.cancelBubble=true;
	if(typeof evt.stopPropagation=='function'){
		evt.stopPropagation();
	}
	evt.returnValue=false;
	if(typeof evt.preventDefault=='function'){
		evt.preventDefault();
	}
}
function ajaxFunction(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	return ajaxRequest;
}
function generic_get(ajaxfile,returndiv,callback){
	if(returndiv){
		var pcdivg=document.getElementById(returndiv);
	}else{
		var pcdivg=false;
	}
	var ajaxg=ajaxFunction();
	if(!ajaxg){return false;}
	ajaxg.onreadystatechange = function(){
		if(ajaxg.readyState == 4){
				var phpreturn=ajaxg.responseText;
			if (ajaxg.status == 200) {
				if(phpreturn!=""){
					//alert(phpreturn);
					if(pcdivg){pcdivg.innerHTML=phpreturn;}
					
					//pleasewait1(false);
				}else{
					if(pcdivg){pcdivg.innerHTML="<p>FORM ERROR</p>".phpreturn;}
				}
				if(callback){eval(callback);}
			}else{
				if(pcdivg){pcdivg.innerHTML="Ajax Error";}
			}
		}
	}
	ajaxg.open("GET","ajax/"+ajaxfile,true); 
	ajaxg.send(null);
	//return false;		
}
function toggle_div(obname){
	var mdiv=document.getElementById(obname);
	mdiv.style.display=(mdiv.style.display=="none"||!mdiv.style.display?"block":"none");
}