var create_link_openers = function(){

	var link_data = [
		{link_class:"xl_movie_link",url:"http://www.vorne.com/xl-movie/index.html",width:"760",height:"465"},
		{link_class:"all_production_view_link",url:"http://www.vorne.com/images/all-production-view.png",width:"863",height:"296"}, // 2009 News
		{link_class:"tpt_link",url:"http://www.vorne.com/images/screenshots-large/total-production-timeline.png",width:"680",height:"519"},
		{link_class:"tpt_chronological_link",url:"http://www.vorne.com/images/total-production-timeline-chronological.png",width:"940",height:"793"}, // 2009 News
		{link_class:"tpt_grouped_link",url:"http://www.vorne.com/images/total-production-timeline-grouped.png",width:"940",height:"685"}, // 2009 News
		{link_class:"tpt_zoom_in_link",url:"http://www.vorne.com/images/total-production-timeline-zoom-in.png",width:"940",height:"200"}, // 2009 News
		{link_class:"downtime_analytics_link",url:"http://www.vorne.com/images/screenshots-large/downtime-analytics.png",width:"680",height:"532"},
		{link_class:"configurable_reason_codes_link",url:"http://www.vorne.com/images/configurable-reason-codes.png",width:"610",height:"420"}, // 2009 News
		{link_class:"barcode_generation_link",url:"http://www.vorne.com/images/barcode-generation.png",width:"496",height:"448"}, // 2009 News
		{link_class:"pareto_charts_link",url:"http://www.vorne.com/images/pareto-charts.png",width:"940",height:"492"}, // 2009 News
		{link_class:"trend_charts_link",url:"http://www.vorne.com/images/trend-charts.png",width:"940",height:"270"}, // 2009 News
		{link_class:"shift_metrics_link",url:"http://www.vorne.com/images/screenshots-large/xl-web-server-real-time-shift.png",width:"600",height:"456"},
		{link_class:"xl_web_interface_link",url:"http://www.vorne.com/images/screenshots-large/xl-web-interface.png",width:"680",height:"601"}, // What's New, Home
		{link_class:"mobile_interface_link",url:"http://www.vorne.com/mobile-interface.htm",width:"800",height:"540"},
		{link_class:"real_time_manufacturing_visibility_link",url:"http://www.vorne.com/real-time-manufacturing-visibility.htm",width:"920",height:"320"}, // Home
		{link_class:"performance_management_tools_link",url:"http://www.vorne.com/performance-management-tools.htm",width:"840",height:"520"}, // Home
		{link_class:"reporting_link",url:"http://www.vorne.com/reporting.htm",width:"680",height:"380"}, // Home
		{link_class:"downtime_analytics2_link",url:"http://www.vorne.com/popups/downtime-analytics.htm",width:"840",height:"532"}, // Home
		{link_class:"oee_analytics_link",url:"http://www.vorne.com/popups/oee-analytics.htm",width:"990",height:"617"}, // Home
		{link_class:"plant_wide_rollup_link",url:"http://www.vorne.com/popups/plant-wide-rollup.htm",width:"931",height:"342"}, // Home
		{link_class:"real_time_information_link",url:"http://www.vorne.com/popups/real-time-information.htm",width:"850",height:"601"}, // Home
		{link_class:"job_on_target_link",url:"http://www.vorne.com/popups/job-on-target.htm",width:"730",height:"270"}, // Home
		{link_class:"setup_take_longer_link",url:"http://www.vorne.com/popups/setup-take-longer.htm",width:"460",height:"270"}, // Home
		{link_class:"any_lines_down_link",url:"http://www.vorne.com/popups/any-lines-down.htm",width:"971",height:"280"}, // Home
		{link_class:"plant_floor_scoreboard_link",url:"http://www.vorne.com/popups/plant-floor-scoreboard.htm",width:"760",height:"450"}, // Home
		{link_class:"win_their_shift_link",url:"http://www.vorne.com/popups/win-their-shift.htm",width:"690",height:"320"}, // Home
		{link_class:"oee_pocket_guide_link",url:"http://www.vorne.com/images/press-releases/oee-website/OEE-Pocket-Guide-300px-wide.jpg",width:"340",height:"706"},
		{link_class:"m1000expresseditor_link",url:"http://www.vorne.com/images/screenshots-large/m1000expresseditor.gif",width:"640",height:"490"}, // M1000 Express for Windows
		{link_class:"grphedtr_link",url:"http://www.vorne.com/images/screenshots-large/grphedtr.gif",width:"686",height:"531"}, // M1000 Express for Windows
		{link_class:"msglist_link",url:"http://www.vorne.com/images/screenshots-large/msglist.gif",width:"606",height:"421"}, // M1000 Express for Windows
		{link_class:"advtab_link",url:"http://www.vorne.com/images/screenshots-large/advtab.gif",width:"685",height:"531"}, // M1000 Express for Windows
		{link_class:"library_link",url:"http://www.vorne.com/images/screenshots-large/library.gif",width:"607",height:"389"}, // M1000 Express for Windows
		{link_class:"m1000expressengine_link",url:"http://www.vorne.com/images/screenshots-large/m1000expressengine.gif",width:"640",height:"333"}, // M1000 Express for Windows
		{link_class:"vdpwmain_link",url:"http://www.vorne.com/images/screenshots-large/vdpwmain.gif",width:"762",height:"520"}, // Display-Pro for 2000C Series
		{link_class:"vdpwreview_link",url:"http://www.vorne.com/images/screenshots-large/vdpwreview.gif",width:"451",height:"254"}, // Display-Pro for 2000C Series
		{link_class:"vdpwprogram_link",url:"http://www.vorne.com/images/screenshots-large/vdpwprogram.gif",width:"529",height:"504"}, // Display-Pro for 2000C Series
		{link_class:"vdp2100main_link",url:"http://www.vorne.com/images/screenshots-large/vdp2100main.gif",width:"517",height:"440"}, // Display-Pro 2100 Programming Utility for 2100C Series
		{link_class:"vdp2100send_link",url:"http://www.vorne.com/images/screenshots-large/vdp2100send.gif",width:"469",height:"450"}, // Display-Pro 2100 Programming Utility for 2100C Series
		{link_class:"vdp2100edit_link",url:"http://www.vorne.com/images/screenshots-large/vdp2100edit.gif",width:"517",height:"440"}, // Display-Pro 2100 Programming Utility for 2100C Series
		{link_class:"clock_87_main_g_link",url:"http://www.vorne.com/images/screenshots-large/clock-87-main-g.gif",width:"793",height:"545"}, // Clock 87 Utility for 87/708 Series
		{link_class:"clock_87_option_g_link",url:"http://www.vorne.com/images/screenshots-large/clock-87-option-g.gif",width:"516",height:"464"}, // Clock 87 Utility for 87/708 Series
		{link_class:"clock_87_set_time_g_link",url:"http://www.vorne.com/images/screenshots-large/clock-87-set-time-g.gif",width:"509",height:"463"}, // Clock 87 Utility for 87/708 Series
		{link_class:"dasingle_link",url:"http://www.vorne.com/images/screenshots-large/dasingle.gif",width:"640",height:"346"}, // 87 Express Pro Software Application
		{link_class:"daall_link",url:"http://www.vorne.com/images/screenshots-large/daall.gif",width:"640",height:"346"}, // 87 Express Pro Software Application
		{link_class:"ddsingle_link",url:"http://www.vorne.com/images/screenshots-large/ddsingle.gif",width:"640",height:"346"}, // 87 Express Pro Software Application
		{link_class:"ddall_link",url:"http://www.vorne.com/images/screenshots-large/ddall.gif",width:"641",height:"347"}, // 87 Express Pro Software Application
		{link_class:"dataxprt_link",url:"http://www.vorne.com/images/screenshots-large/dataxprt.gif",width:"616",height:"128"}, // 87 Express Pro Software Application
		{link_class:"oee_website_200_link",url:"http://www.vorne.com/images/press-releases/oee-website/OEE-Website-200px-wide.jpg",width:"240",height:"194"}, // Media Kits
		{link_class:"oee_website_300_link",url:"http://www.vorne.com/images/press-releases/oee-website/OEE-Website-300px-wide.jpg",width:"340",height:"271"}, // Media Kits
		{link_class:"oee_website_450_link",url:"http://www.vorne.com/images/press-releases/oee-website/OEE-Website-450px-wide.jpg",width:"490",height:"386"}, // Media Kits
		{link_class:"oee_pocket_guide_100_link",url:"http://www.vorne.com/images/press-releases/oee-website/OEE-Pocket-Guide-100px-wide.jpg",width:"140",height:"262"}, // Media Kits
		{link_class:"oee_pocket_guide_150_link",url:"http://www.vorne.com/images/press-releases/oee-website/OEE-Pocket-Guide-150px-wide.jpg",width:"190",height:"373"}, // Media Kits
		{link_class:"oee_pocket_guide_300_link",url:"http://www.vorne.com/images/press-releases/oee-website/OEE-Pocket-Guide-300px-wide.jpg",width:"340",height:"706"}, // Media Kits
		{link_class:"fast_guide_oee_150_link",url:"http://www.vorne.com/images/press-releases/oee-website/Fast-Guide-OEE-150px-wide.jpg",width:"190",height:"234"}, // Media Kits
		{link_class:"fast_guide_oee_300_link",url:"http://www.vorne.com/images/press-releases/oee-website/Fast-Guide-OEE-300px-wide.jpg",width:"340",height:"428"}, // Media Kits
		{link_class:"xl800_32240t_with_bg_link",url:"http://www.vorne.com/news/xl800pr/XL800-32240T_with_background.jpg",width:"440",height:"307"}, // Media Kits
		{link_class:"xl800_32240t_no_bg_link",url:"http://www.vorne.com/news/xl800pr/XL800-32240T_NO_background.jpg",width:"440",height:"117"}, // Media Kits
		{link_class:"xl_documentation_center_link",url:"http://www.vorne.com/images/screenshots-large/xl-documentation-center.png",width:"670",height:"445"}, // 2007 News
		{link_class:"xl800_animated_large_link",url:"http://www.vorne.com/images/xl-gallery/xl800-32080t-graphics-display-animated-large.gif",width:"520",height:"300"} // What's New?
		];

    function addEvent(elm, evType, fn, useCapture)
    {
        if (elm.addEventListener)
        {
            elm.addEventListener(evType, fn, useCapture);
            return true;
        }
        else if (elm.attachEvent)
        {
            var r = elm.attachEvent('on' + evType, fn);
            return r;
        }
        else
        {
            elm['on' + evType] = fn;
            return true;
        }
    }
    
    // get from DHTL Utopia: "Modern Web Design Using JavaScript & DOM"
    function stop_default(e)
    {
        if (e && e.preventDefault)
        {
            e.preventDefault();
            e.stopPropagation();
        }
        else
        {
            window.event.cancelBubble = true;
            window.event.returnValue = false;
        }
    }
   
    function getElementsByClassName(searchClass,node,tag) {
        var classElements = new Array();
        if ( node == null )
            node = document;
        if ( tag == null )
            tag = '*';
        var els = node.getElementsByTagName(tag);
        var elsLen = els.length;
        var pattern = new RegExp("(^|\\\\s)"+searchClass+"(\\\\s|$)");
        for (i = 0, j = 0; i < elsLen; i++) {
            if ( pattern.test(els[i].className) ) {
                classElements[j] = els[i];
                j++;
            }
        }
        return classElements;
    }
    
    function open_window(url,width,height)
    {
        window.open(url,'_blank','width='+width+',height='+height);
    }
        
    return {
        init: function(){
        					
			var make_event_handler = function(link_num) {
			 	return function(e){
					stop_default(e); open_window(link_data[link_num].url,link_data[link_num].width,link_data[link_num].height);
					};
				};
			for (var j = 0; j < link_data.length; j++) {
	            var links = getElementsByClassName(link_data[j].link_class, document);
	            for (var i = 0; i < links.length; ++i) {
	                var link = links[i];
					addEvent(link, "click", make_event_handler(j), true);
	            }
            }
        }
    };
}();
window.onload = create_link_openers.init;