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

smallWindow = 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=smallWindow;
        
        //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, 'small_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=smallWindow;
        
        //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, 'small_window', 'resizable=no,width='+self.window_width+',height='+self.window_height);
    };
}

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