﻿/*------------------------ 
© 2009 Systen, L.L.C. 
10500 Barkley 
Suite 200 
Overland Park, KS 66212 
-----------------------
Created by: Michael Merrell
Date Created: 3/5/2009
-----------------------
Purpose:
-----------------------
*/
function openWin(childURL, childWidth, childHeight, scrollBars, toolbars, resizable, childName) {
    var childWin;
    var childLeft = (screen.width - childWidth) / 2;
    var childTop = (screen.height - childHeight) / 2;
    if ((!childName) || (childName==null)) {
        childName = "";
    }

    childWin = window.open(childURL, childName, 'toolbar=' + toolbars + ',location=no,directories=no,status=no,menubar=no,scrollbars=' + scrollBars +
		',resizable=' + resizable + ',width=' + childWidth + ',height=' + childHeight + ',top=' + childTop + ',left=' + childLeft);

    return childWin;
} //function openWin(childURL, childWidth, childHeight, scrollBars, toolbars, resizable) 

function showWin(childURL, childWidth, childHeight) {
    if (document.documentElement.clientWidth <= childWidth || document.documentElement.clientHeight <= childHeight) {
        openWin(childURL, childWidth, childHeight, 'no', 'no', 'no');
    }
    else if (document.getElementById('dvWindowMain') && document.getElementById('iWindow') && document.getElementById('dvWindow')) {
        var dvWindowMain = document.getElementById('dvWindowMain');
        var dvWindow = document.getElementById('dvWindow');
        var iWindow = document.getElementById('iWindow');

        dvWindowMain.style.display = "block";

        dvWindow.style.width = childWidth + 'px';
        dvWindow.style.height = childHeight + 'px';
        dvWindow.style.left = ((document.documentElement.clientWidth - childWidth) / 2) + 'px';
        dvWindow.style.top = ((document.documentElement.clientHeight - childHeight) / 2) + 'px';

        iWindow.src = childURL;
        iWindow.height = childHeight + 'px';
        iWindow.width = childWidth + 'px';
    }
    else {
        var dvWindowMain = document.createElement('div');
        var dvBlackOut = document.createElement('div');
        var dvWindow = document.createElement('div');
        var iWindow = document.createElement('iframe');

        dvWindowMain.appendChild(dvBlackOut);
        dvWindowMain.appendChild(dvWindow);
        dvWindow.appendChild(iWindow);

        dvWindowMain.id = "dvWindowMain";
        dvWindowMain.style.width = "100%";
        dvWindowMain.style.height = "100%";
        dvWindowMain.style.display = "block";
        dvWindowMain.style.position = "absolute";
        dvWindowMain.style.left = "0px";
        dvWindowMain.style.top = "0px";

        dvBlackOut.className = "dvBlackOut";

        dvWindow.id = "dvWindow";
        dvWindow.className = "dvWindow";
        dvWindow.style.width = childWidth + 'px';
        dvWindow.style.height = childHeight + 'px';
        dvWindow.style.left = ((document.documentElement.clientWidth - childWidth) / 2) + 'px';
        dvWindow.style.top = ((document.documentElement.clientHeight - childHeight) / 2) + 'px';

        iWindow.id = "iWindow"
        iWindow.src = childURL;
        iWindow.height = childHeight + 'px';
        iWindow.width = childWidth + 'px';
        iWindow.frameborder = "0";

        document.forms[0].appendChild(dvWindowMain);
    }
}

function closeWin(bRefresh) {
    if (parent.document.getElementById('dvWindowMain') && bRefresh) {
        parent.document.location = parent.document.location;
    }
    else if (parent.document.getElementById('dvWindowMain') && bRefresh == false) {
        parent.document.getElementById('dvWindowMain').style.display = "none";
        parent.document.getElementById('iWindow').src = "";
    }
    else if (document.getElementById('dvWindowMain') && bRefresh) {
        document.location = document.location;
    }
    else if (document.getElementById('dvWindowMain') && bRefresh == false) {
        document.getElementById('dvWindowMain').style.display = "none";
        document.getElementById('iWindow').src = "";
    }
    else if (self.opener && self.opener.document.getElementById('dvWindowMain') && bRefresh) {
        self.opener.document.location = self.opener.document.location;
        self.close();
    }
    else //if (self.opener && bRefresh == false)
    {
        self.close();
    }
}

function centerWin(win) {
    var dvWindow = document.getElementById(win);
    if ((!win) || (win == null)) {
        dvWindow = document.getElementById('dvWindow');
    }
    if (dvWindow != null) {
        dvWindow.style.left = ((document.documentElement.clientWidth - dvWindow.clientWidth) / 2) + 'px';
        dvWindow.style.top = ((document.documentElement.clientHeight - dvWindow.clientHeight) / 2) + 'px';
    }
}

function setPage(location) {
    $("#nav_" + location).attr("class", "on");
}

var section;

function getLocation() {
    var pathname = window.location.pathname;
    /*
    if ((pathname == "/src/about.aspx") ||
        (pathname == "/src/corevalues.aspx") ||
        (pathname == "/src/executiveteam.aspx") ||
        (pathname == "/src/executiveteam_2.aspx") ||
        (pathname == "/src/experience.aspx") ||
        (pathname == "/src/news.aspx") ||
        (pathname == "/src/staff_bio_3.aspx")) {
        section = "about";
    } else if ((pathname == "/src/properties.aspx") ||
        (pathname == "/src/property_details3.aspx") ||
        (pathname == "/src/property_details_2.aspx") ||
        (pathname == "/src/propertymap.aspx") ||
        (pathname == "/src/copaken_can.aspx") ||
        (pathname == "/src/smartsearch.aspx") ||
        (pathname == "/src/ResultListing.aspx")) {
        section = "properties";
    } else if (pathname == "/src/services.aspx") {
        section = "services";
    } else if (pathname == "/src/contactus.aspx") {
        section = "contact";
    } else if (pathname == "/src/testimonials.aspx") {
        section = "testimonials";
    } else {
        // No Marker
    }
    */

    var page = pathname.substring((pathname.lastIndexOf("/") + 1), pathname.lastIndexOf("."));
    /*
    if ((page == "staff_bio_3") || (page == "executiveteam_2")) {
        page = "executiveteam";
    }
    */
    setPage(page);
}

function pop_application() {
    // openWin("application_showroom.aspx", 600, 600, "yes", "yes", "yes", "showroom_app");
    openWin("../docs/Showroom_Application_2010.pdf", 600, 600, "yes", "yes", "yes", "showroom_app");
    centerWin("showroom_app");
}


/* JQUERY AREA */
$(document).ready(function() {
    getLocation();
});    


/*
* $History: scripts.js $
 * 
 * *****************  Version 3  *****************
 * User: Trye         Date: 4/26/10    Time: 2:02p
 * Updated in $/Designers_Library/Projects/DLWeb/public/scripts
 * 
 * *****************  Version 2  *****************
 * User: Trye         Date: 4/26/10    Time: 12:08p
 * Updated in $/Designers_Library/Projects/DLWeb/public/scripts
 * 
 * *****************  Version 1  *****************
 * User: Builds       Date: 3/05/10    Time: 8:54a
 * Created in $/Designers_Library/Projects/DLWeb/public/scripts
 * 
 * *****************  Version 1  *****************
 * User: Builds       Date: 3/05/10    Time: 8:45a
 * Created in $/Designers_Library/Projects/DLWeb/DLWeb/public/scripts
 * 
 * *****************  Version 4  *****************
 * User: Trye         Date: 2/17/10    Time: 1:51p
 * Updated in $/Designers_Library/Projects/DLWeb/DLWeb/scripts
 * 
 * *****************  Version 3  *****************
 * User: Trye         Date: 2/16/10    Time: 4:30p
 * Updated in $/Designers_Library/Projects/DLWeb/DLWeb/scripts
 * 
 * *****************  Version 2  *****************
 * User: Trye         Date: 1/27/10    Time: 5:51p
 * Updated in $/Designers_Library/Projects/DLWeb/DLWeb/scripts
 * 
 * *****************  Version 1  *****************
 * User: Trye         Date: 1/26/10    Time: 4:25p
 * Created in $/Designers_Library/Projects/DLWeb/DLWeb/scripts
 * 
 * *****************  Version 2  *****************
 * User: Trye         Date: 12/22/09   Time: 12:03p
 * Updated in $/CompResults/Projects/CompResults/Public/scripts
* 
* *****************  Version 1  *****************
* User: Trye         Date: 12/14/09   Time: 5:17p
* Created in $/CompResults/Projects/CompResults/Public/scripts
* 
* *****************  Version 1  *****************
* User: Mmerrell     Date: 12/08/09   Time: 2:08p
* Created in $/CompResults/Projects/CompResults/script
* 
* *****************  Version 1  *****************
* User: Mmerrell     Date: 3/05/09    Time: 9:53a
* Created in $/Systen/Projects/CompResults_08/script
*
*/
