﻿function AddLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                try {
                    oldonload();
                } catch (e) {

                }
            }
            func();
        }
    }
}

function TextBlur(id, style) {
    var obj = document.getElementById(id);
    if (obj) {
        if (obj.value == "") {
            obj.className = style;
        }
        else {
            obj.className = 'DYNInputMouseOver';
        }
    }
}

function TextFocus(id) {
    var obj = document.getElementById(id);
    if (obj) {
        if (obj.value == "") {
            obj.className = 'DYNInputMouseOver';
        }
    }
}
function TextInit(id,style) {
    var obj = document.getElementById(id);
    if (obj) {
        if (!obj.value == "") {
            obj.className = 'DYNInputMouseOver';
        }
    }
}
function addEvent(id, bg) {
    var obj = document.getElementById(id);
    if (obj) {
        obj.onfocus = function() { TextFocus(id); };
        obj.onblur = function() { TextBlur(id, bg); };
    }
}

function AddDynamicInputEvents() {
    addEvent('dnn_ctr362_DynamicForms_TBR_GUIDb034348d-2398-4985-aa61-22c48ad14f8cFirstName', 'DYNFirstName');
    addEvent('dnn_ctr362_DynamicForms_TBR_GUID76424f0a-7928-4ffe-879c-7c05c149533aLastName', 'DYNLastName');
    addEvent('dnn_ctr362_DynamicForms_TBR_GUID9352a39c-d1fb-48cb-a52d-d2b3c29f9b81Email', 'DYNEmail');
    addEvent('dnn_ctr362_DynamicForms_TBR_GUID0fb93aaa-acc4-4dd1-8db2-6a3df8b12146Phone', 'DYNPhone');
}

function InitDynamicInput() {
    TextInit('dnn_ctr362_DynamicForms_TBR_GUIDb034348d-2398-4985-aa61-22c48ad14f8cFirstName', 'DYNFirstName');
    TextInit('dnn_ctr362_DynamicForms_TBR_GUID76424f0a-7928-4ffe-879c-7c05c149533aLastName', 'DYNLastName');
    TextInit('dnn_ctr362_DynamicForms_TBR_GUID9352a39c-d1fb-48cb-a52d-d2b3c29f9b81Email', 'DYNEmail');
    TextInit('dnn_ctr362_DynamicForms_TBR_GUID0fb93aaa-acc4-4dd1-8db2-6a3df8b12146Phone', 'DYNPhone');

}
AddLoadEvent(AddDynamicInputEvents);
AddLoadEvent(InitDynamicInput);


// control show Privacy div ,
// added by Daniel
document.write("<script src='/windowfiles/dhtmlwindow.js' type='text/javascript'></script>");
document.write("<script src='/modalfiles/modal.js' type='text/javascript'></script>");
document.write("<link rel='stylesheet' href='/windowfiles/dhtmlwindow.css' type='text/css' />");
document.write("<link rel='stylesheet' href='/modalfiles/modal.css' type='text/css' />");

function showPrivacy() {
    //    var googlewin = dhtmlmodal.open("googlebox", "iframe", "http://www.darleygreen.tst/PrivacyStatement/tabid/57/Default.aspx", "Privacy Statement", "width=400px,height=300px,resize=0,scrolling=0,center=1")

    //    googlewin.onclose = function() { //Run custom code when window is being closed (return false to cancel action):
    //        //googlewin.hide();
    //        //return window.confirm("Close window 1?")
    //        return true;
    //    }
    //    
    emailwindow = dhtmlmodal.open('EmailBox', 'iframe', '/Default.aspx?tabid=57', 'Privacy Statement', 'width=600px,height=400px,center=1,resize=0,scrolling=1');

    emailwindow.onclose = function() { //Define custom code to run when window is closed
        return true;
    }

    var obj = document.getElementById("dhtmlwindow_close_fix");
    //alert("obj:" + obj);
    if (obj != null) {
       //alert("obj is not null!");
        obj.src = "/portals/0/close.gif";
        //alert('sdf');
    }
}