var codeGenerated=false;
var newWindow = null;

function closeWin(){
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}

function popUpWin(url, type, strWidth, strHeight){
	closeWin();
	
	if (type == "fullScreen"){
alert("popping!");	
		strWidth = screen.availWidth - 10;
		strHeight = screen.availHeight - 160;
	}
	
	var tools="";
	if (type == "standard" || type == "fullScreen") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";
	if (type == "console") tools = "resizable,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+",left=0,top=0";
	newWindow = window.open(url, 'newWin_gen', tools);
	newWindow.focus();
}

function generatePopUp()
{
var strType=document.forms['popupform'].ddlTypeOfPopUp[document.forms['popupform'].ddlTypeOfPopUp.selectedIndex].value;
var strURL=document.forms['popupform'].txtURL.value;
var strLinkText=document.forms['popupform'].txtLinkText.value;
var strWidth=document.forms['popupform'].ddlWidth[document.forms['popupform'].ddlWidth.selectedIndex].value;
var strHeight=document.forms['popupform'].ddlHeight[document.forms['popupform'].ddlHeight.selectedIndex].value;

var strError="";
if ((strType.length==0)||(strURL.length==0)||(strWidth.length==0)||(strHeight.length==0))
	{
	strError="You need to enter a value in all fields.";
	}
else
	{
	var strPopUpCall = '<a href="' + strURL + '" target="popUpWin" onclick="popUpWin(this.href,\'' + strType + '\','+ strWidth +','+ strHeight +');return false;">' + strLinkText + '</a>';
	document.getElementById("linkArea").innerHTML = "<p><br /><strong>This is how your link will appear.</strong><br />Click on it to check that the pop-up behaves accordingly</p><strong>" + strPopUpCall + "</strong><br /><br />";
	document.forms['popupform'].txtCode.value = strPopUpCall;
	document.getElementById("linkArea").style.display='block';
	document.getElementById("code").style.display='block';
	codeGenerated=true;
	}
if (strError.length!=0) alert(strError);
}

function reGenerate()
{
if (codeGenerated==true) generatePopUp();
}

function hide()
{
	document.getElementById("linkArea").style.display='none';
	document.getElementById("code").style.display='none';
}

window.onload=hide;

