


// JavaScript Document
 
/*
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 2 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
    --------------------------------------------------------------------
    
    Simple banner rotator. Version: 1.2.0
    Download, support, contact: http://www.spyka.net 
    (c) Copyright 2009 spyka Web Group
*/
 
/* 
    For full documentation:  http://www.spyka.net/docs/simple-banner-rotator
    For support:             http://www.spyka.net/forums
*/
 
//                                EDIT FROM HERE
///////////////////////////////////////////////////////////////////////////////////
//                                 Program options
 
 
// if 1 (one), all images will be resized to img_width and img_height, else images will display their correct size
var force_size    = 0;
// desired height and width of images, only takes affect if above is one
var img_width    = 728;
var img_height    = 90;
 
// time between refreshs of ad locations, to disable refreshs set to 0. In milliseconds, 1000 = 1 second
//var refresh_time = 8000;
var refresh_time = (10 * 1000);
//

// maximum amount of refreshs, good to set if a user may be on a page for a long period of time.
var refresh_max = 1000;
 
// if you do not want the same banners to display on the same page then set this to 0, else set it to 1.
// this option is only used if you have put the show_banners() javascript code more than once into a page
var duplicate_banners = 0;
 
// ignore/skip this line 
var banners = new Array();
 
// banner list syntax: banners[x] = new banner(website_name, website_url, banner_url, show_until_date);  DATE FORMAT: dd/mm/yyyy
// be sure to increase x by 1 for each banner added!
// to make sure a banner is always rotating, just set the date far into the future, i.e. year 3000
//new banner syntax:  banners[x] = new banner(Title Text, Title URL, Body Text, show_until_date);  DATE FORMAT: dd/mm/yyyy



	
			
			banners[0] = new banner('LPC2478 Developer Kit', '/us/en/techzone/toolsxpress/coop/LPC2478_developer_kit.html', 'The LPC2478 OEM board is equipped with NXP\'s ARM7TDMI-S based LPC2478 microcontroller and is suitable for applications requiring high quality graphic displays.', 'More...', '_blank','/Web Export/techzone/toolsxpress/embedded-artists-lpc2478-100.jpg', 'LPC2478 Developer Kit', 'LPC2478 Developer Kit ', '09/27/2011', '09/28/2012','?WT.z_link_type=Coop&WT.z_link_source=toolsXpress_hp','');

	
			
			banners[1] = new banner('SBC1651', '/us/en/techzone/toolsxpress/coop/SBC1651.html', 'The SBC1651 from Micro/sys Inc is ideal for high-performance, low-power embedded applications. Freescale\'s i.MX515 ARM Cortex-A8 CPU operates at 800 MHz.', 'More...', '_blank','/Web Export/techzone/toolsxpress/microsys-sbc1651-100.jpg', 'SBC1651', 'SBC1651', '09/27/2011', '09/28/2012','?WT.z_link_type=Coop&WT.z_link_source=toolsXpress_hp','');

	
			
			banners[2] = new banner('USB560BP JTAG Emulator', '/us/en/techzone/toolsxpress/coop/USB560BP_jtag_emulator.html', 'The compact Blackhawk USB560BP is the only bus-powered USB JTAG Emulator that supports all of the advanced capabilities of Texas Instruments latest DSPs.', 'More...', '_blank','/Web Export/techzone/toolsxpress/blackhawk-usb560bp-100.jpg', 'USB560BP JTAG Emulator', 'USB560BP JTAG Emulator', '09/27/2011', '09/28/2012','?WT.z_link_type=Coop&WT.z_link_source=toolsXpress_hp','');

 
 
//                         There is no need to edit below here
///////////////////////////////////////////////////////////////////////////////////
 
var used = 0;
var first_pass = 0;
var location_counter = 1;
var refresh_counter = 1;
 
function banner(title, url, bodyText, moreLabel, target, image, altText, imageTitleText, startDate, endDate,webTrends,dcsMultiTrack)
{
    this.title    = title;
    this.url    = url;
    this.bodyText    = bodyText;	
	this.moreLabel = moreLabel;
	this.target = target;
	
	this.image = image;
	this.altText = altText;
	this.imageTitleText = imageTitleText;
    this.startDate = startDate;
    this.endDate    = endDate;
	this.webTrends = webTrends;
	this.dcsMultiTrack = dcsMultiTrack.replace(/\"/g,"\'");
    this.active = 1;
	
	//if the featured product is current or not.
	this.current = false;
}
 
function show_banners()
{
    var html = '<div id="adLocation-' + location_counter + '"></div>';
    document.write(html);
    display_banners(location_counter);
    location_counter++;
}

function startBanners() {
    var current = 0;
    var now  = new Date();

    for (var index in banners) {
        //alert(banners[index].title);
               
        var inputEndDate    = banners[index].endDate;
        var inputStartDate = banners[index].startDate;

        inputStartDate = inputStartDate.split('/', 3);
        inputEndDate = inputEndDate.split('/', 3);

        //new Date(year, month, day, hours, minutes, seconds, milliseconds)
        //month starts at 0 in javascript.
        var start_date = new Date(eval(inputStartDate[2]), (eval(inputStartDate[0]) - 1), eval(inputStartDate[1]), 00, 00, 00, 00);
        var end_date    = new Date(eval(inputEndDate[2]), (eval(inputEndDate[0]) - 1), eval(inputEndDate[1]), 23, 59, 59, 00);
        
        if((now > start_date) && (now < end_date)) {
			banners[index].current = true;
            current++;
        }

    }
    //alert("currentDate : " + current);

    if (current == 1) {
        show_banners();
    }

    else if (current == 2) {
        show_banners();
        show_banners();
    }

    else if (current >= 3) {
        show_banners();
        show_banners();
        show_banners();
    }

    else {
        //do nothing
    }
}


function display_banners(location)
{
    if(location == '' || !location || location < 0)
    {
        // no location given
        return;
    }
    
    var am    = banners.length;
    
    if((am == used) && duplicate_banners == 0) {
        // all banners have been used
        return;
    }
 
    var rand    = Math.floor(Math.random()*am);    
    var bn         = banners[rand];
    
    var image_size     = (force_size == 1) ? ' width="' + img_width + '" height="' + img_height + '"' : '';
    //var html         = '<a href="' + bn.url + '" title="' + bn.name + '" target="_blank"><img border="0" src="' + bn.image + '"' + image_size + ' alt="' + bn.name+ '" /></a>';
	
	
	// if the image doesn't exists, do not use the image tag
	if (bn.image == '' || bn.image == ' ') {
		var html = "<div style=\"background:url(/Web%20Export/techzone/ms_featured_prod_bg.jpg) bottom no-repeat; padding: 0px 10px 0px 15px; font-size: 12px;\">\n\
					<br />\n\
					<a onclick=\"" +bn.dcsMultiTrack+ "\" onmouseover=\"freezebanner()\" onmouseout=\"unfreezebanner()\" href=\"" + bn.url + bn.webTrends + "\" target=\"" + bn.target + "\"><b>" + bn.title + "</b></a><br />" + bn.bodyText + "&nbsp;<a onclick=\"" +bn.dcsMultiTrack+ "\" href=\"" + bn.url + bn.webTrends + "\" target=\"" + bn.target + "\">" + bn.moreLabel + "</a><br /><br />\n\
				</div></br>"
	}
	
	else {
		var html = "<div style=\"background:url(/Web%20Export/techzone/ms_featured_prod_bg.jpg) bottom no-repeat; padding: 0px 10px 0px 15px; font-size: 12px;\">\n\
						<br /><a onclick=\"" +bn.dcsMultiTrack+ "\" href=\"" + bn.url + bn.webTrends + "\" target=\"" + bn.target + "\"><img onmouseover=\"freezebanner()\" onmouseout=\"unfreezebanner()\" border=\"0\" hspace=\"10\" align=\"left\" src=\"" + bn.image + "\"/></a>\n\
						<a onclick=\"" + bn.dcsMultiTrack + "\" href=\"" + bn.url + bn.webTrends + "\" target=\"" + bn.target + "\"><b>" + bn.title + "</b></a><br />" + bn.bodyText + "&nbsp;<a onclick=\"" +bn.dcsMultiTrack+ "\" href=\"" + bn.url + bn.webTrends + "\" target=\"" + bn.target + "\">" + bn.moreLabel + "</a><br /><br />\n\
					</div></br>"
	}
    

    if ((bn.active == 1) && (bn.current))
    {
        var location_element = document.getElementById('adLocation-' + location);
        
        if(location_element == null)
        {
            // ad location doesn't exist
            alert('spyka Webmaster banner rotator\nError: adLocation doesn\'t exist!');
        }
        else
        {
            location_element.innerHTML = html;
            
            if(duplicate_banners == 0)
            {
                bn.active = 0;
                used++;
            }
        }
    }
    else
    {
        display_banners(location);
    }
}
 
function refresh_banners()
{
    if((refresh_counter == refresh_max) || refresh_time < 1)
    {
        clearInterval(banner_refresh);  
    }
    used = 0;
    for(i = 0; i < banners.length; i++)
    {
        banners[i].active = 1;
    }
    for(i = 1; i < location_counter; i++)
    {
        display_banners(i);
    }
    refresh_counter++;
}
var banner_refresh = window.setInterval(refresh_banners, refresh_time);
function freezebanner()
{
clearInterval(banner_refresh); 
}
function unfreezebanner()
{
clearInterval(banner_refresh);
banner_refresh = window.setInterval(refresh_banners, refresh_time);
}
//Triggers dcsMultiTrack() for tagging offsite link and documents
function wtExtTagging(z_link_type,z_link_source,mc_id,z_supplier_id)
{
	_tag.WT.z_link_type = z_link_type;
	_tag.WT.z_link_source = z_link_source;
	_tag.WT.mc_id = mc_id;
	_tag.WT.z_supplier_id = z_supplier_id;
}

