var pvwName = "PreviewWindow"; // set form's target to this name
var pvwWin = null;

function MM_openCentredWindow(theURL,width,height,offset)
{

    // test to see if window exists and close if already open
    if (pvwWin && pvwWin.open && !pvwWin.closed) pvwWin.close();

    // see if pixels or percentage has been nominated
    if (width <= 1) {
    var pvwWidth = screen.width * width;
    }
    else {
    var pvwWidth = width;
    }
    if (height <= 1) {var pvwHeight = screen.height * height;}
    else {var pvwHeight = height;}

    // get screen dimensions
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 800, yMax=600;

    // set top-left corner offsets for centred window
    var xOffset = (xMax - pvwWidth)/2, yOffset = (yMax - pvwHeight)/2;
    // adjust offsets if window is not to be centred - based on % of window size 
    if (offset > 0 || offset < 1) {
    var xPos = offset, yPos = offset
    if (xOffset > (xMax * xPos)) {var xOffset = xMax * xPos;}
    if (yOffset > (yMax * yPos)) {var yOffset = yMax * yPos;}
    }

    // set window features
    var features = "location=no,scrollbars=yes,menubar=no,toolbar=no,resizable=yes,status=no,width="+pvwWidth+",height="+pvwHeight+",InnerWidth="+pvwWidth+",InnerHeight="+pvwHeight+",screenX="+xOffset+",screenY="+yOffset+",top="+yOffset+",left="+xOffset;
    // open new window and set focus
    pvwWin = window.open(theURL,pvwName,features);
    pvwWin.focus(); // bring it to the top
    //return true; // submit the form into this window
}

function CentredPreview(pvwName,width,height,offset)
{

    // test to see if window exists and close if already open
    if (pvwWin && pvwWin.open && !pvwWin.closed) pvwWin.close();

    // see if pixels or percentage has been nominated
    if (width <= 1) {
    var pvwWidth = screen.width * width;
    }
    else {
    var pvwWidth = width;
    }
    if (height <= 1) {var pvwHeight = screen.height * height;}
    else {var pvwHeight = height;}

    // get screen dimensions
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 800, yMax=600;

    // set top-left corner offsets for centred window
    var xOffset = (xMax - pvwWidth)/2, yOffset = (yMax - pvwHeight)/2;
    // adjust offsets if window is not to be centred - based on % of window size 
    if (offset > 0 || offset < 1) {
    var xPos = offset, yPos = offset
    if (xOffset > (xMax * xPos)) {var xOffset = xMax * xPos;}
    if (yOffset > (yMax * yPos)) {var yOffset = yMax * yPos;}
    }

    // set window features
    var features = "location=no,scrollbars=yes,menubar=no,toolbar=no,resizable=yes,status=no,width="+pvwWidth+",height="+pvwHeight+",InnerWidth="+pvwWidth+",InnerHeight="+pvwHeight+",screenX="+xOffset+",screenY="+yOffset+",top="+yOffset+",left="+xOffset;
    // open new window and set focus
    pvwWin = window.open("",pvwName,features);
    pvwWin.focus(); // bring it to the top
    //return true; // submit the form into this window
}

function closeDep() {
    if (pvwWin && pvwWin.open && !pvwWin.closed) pvwWin.close();
}

function previewOpen()
{
	var width = .8, height = .8, offset = 1;
           MM_openCentredWindow("",width,height,offset);
}

function MM_openBrWindow(theURL,winName,features){ //v2.0
    window.open(theURL,winName,features);
}

function there(dropdown) {
	var width = .8, height = .7, offset = 1;
	var URL = dropdown.options[dropdown.selectedIndex].value;
       if(URL!="") {
           MM_openCentredWindow(URL,width,height,offset);}
}

