
function openNewWindow(url) {
    var newwindow;
    newwindow = (url,
 'open_window',
 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes, width=640, height=640, left=0, top=0');
}



// 06/14/2010 : TJV : Provide a popup window that excepts width and height vars..
function PopUpWindow(url, varWidth, varheight) {
    var configPopup = "'menubar=0, resizable=1, scrollbars=1, status=0, width=" + varWidth + ",height=" + varheight + "'";
    window.open(url, 'newwindow', configPopup);
}


//03/14/2009 - KJV
function jumpTo(ID) {
    //This is all about trying your best to support FireFox, IE and Safari
    try {
        //alert('scrollintoview');
        document.getElementById(ID).scrollintoview(); //IE 6
    }
    catch (e) {
        try {
            // 10/23/2009 KG: Bug with IE offsetTop... position relative to parent(s), so add up offsets.
            obj = document.getElementById(ID);
            var y = obj.offsetTop;
            while (obj = obj.offsetParent) y += obj.offsetTop
            window.scrollTo(0, y);
        }
        catch (e) {
            try {
                //alert('node scroll');
                var nodes = document.getElementsByName(ID); //Safari
                setTimeout(window.scrollTo(0, nodes[0].offsetTop), 1);
            }
            catch (e) { }

        }
    }
}

/* 
02/09/2010 - TJV
Added functionality to redirect user to another page..
Used to make everything clickable within a panel.  Handy if
they all share the same location when clicked and a hyperlink is not used.
*/
function urlRedirect(ctrlName) {
    var url = document.getElementById(ctrlName);
    window.location = url;
}


/* 02/10/2010 - TJV  speed up the time the popup menu appears  */
var addthis_config = {
    ui_click: true,
    services_exclude: 'print,email',
    services_compact: 'favorites, linkedin, twitter, facebook, digg, delicious, myspace, google, live, blogger'
}



/* ------------- 07:11:10: Trebly : Dynamic jquery functionality for fancybox ---------------
Wraps object in hyperlink then asigns jquery css class.*/

/* I don't want to change jquery.fancybox.css path. We want all title backgrounds
to be the same when created from TeamSite.  Using global siteURL from javasctipt function*/
function BuildImageButtonPath() {

    //Only if created from TeamSite.. Title must allways come from this location.
    $('#fancy_title_main').css('background-image', 'url(' + siteURL + 'images/buttons/fancy_title_main.png)');
    $('#fancy_title_left').css('background-image', 'url(' + siteURL + 'images/buttons/fancy_title_left.png)');
    $('#fancy_title_right').css('background-image', 'url(' + siteURL + 'images/buttons/fancy_title_right.png)');
    $('#fancy_close').css('background-image', 'url(' + siteURL + 'images/buttons/fancy_closebox.png)');    
}


//Read meta tag meric and ge division attribute
function SetDivisonPathIn(currentObjPath) {

    var newUrl;
    var division = $('meta[name=PHILIPS.METRICS.DIVISION]').attr("content");

    if (division == 'HC') {
        newUrl = currentObjPath.replace('TEMP_DIVISION', "pwc_hc");
    } else if (division == 'LI') {
        newUrl = currentObjPath.replace('TEMP_DIVISION', "pwc_li");
    } else if (division == 'CO') {
        newUrl = currentObjPath.replace('TEMP_DIVISION', "pwc_nc");
    } else {
        newUrl = currentObjPath;
    }
    return newUrl;
}


function ShowFancyBox(objID, objPath, objHeight, objWidth, popupTitle, shadeBackground) {

    $(document).ready(function() {
        var overlayShowVar = shadeBackground;
        var updatedPath = SetDivisonPathIn(objPath); 	//Need metatag information
        var objectPath = updatedPath.toString().split('.');

        if ($("#divFancy").length) $("#divFancy").remove(); //remove initial if exist
        
        BuildImageButtonPath();
        if (popupTitle != "") $('#' + objID + '').attr("title", popupTitle);  //Set tag title
        objectPath.reverse();   //Grap last index that has file extension after reversing string
        IsFlashDiv(updatedPath, objHeight, objWidth, objectPath[0]);  //Create dynamic objects

        $('a#' + objID + '').live('click', function() {
            $('a#' + objID + '').fancybox({
                'titleShow': true,
                'titlePosition': 'outside',
                'frameWidth': parseFloat(objWidth),
                'frameHeight': parseFloat(objHeight),
                'overlayShow': overlayShowVar,
                'showCloseButton': true,
                'enableEscapeButton': true,
                'hideOnContentClick': false,
                'zoomSpeedIn': 300,
                'zoomSpeedOut': 300,
                'callbackOnClose': function() {
                    $("#videoObject").remove();
                    $("#imageObject").remove();
                    $("#divFancy").remove();
                }
            }).trigger('click');  //trigger the click event immediately after assigning.
            return false;
        })
    });
}


// 07.14.2010 : Trebly : Creates div and video object for jquery fancybox
function IsFlashDiv(objectPath, height, width, fileType) {

    var divHld = document.createElement("div");
    divHld.setAttribute('id', "divFancy");  //Create div tag

    //Create video object
    if (fileType == 'swf') {
        var flash = document.createElement("embed");
        flash.setAttribute('id', "videoObject");
        flash.setAttribute('height', height);
        flash.setAttribute('width', width);
        flash.setAttribute('src', objectPath);
        flash.setAttribute('type', "application/x-shockwave-flash");
        flash.setAttribute('pluginspace', "http://www.macromedia.com/go/getflashplayer");
        flash.setAttribute('allowscriptaccess', "always");
        flash.setAttribute('allowfullscreen', "true");
        divHld.appendChild(flash);   //Appdend flash object inside div tag
    } else {
        var img = document.createElement("img");
        img.setAttribute('id', "imageObject");
        img.setAttribute("src", objectPath);
        img.setAttribute("alt", '');
        divHld.appendChild(img);     //Appdend img object inside div tag
    }
    document.body.appendChild(divHld); //Appdend div with embedded flash object to form
    divHld.style.display = "none";     //Hide div to be displayed
}
/* -------------------- End Dynamic jquery functionality ------------------*/