function HelpPopUp(sTopic)
{
	var nWidth =400;
	var posLeft=(screen.width-nWidth)/2;
	var nHeight =300;
	var posTop=(screen.height-nHeight-100)/2;

	var sTitle = 'HelpPopup';
	var strUrl = '/include/help.asp?Topic=' + sTopic;
	var strStyle = 'location=no,scrollbars=yes,status=no,toolbar=no,height='+nHeight+',top='+posTop+',width='+nWidth+',left='+posLeft;
	var win=window.open(strUrl, sTitle, strStyle);
	win.focus();
}

function PopUp(sURL, PopUpwidth, PopUpHeight)
{
	// opens popup in center of screen

	var PosX;			// xposition of pop-up
	var PosY;			// yposition of pop-up
	
	// Quick fix to provide for font change to Verdana
	PopUpHeight = PopUpHeight + 80;
	PopupWidth = PopupWidth + 50;
	
	PosX = Math.ceil((screen.width-PopUpwidth)/2);		// integer value!
	PosY = Math.ceil((screen.height-PopUpHeight)/2);

	var sFeatures = 'toolbar=no,resizable=yes,width=' + PopUpwidth + ',height=' + PopUpHeight + ',scrollbars=yes,top=' + PosY + ',left=' + PosX;
	win=window.open(sURL,'',sFeatures);
	win.focus();
}		

function PopUpCenter(nWidth,nHeight)
{
	/*
	This function writes PART of the parameterstring used in a window.open() method
	window's height, width and position will be included in resultstring
	these parameters depend ONLY on width and height of popup strStyle
		Optional method by hiding, moving and focussing popupscreen
		X = window.open(strURL, "View", "toolbar=no,width=1,height=1,scrollbars=no");
		X.moveTo((screen.availWidth - 400) / 2, (screen.availHeight - 250) / 2);
		X.resizeTo(400, 250);
		X.focus();
	*/

	// Quick fix to provide for font change to Verdana
	displayHeight = nHeight + 40;
	displayWidth = nWidth + 40;
	
	var posLeft=(screen.width-displayWidth)/2;
	var posTop=(screen.height-displayHeight)/2;
	var strStyle = 'location=no,menubar=no,resizable=yes,status=no,toolbar=no,height='+displayHeight+',top='+posTop+',width='+displayWidth+',left='+posLeft;
	return strStyle;
}

function GraphPopUp(nWidth,nHeight,sChartMode,sGraphURL,sKey,sFields,sSupportedChartModes,sSupportedFields){
	// build the url string
	var sURL = '/graphs/ppGraphPopUp.asp?chartMode='+sChartMode+
																			'&TitleKey='+sKey+
																			'&fields='+sFields+
																			'&src='+fncURLEncode(sGraphURL)+
																			'&SupportedChartModes='+sSupportedChartModes+
																			'&SupportedFields='+sSupportedFields;
	var sStyle = PopUpCenter(nWidth,nHeight)+',scrollbars=yes';
	var win=window.open(sURL, 'GraphPopUp',sStyle);
	win.focus();
}

function fncDefaultPopUp(strURL,strStyle)
{
	var popWin=window.open(strURL,'',strStyle);
	popWin.focus();
	//return false;
}

function fncViewSupplier(id)
/* Pop up shows the supplier registration as Supplier presentation */
	{
		if(id>0){
			var strURL = '/search/companyDetails.asp?idProfile='+id.toString();
			var strStyle = PopUpCenter(1000,600)+',scrollbars=yes,resizable=yes';
			var win=window.open(strURL, 'ppViewComp'+id.toString(), strStyle);
			win.focus();
		}
	}

function fncViewBuyer(id)
/* Pop up shows the Buyer presentation */
	{
		if(id>0){
			var strURL = '/search/companyDetails.asp?idProfile=' + id.toString() + '&hidealternatives=true';
			var strStyle = PopUpCenter(980,500)+',scrollbars=yes';
			var win=window.open(strURL, 'ppViewComp', strStyle);
			win.focus();
		}
	}

function Terms(sLanguageId)
{
	var strURL = '/popup.asp?id=26'+sLanguageId;
	var strStyle = PopUpCenter(500,400)+',scrollbars=yes';
	window.open(strURL,'',strStyle);
}


function fncPpFtpUpload(strUrl)
{
	var strURL = strUrl;
	var strStyle = PopUpCenter(800,400)+',toolbar=yes,location=no,directories=yes,status=no,menubar=yes,scrollbars=yes,resizable=yes';
	window.open(strURL,'',strStyle);
}

function fncURLEncode(s){
	var i=0;
	var oStr=new String(s);
	var oExp;
	// all chars in arr will be replaced; NB: order
	var arr=new Array( new Array(/\?/,'%3F'),
											new Array(/\./,'%2E'),
											new Array(/[\/]/,'%2F'),
											new Array(/[\\]/,'%5C'),
											new Array(/[&]/,'%26')
										);
	for(i=0;i<arr.length;i++){
		oExp= arr[i][0] ;
		while( oStr.search(oExp) > -1){
			// replace as long as there exists an entry
			oStr = oStr.replace(oExp,arr[i][1]);
		}
	}
	
	return oStr;
}

/* Opens a pop up with all the country codes */
function popCountry(showAll){
    var win
    var val
    var strURL;
    var strStyle = PopUpCenter(645,500)+',status=yes,scrollbars=yes';

    val=document.TheForm.CY.value;
    strURL = '/tenders/web/TendersCountries.asp?mode=Tenders&SelectedCodes='+val+'&showAll='+showAll;

    win=window.open(strURL, 'Country', strStyle);
    win.focus();
}

/* Opens a pop up with all the CPV codes */
function popCpv(){
    var win
    var val
    var strURL
    var strStyle = PopUpCenter(645,500)+',status=yes,scrollbars=yes';

		/* We use two different input fields, so check wich one this */
		if(document.TheForm.PC){
			val=document.TheForm.PC.value;
    }
    else if(document.TheForm.ctpCpv){
    	val=document.TheForm.ctpCpv.value;
    }
    else {
			alert('Geen geldig veld');
		}
    strURL='/tenders/web/TendersCpv.asp?SelectedCodes='+val;

    win=window.open(strURL, 'CPV', strStyle);
    win.focus();
}

/* Opens a pop up with a specified link */
function poplink(strURL){
		var win0
		var strStyle = PopUpCenter(770,500)+',scrollbars=no,alwaysRaised';
		win0=window.open(strURL,'Link',strStyle);
		win0.focus();
}	

