//USED by webcontent
//used by the ShowPic tag
//21/08/03 DM   New Forms
//04/Jun/04 SA updated popupListDetails to cater for eventdetails in stripped sites
//19Feb07 ShowDynFormSSP
//10Apr07 ShowDynFormQueryString
//26Feb09 popup and popupXY
//22Dec09 Simple AJAX request
function showPic(picture,sCaption) {
	var iHeight=398;
	var iWidth=600;
	var iTop=(window.screen.height-iHeight)/2;
	var iLeft=(window.screen.width-iWidth)/2;
	var toOpen='ShowPic.asp?p='+picture+'&caption='+sCaption;
	var winDetails='titlebar=no,left='+iLeft+',top='+iTop+',width='+iWidth+',height='+iHeight;
	var win2=window.open(toOpen,'picture',winDetails); 
	win2.focus();
};
//used by details of the lists (eventlist, personnellist, docList & imageList)
//this window size is proportional to the screen size unlike above, where the popup is fixed, but positioned based upon screen size
function popupXY(sURL,iWidth,iHeight){
	var iTop=(window.screen.height-iHeight)/2;
	var iLeft=(window.screen.width-iWidth)/2;
	//var winDetails='titlebar=no,left='+iLeft+',top='+iTop+',width='+iWidth+',height='+iHeight;
	var winDetails='scrollbars=yes,directories=no,location=no,menubar=no,resizable=yes,left=';
	winDetails+=iLeft+',top='+iTop+',width='+iWidth+',height='+iHeight;
	
	var winListDets=window.open(sURL,'ListDetails',winDetails);
	if(window.event){
		window.event.cancelBubble=true;
		window.event.returnValue=false;
	}
	//winListDets.focus();
};

function popupListDetails(sURL) {
	var iHeight=500;
	var iWidth=600;
	var toOpen;
	if (sURL.indexOf(".asp")>0) toOpen='../'+sURL; // dynamic site
	else toOpen=sURL; // stripped site
	//alert(toOpen);
	popupXY(toOpen,iWidth,iHeight);
};
function popup(sURL){
	popupListDetails(sURL);
}

function ShowDynForm(UFID,iWidth,iHeight){
	sURL='../WebFormPopup.asp?PU=Y&FormDataOwnerID='+UFID;
	//popupListDetailsXY(sURL,iWidth,iHeight);
	popupXY(sURL,iWidth,iHeight);
};
function ShowDynFormSSP(sURL,UFID,iWidth,iHeight){
	//popupListDetailsXY(sURL,iWidth,iHeight);
	popupXY(sURL,iWidth,iHeight);
};
function ShowDynFormQueryString(UFID,iWidth,iHeight,QueryString){
	sURL='../WebFormPopup.asp?PU=Y&FormDataOwnerID='+UFID+'&'+QueryString;
	//popupListDetailsXY(sURL,iWidth,iHeight);
	popupXY(sURL,iWidth,iHeight);
};

//DM simple AJAX code - lifted from Dave's, but in this case we want a simple call
// we assuming a simple call of a url that will action something
// eg http://192.168.0.10/!ComWeb/ComWeb/Main/Reports/Reports.asp?id=578&EventID=106&disptype=5
var xmlhttp=null;
var bDoRefresh=false;

function getItemSimple(url,doRefresh){
	xmlhttp=null;
	bDoRefresh=doRefresh;
	if (window.XMLHttpRequest){// Most new Browsers
		xmlhttp=new XMLHttpRequest();
	}else if (window.ActiveXObject){// IE56
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}

	if (xmlhttp!=null){
		xmlhttp.onreadystatechange=new Function("doItemSimple()");
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
	}else{
		//error in creating object
		alert('Cannot process this request. Your browser does not support javascript HTTP requests to the server.');
	};
	return false;//expected to cease href following
};

function doItemSimple(){
	if(xmlhttp.readyState==4){// 4="loaded"
		if(xmlhttp.status==200){// 200=OK
			var result=xmlhttp.responseText;
			if(result){ alert(result) }
			if(bDoRefresh){ window.location.reload() }
		}else{ //not 200=OK
			alert('Cannot process this request. Server request resulted in code '+xmlhttp.status);
		};
	}else{//not 4="loaded"
		return;
	};
};

function DCDPersLink(email,URL){
	var sURL,iWidth,iHeight
	sURL=URL.replace('<email>',email)
	//alert(sURL)
	iWidth=window.screen.width-100
	iHeight=window.screen.height-200
	popupXY(sURL,iWidth,iHeight)
}



