/**
 * the old popupfunction, maybe needed for the old oc_stream etc.
 * 
 * @param	integer		pageid:	the target pageid
 * @param	integer		userid: the userid
 * @param	integer		questionPlugin: the id of the questionPlugin
 * @param	integer		questionFolder: the page that containts all questions
 * @param	integer		width: the width of the new window
 * @param	integer		height: the height of the new window
 * @param	string		scrollbars: yes enable, no disable
 * @param	string		resizable: yes enable, no disable
 * @return	void
 */
function questionpop(pageid,userid,questionPlugin,questionFolder,width, height,scrollbars,resizable) {
	
	if (width==0)	{
		width = 720;
	}
	if (height==0){
		height = 715;
	}
	if (scrollbars!='yes' && scrollbars!='no'){
		scrollbars = 'yes';
	}
	if (resizable!='yes' && resizable!='no')	{
		resizable = 'yes';
	}
	pageid = pageid.toString();
	pageidtest = pageid.substring(0,5);
	if (pageid == parseInt(pageidtest))	{
		pageid = 'index.php?id=' + pageid;
		windowname = 'Fenster';
	} else	{
		pageid = pageid;
		windowsname = 'Result';
		opener.close();
	}
	window.open(pageid + '&userid=' + userid + '&questionPlugin=' + questionPlugin + '&questionFolder=' + questionFolder,windowname,'width='+width+',height='+height+',left=0,top=0,scrollbars='+scrollbars+',resizable='+resizable+''); 
}


/**
 * the new popup function 
 * 
 * @param	integer		pageid: the target pageid
 * @param	integer		questionFolder: the folder that containt all the question
 * @param	integer		width: the width from the new window
 * @param	integer		height: the height from the new window
 * @param	string		scrollbars: yes enable, no disable
 * @param	string		resizable: yes enable, no disable
 * @return	void
 */
function pbsurveyResultQuestionPopup(pageid,questionFolder,width, height,scrollbars,resizable) {
	if (width==0 || width==undefined)	{
		width = 720;
	}
	if (height==0 || height==undefined){
		height = 715;
	}
	if (scrollbars!='yes' && scrollbars!='no'){
		scrollbars = 'yes';
	}
	if (resizable!='yes' && resizable!='no')	{
		resizable = 'yes';
	}
	pageid = pageid.toString();
	pageidtest = pageid.substring(0,5);
	if (pageid == parseInt(pageidtest))	{
		pageid = 'index.php?id=' + pageid;
		windowname = 'Fenster';
	} else	{
		pageid = pageid;
		windowsname = 'pbsurveyResult';
		opener.close();
	}
	window.open(pageid + '&questionFolder=' + questionFolder,windowname,'width='+width+',height='+height+',left=0,top=0,toolbar=no,location=no,menubar=no,scrollbars='+scrollbars+',resizable='+resizable+''); 
}


/**
 * open a new popup, when ocEventWindow is closed
 * 
 * @param	integer		questionSwitch: the page with the switch script
 * @param	integer		questionFolder: the folder with the questions
 * @return	void
 */
function pbsurveyResultCheckWindow(questionSwitch, questionFolder)	{
	if (ocEventWindow.closed == true)	{
		window.clearInterval(pbsurveyResultActive);
		pbsurveyResultQuestionPopup(questionSwitch,questionFolder);
	}
}

/**
 * start checking if the window ocEventWindow exist
 * 
 * @param	integer		questionSwitch: the page with the switch script
 * @param	integer		questionFolder: the folder with the questions
 * @return	void
 */
function pbsurveyResultStartWindowCheck(questionSwitch, questionFolder)	{
	if (ocEventWindow.closed == false)	{
		pbsurveyResultActive = window.setInterval("pbsurveyResultCheckWindow(" + questionSwitch +"," + questionFolder + ")", 500);
	} else	{
		pbsurveyResultQuestionPopup(questionSwitch,questionFolder);
	}
}
