﻿var curPopupWindow = null;

function clearText(thefield) {
    if (thefield.defaultValue == thefield.value)
        thefield.value = ""
}

function ShowPopup(hoveritem) {
    hp = document.getElementById("hoverpopup");

    // Set popup to visible
    hp.style.visibility = "Visible";

}

function HidePopup() {
    hp = document.getElementById("hoverpopup");
    hp.style.visibility = "Hidden";
}

function OpenSurvey() {
    openPopup(
			'feedback.aspx',
			'Chestionar',
			400,
			700,
			'width=400,height=700,scrollbars=yes,toolbar=no,status=no,directories=no,menubar=no,resizable=yes',
			true);
}

function openPopup(url, name, pWidth, pHeight, features, snapToLastMousePosition) {
    openPopupFocus(url, name, pWidth, pHeight, features, snapToLastMousePosition, true);
}

function openPopupFocus(url, name, pWidth, pHeight, features, snapToLastMousePosition, closeOnLoseFocus) {
    closePopup();

    //lastMouseX = 300;
    //lastMouseY = 400;   
    //features += ",screenX=" + lastMouseX + ",left=" + lastMouseX + ",screenY=" + lastMouseY + ",top=" + lastMouseY;
    
    var left = (screen.width/2)-(pWidth/2);
    var top = (screen.height/2)-(pHeight/2);
    features+=", top="+top+", left="+left;

    if (closeOnLoseFocus) {
        curPopupWindow = window.open(url, name, features, false);
        curPopupWindow.focus();
    } else {
        win = window.open(url, name, features, false);
        win.focus();
    }
}

function closePopup() {
    if (curPopupWindow != null) {

        if (!curPopupWindow.closed) {
            curPopupWindow.close();
        }
        curPopupWindow = null;
    }
}

