$(
	function() {
	$('ul#avti').innerfade({
		speed: 1000,
		timeout: 3000,
		type: 'random',
		containerheight: '80px'
	});
	$('ul#banners').innerfade({
		speed: 1500,
		timeout: 6000,
		type: 'sequence',
		containerheight: '80px'
	});
	//hide the all of the element with class msg_body
	$(".msgbody").hide();
	//toggle the componenet with class msg_body
	$(".msghead").click(function()
	{
		$(this).next(".msgbody").slideToggle(600);
	});
	$('a[@rel*=lightbox]').lightBox();
});

function trim(str, charlist) {
    charlist = !charlist ? ' \s\xA0' : charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1');
    var re = new RegExp('^[' + charlist + ']+|[' + charlist + ']+$', 'g');
    return str.replace(re, '');
}

function explode( delimiter, string ) {
    var emptyArray = { 0: '' };
    if ( arguments.length != 2 || typeof arguments[0] == 'undefined' || typeof arguments[1] == 'undefined' ) {
        return null;
    }
 
    if ( delimiter === '' || delimiter === false || delimiter === null ) {
        return false;
    }
 
    if ( typeof delimiter == 'function' || typeof delimiter == 'object' || typeof string == 'function' || typeof string == 'object' ) {
        return emptyArray;
    }
 
    if ( delimiter === true ) {
        delimiter = '1';
    }
 
    return string.toString().split ( delimiter.toString() );
}

function ShowMeWhatINeed(picked){

	var area = document.getElementById("partnerji");
	var divs = area.getElementsByTagName("div");
	var goes = divs.length;
	var tmp  = [];
	var ingoes;
	var chk;
	
	if(picked=='0') { for(i=0; i<goes; i++) { divs[i].style.display="block";} return false }
	
	for(i=0; i<goes; i++) {
		tmp=explode(" ", divs[i].className);
		ingoes=tmp.length;
		for(j=0; j<ingoes; j++){
			if(trim(tmp[j])!="p"+picked) {
				divs[i].style.display="none";
			}
			else {
				divs[i].style.display="block";
				break;
			}
		}
	}
}

function get_rss_feed() {		
	$.get('http://www.avto-magazin.si/rss/?mod=305', function(d){ 
		$('#avtoinforss').append('<ul>');
		$(d).find('item').each(function(){
			var $item = $(this);   
			var title = $item.find('title').text();
			var link = $item.find('link').text();
			var description = $item.find('description').text(); 
			var pubDate = $item.find('pubDate').text();
				 
			var html = '<li>' + title + '&nbsp;' + pubDate + '<br />' + description + '<br />' ;  
			html += '<a href="' + link + '" target="_blank">Več...</a>';
			html += '</li>';
			
            $('#avtoinforss').append($(html));    
        });
		$('#avtoinforss').append('</ul>'); 
	});  
}

