/* 
 * Slider 8
 * @version:    Alpha 1
 * @author:     Dariusz Zieliński
 */ 

function typeOf(o){
    var type = typeof o;
         //If typeof return something different than object then returns it.
    if (type !== 'object') {
        return type;
         //If it is an instance of the Array then return "array"
    } else if (Object.prototype.toString.call(o) === '[object Array]') {
        return 'array';
         //If it is null then return "null"
    } else if (o === null) {
        return 'null';
       //if it gets here then it is an "object"
    } else {
        return 'object';
    }
}

var items = new Array(

    /* 
    
    new Object({ // Zapro na chat
        title: 'Zapraszamy na Chat - 18 stycznia',
        type: 'img',
        src: 'http://www.ingsecurities.pl/upload_module/banners/chat/chat-2012.01.18-sol.jpg',
        href: 'http://serwis.ingsecurities.pl/serwis_chat_wstep.xml',
        target: '_blank',
        prio: 10,
        time: 12000
    })
    
    new Object({ // Chat trwa!
        title: 'Chat trwa - 18 stycznia',
        type: 'img',
        src: 'http://www.ingsecurities.pl/upload_module/banners/chat/chat-trwa-do12sol.jpg',
        href: 'http://chat.ingsecurities.pl',
        target: '_blank',
        prio: 10,
        time: 12000
    })
    
    new Object({ // Archiwum chatu
        title: 'Chat 18 stycznia - archiwum',
        type: 'img',
        src: 'http://www.ingsecurities.pl/upload_module/banners/chat/chat-2012.01.18archiwum-sol.jpg',
        href: 'http://serwis.ingsecurities.pl/serwis_chat_wstep.xml',
        target: '_blank',
        prio: 10,
        time: 12000
    })
    
    */
);


jQuery(document).ready(function() {
    var code = '';
    
    if(items.length > 0){
	    for(var i=0; i<items.length; i++){
	        
	        var id, baner, baner_name, type;
	        var item = items[i];
	        
	        if(typeOf(item['src']) != 'array')
	        {
	            baner = item['src'];
	            baner_name = '';
	            type = item['type'];
	            
	            if(typeof item['href'] != 'undefined'){ // GOT LINK?
	                code += '<a href="'+item['href']+
	                        '" target="'+item['target']+
	                        '" onclick="_gaq.push([\'_trackEvent\', \'Banery\', \''+item['title']+baner_name+'\', \''+item['href']+'\']);">'+
	                        '<img src="'+baner+'" alt="'+item['title']+'" /></a>';
	            }else{
	                code += '<img src="'+baner+'" alt="'+item['title']+'" />';
	            }
	        }
	        
	        jQuery('#komunikat').append(code);
	    }
    }else{
    	$('.kom-box').css('display', 'none');
    }
    
    $('.two-cols p').eq(0).append('<div style="padding: 8px; background: none repeat scroll 0% 0% rgb(0, 0, 120); color: #b4c3e1; "><b>Przeczytaj:</b> <a style="color: white;" href="http://www.ingsecurities.pl/main_informacja_o_rozliczeniu_podatkowym_2011.xml">informacja o rozliczeniu podatkowym za rok 2011</a></div>');
    
    $('.kom-box').removeClass('alert-box');
    $('#komunikat').css('border', 'none');
    $('.kom-box .alert-box-tl').remove();
    $('.kom-box .alert-box-tr').remove();
    $('.kom-box .alert-box-bl').remove();
    $('.kom-box .alert-box-br').remove();
});
