jQuery(document).ready(function() {
    jQuery('.twitter .tweet').each(function(i) {
        jQuery(this).hover(function() {
            jQuery(this).css('filter', 'alpha(opacity=100)');
            jQuery(this).css('-moz-opacity', '1.0');
            jQuery(this).css('opacity', '1.0');
            /*jQuery(this).find('*').css('filter', 'alpha(opacity=100)');
            jQuery(this).find('*').css('-moz-opacity', '1.0');
            jQuery(this).find('*').css('opacity', '1.0');*/
        }, function() {
            jQuery(this).css('filter', 'alpha(opacity=80)');
            jQuery(this).css('-moz-opacity', '0.8');
            jQuery(this).css('opacity', '0.8');
            /*jQuery(this).find('*').css('filter', 'alpha(opacity=80)');
            jQuery(this).find('*').css('-moz-opacity', '0.8');
            jQuery(this).find('*').css('opacity', '0.8');*/
        });
    });
    jQuery("#newsTicker").newsTicker();
    var imgwidth = 0;
    var multip = 0;
    var lastFound = false;
    jQuery('.pic118 dl').each(function(i) {
    	imgwidth = parseInt(jQuery(this).find('img').css('width'))+2;
    	jQuery(this).css('width', imgwidth);
    	if((!lastFound) && (!jQuery(this).hasClass('csc-textpic-lastcol'))) {
    		multip++;
   		} else {
    		if(!lastFound) multip++;
    		lastFound = true;
   		}
    });
    jQuery('.pic118 div').css('width', (imgwidth*multip)+(10 * (multip - 1)));
    toggleTheme(jQuery('a.tw').get(0));
});

function writeListLine(text, link) {
	var content = '';
	if(link != undefined) {
		content = '<a href="'+link+'">';
	}
	content += text;
	if(link != undefined) {
		content += '<a href="'+link+'">';
	}
	jQuery('.ref ul').append('<li>'+content+'</li>');
	//toggleTheme(jQuery('.twitter a.tw').get(0));
}

//function toggleTheme(text, img)
function toggleTheme(obj)
{
    /*var text = jQuery(obj).find('.text').html();*/
    var index = 0;
    jQuery('.twitter a.tw').each(function(i) {
        if(this == obj)
            index = i;
    });
    jQuery('div#teasertxt').find('blockquote').hide();
    jQuery('div#teasertxt').find('blockquote').eq(index).show();
    var img = jQuery(obj).find('img').attr('src');
    var pos = img.lastIndexOf('/');
    var path = img.substring(0, pos + 1);
    var imgName = img.substring(pos + 1);
    pos = imgName.indexOf('-');
    imgName = imgName.substring(0 ,pos);
    imgName = 'Teaser-' + imgName + '.jpg';
    jQuery('img#teaserimg').attr('src', path + imgName);
    //jQuery('div#teasertxt').html(text);
}