//script for opening link target in a smaller window
//used for Flash videos on testimonials page

newWindow = new function() {
    //dimensions of window to open
    this.window_width='320';
    this.window_height='225';

    //initialize functionality on page load
    this.initialize = function() {
        var self=newWindow;
        
        //get all links on page
        var all_links=document.getElementsByTagName('a');
        var all_links_length=all_links.length;
        var link=null;
        for (x=0; x<all_links_length; x++) {
            link=all_links[x];
            if (checkClass(link, 'new_window')) {
                //check all links for 'small_window' class and add event handler
                addEvent(link, 'click', stopDefault, false);
                link.onclick=stopDefaultSafari;
                addEvent(link, 'click', self.openWindow, false);
            }
        }
    };
    
    //open the window on click
    this.openWindow = function(e) {
        var self=newWindow;
        
        //get the element that triggered the event and make sure it is a link
        var el=findTarget(e);
        while (el.tagName.toLowerCase()!='a' && el.parentNode) {
            el=el.parentNode;
        }
        
        //get the link path and open the window
        var path=el.href;
        window.open(path);
    };
}

if (document.getElementById && document.getElementsByTagName) {
    addEvent(window, 'load', newWindow.initialize, false);
}